Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //define some constants
- define('FUNCTIONS_PATH', STYLESHEETPATH . '/functions/');
- define('FUNCTIONS', get_bloginfo('stylesheet_directory') . '/functions/');
- // Require WP_Alchemy Meta Box Class
- require_once(FUNCTIONS_PATH . 'WPAlchemy/MetaBox.php');
- // include css to help style our custom meta boxes
- // this should be a global stylesheet used by all similar meta boxes
- if (is_admin()) wp_enqueue_style('custom_meta_css', FUNCTIONS .'WPAlchemy/meta.css');
- // Define Metaboxes
- $featured_metabox = new WPAlchemy_MetaBox(array
- (
- 'id' => '_featured_meta', // underscore prefix hides fields from the custom fields area
- 'title' => _('Add Slides'),
- 'template' => FUNCTIONS_PATH .'WPAlchemy/new_featured_meta.php',
- 'prefix' => '_featured_meta_',
- 'types' => array('page'),
- 'priority' => 'high',
- 'init_action' => 'featured_init_action', // defaults to NULL
- 'head_action' => 'featured_head_action',
- ));
- function featured_init_action(){
- wp_enqueue_script('jquery-ui', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js' , array( 'jquery' ));
- }
- function featured_head_action() {
- global $featured_metabox; ?>
- <script type='text/javascript'>
- /* <![CDATA[ */
- //avoid jquery flicker
- document.write('<style type="text/css">body{display:none}</style>');
- jQuery(document).ready(function($) {
- $('#js-warning').hide();
- /*
- * Change title of custom slide on change of input box
- */
- $('.slide_title').live('change', function() {
- $(this).parents('.wpa_group').children('h4:first').html("<?php _e('Custom Slide: ');?>" + $(this).val());
- });
- var formfield;
- $('.upload_image_button').live('click', function() {
- formfield = $(this).prev('input');
- tb_show('', 'media-upload.php?type=image&TB_iframe=true');
- return false;
- });
- window.original_send_to_editor = window.send_to_editor;
- window.send_to_editor = function(html){
- if (formfield) {
- fileurl = $('img',html).attr('src');
- formfield.val(fileurl);
- formfield.prev('img').attr('src',fileurl).fadeIn();
- tb_remove();
- formfield = ''; //reset formfield to null so original works
- } else {
- window.original_send_to_editor(html);
- }
- };
- });
- /* ]]> */
- </script> <?php
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement