/** * Enqueues ACF uploader scripts * @param mixed $options either false or json encoded options */ public function acf_scripts($options) { if (function_exists('acf_enqueue_uploader')) { acf_enqueue_uploader(); wp_enqueue_script('wa-fronted-acf-scripts', plugins_url('/acf.min.js', __FILE__), array('wa-fronted-scripts'), '0.1', true); } }
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 }
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) { // 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) { // 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 }
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 }
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>'; }
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 }
<div class="pnl"> <a href="<?php echo $pnl; ?> ">privacy</a> & <a href="<?php echo $legal; ?> ">legal</a> | <a href="<?php echo $sitemap; ?> ">sitemap</a> </div><!-- pnl --> <div class="clear"></div> <div class="pnl"> site by <a href="http://bellaworksweb.com">bellaworks</a></div> </div><!-- footer left --> </div><!-- .site-info --> </footer><!-- #colophon --> </div><!-- #page --> <?php the_field('google_analytics', 'option'); acf_enqueue_uploader(); wp_footer(); ?> <!-- liquid web --> </body> </html>
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>'; }
function render_field($field) { // enqueue acf_enqueue_uploader(); // vars $id = 'wysiwyg-' . $field['id'] . '-' . uniqid(); // filter value for editor remove_all_filters('acf_the_editor_content'); if (user_can_richedit()) { 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 tmce-active" data-toolbar="<?php echo $field['toolbar']; ?> " data-upload="<?php echo $field['media_upload']; ?> "> <?php if (user_can_richedit() && $field['media_upload']) { ?> <div id="wp-<?php echo $id; ?> -editor-tools" class="wp-editor-tools hide-if-no-js"> <div id="wp-<?php echo $id; ?> -media-buttons" class="wp-media-buttons"> <?php do_action('media_buttons'); ?> </div> </div> <?php } ?> <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 echo $field['value']; ?> </textarea> </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>'; }
function acf_form_data($args = array()) { // make sure scripts and styles have been included // case: front end bbPress edit user acf_enqueue_scripts(); // defaults $args = acf_parse_args($args, array('post_id' => 0, 'nonce' => 'post', 'validation' => 1, 'ajax' => 0)); // save form_data for later actions acf_update_setting('form_data', $args); // enqueue uploader if page allows AJAX fields to appear if ($args['ajax']) { acf_enqueue_uploader(); } ?> <div id="acf-form-data" class="acf-hidden"> <input type="hidden" name="_acfnonce" value="<?php echo wp_create_nonce($args['nonce']); ?> " /> <input type="hidden" name="_acfchanged" value="0" /> <?php do_action('acf/input/form_data', $args); ?> </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 }
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 }
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 }
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 }