$portfoliourl_1_metabox = array( 'id' => 'portfoliourl', 'title' => 'Portfolio URL', 'page' => array('portfolio'), 'context' => 'side', 'priority' => 'low', 'fields' => array( array( 'name' => 'Portfolio Meta URL', 'desc' => 'Enter a URL you want to use somewhere in the portfolio for a link', 'id' => 'nick_portfolio_url', 'class' => 'nick_portfolio_url', 'type' => 'text', 'rich_editor' => 0, 'max' => 0 ), ) ); add_action('admin_menu', 'nick_add_portfoliourl_1_meta_box'); function nick_add_portfoliourl_1_meta_box() { global $portfoliourl_1_metabox; foreach($portfoliourl_1_metabox['page'] as $page) { add_meta_box($portfoliourl_1_metabox['id'], $portfoliourl_1_metabox['title'], 'nick_show_portfoliourl_1_box', $page, 'side', 'low', $portfoliourl_1_metabox); } } // function to show meta boxes function nick_show_portfoliourl_1_box() { global $post; global $portfoliourl_1_metabox; global $nick_prefix; global $wp_version; // Use nonce for verification echo ''; echo ''; foreach ($portfoliourl_1_metabox['fields'] as $field) { // get current post meta data $meta = get_post_meta($post->ID, $field['id'], true); echo '', '', ''; } echo '
'; switch ($field['type']) { case 'text': echo '
', '', stripslashes($field['desc']); break; } echo '
', '
'; } // Save data from meta box add_action('save_post', 'nick_portfoliourl_1_save'); function nick_portfoliourl_1_save($post_id) { global $post; global $portfoliourl_1_metabox; // verify nonce if ( ! isset( $_POST['nick_portfoliourl_1_meta_box_nonce'] ) || ! wp_verify_nonce($_POST['nick_portfoliourl_1_meta_box_nonce'], basename(__FILE__))) { return $post_id; } // check autosave if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return $post_id; } // check 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 ($portfoliourl_1_metabox['fields'] as $field) { $old = get_post_meta($post_id, $field['id'], true); $new = $_POST[$field['id']]; if ($new && $new != $old) { if($field['type'] == 'date') { $new = nick_format_date($new); update_post_meta($post_id, $field['id'], $new); } else { if(is_string($new)) { $new = $new; } update_post_meta($post_id, $field['id'], $new); } } elseif ('' == $new && $old) { delete_post_meta($post_id, $field['id'], $old); } } } function nick_export_ui_scripts() { global $nick_options, $post; ?>