Example #1
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 #2
0
 function screen_settings($current)
 {
     // vars
     $show_field_keys = acf_get_user_setting('show_field_keys', 0);
     // heading
     $current .= '<h5>' . __("Fields", 'acf') . '</h5>';
     // radio buttons
     $current .= '<div class="show-field-keys">' . __('Show Field Keys', 'acf') . ':';
     $current .= '<label><input type="radio" ' . ($show_field_keys ? 'checked="checked"' : '') . ' name="show_field_keys" value="1" />' . __('Yes', 'acf') . '</label>';
     $current .= '<label><input type="radio" ' . ($show_field_keys ? '' : 'checked="checked"') . ' name="show_field_keys" value="0" />' . __('No', 'acf') . '</label>';
     $current .= '</div>';
     // return
     return $current;
 }
Example #3
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 #4
0
 function screen_settings($html)
 {
     // vars
     $checked = acf_get_user_setting('show_field_keys') ? 'checked="checked"' : '';
     // append
     $html .= '<div id="acf-append-show-on-screen" class="acf-hidden">';
     $html .= '<label for="acf-field-key-hide"><input id="acf-field-key-hide" type="checkbox" value="1" name="show_field_keys" ' . $checked . ' /> ' . __('Field Keys', 'acf') . '</label>';
     $html .= '</div>';
     // return
     return $html;
 }
Example #5
0
        function render_field($field)
        {
            // global
            global $wp_version;
            // enqueue
            acf_enqueue_uploader();
            // vars
            $id = uniqid('acf-editor-');
            $default_editor = 'html';
            $show_tabs = true;
            $button = '';
            // get height
            $height = acf_get_user_setting('wysiwyg_height', 300);
            $height = max($height, 300);
            // minimum height is 300
            // detect mode
            if (!user_can_richedit()) {
                $show_tabs = false;
            } elseif ($field['tabs'] == 'visual') {
                // case: visual tab only
                $default_editor = 'tinymce';
                $show_tabs = false;
            } elseif ($field['tabs'] == 'text') {
                // case: text tab only
                $show_tabs = false;
            } elseif (wp_default_editor() == 'tinymce') {
                // case: both tabs
                $default_editor = 'tinymce';
            }
            // must be logged in tp upload
            if (!current_user_can('upload_files')) {
                $field['media_upload'] = 0;
            }
            // mode
            $switch_class = $default_editor === 'html' ? 'html-active' : 'tmce-active';
            // filter value for editor
            remove_filter('acf_the_editor_content', 'format_for_editor', 10, 2);
            remove_filter('acf_the_editor_content', 'wp_htmledit_pre', 10, 1);
            remove_filter('acf_the_editor_content', 'wp_richedit_pre', 10, 1);
            // WP 4.3
            if (version_compare($wp_version, '4.3', '>=')) {
                add_filter('acf_the_editor_content', 'format_for_editor', 10, 2);
                $button = 'data-wp-editor-id="' . $id . '"';
                // WP < 4.3
            } else {
                $function = $default_editor === 'html' ? 'wp_htmledit_pre' : 'wp_richedit_pre';
                add_filter('acf_the_editor_content', $function, 10, 1);
                $button = 'onclick="switchEditors.switchto(this);"';
            }
            // filter
            $field['value'] = apply_filters('acf_the_editor_content', $field['value'], $default_editor);
            ?>
		<div id="wp-<?php 
            echo $id;
            ?>
-wrap" class="acf-editor-wrap wp-core-ui wp-editor-wrap <?php 
            echo $switch_class;
            ?>
" data-toolbar="<?php 
            echo $field['toolbar'];
            ?>
" data-upload="<?php 
            echo $field['media_upload'];
            ?>
">
			<div id="wp-<?php 
            echo $id;
            ?>
-editor-tools" class="wp-editor-tools hide-if-no-js">
				<?php 
            if ($field['media_upload']) {
                ?>
				<div id="wp-<?php 
                echo $id;
                ?>
-media-buttons" class="wp-media-buttons">
					<?php 
                do_action('media_buttons', $id);
                ?>
				</div>
				<?php 
            }
            ?>
				<?php 
            if (user_can_richedit() && $show_tabs) {
                ?>
					<div class="wp-editor-tabs">
						<button id="<?php 
                echo $id;
                ?>
-tmce" class="wp-switch-editor switch-tmce" <?php 
                echo $button;
                ?>
 type="button"><?php 
                echo __('Visual', 'acf');
                ?>
</button>
						<button id="<?php 
                echo $id;
                ?>
-html" class="wp-switch-editor switch-html" <?php 
                echo $button;
                ?>
 type="button"><?php 
                echo _x('Text', 'Name for the Text editor tab (formerly HTML)', 'acf');
                ?>
</button>
					</div>
				<?php 
            }
            ?>
			</div>
			<div id="wp-<?php 
            echo $id;
            ?>
-editor-container" class="wp-editor-container">
				<textarea id="<?php 
            echo $id;
            ?>
" class="wp-editor-area" name="<?php 
            echo $field['name'];
            ?>
" <?php 
            if ($height) {
                ?>
style="height:<?php 
                echo $height;
                ?>
px;"<?php 
            }
            ?>
><?php 
            echo $field['value'];
            ?>
</textarea>
			</div>
		</div>
		<?php 
        }
