Example #1
0
        function render_field($field)
        {
            // vars
            $atts = array('class' => 'acf-tab', 'data-placement' => $field['placement'], 'data-endpoint' => $field['endpoint']);
            ?>
		<div <?php 
            acf_esc_attr_e($atts);
            ?>
><?php 
            echo $field['label'];
            ?>
</div>
		<?php 
        }
Example #2
0
        function render_field($field)
        {
            // enqueue
            acf_enqueue_uploader();
            // vars
            $div_atts = array('class' => 'acf-image-uploader acf-cf', 'data-preview_size' => $field['preview_size'], 'data-library' => $field['library']);
            $input_atts = array('type' => 'hidden', 'name' => $field['name'], 'value' => $field['value'], 'data-name' => 'id');
            $url = '';
            // has value?
            if ($field['value'] && is_numeric($field['value'])) {
                $url = wp_get_attachment_image_src($field['value'], $field['preview_size']);
                $url = $url[0];
                $div_atts['class'] .= ' has-value';
            }
            ?>
<div <?php 
            acf_esc_attr_e($div_atts);
            ?>
>
	<div class="acf-hidden">
		<input <?php 
            acf_esc_attr_e($input_atts);
            ?>
/>
	</div>
	<div class="view show-if-value acf-soh">
		<ul class="acf-hl acf-soh-target">
			<li><a class="acf-icon dark" data-name="edit" href="#"><i class="acf-sprite-edit"></i></a></li>
			<li><a class="acf-icon dark" data-name="remove" href="#"><i class="acf-sprite-delete"></i></a></li>
		</ul>
		<img data-name="image" src="<?php 
            echo $url;
            ?>
" alt=""/>
	</div>
	<div class="view hide-if-value">
		<p><?php 
            _e('No image selected', 'acf');
            ?>
 <a data-name="add" class="acf-button" href="#"><?php 
            _e('Add Image', 'acf');
            ?>
</a></p>
	</div>
</div>
<?php 
        }
Example #3
0
        function render_field($field)
        {
            // force value to array
            $field['value'] = acf_force_type_array($field['value']);
            // convert values to int
            $field['value'] = array_map('intval', $field['value']);
            // vars
            $div = array('class' => 'acf-taxonomy-field acf-soh', 'data-load_save' => $field['load_save_terms'], 'data-type' => $field['field_type'], 'data-taxonomy' => $field['taxonomy']);
            // get taxonomy
            $taxonomy = get_taxonomy($field['taxonomy']);
            ?>
<div <?php 
            acf_esc_attr_e($div);
            ?>
>
	<?php 
            if ($field['add_term'] && current_user_can($taxonomy->cap->manage_terms)) {
                ?>
	<a href="#" class="acf-js-tooltip acf-icon small acf-soh-target" data-name="add" title="<?php 
                echo sprintf(__('Add new %s ', 'acf'), $taxonomy->labels->singular_name);
                ?>
">
		<i class="acf-sprite-add"></i>
	</a>
	<?php 
            }
            if ($field['field_type'] == 'select') {
                $field['multiple'] = 0;
                $this->render_field_select($field);
            } elseif ($field['field_type'] == 'multi_select') {
                $field['multiple'] = 1;
                $this->render_field_select($field);
            } elseif ($field['field_type'] == 'radio') {
                $this->render_field_checkbox($field);
            } elseif ($field['field_type'] == 'checkbox') {
                $this->render_field_checkbox($field);
            }
            ?>
</div><?php 
        }
    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 
    }
    function render_field($field)
    {
        // enqueue
        acf_enqueue_uploader();
        // get data from value
        //$data = json_decode($field['value']);
        $imageData = $this->get_image_data($field);
        $url = '';
        $orignialImage = null;
        if ($imageData->original_image) {
            $originalImage = wp_get_attachment_image_src($imageData->original_image, 'full');
            $url = $imageData->preview_image_url;
        }
        $width = 0;
        $height = 0;
        if ($field['target_size'] == 'custom') {
            $width = $field['width'];
            $height = $field['height'];
        } else {
            global $_wp_additional_image_sizes;
            $s = $field['target_size'];
            if (isset($_wp_additional_image_sizes[$s])) {
                $width = intval($_wp_additional_image_sizes[$s]['width']);
                $height = intval($_wp_additional_image_sizes[$s]['height']);
            } else {
                $width = get_option($s . '_size_w');
                $height = get_option($s . '_size_h');
            }
        }
        // Retina mode
        if ($this->getOption('retina_mode') || $field['retina_mode'] == 'yes') {
            $width = $width * 2;
            $height = $height * 2;
        }
        // vars
        $div_atts = array('class' => 'acf-image-uploader acf-cf acf-image-crop', 'data-crop_type' => $field['crop_type'], 'data-target_size' => $field['target_size'], 'data-width' => $width, 'data-height' => $height, 'data-force_crop' => $field['force_crop'] == 'yes' ? 'true' : 'false', 'data-save_to_media_library' => $field['save_in_media_library'], 'data-save_format' => $field['save_format'], 'data-preview_size' => $field['preview_size'], 'data-library' => $field['library']);
        $input_atts = array('type' => 'hidden', 'name' => $field['name'], 'value' => htmlspecialchars($field['value']), 'data-name' => 'id', 'data-original-image' => $imageData->original_image, 'data-cropped-image' => json_encode($imageData->cropped_image), 'class' => 'acf-image-value');
        // has value?
        if ($imageData->original_image) {
            $url = $imageData->preview_image_url;
            $div_atts['class'] .= ' has-value';
        }
        ?>
<div <?php 
        acf_esc_attr_e($div_atts);
        ?>
>
    <div class="acf-hidden">
        <input <?php 
        acf_esc_attr_e($input_atts);
        ?>
/>
    </div>
    <div class="view show-if-value acf-soh">
        <ul class="acf-hl acf-soh-target">
            <li><a class="acf-icon dark" data-name="edit" href="#"><i class="acf-sprite-edit"></i></a></li>
            <li><a class="acf-icon dark" data-name="remove" href="#"><i class="acf-sprite-delete"></i></a></li>
        </ul>
        <img data-name="image" src="<?php 
        echo $url;
        ?>
" alt=""/>
        <div class="crop-section">
            <div class="crop-stage">
                <div class="crop-action">
                    <h4><?php 
        _e('Crop the image', 'acf-image_crop');
        ?>
</h4>
                <?php 
        if ($imageData->original_image) {
            ?>
                    <img class="crop-image" src="<?php 
            echo $imageData->original_image_url;
            ?>
" data-width="<?php 
            echo $imageData->original_image_width;
            ?>
" data-height="<?php 
            echo $imageData->original_image_height;
            ?>
" alt="">
                <?php 
        }
        ?>
                </div>
                <div class="crop-preview">
                    <h4><?php 
        _e('Preview', 'acf-image_crop');
        ?>
</h4>
                    <div class="preview"></div>
                    <div class="crop-controls">
                        <a href="#" class="button button-large cancel-crop-button"><?php 
        _e('Cancel', 'acf-image_crop');
        ?>
</a> <a href="#" class="button button-large button-primary perform-crop-button"><?php 
        _e('Crop!', 'acf-image_crop');
        ?>
</a>
                    </div>
                </div>
            </div>
            <a href="#" class="button button-large init-crop-button"><?php 
        _e('Crop', 'acf-image_crop');
        ?>
</a>
        </div>
    </div>
    <div class="view hide-if-value">
        <p><?php 
        _e('No image selected', 'acf');
        ?>
 <a data-name="add" class="acf-button" href="#"><?php 
        _e('Add Image', 'acf');
        ?>
</a></p>
    </div>
</div>
<?php 
    }
