'tmk-meta-box-page-page', 'title' => __('Background Image', 'weddingalbum'), 'page' => 'page', 'context' => 'normal', 'priority' => 'high', 'fields' => array( array( 'name' => __('Background Image', 'weddingalbum'), 'desc' => __('Upload a custom background image for this page.', 'weddingalbum'), 'id' => 'tmk_background_image', 'type' => 'text', 'std' => '' ), array( 'name' => '', 'desc' => '', 'id' => 'tmk_background_image_button', 'type' => 'button', 'class' => 'image-button', 'std' => 'Browse' ), ), ); //Add meta box function tmk_add_box_page() { global $meta_box_page; add_meta_box($meta_box_page['id'], $meta_box_page['title'], 'tmk_show_box_page', $meta_box_page['page'], $meta_box_page['context'], $meta_box_page['priority']); add_meta_box($meta_box_page['id'], $meta_box_page['title'], 'tmk_show_box_page', 'post', $meta_box_page['context'], $meta_box_page['priority']); add_meta_box($meta_box_page['id'], $meta_box_page['title'], 'tmk_show_box_page', 'gallery', $meta_box_page['context'], $meta_box_page['priority']); } add_action('admin_menu', 'tmk_add_box_page'); //Callback function function tmk_show_box_page() { global $meta_box_page, $post; echo ''; echo ''; foreach ($meta_box_page['fields'] as $field) { echo TmkRenderer::renderMeta($field); } echo '
'; } //Save data function tmk_save_data_page($post_id) { global $meta_box_page; //Check autosave if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return $post_id; } //Verify nonce if (!wp_verify_nonce($_POST['tmk_meta_box_page_nonce'], basename(__FILE__))) { return $post_id; } //Check user permissions if ('page' == $_POST['post_type']) { if (!current_user_can('edit_page', $post_id)) { return $post_id; } } elseif (!current_user_can('edit_post', $post_id)) { return $post_id; } foreach ($meta_box_page['fields'] as $field) { $old_value = get_post_meta($post_id, $field['id'], true); $new_value = $_POST[$field['id']]; if ($new_value && $new_value != $old) { update_post_meta($post_id, $field['id'], stripslashes(htmlspecialchars($new_value))); } elseif ($new_value == '' && $old_value) { delete_post_meta($post_id, $field['id'], $old_value); } } } add_action('save_post', 'tmk_save_data_page'); //Add styles and scripts function tmk_admin_scripts_page() { wp_enqueue_script('media-upload'); wp_enqueue_script('thickbox'); wp_register_script('tmk_upload', THEME_URI.'/admin/js/upload_button.js', array('jquery','media-upload','thickbox')); wp_enqueue_script('tmk_upload'); } function tmk_admin_styles_page() { wp_enqueue_style('thickbox'); } add_action('admin_print_scripts', 'tmk_admin_scripts_page'); add_action('admin_print_styles', 'tmk_admin_styles_page'); ?> Our Wedding | Karena Album foto is too Mainstream!