Example #6
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 
        }
        function render_field($field)
        {
            // enqueue
            acf_enqueue_uploader();
            // vars
            $id = $field['id'] . '-' . uniqid();
            $mode = 'html';
            $show_tabs = true;
            // get height
            $height = acf_get_user_setting('wysiwyg_height', 300);
            $height = max($height, 300);
            // minimum height is 300
            // detect mode
            if ($field['tabs'] == 'visual') {
                // case: visual tab only
                $mode = 'tmce';
                $show_tabs = false;
            } elseif ($field['tabs'] == 'text') {
                // case: text tab only
                $show_tabs = false;
            } elseif (wp_default_editor() == 'tinymce') {
                // case: both tabs
                $mode = 'tmce';
            }
            // mode
            $switch_class = $mode . '-active';
            // filter value for editor
            remove_all_filters('acf_the_editor_content');
            if ($mode == 'tmce') {
                add_filter('acf_the_editor_content', 'wp_richedit_pre');
            } else {
                add_filter('acf_the_editor_content', 'wp_htmledit_pre');
            }
            $field['value'] = apply_filters('acf_the_editor_content', $field['value']);
            ?>
		<div id="wp-<?php 
            echo $id;
            ?>
-wrap" class="acf-wysiwyg-wrap wp-core-ui wp-editor-wrap <?php 
            echo $switch_class;
            ?>
" data-toolbar="<?php 
            echo $field['toolbar'];
            ?>
" data-upload="<?php 
            echo $field['media_upload'];
            ?>
">
			<div id="wp-<?php 
            echo $id;
            ?>
-editor-tools" class="wp-editor-tools hide-if-no-js">
				<?php 
            if ($field['media_upload']) {
                ?>
				<div id="wp-<?php 
                echo $id;
                ?>
-media-buttons" class="wp-media-buttons">
					<?php 
                do_action('media_buttons');
                ?>
				</div>
				<?php 
            }
            ?>
				<?php 
            if (user_can_richedit() && $show_tabs) {
                ?>
					<div class="wp-editor-tabs">
						<a id="<?php 
                echo $id;
                ?>
-html" class="wp-switch-editor switch-html" onclick="switchEditors.switchto(this);"><?php 
                echo _x('Text', 'Name for the Text editor tab (formerly HTML)');
                ?>
</a>
						<a id="<?php 
                echo $id;
                ?>
-tmce" class="wp-switch-editor switch-tmce" onclick="switchEditors.switchto(this);"><?php 
                echo __('Visual');
                ?>
</a>
					</div>
				<?php 
            }
            ?>
			</div>
			<div id="wp-<?php 
            echo $id;
            ?>
-editor-container" class="wp-editor-container">
				<textarea id="<?php 
            echo $id;
            ?>
" class="wp-editor-area" name="<?php 
            echo $field['name'];
            ?>
" <?php 
            if ($height) {
                ?>
style="height:<?php 
                echo $height;
                ?>
px;"<?php 
            }
            ?>
><?php 
            echo $field['value'];
            ?>
</textarea>
			</div>
		</div>
		<?php 
        }