Example #6
0
        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 
                    acf_the_field_label($sub_field);
                    ?>
						<?php 
                    if ($sub_field['instructions']) {
                        ?>
							<p class="description"><?php 
                        echo $sub_field['instructions'];
                        ?>
</p>
						<?php 
                    }
                    ?>
					</th>
					
				<?php 
                }
                ?>

				<?php 
                if ($show_remove) {
                    ?>
					<th class="remove"><span class="remove-spacer"></span></th>
				<?php 
                }
                ?>
			</tr>
		</thead>
	<?php 
            }
            ?>
	
	<tbody>
		<?php 
            foreach ($field['value'] as $i => $row) {
                ?>
			<tr class="acf-row<?php 
                echo $i === 'acfcloneindex' ? ' acf-clone' : '';
                ?>
">
				
				<?php 
                if ($show_order) {
                    ?>
					<td class="order" title="<?php 
                    _e('Drag to reorder', 'acf');
                    ?>
"><?php 
                    echo intval($i) + 1;
                    ?>
</td>
				<?php 
                }
                ?>
				
				<?php 
                echo $before_fields;
                ?>
				
				<?php 
                foreach ($field['sub_fields'] as $sub_field) {
                    // prevent repeater field from creating multiple conditional logic items for each row
                    if ($i !== 'acfcloneindex') {
                        $sub_field['conditional_logic'] = 0;
                    }
                    // add value
                    if (isset($row[$sub_field['key']])) {
                        // this is a normal value
                        $sub_field['value'] = $row[$sub_field['key']];
                    } elseif (isset($sub_field['default_value'])) {
                        // no value, but this sub field has a default value
                        $sub_field['value'] = $sub_field['default_value'];
                    }
                    // update prefix to allow for nested values
                    $sub_field['prefix'] = "{$field['name']}[{$i}]";
                    // render input
                    acf_render_field_wrap($sub_field, $el);
                    ?>
					
				<?php 
                }
                ?>
				
				<?php 
                echo $after_fields;
                ?>
				
				<?php 
                if ($show_remove) {
                    ?>
					<td class="remove">
						<a class="acf-icon small acf-repeater-add-row" href="#" data-before="1" title="<?php 
                    _e('Add row', 'acf');
                    ?>
"><i class="acf-sprite-add"></i></a>
						<a class="acf-icon small acf-repeater-remove-row" href="#" title="<?php 
                    _e('Remove row', 'acf');
                    ?>
"><i class="acf-sprite-remove"></i></a>
					</td>
				<?php 
                }
                ?>
				
			</tr>
		<?php 
            }
            ?>
	</tbody>
</table>
<?php 
            if ($show_add) {
                ?>
	
	<ul class="acf-hl acf-clearfix">
		<li class="acf-fr">
			<a href="#" class="acf-button blue acf-repeater-add-row"><?php 
                echo $field['button_label'];
                ?>
</a>
		</li>
	</ul>
			
<?php 
            }
            ?>
</div>
<?php 
        }
        function render_field($field)
        {
            // enqueue
            acf_enqueue_uploader();
            // vars
            $o = array('class' => 'acf-file-uploader acf-cf', 'icon' => '', 'title' => '', 'size' => '', 'url' => '', 'name' => '');
            if ($field['value'] && is_numeric($field['value'])) {
                $file = get_post($field['value']);
                if ($file) {
                    $o['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) {
                $o['class'] .= ' basic';
            }
            ?>
<div <?php 
            acf_esc_attr_e(array('class' => $o['class'], 'data-library' => $field['library']));
            ?>
>
	<div class="acf-hidden">
		<input type="hidden" <?php 
            acf_esc_attr_e(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="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>
				<?php 
            }
            ?>
				<li><a class="acf-icon dark" data-name="remove" href="#"><i class="acf-sprite-delete"></i></a></li>
			</ul>
			
		</div>
	</div>
	<div class="hide-if-value">
		<?php 
            if ($basic) {
                ?>
			
			<?php 
                if ($field['value'] && !is_numeric($field['value'])) {
                    ?>
				<div class="acf-error-message"><p><?php 
                    echo $field['value'];
                    ?>
</p></div>
			<?php 
                }
                ?>
			
			<input type="file" name="<?php 
                echo $field['name'];
                ?>
" id="<?php 
                echo $field['id'];
                ?>
" />
			
		<?php 
            } else {
                ?>
			
			<p style="margin:0;"><?php 
                _e('No File selected', 'acf');
                ?>
 <a data-name="add" class="acf-button" href="#"><?php 
                _e('Add File', 'acf');
                ?>
</a></p>
			
		<?php 
            }
            ?>
		
	</div>
</div>
<?php 
        }
Example #8
0
        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 
            }
            ?>
			
		</div>
		
		<div class="acf-gallery-toolbar">
			
			<ul class="acf-hl">
				<li>
					<a href="#" class="acf-button button button-primary acf-gallery-add"><?php 
            _e('Add to gallery', 'acf');
            ?>
</a>
				</li>
				<li class="acf-fr">
					<select class="acf-gallery-sort">
						<option value=""><?php 
            _e('Bulk actions', 'acf');
            ?>
</option>
						<option value="date"><?php 
            _e('Sort by date uploaded', 'acf');
            ?>
</option>
						<option value="modified"><?php 
            _e('Sort by date modified', 'acf');
            ?>
</option>
						<option value="title"><?php 
            _e('Sort by title', 'acf');
            ?>
</option>
						<option value="reverse"><?php 
            _e('Reverse current order', 'acf');
            ?>
</option>
					</select>
				</li>
			</ul>
			
		</div>
		
	</div>
	
	<div class="acf-gallery-side">
	<div class="acf-gallery-side-inner">
			
		<div class="acf-gallery-side-data"></div>
						
		<div class="acf-gallery-toolbar">
			
			<ul class="acf-hl">
				<li>
					<a href="#" class="acf-button button acf-gallery-close"><?php 
            _e('Close', 'acf');
            ?>
</a>
				</li>
				<li class="acf-fr">
					<a class="acf-button button button-primary acf-gallery-update"><?php 
            _e('Update', 'acf');
            ?>
</a>
				</li>
			</ul>
			
		</div>
		
	</div>	
	</div>
	
</div>
		<?php 
        }
Example #9
0
        function render_field($field)
        {
            // vars
            $uploader = acf_get_setting('uploader');
            // enqueue
            if ($uploader == 'wp') {
                acf_enqueue_uploader();
            }
            // vars
            $url = '';
            $div = array('class' => 'acf-image-uploader acf-cf', 'data-preview_size' => $field['preview_size'], 'data-library' => $field['library'], 'data-mime_types' => $field['mime_types'], 'data-uploader' => $uploader);
            // has value?
            if ($field['value'] && is_numeric($field['value'])) {
                $url = wp_get_attachment_image_src($field['value'], $field['preview_size']);
                if ($url) {
                    $url = $url[0];
                    $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="view show-if-value acf-soh">
		<img data-name="image" src="<?php 
            echo $url;
            ?>
" alt=""/>
		<ul class="acf-hl acf-soh-target">
			<?php 
            if ($uploader != 'basic') {
                ?>
				<li><a class="acf-icon acf-icon-pencil dark" data-name="edit" href="#"></a></li>
			<?php 
            }
            ?>
			<li><a class="acf-icon acf-icon-cancel dark" data-name="remove" href="#"></a></li>
		</ul>
	</div>
	<div class="view 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 
                }
                ?>
			
			<input type="file" name="<?php 
                echo $field['name'];
                ?>
" id="<?php 
                echo $field['id'];
                ?>
" />
			
		<?php 
            } else {
                ?>
			
			<p style="margin:0;"><?php 
                _e('No image selected', 'acf');
                ?>
 <a data-name="add" class="acf-button" href="#"><?php 
                _e('Add Image', 'acf');
                ?>
</a></p>
			
		<?php 
            }
            ?>
	</div>
</div>
<?php 
        }
    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
        $div = array('class' => 'acf-image-uploader acf-cf', 'data-preview_size' => $field['preview_size'], '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-image-uploader acf-cf';
            // has value?
            if ($field['value'] && is_numeric($field['value'])) {
                $url = wp_get_attachment_image_src($field['value'], $field['preview_size']);
                $url = $url[0];
                $div['class'] .= ' has-value';
            }
            // 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="view show-if-value acf-soh">
					<img data-name="image" src="<?php 
            echo $url;
            ?>
" alt=""/>
					<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>
						<?php 
            }
            ?>
						<li><a class="acf-icon dark" data-name="remove" href="#"><i class="acf-sprite-delete"></i></a></li>
					</ul>
				</div>
				<div class="view hide-if-value">
					<?php 
            if ($basic) {
                ?>
						<?php 
                if ($field['value'] && !is_numeric($field['value'])) {
                    ?>
							<div class="acf-error-message"><p><?php 
                    echo $field['value'];
                    ?>
</p></div>
						<?php 
                }
                ?>
						<input type="file" name="<?php 
                echo $field['name'];
                ?>
" id="<?php 
                echo $field['id'];
                ?>
" />
					<?php 
            } else {
                ?>
						<p style="margin:0;"><?php 
                _e('No image selected', 'acf');
                ?>
 <a data-name="add" class="acf-button" href="#"><?php 
                _e('Add Image', 'acf');
                ?>
</a></p>
					<?php 
            }
            ?>
				</div>
			</div>

		<?php 
        }
        echo '</div>';
    }
