function show_metabox() { global $page_layout, $post, $meta_box; // Defines custom sidebar widget based on custom option $iva_sidebarwidget = get_option('atp_customsidebar'); // Use nonce for verification echo '<input type="hidden" name="page_page_layout_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />'; // M E T A B O X W R A P //-------------------------------------------------------- echo '<div class="atp_meta_options">'; foreach ($this->_meta_box['fields'] as $field) { // get current post meta data $meta = get_post_meta($post->ID, $field['id'], true); if ($meta == "") { $meta = $field['std']; //Default Meta Array Value if empty } if (!isset($field['class'])) { $field['class'] = ''; } if (!isset($field['desc'])) { $field['desc'] = ''; } // M E T A B O X O P T I O N S //-------------------------------------------------------- echo '<div class="atp_options_box ' . $field['class'] . '">', '<div class="atp_label"><label>', $field['name'], '</label></div>', '<div class="atp_inputs">'; switch ($field['type']) { case 'text': echo '<input type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : $field['std'], '" size="30" />'; break; case 'color': ?> <?php echo '<div class="meta_page_selectwrap"><input class="color" name="' . $field['id'] . '" id="' . $field['id'] . '" type="text" value="', $meta ? $meta : $field['std'], '" />'; ?> <div id="<?php echo $field['id']; ?> _color" class="wpcolorSelector"><div></div></div></div> <?php break; case 'textarea': echo '<textarea name="', $field['id'], '" id="', $field['id'], '" cols="60" rows="4">', $meta ? $meta : $field['std'], '</textarea>'; break; case 'select': echo '<div class="select_wrapper ', $field['class'], '"><select class="select" name="', $field['id'], '" id="', $field['id'], '">'; foreach ($field['options'] as $key => $value) { echo '<option value="' . $key . '"', $meta == $key ? ' selected="selected"' : '', '>', $value, '</option>'; } echo '</select></div>'; break; case 'multiselect': echo '<div class="select_wrapper2">'; $count = count($field['options']); if ($count > 0) { echo '<select multiple="multiple" name="', $field['id'], '[]" id="', $field['id'], '[]">'; foreach ($field['options'] as $key => $value) { echo '<option value="' . $key . '"', is_array($meta) && in_array($key, $meta) ? ' selected="selected"' : '', '>', $value, '</option>'; } echo '</select>'; } else { echo '<strong>' . __('No Posts IN Categories', 'iva_theme_admin') . '</strong>'; } echo '</div>'; break; case 'customselect': echo '<div class="select_wrapper ', $field['class'], '"><select class="select" name="', $field['id'], '" id="', $field['id'], '">'; echo '<option value="">select</option>'; if ($iva_sidebarwidget != "") { foreach ($field['options'] as $key => $value) { echo '<option value="' . $value . '"', $meta == $value ? ' selected="selected"' : '', '>', $value, '</option>'; } } echo '</select></div>'; break; case 'newmeta': $output = '<div id="custom_widget_sidebar"><table id="custom_widget_table" cellpadding="0" cellspacing="0">'; $output .= '<tbody>'; if ($meta != "") { foreach ($meta as $custom_meta) { $output .= '<tr><td><input type="text" name="' . $field['id'] . '[]" value="' . $custom_meta . '" size="30" style="width:97%" /></td><td><a class="button button-secondary" href="javascript:void(0);return false;" onClick="jQuery(this).parent().parent().remove();">' . __('Delete', 'iva_theme_admin') . '</a></td></tr>'; } } $output .= '</tbody></table><button type="button" class="button button-primary button-large" name="add_custom_widget" value="Add Meta" onClick="addWidgetRow()">' . __('Add Meta', 'iva_theme_admin') . '</button></div>'; ?> <script type="text/javascript" language="javascript"> function addWidgetRow(){ jQuery('#custom_widget_table').append('<tr><td><input type="text" name="<?php echo $field['id']; ?> []" value="" size="30" style="width:97%" /></td><td><a class="button button-secondary" href="javascript:void(0);return false;" onClick="jQuery(this).parent().parent().remove();"><?php _e('Delete', 'iva_theme_admin'); ?> </a></td></tr>'); } </script> <?php echo $output; break; case 'radio': $link_page = $link_cat = $link_post = $link_manually = ''; foreach ($field['options'] as $key => $value) { echo '<label class="rlabel"><input onclick="sys_custom_url_meta()" type="radio" name="', $field['id'], '" value="', $key, '"', $meta == $key ? ' checked="checked"' : '', ' />', $value, '</label>'; } global $post; $custom = get_post_custom($post->ID); if (isset($custom['link_page'])) { $link_page = $custom["link_page"][0]; } if (isset($custom['link_cat'])) { $link_cat = $custom["link_cat"][0]; } if (isset($custom['link_post'])) { $link_post = $custom["link_post"][0]; } if (isset($custom['link_manually'])) { $link_manually = stripslashes($custom["link_manually"][0]); } echo '<div id="customurl" >'; echo '<div id="sys_link" class="postlinkurl linkpage select_wrapper">'; echo '<select name="link_page" class="select">'; echo '<option value="">' . __('Select Page', 'iva_theme_admin') . '</option>'; foreach ($this->get_custom_options('page') as $key => $option) { echo '<option value="' . $key . '"'; if ($key == $link_page) { echo ' selected="selected"'; } echo '>' . $option . '</option>'; } echo '</select>'; echo '</div>'; echo '<div id="sys_category" class="postlinkurl linktocategory">'; echo '<select name="link_cat">'; echo '<option value="">' . __('Select Category', 'iva_theme_admin') . '</option>'; foreach ($this->get_custom_options('cat') as $key => $option) { echo '<option value="' . $key . '"'; if ($key == $link_cat) { echo ' selected="selected"'; } echo '>' . $option . '</option>'; } echo '</select>'; echo '</div>'; echo '<div id="sys_post" class="postlinkurl linktopost">'; echo '<select name="link_post">'; echo '<option value="">' . __('Select Post', 'iva_theme_admin') . '</option>'; foreach ($this->get_custom_options('post') as $key => $option) { echo '<option value="' . $key . '"'; if ($key == $link_post) { echo ' selected="selected"'; } echo '>' . $option . '</option>'; } echo '</select>'; echo '</div>'; echo '<div id="sys_manually" class="postlinkurl linkmanually">'; if (isset($link_manually)) { echo '<input type="text" name="link_manually" value="' . $link_manually . '" size="50%" />'; } else { echo '<input type="text" name="link_manually" value="" size="50%" />'; } echo '</div></div>'; break; case 'upload': echo '<input name="' . $field['id'] . '" id="' . $field['id'] . '" type="hidden" class="custom_upload_image" value="' . stripslashes(get_post_meta($post->ID, $field['id'], true)) . '" />'; echo '<input name="' . $field['id'] . '" id="' . $field['id'] . '" class="custom_upload_image_button button button-primary button-large clearfix" type="button" value="Choose Image" />'; echo '<div id="atp_imagepreview-' . $field['id'] . '" class="iva-screenshot">'; if (get_post_meta($post->ID, $field['id'], true)) { $iva_img = get_post_meta($post->ID, $field['id'], true); $image_attributes = wp_get_attachment_image_src(iva_get_attachment_id_from_src($iva_img)); if ($image_attributes[0] != '') { echo '<img src="' . esc_url($image_attributes[0]) . '" class="custom_preview_image" alt="" />'; echo '<a href="#" class="cimage_remove button button-primary">x</a>'; } else { echo '<img src="' . esc_url($iva_img) . '" class="custom_preview_image" alt="" />'; echo '<a href="#" class="cimage_remove button button-primary">x</a>'; } } echo '</div>'; break; case 'date': echo '<script type="text/javascript"> jQuery(document).ready(function() { "use strict"; jQuery("#' . $field['id'] . '").datepicker({ dateFormat: "d-M-yy" }); }); </script>'; echo '<input type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : $field['std'], '" size="30"/>'; break; case 'dateformat': global $default_date, $atp_defaultdate; echo '<script type="text/javascript"> jQuery(document).ready(function() { "use strict"; jQuery("#' . $field['id'] . '").datepicker({ dateFormat: "' . $atp_defaultdate . '" }); jQuery("#ui-datepicker-div").addClass("iva-date-ui"); }); </script>'; if ($meta != '') { if (is_numeric($meta)) { $meta = date_i18n($default_date, $meta); } else { $meta = $meta; $atp_defaultdate = 'd-MM-yy'; } } echo '<input type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : $field['std'], '" size="', $field['inputsize'], '" />'; break; case 'layout': $i = 0; $select_value = $meta; foreach ($field['options'] as $key => $value) { $i++; $checked = ''; $selected = ''; if ($select_value != '') { if ($select_value == $key) { $checked = ' checked'; $selected = 'atp-radio-option-selected'; } } else { if ($meta == $key) { $checked = ' checked'; $selected = 'atp-radio-option-selected'; } elseif ($i == 1 && !isset($select_value)) { $checked = ' checked'; $selected = 'atp-radio-option-selected'; } elseif ($i == 1 && $meta == '') { $checked = ' checked'; $selected = 'atp-radio-option-selected'; } else { $checked = 'checked'; } } echo '<div class="layout"><input value="' . $key . '" class="checkbox atp-radio-img-radio" type="radio" id="' . $field['id'] . $i . '" name="' . $field['id'] . '"' . $checked . ' />'; echo '<img src="' . esc_url($value) . '" alt="" class="atp-radio-option ' . $selected . '" onClick="document.getElementById(\'' . $field['id'] . $i . '\').checked = true;" /><span class="label">' . $key . '</span></div>'; } break; case 'checkbox': $meta != '' ? 'on' : 'off'; echo '<input type="checkbox" name="', $field['id'], '" id="', $field['id'], '"', $meta == 'on' ? ' checked="checked"' : '', ' /> <label for="', $field['id'], '">', $field['desc'], '</label>'; break; case 'background': $bg_color = ''; if (is_array($meta)) { if (!empty($meta)) { $bg_image = $meta['0']['image']; $bg_color = $meta['0']['color']; $bg_repeat = $meta['0']['repeat']; $bg_position = $meta['0']['position']; $bg_attachement = $meta['0']['attachement']; } } else { $bg_image = $meta; } // Position Properties Array $positionarray = array('left top' => 'Left Top', 'left center' => 'Left Center', 'left bottom' => 'Left Bottom', 'right top' => 'Right Top', 'right center' => 'Right Center', 'right bottom' => 'Right Bottom', 'center top' => 'Center Top', 'center center' => 'Center Center', 'center bottom' => 'Center Bottom'); // Repeat Properties Array $repeatarray = array('repeat' => 'Repeat', 'no-repeat' => 'No-Repeat', 'repeat-x' => 'Repeat-X', 'repeat-y' => 'Repeat-Y'); // Attachment Properties Array $attacharray = array('scroll' => 'Scroll', 'fixed' => 'Fixed'); echo '<div class="section section-background">'; //Upload Field echo '<div class="atp-background-upload clearfix">'; echo '<input type="text" name="' . $field['id'] . '_image" id="' . $field['id'] . '_image" class="custom_upload_image" value="' . $bg_image . '" />'; echo '<input type="button" name="' . $field['id'] . '_image" class="custom_upload_image_button button button-primary button-large" value="' . __('Choose Image', 'iva_theme_admin') . '" />'; echo '<div class="clear"></div>'; echo '<div id="atp_imagepreview-' . $field['id'] . '_image" class="iva-screenshot">'; if ($bg_image != '') { $image_attributes = wp_get_attachment_image_src(iva_get_attachment_id_from_src($bg_image)); if ($image_attributes[0] != '') { echo '<img src="' . esc_url($image_attributes[0]) . '" class="custom_preview_image" alt="" />'; echo '<a href="#" class="cimage_remove button button-primary">x</a>'; } else { echo '<img src="' . esc_url($bg_image) . '" class="custom_preview_image" alt="" />'; echo '<a href="#" class="cimage_remove button button-primary">x</a>'; } } echo '</div></div>'; //Color Input echo '<div class="atp-background-color">'; echo '<input class="color" name="' . $field['id'] . '_color" id="' . $field['id'] . '_color" type="text" value="' . $bg_color . '">'; echo '<div id="' . $field['id'] . '_color" class="wpcolorSelector"><div></div></div>'; echo '</div>'; // Background Repeat Options Input echo '<div class="atp-background-repeat">'; echo '<div class="select_wrapper">'; echo '<select class="select" name="' . $field['id'] . '_repeat" id="' . $field['id'] . '_repeat">'; foreach ($repeatarray as $key => $value) { $selected = $key == $bg_repeat ? ' selected="selected"' : ''; echo '<option value="' . $key . '" ' . $selected . '>' . $value . '</option>'; } echo '</select>'; echo '</div></div>'; //Background Position Options Input echo '<div class="atp-background-position"><div class="select_wrapper">'; echo '<select class="select" name="' . $field['id'] . '_position" id="' . $field['id'] . '_position">'; foreach ($positionarray as $key => $value) { $selected = $key == $bg_position ? ' selected="selected"' : ''; echo '<option value="' . $key . '" ' . $selected . '>' . $value . '</option>'; } echo '</select>'; echo '</div></div>'; //Background Attachement Options Input echo '<div class="atp-background-attachment"><div class="select_wrapper">'; echo '<select class="select" name="' . $field['id'] . '_attachement" id="' . $field['id'] . '_attachement">'; foreach ($attacharray as $key => $value) { $selected = $key == $bg_attachement ? ' selected="selected"' : ''; echo '<option value="' . $key . '" ' . $selected . '>' . $value . '</option>'; } echo '</select>'; echo '</div></div>'; echo '</div>'; break; case 'multicheckbox': foreach ($field['options'] as $key => $value) { echo '<div><input type="checkbox" ', isset($meta[$key]) == $key ? ' checked="checked"' : '', ' name="', $field['id'], '[', $key, ']', '" value="', $key, '" id="', $value, '" /> '; echo '<label for="', $value, '">', $value, '</label></div>'; } break; case 'default_editor': $editor_settings = array('wpautop' => true, 'media_buttons' => true, 'editor_class' => '', 'textarea_rows' => 5, 'tabindex' => 4, 'teeny' => true); $meta_box_value = $meta ? $meta : $field['std']; wp_editor($meta_box_value, $field['id'], $editor_settings); break; // Timings // Timings case 'add_timings': $iva_meta_options = array('meta' => $meta, 'field_id' => $field['id']); echo apply_filters('add_timings', $iva_meta_options); break; // GoogleMap // GoogleMap case 'googlemap': $iva_meta_options = array('meta' => $meta, 'field_id' => $field['id']); echo apply_filters('add_googlemap', $iva_meta_options); break; } if ($field['type'] != 'checkbox') { echo '<p class="desc">', $field['desc'], '</p>'; } echo '</div><div class="clear"></div>'; echo '</div>'; } echo '</div>'; }
function optionsframework_medialibrary_uploader($_id, $_value, $_mode = 'full', $_desc = '', $_postid = 0, $_name = '') { /* earlier code $optionsframework_settings = get_option($_id); //print_r($optionsframework_settings); // Gets the unique option id $option_name = $optionsframework_settings['id']; */ /* new code*/ $option_name = get_option($_id); /* end new code */ $output = $id = $class = $int = $name = ''; $value = get_option($_id); $id = strip_tags(strtolower($_id)); // Change for each field, using a "silent" post. If no post is present, one will be created. $int = ''; // If a value is passed and we don't have a stored value, use the value that's passed through. if ($_value != '' && $value == '') { $value = $_value; } if ($_name != '') { $name = $option_name . '[' . $id . '][' . $_name . ']'; } else { $name = $option_name . '[' . $id . ']'; } if ($value) { $class = ' has-file'; } $output .= '<input id="' . $id . '" class="upload' . $class . '" type="text" name="' . $id . '" value="' . $value . '" />' . "\n"; $output .= '<input id="upload_' . $id . '" class="upload_button button-primary button-large" type="button" value="' . __('Upload', 'iva_theme_admin') . '" rel="' . $int . '" />' . "\n"; if ($_desc != '') { $output .= '<span class="of_metabox_desc">' . $_desc . '</span>' . "\n"; } $output .= '<div class="clear"></div><div class="iva-screenshot" id="' . $id . '_image">' . "\n"; if ($value != '') { $remove = '<a href="javascript:(void);" class="custom_clear_image_button button button-primary">x</a>'; $image = preg_match('/(^.*\\.jpg|jpeg|png|gif*)/i', $value); if ($image) { $image_attributes = wp_get_attachment_image_src(iva_get_attachment_id_from_src($value)); if ($image_attributes[0] != '') { $output .= '<img src="' . esc_url($image_attributes[0]) . '" alt="" />' . $remove . ''; } else { $output .= '<img src="' . esc_url($value) . '" alt="" />' . $remove . ''; } } else { $parts = explode("/", $value); for ($i = 0; $i < sizeof($parts); ++$i) { $title = $parts[$i]; } // No output preview if it's not an image. $output .= ''; // Standard generic output if it's not an image. $title = __('View File', 'iva_theme_admin'); $output .= '<div class="no_image"><span class="file_link"></span>' . $remove . '</div>'; } } $output .= '</div>' . "\n"; return $output; }