Example #8
0
function acf_is_row_collapsed($field_key = '', $row_index = 0)
{
    // collapsed
    $collapsed = acf_get_user_setting('collapsed_' . $field_key, '');
    // cookie fallback ( version < 5.3.2 )
    if ($collapsed === '') {
        $collapsed = acf_extract_var($_COOKIE, "acf_collapsed_{$field_key}", '');
        $collapsed = str_replace('|', ',', $collapsed);
        // update
        acf_update_user_setting('collapsed_' . $field_key, $collapsed);
    }
    // explode
    $collapsed = explode(',', $collapsed);
    $collapsed = array_filter($collapsed, 'is_numeric');
    // collapsed class
    return in_array($row_index, $collapsed);
}
    function render_field($field)
    {
        // enqueue
        acf_enqueue_uploader();
        // vars
        $id = uniqid('acf-editor-');
        //$id = $field['id'] . '-' . uniqid();
        $mode = 'html';
        $show_tabs = true;
        // get height
        $height = acf_get_user_setting('wysiwyg_height', 300);
        $height = max($height, 300);
        // minimum height is 300
        // detect mode
        // case: visual tab only
        if ($field['tabs'] == 'visual') {
            $mode = 'tmce';
            $show_tabs = false;
        } elseif ($field['tabs'] == 'text') {
            $show_tabs = false;
        } elseif (wp_default_editor() == 'tinymce') {
            $mode = 'tmce';
        }
        // mode
        $switch_class = $mode . '-active';
        // filter value for editor
        remove_all_filters('acf_the_editor_content');
        if ($mode == 'tmce') {
            add_filter('acf_the_editor_content', 'wp_richedit_pre');
        } else {
            add_filter('acf_the_editor_content', 'wp_htmledit_pre');
        }
        global $q_config, $wp_version;
        $languages = qtrans_getSortedLanguages(true);
        $values = qtrans_split($field['value'], $quicktags = true);
        $currentLanguage = $this->plugin->get_active_language();
        echo '<div class="multi-language-field multi-language-field-wysiwyg">';
        foreach ($languages as $language) {
            $class = $language === $currentLanguage ? 'wp-switch-editor current-language' : 'wp-switch-editor';
            echo '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
        }
        $uid = uniqid('acf-editor-');
        foreach ($languages as $language) {
            $value = apply_filters('acf_the_editor_content', $values[$language]);
            $id = $uid . "-{$language}";
            $name = $field['name'] . "[{$language}]";
            $class = $switch_class;
            if ($language === $currentLanguage) {
                $class .= ' current-language';
            }
            ?>
			<div id="wp-<?php 
            echo $id;
            ?>
-wrap" class="acf-editor-wrap wp-core-ui wp-editor-wrap <?php 
            echo $class;
            ?>
" data-toolbar="<?php 
            echo $field['toolbar'];
            ?>
" data-upload="<?php 
            echo $field['media_upload'];
            ?>
" data-language="<?php 
            echo $language;
            ?>
">
				<div id="wp-<?php 
            echo $id;
            ?>
-editor-tools" class="wp-editor-tools hide-if-no-js">
					<?php 
            if ($field['media_upload']) {
                ?>
					<div id="wp-<?php 
                echo $id;
                ?>
-media-buttons" class="wp-media-buttons">
						<?php 
                do_action('media_buttons');
                ?>
					</div>
					<?php 
            }
            ?>
					<?php 
            if (user_can_richedit() && $show_tabs) {
                ?>
						<div class="wp-editor-tabs">
							<button id="<?php 
                echo $id;
                ?>
-tmce" class="wp-switch-editor switch-tmce" onclick="switchEditors.switchto(this);" type="button"><?php 
                echo __('Visual', 'acf');
                ?>
</button>
							<button id="<?php 
                echo $id;
                ?>
-html" class="wp-switch-editor switch-html" onclick="switchEditors.switchto(this);" type="button"><?php 
                echo _x('Text', 'Name for the Text editor tab (formerly HTML)', 'acf');
                ?>
</button>
						</div>
					<?php 
            }
            ?>
				</div>
				<div id="wp-<?php 
            echo $id;
            ?>
-editor-container" class="wp-editor-container">
					<textarea id="<?php 
            echo $id;
            ?>
" class="qtx-wp-editor-area" name="<?php 
            echo $name;
            ?>
" <?php 
            if ($height) {
                ?>
style="height:<?php 
                echo $height;
                ?>
px;"<?php 
            }
            ?>
><?php 
            echo $value;
            ?>
</textarea>
				</div>
			</div>

		<?php 
        }
        echo '</div>';
    }
Example #10
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 #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']);
            // vars
            $height = acf_get_user_setting('gallery_height', 400);
            $height = max($height, 200);
            // minimum height is 200
            $atts['style'] = "height:{$height}px";
            ?>
<div <?php 
            acf_esc_attr_e($atts);
            ?>
>
	
	<div class="acf-hidden">
		<input type="hidden" <?php 
            acf_esc_attr_e(array('name' => $field['name'], 'value' => '', 'data-name' => 'ids'));
            ?>
 />
	</div>
	
	<div class="acf-gallery-main">
		
		<div class="acf-gallery-attachments">
			
			<?php 
            if (!empty($field['value'])) {
                // force value to array
                $field['value'] = acf_force_type_array($field['value']);
                // convert values to int
                $field['value'] = array_map('intval', $field['value']);
                foreach ($field['value'] as $id) {
                    // vars
                    $mime_type = get_post_mime_type($id);
                    $src = '';
                    if (strpos($mime_type, 'image') !== false) {
                        $src = wp_get_attachment_image_src($id, $field['preview_size']);
                        $src = $src[0];
                    } else {
                        $src = wp_mime_type_icon($id);
                    }
                    ?>
					
					<div class="acf-gallery-attachment acf-soh" data-id="<?php 
                    echo $id;
                    ?>
">
						<input type="hidden" name="<?php 
                    echo $field['name'];
                    ?>
[]" value="<?php 
                    echo $id;
                    ?>
" />
						<div class="padding">
							<img src="<?php 
                    echo $src;
                    ?>
" alt="" />
						</div>
						<div class="actions acf-soh-target">
							<a class="acf-icon dark remove-attachment" data-id="<?php 
                    echo $id;
                    ?>
" href="#">
								<i class="acf-sprite-delete"></i>
							</a>
						</div>
					</div>
					
				<?php 
                }
                ?>
				
			<?php 
            }
            ?>
			
			
		</div>
		
		<div class="acf-gallery-toolbar">
			
			<ul class="acf-hl">
				<li>
					<a href="#" class="acf-button blue add-attachment"><?php 
            _e('Add to gallery', 'acf');
            ?>
</a>
				</li>
				<li class="acf-fr">
					<select class="bulk-actions">
						<option value=""><?php 
            _e('Bulk actions', 'acf');
            ?>
</option>
						<option value="date"><?php 
            _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 
        }