Example #11
0
        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']);
            ?>
<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" data-name="remove-attachment-button" 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 data-name="add-attachment-button" class="acf-button blue"><?php 
            _e('Add to gallery', 'acf');
            ?>
</a>
				</li>
				<li class="acf-fr">
					<select data-name="bulk-actions-select">
						<option value=""><?php 
            _e('Bulk actions', 'acf');
            ?>
</option>
						<option value="date"><?php 
            _e('Sort by date uploaded', 'acf');
            ?>
</option>
						<option value="modified"><?php 
            _e('Sort by date modified', 'acf');
            ?>
</option>
						<option value="title"><?php 
            _e('Sort by title', 'acf');
            ?>
</option>
						<option value="reverse"><?php 
            _e('Reverse current order', 'acf');
            ?>
</option>
					</select>
					<!-- <a class="acf-button bulk-actions-apply"><?php 
            _e('Apply', 'acf');
            ?>
</a> -->
				</li>
			</ul>
			
		</div>
		
	</div>
	
	<div class="acf-gallery-side">
	<div class="acf-gallery-side-inner">
			
		<div class="acf-gallery-side-data">
		
			<?php 
            //echo get_media_item( 158 );
            ?>
			
		</div>
						
		<div class="acf-gallery-toolbar">
			
			<ul class="acf-hl">
				<li>
					<a data-name="close-attachment-button" class="acf-button"><?php 
            _e('Close', 'acf');
            ?>
</a>
				</li>
				<li class="acf-fr">
					<a data-name="save-attachment-button" class="acf-button blue"><?php 
            _e('Update', 'acf');
            ?>
</a>
				</li>
			</ul>
			
		</div>
		
	</div>	
	</div>
	
</div>
		<?php 
        }
Example #12
0
        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 
                foreach ($field['sub_fields'] as $sub_field) {
                    $atts = array('class' => 'acf-th', 'data-key' => $sub_field['key']);
                    // add type
                    $atts['class'] .= ' acf-th-' . $sub_field['type'];
                    // 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']) {
                        ?>
							<p class="description"><?php 
                        echo $sub_field['instructions'];
                        ?>
</p>
						<?php 
                    }
                    ?>
					</th>
					
				<?php 
                }
                ?>

				<?php 
                if ($show_remove) {
                    ?>
					<th class="acf-row-handle"><span></span></th>
				<?php 
                }
                ?>
			</tr>
		</thead>
	<?php 
            }
            ?>
	
	<tbody>
		<?php 
            foreach ($field['value'] as $i => $row) {
                $row_class = 'acf-row';
                if ($i === 'acfcloneindex') {
                    $row_class .= ' acf-clone';
                } elseif (in_array($i, $collapsed)) {
                    $row_class .= ' -collapsed';
                }
                ?>
			<tr class="<?php 
                echo $row_class;
                ?>
" data-id="<?php 
                echo $i;
                ?>
">
				
				<?php 
                if ($show_order) {
                    ?>
					<td class="acf-row-handle order" title="<?php 
                    _e('Drag to reorder', 'acf');
                    ?>
">
						<?php 
                    if ($field['collapsed']) {
                        ?>
						<a class="acf-icon -collapse small" href="#" data-event="collapse-row" title="<?php 
                        _e('Click to toggle', 'acf');
                        ?>
"></a>
						<?php 
                    }
                    ?>
						<span><?php 
                    echo intval($i) + 1;
                    ?>
</span>
					</td>
				<?php 
                }
                ?>
				
				<?php 
                echo $before_fields;
                ?>
				
				<?php 
                foreach ($field['sub_fields'] as $sub_field) {
                    // prevent repeater field from creating multiple conditional logic items for each row
                    if ($i !== 'acfcloneindex') {
                        $sub_field['conditional_logic'] = 0;
                    }
                    // add value
                    if (isset($row[$sub_field['key']])) {
                        // this is a normal value
                        $sub_field['value'] = $row[$sub_field['key']];
                    } elseif (isset($sub_field['default_value'])) {
                        // no value, but this sub field has a default value
                        $sub_field['value'] = $sub_field['default_value'];
                    }
                    // update prefix to allow for nested values
                    $sub_field['prefix'] = "{$field['name']}[{$i}]";
                    // render input
                    acf_render_field_wrap($sub_field, $el);
                    ?>
					
				<?php 
                }
                ?>
				
				<?php 
                echo $after_fields;
                ?>
				
				<?php 
                if ($show_remove) {
                    ?>
					<td class="acf-row-handle remove">
						<a class="acf-icon -plus small" href="#" data-event="add-row" title="<?php 
                    _e('Add row', 'acf');
                    ?>
"></a>
						<a class="acf-icon -minus small" href="#" data-event="remove-row" title="<?php 
                    _e('Remove row', 'acf');
                    ?>
"></a>
					</td>
				<?php 
                }
                ?>
				
			</tr>
		<?php 
            }
            ?>
	</tbody>
</table>
<?php 
            if ($show_add) {
                ?>
	
	<ul class="acf-hl">
		<li class="acf-fr">
			<a href="#" class="acf-button blue" data-event="add-row"><?php 
                echo $field['button_label'];
                ?>
</a>
		</li>
	</ul>
			
<?php 
            }
            ?>
</div>
<?php 
        }
Example #13
0
        function render_field($field)
        {
            // validate value
            if (empty($field['value'])) {
                $field['value'] = array();
            }
            // value
            $field['value'] = wp_parse_args($field['value'], array('address' => '', 'lat' => '', 'lng' => ''));
            // default options
            foreach ($this->default_values as $k => $v) {
                if (empty($field[$k])) {
                    $field[$k] = $v;
                }
            }
            // vars
            $atts = array('id' => $field['id'], 'class' => "acf-google-map {$field['class']}", 'data-lat' => $field['center_lat'], 'data-lng' => $field['center_lng'], 'data-zoom' => $field['zoom']);
            // has value
            if ($field['value']['address']) {
                $atts['class'] .= ' -value';
            }
            ?>
<div <?php 
            acf_esc_attr_e($atts);
            ?>
>
	
	<div class="acf-hidden">
		<?php 
            foreach ($field['value'] as $k => $v) {
                ?>
			<input type="hidden" class="input-<?php 
                echo $k;
                ?>
" name="<?php 
                echo esc_attr($field['name']);
                ?>
[<?php 
                echo $k;
                ?>
]" value="<?php 
                echo esc_attr($v);
                ?>
" />
		<?php 
            }
            ?>
	</div>
	
	<div class="title acf-soh">
		
		<div class="actions acf-soh-target">
			<a href="#" data-name="search" class="acf-icon -search grey" title="<?php 
            _e("Search", 'acf');
            ?>
"></a>
			<a href="#" data-name="clear" class="acf-icon -cancel grey" title="<?php 
            _e("Clear location", 'acf');
            ?>
"></a>
			<a href="#" data-name="locate" class="acf-icon -location grey" title="<?php 
            _e("Find current location", 'acf');
            ?>
"></a>
		</div>
		
		<input class="search" type="text" placeholder="<?php 
            _e("Search for address...", 'acf');
            ?>
" value="<?php 
            echo $field['value']['address'];
            ?>
" />
		<i class="acf-loading"></i>
				
	</div>
	
	<div class="canvas" style="height: <?php 
            echo $field['height'];
            ?>
px"></div>
	
</div>
<?php 
        }
Example #14
0
function acf_form($args = array())
{
    // vars
    $url = acf_get_current_url();
    // defaults
    $args = wp_parse_args($args, array('id' => 'acf-form', 'post_id' => false, 'new_post' => false, 'field_groups' => false, 'fields' => false, 'post_title' => false, 'post_content' => false, 'form' => true, 'form_attributes' => array(), 'return' => add_query_arg('updated', 'true', $url), 'html_before_fields' => '', 'html_after_fields' => '', 'submit_value' => __("Update", 'acf'), 'updated_message' => __("Post updated", 'acf'), 'label_placement' => 'top', 'instruction_placement' => 'label', 'field_el' => 'div'));
    $args['form_attributes'] = wp_parse_args($args['form_attributes'], array('id' => 'post', 'class' => '', 'action' => '', 'method' => 'post'));
    // filter post_id
    $args['post_id'] = acf_get_valid_post_id($args['post_id']);
    // load values from this post
    $post_id = $args['post_id'];
    // new post?
    if ($post_id == 'new_post') {
        // dont load values
        $post_id = false;
        // new post defaults
        $args['new_post'] = acf_parse_args($args['new_post'], array('post_type' => 'post', 'post_status' => 'draft'));
    }
    // attributes
    $args['form_attributes']['class'] .= ' acf-form';
    // 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 (!empty($args['fields'])) {
        foreach ($args['fields'] as $selector) {
            $fields[] = get_field_object($selector, $post_id, false, false);
        }
    } elseif (!empty($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);
                }
            }
        }
    }
    // updated message
    if (!empty($_GET['updated']) && $args['updated_message']) {
        echo '<div id="message" class="updated"><p>' . $args['updated_message'] . '</p></div>';
    }
    // display form
    if ($args['form']) {
        ?>
	
	<form <?php 
        acf_esc_attr_e($args['form_attributes']);
        ?>
>
	
	<?php 
    }
    // render post data
    acf_form_data(array('post_id' => $args['post_id'], 'nonce' => 'acf_form'));
    ?>
	<div class="acf-hidden">
		<?php 
    acf_hidden_input(array('name' => '_acf_form', 'value' => base64_encode(json_encode($args))));
    ?>
	</div>
	<div class="acf-fields acf-form-fields">
	
		<?php 
    // html before fields
    echo $args['html_before_fields'];
    // start table
    if ($args['label_placement'] == 'left') {
        $args['field_el'] = 'tr';
        ?>
<table class="acf-table"><tbody><?php 
    }
    acf_render_fields($post_id, $fields, $args['field_el'], $args['instruction_placement']);
    // end table
    if ($args['label_placement'] == 'left') {
        ?>
</tbody></table><?php 
    }
    // html after fields
    echo $args['html_after_fields'];
    ?>
	
	</div><!-- acf-form-fields -->
	<?php 
    if ($args['form']) {
        ?>
	
	<!-- Submit -->
	<div class="acf-form-submit">
	
		<input type="submit" class="button button-primary button-large" value="<?php 
        echo $args['submit_value'];
        ?>
" />
		<span class="acf-loading" style="display: none;"></span>
		
	</div>
	<!-- / Submit -->
	
	</form>
	<script type="text/javascript">
	(function($) {
		
		// vars
		var $spinner = $('#<?php 
        echo $args['form_attributes']['id'];
        ?>
 .acf-form-submit .acf-loading');
		
		
		// show spinner on submit
		$(document).on('submit', '#<?php 
        echo $args['form_attributes']['id'];
        ?>
', function(){
			
			// show spinner
			$spinner.css('display', 'inline-block');
			
		});
		
		
		// hide spinner after validation
		acf.add_filter('validation_complete', function( json, $form ){
			
			// hide spinner
			$spinner.css('display', 'none');
			
			
			// return
			return json;
					
		});
		
	})(jQuery);	
	</script>
	<?php 
    }
}
        function render_field($field)
        {
            // defaults
            if (empty($field['button_label'])) {
                $field['button_label'] = $this->defaults['button_label'];
            }
            // sort layouts into names
            $layouts = array();
            foreach ($field['layouts'] as $k => $layout) {
                $layouts[$layout['name']] = $layout;
            }
            // hidden input
            acf_hidden_input(array('type' => 'hidden', 'name' => $field['name']));
            // no value message
            $no_value_message = __('Click the "%s" button below to start creating your layout', 'acf');
            $no_value_message = apply_filters('acf/fields/flexible_content/no_value_message', $no_value_message, $field);
            ?>
<div <?php 
            acf_esc_attr_e(array('class' => 'acf-flexible-content', 'data-min' => $field['min'], 'data-max' => $field['max']));
            ?>
>
	
	<div class="no-value-message" <?php 
            if ($field['value']) {
                echo 'style="display:none;"';
            }
            ?>
>
		<?php 
            printf($no_value_message, $field['button_label']);
            ?>
	</div>
	
	<div class="clones">
		<?php 
            foreach ($layouts as $layout) {
                ?>
			<?php 
                $this->render_layout($field, $layout, 'acfcloneindex', array());
                ?>
		<?php 
            }
            ?>
	</div>
	
	<div class="values">
		<?php 
            if (!empty($field['value'])) {
                ?>
			<?php 
                foreach ($field['value'] as $i => $value) {
                    ?>
				<?php 
                    // validate
                    if (empty($layouts[$value['acf_fc_layout']])) {
                        continue;
                    }
                    $this->render_layout($field, $layouts[$value['acf_fc_layout']], $i, $value);
                    ?>
			<?php 
                }
                ?>
		<?php 
            }
            ?>
	</div>
	
	<ul class="acf-actions acf-hl">
		<li>
			<a class="acf-button button button-primary" data-event="add-layout"><?php 
            echo $field['button_label'];
            ?>
</a>
		</li>
	</ul>
	
	<script type="text-html" class="tmpl-popup"><?php 
            ?>
<div class="acf-fc-popup">
			<ul>
				<?php 
            foreach ($layouts as $layout) {
                $atts = array('data-layout' => $layout['name'], 'data-min' => $layout['min'], 'data-max' => $layout['max']);
                ?>
					<li>
						<a href="#" <?php 
                acf_esc_attr_e($atts);
                ?>
><?php 
                echo $layout['label'];
                ?>
</a>
					</li>
				<?php 
            }
            ?>
			</ul>
			<a href="#" class="focus"></a>
		</div>
	</script>
	
</div>
<?php 
        }
    function render_field($field)
    {
        // default value
        if (!is_array($field['value'])) {
            $field['value'] = array();
        }
        $field['value'] = wp_parse_args($field['value'], array('map_name' => '', 'name' => '', 'address' => array('line_1' => '', 'line_2' => '', 'city' => '', 'state' => '', 'zip' => '', 'country' => ''), 'info' => array('phone' => '', 'website' => '', 'email' => '', 'google_map' => ''), 'lat' => '', 'lng' => ''));
        /*
        		// default options
        		foreach( $this->default_values as $k => $v )
        		{
        			if( ! $field[ $k ] )
        			{
        				$field[ $k ] = $v;
        			}	
        		}
        */
        // vars
        $atts = array('id' => $field['id'], 'class' => $field['class'], 'data-id' => $field['id'] . '-' . uniqid(), 'data-lat' => $field['center_lat'], 'data-lng' => $field['center_lng'], 'data-zoom' => $field['zoom']);
        // modify atts
        $atts['class'] .= ' acf-address-map';
        if ($field['value']['address']['line_1']) {
            $atts['class'] .= ' active';
        }
        ?>
		
		<div <?php 
        acf_esc_attr_e($atts);
        ?>
>
			
			<div style="display:none;">
				<?php 
        /* foreach( $field['value'] as $k => $v ): ?>
        				<input type="hidden" class="input-<?php echo $k; ?>" name="<?php echo esc_attr($field['name']); ?>[<?php echo $k; ?>]" value="<?php echo esc_attr( $v ); ?>" />
        			<?php endforeach; */
        ?>
			</div>
			
			<div class="title">
				
				<div class="has-value">
					<a href="#" class="acf-icon light acf-soh-target" title="<?php 
        _e("Clear location", 'acf');
        ?>
">
						<i class="acf-sprite-delete"></i>
					</a>
					<h4><?php 
        echo $field['value']['map_name'];
        ?>
</h4>
				</div>
				
				<div class="no-value">
					<a href="#" class="acf-icon light acf-soh-target" title="<?php 
        _e("Find current location", 'acf');
        ?>
">
						<i class="acf-sprite-locate"></i>
					</a>
					<input type="text" name="<?php 
        echo $field['name'];
        ?>
[map_name]" placeholder="<?php 
        _e("Search for address...", 'acf');
        ?>
" class="search" value="<?php 
        echo $this->cond_display_value($field, array('name'));
        ?>
"/>
				</div>
				
			</div>
			
			<div class="address">
			
				<table >				
				<tbody>
				<tr class="name">
					<td>Business Name</td>
					<td><input class="business_name" name="<?php 
        echo esc_attr($field['name']);
        ?>
[name]" type="text" value="<?php 
        echo $this->cond_display_value($field, array('name'));
        ?>
"></td>
				</tr>
				
				<tr class="phone">
					<td>Phone</td>
					<td><input class="phone" name="<?php 
        echo esc_attr($field['name']);
        ?>
[info][phone]" type="text" value="<?php 
        echo $this->cond_display_value($field, array('info', 'phone'));
        ?>
"></td>
				</tr>
				
				<tr class="website">
					<td>Website</td>
					<td><input class="website" name="<?php 
        echo esc_attr($field['name']);
        ?>
[info][website]" type="url" value="<?php 
        echo $this->cond_display_value($field, array('info', 'website'));
        ?>
"></td>
				</tr>
				
				<tr class="email">
					<td>Email</td>
					<td><input class="email" name="<?php 
        echo esc_attr($field['name']);
        ?>
[info][email]" type="email" value="<?php 
        echo $this->cond_display_value($field, array('info', 'email'));
        ?>
"></td>
				</tr>
				
				<tr class="address_line address_1">
					<td>Address Line 1</td>
					<td><input class="address_one" name="<?php 
        echo esc_attr($field['name']);
        ?>
[address][line_1]" type="text" value="<?php 
        echo $this->cond_display_value($field, array('address', 'line_1'));
        ?>
"></td>
				</tr>
				
				<tr class="address_line address_two">
					<td>Address Line 2</td>
					<td><input class="address_two" name="<?php 
        echo esc_attr($field['name']);
        ?>
[address][line_2]" type="text" value="<?php 
        echo $this->cond_display_value($field, array('address', 'line_2'));
        ?>
"></td>
				</tr>
				
				<tr class="city">
					<td>City</td>
					<td><input class="city" name="<?php 
        echo esc_attr($field['name']);
        ?>
[address][city]" type="text" value="<?php 
        echo $this->cond_display_value($field, array('address', 'city'));
        ?>
"></td>
				</tr>
				
				<tr class="state">
					<td>State</td>
					<td><input class="state" name="<?php 
        echo esc_attr($field['name']);
        ?>
[address][state]" type="text" value="<?php 
        echo $this->cond_display_value($field, array('address', 'state'));
        ?>
"></td>
				</tr>
				
				<tr class="zip">
					<td>Zip</td>
					<td><input class="zip" name="<?php 
        echo esc_attr($field['name']);
        ?>
[address][zip]" type="text" value="<?php 
        echo $this->cond_display_value($field, array('address', 'zip'));
        ?>
"></td>
				</tr>
				
				<tr class="country">
					<td>Country</td>
					<td><input class="country" name="<?php 
        echo esc_attr($field['name']);
        ?>
[address][country]" type="text" value="<?php 
        echo $this->cond_display_value($field, array('address', 'country'));
        ?>
"></td>
				</tr>
				
				<tr class="location">
					<td>Location</td>
					<td>
						<input name="<?php 
        echo esc_attr($field['name']);
        ?>
[lat]" class="latitude" type="text" value="<?php 
        echo $this->cond_display_value($field, array('lat'));
        ?>
">
						<input name="<?php 
        echo esc_attr($field['name']);
        ?>
[lng]" class="longitude" type="text" value="<?php 
        echo $this->cond_display_value($field, array('lng'));
        ?>
">
					</td>
				</tr>
				
				<tr class="google-map">
					<td>Google Map URL</td>
					<td><input class="google-map" name="<?php 
        echo esc_attr($field['name']);
        ?>
[info][google_map]" type="text" value="<?php 
        echo $this->cond_display_value($field, array('info', 'google_map'));
        ?>
"></td>
				</tr>
				
			<!--
	<tr class="options">
					<td><a href="#" data-action="reset-fields" class="button button-secondary button-large">Reset</a></td>
					<td><?php 
        submit_button('Update', 'primary', 'submit', false);
        ?>
</td>
				</tr>
-->
				</tbody>
				
				</table>
			
			</div>
			
			<div class="canvas">
				
			</div>
			
		</div>
		<?php 
    }
Example #17
0
function acf_form($args = array())
{
    // vars
    $url = acf_get_current_url();
    // defaults
    $args = wp_parse_args($args, array('id' => 'acf-form', 'post_id' => false, 'new_post' => false, 'field_groups' => false, 'fields' => false, 'post_title' => false, 'post_content' => false, 'form' => true, 'form_attributes' => array(), 'return' => add_query_arg('updated', 'true', $url), 'html_before_fields' => '', 'html_after_fields' => '', 'submit_value' => __("Update", 'acf'), 'updated_message' => __("Post updated", 'acf'), 'label_placement' => 'top', 'instruction_placement' => 'label', 'field_el' => 'div', 'uploader' => 'wp'));
    $args['form_attributes'] = wp_parse_args($args['form_attributes'], array('id' => 'post', 'class' => '', 'action' => '', 'method' => 'post'));
    // filter post_id
    $args['post_id'] = acf_get_valid_post_id($args['post_id']);
    // load values from this post
    $post_id = $args['post_id'];
    // new post?
    if ($post_id == 'new_post') {
        // dont load values
        $post_id = false;
        // new post defaults
        $args['new_post'] = acf_parse_args($args['new_post'], array('post_type' => 'post', 'post_status' => 'draft'));
    }
    // attributes
    $args['form_attributes']['class'] .= ' acf-form';
    // 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);
                }
            }
        }
    }
    // updated message
    if (!empty($_GET['updated']) && $args['updated_message']) {
        echo '<div id="message" class="updated"><p>' . $args['updated_message'] . '</p></div>';
    }
    // uploader (always set incase of multiple forms on the page)
    acf_update_setting('uploader', $args['uploader']);
    // display form
    if ($args['form']) {
        ?>

	
	<form <?php 
        acf_esc_attr_e($args['form_attributes']);
        ?>
>
	
	<?php 
    }
    // render post data
    acf_form_data(array('post_id' => $args['post_id'], 'nonce' => 'acf_form'));
    ?>

	<div class="acf-hidden">
		<?php 
    acf_hidden_input(array('name' => '_acf_form', 'value' => base64_encode(json_encode($args))));
    ?>

	</div>
	<div class="acf-fields acf-form-fields -<?php 
    echo $args['label_placement'];
    ?>
">
	
		<?php 
    // html before fields
    echo $args['html_before_fields'];
    // render
    acf_render_fields($post_id, $fields, $args['field_el'], $args['instruction_placement']);
    // html after fields
    echo $args['html_after_fields'];
    ?>

	
	</div><!-- acf-form-fields -->
	<?php 
    if ($args['form']) {
        ?>

	
	<!-- Submit -->
	<div class="acf-form-submit">
	
		<input type="submit" class="button button-primary button-large" value="<?php 
        echo $args['submit_value'];
        ?>
" />
		<span class="acf-spinner"></span>
		
	</div>
	<!-- / Submit -->
	
	</form>
	<?php 
    }
}
Example #18
0
        function render_field($field)
        {
            // validate value
            if (empty($field['value'])) {
                $field['value'] = array();
            }
            // value
            $field['value'] = acf_parse_args($field['value'], array('address' => '', 'lat' => '', 'lng' => ''));
            // default options
            foreach ($this->default_values as $k => $v) {
                if (empty($field[$k])) {
                    $field[$k] = $v;
                }
            }
            // vars
            $atts = array('id' => $field['id'], 'class' => $field['class'], 'data-id' => $field['id'] . '-' . uniqid(), 'data-lat' => $field['center_lat'], 'data-lng' => $field['center_lng'], 'data-zoom' => $field['zoom']);
            // modify atts
            $atts['class'] .= ' acf-google-map';
            if ($field['value']['address']) {
                $atts['class'] .= ' active';
            }
            ?>
<div <?php 
            acf_esc_attr_e($atts);
            ?>
>
	
	<div class="acf-hidden">
		<?php 
            foreach ($field['value'] as $k => $v) {
                ?>
			<input type="hidden" class="input-<?php 
                echo $k;
                ?>
" name="<?php 
                echo esc_attr($field['name']);
                ?>
[<?php 
                echo $k;
                ?>
]" value="<?php 
                echo esc_attr($v);
                ?>
" />
		<?php 
            }
            ?>
	</div>
	
	<div class="title acf-soh">
		
		<div class="has-value">
			<a href="#" data-name="clear-location" class="acf-icon light acf-soh-target" title="<?php 
            _e("Clear location", 'acf');
            ?>
">
				<i class="acf-sprite-delete"></i>
			</a>
			<h4><?php 
            echo $field['value']['address'];
            ?>
</h4>
		</div>
		
		<div class="no-value">
			<a href="#" data-name="find-location" class="acf-icon light acf-soh-target" title="<?php 
            _e("Find current location", 'acf');
            ?>
">
				<i class="acf-sprite-locate"></i>
			</a>
			<input type="text" placeholder="<?php 
            _e("Search for address...", 'acf');
            ?>
" class="search" />
		</div>
		
	</div>
	
	<div class="canvas" style="height: <?php 
            echo $field['height'];
            ?>
px">
		
	</div>
	
</div>
<?php 
        }
						<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 
        acf_the_field_label($sub_field);
        ?>
							<?php 
        if ($sub_field['instructions']) {
            ?>
					<p class="description"><?php 
            echo $sub_field['instructions'];
            ?>
</p>
				<?php 
        }
        ?>
Example #20
0
        function render_field($field)
        {
            // force value to array
            $field['value'] = acf_get_array($field['value']);
            // vars
            $div = array('class' => 'acf-taxonomy-field acf-soh', 'data-save' => $field['save_terms'], 'data-type' => $field['field_type'], 'data-taxonomy' => $field['taxonomy']);
            // get taxonomy
            $taxonomy = get_taxonomy($field['taxonomy']);
            ?>
<div <?php 
            acf_esc_attr_e($div);
            ?>
>
	<?php 
            if ($field['add_term'] && current_user_can($taxonomy->cap->manage_terms)) {
                ?>
	<a href="#" class="acf-icon -plus acf-js-tooltip small acf-soh-target" data-name="add" title="<?php 
                echo esc_attr($taxonomy->labels->add_new_item);
                ?>
"></a>
	<?php 
            }
            if ($field['field_type'] == 'select') {
                $field['multiple'] = 0;
                $this->render_field_select($field);
            } elseif ($field['field_type'] == 'multi_select') {
                $field['multiple'] = 1;
                $this->render_field_select($field);
            } elseif ($field['field_type'] == 'radio') {
                $this->render_field_checkbox($field);
            } elseif ($field['field_type'] == 'checkbox') {
                $this->render_field_checkbox($field);
            }
            ?>
</div><?php 
        }
Example #21
0
        function render_field_table($field)
        {
            ?>
<table class="acf-table">
	<thead>
		<tr>
		<?php 
            foreach ($field['sub_fields'] as $sub_field) {
                $atts = array('class' => 'acf-th', 'data-key' => $sub_field['key']);
                // add type
                $atts['class'] .= ' acf-th-' . $sub_field['type'];
                // Add custom width
                if ($sub_field['wrapper']['width']) {
                    $atts['data-width'] = $sub_field['wrapper']['width'];
                }
                ?>
			<th <?php 
                acf_esc_attr_e($atts);
                ?>
>
				<?php 
                echo acf_get_field_label($sub_field);
                ?>
				<?php 
                if ($sub_field['instructions']) {
                    ?>
					<p class="description"><?php 
                    echo $sub_field['instructions'];
                    ?>
</p>
				<?php 
                }
                ?>
			</th>
		<?php 
            }
            ?>
		</tr>
	</thead>
	<tbody>
		<tr class="acf-row">
		<?php 
            foreach ($field['sub_fields'] as $sub_field) {
                acf_render_field_wrap($sub_field, 'td');
            }
            ?>
		</tr>
	</tbody>
</table>
<?php 
        }
Example #22
0
        function render_field($field)
        {
            // default options
            foreach ($this->default_values as $k => $v) {
                if (empty($field[$k])) {
                    $field[$k] = $v;
                }
            }
            // atts
            $atts = array('class' => 'acf-oembed', 'data-width' => $field['width'], 'data-height' => $field['height']);
            if ($field['value']) {
                $atts['class'] .= ' has-value';
            }
            ?>
<div <?php 
            acf_esc_attr_e($atts);
            ?>
>
	<div class="acf-hidden">
		<input type="hidden" data-name="value-input" name="<?php 
            echo esc_attr($field['name']);
            ?>
" value="<?php 
            echo esc_attr($field['value']);
            ?>
" />
	</div>
	<div class="title acf-soh">
		
		<div class="title-value">
			<h4 data-name="value-title"><?php 
            echo $field['value'];
            ?>
</h4>
		</div>
		
		<div class="title-search">
			
			<input data-name="search-input" type="text" placeholder="<?php 
            _e("Enter URL", 'acf');
            ?>
" autocomplete="off" />
		</div>
		
		<a data-name="clear-button" href="#" class="acf-icon -cancel grey acf-soh-target"></a>
		
	</div>
	<div class="canvas">
		
		<div class="canvas-loading">
			<i class="acf-loading"></i>
		</div>
		
		<div class="canvas-error">
			<p><strong><?php 
            _e("Error", 'acf');
            ?>
</strong>. <?php 
            _e("No embed found for the given URL", 'acf');
            ?>
</p>
		</div>
		
		<div class="canvas-media" data-name="value-embed">
			<?php 
            if (!empty($field['value'])) {
                ?>
				<?php 
                echo $this->wp_oembed_get($field['value'], $field['width'], $field['height']);
                ?>
			<?php 
            }
            ?>
		</div>
		
		<i class="acf-icon -picture hide-if-value"></i>
		
	</div>
	
</div>
<?php 
        }
Example #23
0
        function render_field($field)
        {
            // vars
            $values = array();
            $atts = array('id' => $field['id'], 'class' => "acf-relationship {$field['class']}", 'data-min' => $field['min'], 'data-max' => $field['max'], 'data-s' => '', 'data-post_type' => '', 'data-taxonomy' => '', 'data-paged' => 1);
            // Lang
            if (defined('ICL_LANGUAGE_CODE')) {
                $atts['data-lang'] = ICL_LANGUAGE_CODE;
            }
            // data types
            $field['post_type'] = acf_force_type_array($field['post_type']);
            $field['taxonomy'] = acf_force_type_array($field['taxonomy']);
            // post_types
            $post_types = array();
            if (!empty($field['post_type'])) {
                $post_types = $field['post_type'];
            } else {
                $post_types = acf_get_post_types();
            }
            $post_types = acf_get_pretty_post_types($post_types);
            // taxonomies
            $taxonomies = array();
            if (!empty($field['taxonomy'])) {
                // get the field's terms
                $term_groups = acf_force_type_array($field['taxonomy']);
                $term_groups = acf_decode_taxonomy_terms($term_groups);
                // update taxonomies
                $taxonomies = array_keys($term_groups);
            } elseif (!empty($field['post_type'])) {
                // loop over post types and find connected taxonomies
                foreach ($field['post_type'] as $post_type) {
                    $post_taxonomies = get_object_taxonomies($post_type);
                    // bail early if no taxonomies
                    if (empty($post_taxonomies)) {
                        continue;
                    }
                    foreach ($post_taxonomies as $post_taxonomy) {
                        if (!in_array($post_taxonomy, $taxonomies)) {
                            $taxonomies[] = $post_taxonomy;
                        }
                    }
                }
            } else {
                $taxonomies = acf_get_taxonomies();
            }
            // terms
            $term_groups = acf_get_taxonomy_terms($taxonomies);
            // update $term_groups with specific terms
            if (!empty($field['taxonomy'])) {
                foreach (array_keys($term_groups) as $taxonomy) {
                    foreach (array_keys($term_groups[$taxonomy]) as $term) {
                        if (!in_array($term, $field['taxonomy'])) {
                            unset($term_groups[$taxonomy][$term]);
                        }
                    }
                }
            }
            // width for select filters
            $width = array('search' => 0, 'post_type' => 0, 'taxonomy' => 0);
            if (!empty($field['filters'])) {
                $width = array('search' => 50, 'post_type' => 25, 'taxonomy' => 25);
                foreach (array_keys($width) as $k) {
                    if (!in_array($k, $field['filters'])) {
                        $width[$k] = 0;
                    }
                }
                // search
                if ($width['search'] == 0) {
                    $width['post_type'] = $width['post_type'] == 0 ? 0 : 50;
                    $width['taxonomy'] = $width['taxonomy'] == 0 ? 0 : 50;
                }
                // post_type
                if ($width['post_type'] == 0) {
                    $width['taxonomy'] = $width['taxonomy'] == 0 ? 0 : 50;
                }
                // taxonomy
                if ($width['taxonomy'] == 0) {
                    $width['post_type'] = $width['post_type'] == 0 ? 0 : 50;
                }
                // search
                if ($width['post_type'] == 0 && $width['taxonomy'] == 0) {
                    $width['search'] = $width['search'] == 0 ? 0 : 100;
                }
            }
            ?>
<div <?php 
            acf_esc_attr_e($atts);
            ?>
>
	
	<div class="acf-hidden">
		<input type="hidden" name="<?php 
            echo $field['name'];
            ?>
" value="" />
	</div>
	
	<?php 
            if ($width['search'] > 0 || $width['post_type'] > 0 || $width['taxonomy'] > 0) {
                ?>
	<div class="filters">
		
		<ul class="acf-hl">
		
			<?php 
                if ($width['search'] > 0) {
                    ?>
			<li style="width:<?php 
                    echo $width['search'];
                    ?>
%;">
				<div class="inner">
				<input class="filter" data-filter="s" placeholder="<?php 
                    _e("Search...", 'acf');
                    ?>
" type="text" />
				</div>
			</li>
			<?php 
                }
                ?>
			
			<?php 
                if ($width['post_type'] > 0) {
                    ?>
			<li style="width:<?php 
                    echo $width['post_type'];
                    ?>
%;">
				<div class="inner">
				<select class="filter" data-filter="post_type">
					<option value=""><?php 
                    _e('Select post type', 'acf');
                    ?>
</option>
					<?php 
                    foreach ($post_types as $k => $v) {
                        ?>
						<option value="<?php 
                        echo $k;
                        ?>
"><?php 
                        echo $v;
                        ?>
</option>
					<?php 
                    }
                    ?>
				</select>
				</div>
			</li>
			<?php 
                }
                ?>
			
			<?php 
                if ($width['taxonomy'] > 0) {
                    ?>
			<li style="width:<?php 
                    echo $width['taxonomy'];
                    ?>
%;">
				<div class="inner">
				<select class="filter" data-filter="taxonomy">
					<option value=""><?php 
                    _e('Select taxonomy', 'acf');
                    ?>
</option>
					<?php 
                    foreach ($term_groups as $k_opt => $v_opt) {
                        ?>
						<optgroup label="<?php 
                        echo $k_opt;
                        ?>
">
							<?php 
                        foreach ($v_opt as $k => $v) {
                            ?>
								<option value="<?php 
                            echo $k;
                            ?>
"><?php 
                            echo $v;
                            ?>
</option>
							<?php 
                        }
                        ?>
						</optgroup>
					<?php 
                    }
                    ?>
				</select>
				</div>
			</li>
			<?php 
                }
                ?>
		</ul>
		
	</div>
	<?php 
            }
            ?>
	
	<div class="selection acf-cf">
	
		<div class="choices">
		
			<ul class="acf-bl list"></ul>
			
		</div>
		
		<div class="values">
		
			<ul class="acf-bl list">
			
				<?php 
            if (!empty($field['value'])) {
                // get posts
                $posts = acf_get_posts(array('post__in' => $field['value'], 'post_type' => $field['post_type']));
                // set choices
                if (!empty($posts)) {
                    foreach (array_keys($posts) as $i) {
                        // vars
                        $post = acf_extract_var($posts, $i);
                        ?>
<li>
								<input type="hidden" name="<?php 
                        echo $field['name'];
                        ?>
[]" value="<?php 
                        echo $post->ID;
                        ?>
" />
								<span data-id="<?php 
                        echo $post->ID;
                        ?>
" class="acf-rel-item">
									<?php 
                        echo $this->get_post_title($post, $field);
                        ?>
									<a href="#" class="acf-icon small dark" data-name="remove_item"><i class="acf-sprite-remove"></i></a>
								</span>
							</li><?php 
                    }
                }
            }
            ?>
				
			</ul>
			
		</div>
		
	</div>
	
</div>
		<?php 
        }
Example #24
0
        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']) {
                            ?>
							<p class="description"><?php 
                            echo $sub_field['instructions'];
                            ?>
</p>
						<?php 
                        }
                        ?>
					</th>
					
				<?php 
                    }
                    ?>
 
			</tr>
		</thead>
		
		<tbody>
	<?php 
                } else {
                    ?>
	<div class="acf-fields <?php 
                    if ($layout['display'] == 'row') {
                        ?>
-left<?php 
                    }
                    ?>
">
	<?php 
                }
                ?>
	
		<?php 
                // loop though sub fields
                foreach ($layout['sub_fields'] as $sub_field) {
                    // prevent repeater field from creating multiple conditional logic items for each row
                    if ($i !== 'acfcloneindex') {
                        $sub_field['conditional_logic'] = 0;
                    }
                    // add value
                    if (isset($value[$sub_field['key']])) {
                        // this is a normal value
                        $sub_field['value'] = $value[$sub_field['key']];
                    } elseif (isset($sub_field['default_value'])) {
                        // no value, but this sub field has a default value
                        $sub_field['value'] = $sub_field['default_value'];
                    }
                    // update prefix to allow for nested values
                    $sub_field['prefix'] = "{$field['name']}[{$i}]";
                    // render input
                    acf_render_field_wrap($sub_field, $el);
                }
                ?>
			
	<?php 
                if ($layout['display'] == 'table') {
                    ?>
		</tbody>
	</table>
	<?php 
                } else {
                    ?>
	</div>
	<?php 
                }
                ?>

<?php 
            }
            ?>

</div>
<?php 
        }
Example #25
0
        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 
                    echo $post->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 
            _e('Sort by date uploaded', 'acf');
            ?>
</option>
						<option value="modified"><?php 
            _e('Sort by date modified', 'acf');
            ?>
</option>
						<option value="title"><?php 
            _e('Sort by title', 'acf');
            ?>
</option>
						<option value="reverse"><?php 
            _e('Reverse current order', 'acf');
            ?>
</option>
					</select>
				</li>
			</ul>
			
		</div>
		
	</div>
	
	<div class="acf-gallery-side">
	<div class="acf-gallery-side-inner">
			
		<div class="acf-gallery-side-data"></div>
						
		<div class="acf-gallery-toolbar">
			
			<ul class="acf-hl">
				<li>
					<a href="#" class="acf-button close-sidebar"><?php 
            _e('Close', 'acf');
            ?>
</a>
				</li>
				<li class="acf-fr">
					<a class="acf-button blue update-attachment"><?php 
            _e('Update', 'acf');
            ?>
</a>
				</li>
			</ul>
			
		</div>
		
	</div>	
	</div>
	
</div>
		<?php 
        }
Example #26
0
        function render_field_table($field)
        {
            ?>
<table class="acf-table">
	<thead>
		<tr>
		<?php 
            foreach ($field['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;
                }
                // vars
                $atts = array();
                $atts['class'] = 'acf-th';
                $atts['data-name'] = $sub_field['_name'];
                $atts['data-type'] = $sub_field['type'];
                $atts['data-key'] = $sub_field['key'];
                // Add custom width
                if ($sub_field['wrapper']['width']) {
                    $atts['data-width'] = $sub_field['wrapper']['width'];
                    $atts['style'] = 'width: ' . $sub_field['wrapper']['width'] . '%;';
                }
                ?>
			<th <?php 
                acf_esc_attr_e($atts);
                ?>
>
				<?php 
                echo acf_get_field_label($sub_field);
                ?>
				<?php 
                if ($sub_field['instructions']) {
                    ?>
					<p class="description"><?php 
                    echo $sub_field['instructions'];
                    ?>
</p>
				<?php 
                }
                ?>
			</th>
		<?php 
            }
            ?>
		</tr>
	</thead>
	<tbody>
		<tr class="acf-row">
		<?php 
            foreach ($field['sub_fields'] as $sub_field) {
                acf_render_field_wrap($sub_field, 'td');
            }
            ?>
		</tr>
	</tbody>
</table>
<?php 
        }
    function render_field($field)
    {
        /*
         *  Review the data of $field.
         *  This will show what data is available
         */
        // validate value
        if (empty($field['value'])) {
            $field['value'] = array();
        }
        // value
        $field['value'] = acf_parse_args($field['value'], array('x' => '', 'y' => ''));
        // vars
        $atts = array('id' => $field['id'], 'class' => "acf-openlayers_map {$field['class']}");
        ?>

		<div <?php 
        acf_esc_attr_e($atts);
        ?>
>
			
			<div class="acf-hidden">
				<?php 
        foreach ($field['value'] as $k => $v) {
            ?>
					<input type="hidden" id="input-<?php 
            echo $k;
            ?>
" name="<?php 
            echo esc_attr($field['name']);
            ?>
[<?php 
            echo $k;
            ?>
]" value="<?php 
            echo esc_attr($v);
            ?>
" />
				<?php 
        }
        ?>
			</div>

			<div id="map" class="map"></div>

		</div>

		<?php 
    }
Example #28
0
        function render_layout($field, $layout, $i, $value)
        {
            // vars
            $order = 0;
            // atts
            $layout_atts = array('class' => 'layout', 'data-layout' => $layout['name'], 'data-toggle' => 'open');
            $table_atts = array('class' => "acf-table acf-input-table {$layout['display']}-layout");
            // collapsed
            if (!empty($_COOKIE["acf_collapsed_{$field['key']}"])) {
                $collapsed = $_COOKIE["acf_collapsed_{$field['key']}"];
                $collapsed = explode('|', $collapsed);
                if (in_array($i, $collapsed)) {
                    $layout_atts['data-toggle'] = 'closed';
                    $table_atts['style'] = 'display:none;';
                }
            }
            // clone
            if (is_numeric($i)) {
                $order = $i + 1;
            } else {
                $layout_atts['class'] .= ' acf-clone';
            }
            // field wrap
            $el = 'td';
            $before_fields = '';
            $after_fields = '';
            if ($layout['display'] == 'row') {
                $el = 'tr';
                $before_fields = '<td class="acf-table-wrap"><table class="acf-table">';
                $after_fields = '</table></td>';
            } elseif ($layout['display'] == 'block') {
                $el = 'div';
                $before_fields = '<td class="acf-fields">';
                $after_fields = '</td>';
            }
            ?>
<div <?php 
            acf_esc_attr_e($layout_atts);
            ?>
>
			
	<div style="display:none">
		<?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 acf-clearfix">
		<li>
			<a class="acf-icon acf-icon-plus small acf-fc-add" href="#" data-before="1" title="<?php 
            _e('Add layout', 'acf');
            ?>
"></a>
		</li>
		<li>
			<a class="acf-icon acf-icon-minus small acf-fc-remove" href="#" title="<?php 
            _e('Remove layout', 'acf');
            ?>
"></a>
		</li>
	</ul>
	
<?php 
            if (!empty($layout['sub_fields'])) {
                ?>
		
	<table <?php 
                acf_esc_attr_e($table_atts);
                ?>
>
		
		<?php 
                if ($layout['display'] == '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']) {
                            ?>
								<p class="description"><?php 
                            echo $sub_field['instructions'];
                            ?>
</p>
							<?php 
                        }
                        ?>
						</th>
						
					<?php 
                    }
                    ?>
 

				</tr>
			</thead>
			
		<?php 
                }
                ?>
		
		<tbody>
			<tr>
			<?php 
                echo $before_fields;
                // loop though sub fields
                foreach ($layout['sub_fields'] as $sub_field) {
                    // prevent repeater field from creating multiple conditional logic items for each row
                    if ($i !== 'acfcloneindex') {
                        $sub_field['conditional_logic'] = 0;
                    }
                    // add value
                    if (isset($value[$sub_field['key']])) {
                        // this is a normal value
                        $sub_field['value'] = $value[$sub_field['key']];
                    } elseif (isset($sub_field['default_value'])) {
                        // no value, but this sub field has a default value
                        $sub_field['value'] = $sub_field['default_value'];
                    }
                    // update prefix to allow for nested values
                    $sub_field['prefix'] = "{$field['name']}[{$i}]";
                    // render input
                    acf_render_field_wrap($sub_field, $el);
                }
                // layout: Row
                echo $after_fields;
                ?>
							
			</tr>
		</tbody>
		
	</table>

<?php 
            }
            ?>

</div>
<?php 
        }
Example #29
0
        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 
                }
                ?>
			
			<input type="file" name="<?php 
                echo $field['name'];
                ?>
" id="<?php 
                echo $field['id'];
                ?>
" />
			
		<?php 
            } else {
                ?>
			
			<p style="margin:0;"><?php 
                _e('No file selected', 'acf');
                ?>
 <a data-name="add" class="acf-button button" href="#"><?php 
                _e('Add File', 'acf');
                ?>
</a></p>
			
		<?php 
            }
            ?>
		
	</div>
</div>
<?php 
        }
Example #30
0
    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>
							<?php 
            }
            ?>
							<li><a class="acf-icon dark" data-name="remove" href="#"><i class="acf-sprite-delete"></i></a></li>
						</ul>
					</div>
				</div>
				<div class="hide-if-value">
					<?php 
            if ($basic) {
                ?>

						<?php 
                if ($field['value'] && !is_numeric($field['value'])) {
                    ?>
							<div class="acf-error-message"><p><?php 
                    echo $field['value'];
                    ?>
</p></div>
						<?php 
                }
                ?>

						<input type="file" name="<?php 
                echo $field['name'];
                ?>
" id="<?php 
                echo $field['id'];
                ?>
" />

					<?php 
            } else {
                ?>

						<p style="margin:0;"><?php 
                _e('No File selected', 'acf');
                ?>
 <a data-name="add" class="acf-button" href="#"><?php 
                _e('Add File', 'acf');
                ?>
</a></p>

					<?php 
            }
            ?>

				</div>
			</div>

		<?php 
        }
        echo '</div>';
    }