'; echo ''; } add_action( 'admin_head', 'wpboxer_admin_head' ); } else { function wpboxer_head() { echo ''; } add_action( 'wp_head', 'wpboxer_head' ); } add_filter( 'widget_text', 'do_shortcode' ); add_theme_support( 'post-thumbnails', array( 'boxes' ) ); /** * Add custom columns to the columns array * * @param array $columns */ function admin_boxes_header_columns( $columns ) { if ( ! isset( $columns['id'] ) ) $columns['id'] = "Box ID"; if ( ! isset( $columns['boxset'] ) ) $columns['boxset'] = "Box Set"; if ( ! isset( $columns['boxwidth'] ) ) $columns['boxwidth'] = "Box Width"; if ( ! isset( $columns['boxindex'] ) ) $columns['boxindex'] = "Box Index"; return $columns; } add_filter( 'manage_edit-boxes_columns', 'admin_boxes_header_columns', 10, 1 ); /** * Populate the custom columns with values row by row * * @param string $column_name * @param int $post_id */ function admin_boxes_data_row( $column_name, $post_id ) { switch( $column_name ) { case 'id': echo $post_id; break; case 'boxset': echo get_the_term_list( $post_id, 'box-sets', '', ', ' ); break; case 'boxwidth': echo post_custom( 'box-width' ); break; case 'boxindex': echo post_custom( 'box-index' ); break; default: break; } } add_action( 'manage_posts_custom_column', 'admin_boxes_data_row', 10, 2 ); function wpboxer_action_links( $links, $file ) { if ( $file == 'boxer/wp-boxer.php' ) { $links[] = 'Settings'; $links[] = 'Screencast'; } return $links; } add_filter('plugin_action_links', 'wpboxer_action_links', 10, 2); // ==================================================================================== // = REGISTER BOX - Used to register custom post type "box" // ==================================================================================== function wpboxer_post_type_register() { $labels = array( "name" => _x("Boxes", "post type general name"), "singular_name" => _x("Box Item", "post type singular name"), "add_new" => _x("Add New", "Box item"), "add_new_item" => __("Add New Box"), "edit_item" => __("Edit Box Item"), "new_item" => __("New Box Item"), "view_item" => __("View Box Item"), "search_items" => __("Search Box"), "not_found" => __("Nothing found"), "not_found_in_trash" => __("Nothing found in Trash"), "parent_item_colon" => "" ); $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'query_var' => true, //'menu_icon' => get_stylesheet_directory_uri() . '/article16.png', 'rewrite' => true, 'capability_type' => 'post', 'hierarchical' => false, 'menu_position' => null, 'supports' => array('title','editor','thumbnail') ); register_post_type( 'boxes' , $args ); } add_action('init', 'wpboxer_post_type_register'); // ==================================================================================== // = REGISTER BOX-SET - Used to register custom taxonomy "box set" // ==================================================================================== function wpboxer_build_taxonomies() { // Add new taxonomy, make it hierarchical (like categories) $labels = array( 'name' => _x( 'Box Sets', 'taxonomy general name' ), 'singular_name' => _x( 'Box Set', 'taxonomy singular name' ), 'search_items' => __( 'Search Box Sets' ), 'all_items' => __( 'All Box Sets' ), 'parent_item' => __( 'Parent Box Set' ), 'parent_item_colon' => __( 'Parent Box Set:' ), 'edit_item' => __( 'Edit Box Set' ), 'update_item' => __( 'Update Box Set' ), 'add_new_item' => __( 'Add New Box Set' ), 'new_item_name' => __( 'New Box Set Name' ), 'menu_name' => __( 'Box Set' ), ); register_taxonomy('box-sets', array('boxes'), array( 'hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'box-set' ), )); } add_action('init', 'wpboxer_build_taxonomies', 0); // ==================================================================================== // = REGISTER META BOX - Used to register our meta box with additional settings // ==================================================================================== function wpboxer_box_info_init() { add_meta_box("cow_box_info", "Additional Box Settings", "wpboxer_box_info_cb", "boxes", "normal", "high"); } add_action("add_meta_boxes", "wpboxer_box_info_init"); function wpboxer_box_info_cb() { global $post, $widths; $custom = get_post_custom( $post->ID ); ! empty( $custom["box-type"][0] ) ? $box_type = $custom["box-type"][0] : $box_type = get_option( 'cow_box_type' ); ! empty( $custom["box-header-color"][0] ) ? $box_header_color = $custom["box-header-color"][0] : $box_header_color = get_option( 'cow_header_color' ); ! empty( $custom["image-frame"][0] ) ? $image_frame = $custom["image-frame"][0] : $image_frame = get_option( 'cow_image_frame' ); ! empty( $custom["box-text-align"][0] ) ? $box_text_align = $custom["box-text-align"][0] : $box_text_align = get_option( 'cow_text_align' ); ! empty( $custom["box-index"][0] ) ? $box_index = $custom["box-index"][0] : $box_index = -1; ! empty( $custom["box-width"][0] ) ? $box_width = $custom["box-width"][0] : $box_width = get_option( 'cow_box_width' ); ! empty( $custom["box-link"][0] ) ? $box_link = $custom["box-link"][0] : $box_link = get_option( 'cow_box_link' ); ! empty( $custom["box-link-type"][0] ) ? $box_link_type = $custom["box-link-type"][0] : $box_link_type = get_option( 'cow_box_link_type' ); ! empty( $custom["box-link-text"][0] ) ? $box_link_text = $custom["box-link-text"][0] : $box_link_text = get_option( 'cow_box_link_text' ); ?>
> box-type-01 > box-type-02 > box-type-03 > box-type-04 > box-type-05 > box-type-06 > box-type-07 > box-type-08
/>
>
>
ID, "box-type", $_POST["box-type"] ); } if ( isset( $_POST['box-header-color'] ) ) { update_post_meta( $post->ID, "box-header-color", $_POST["box-header-color"] ); } if ( isset( $_POST['image-frame'] ) ) { update_post_meta( $post->ID, "image-frame", $_POST["image-frame"] ); } else { // Set option when unchecked update_post_meta( $post->ID, "image-frame", "off" ); } if ( isset( $_POST['box-text-align'] ) ) { update_post_meta( $post->ID, "box-text-align", $_POST["box-text-align"] ); } if ( isset( $_POST['box-index'] ) ) { update_post_meta( $post->ID, "box-index", $_POST["box-index"] ); } if ( isset( $_POST['box-width'] ) ) { update_post_meta( $post->ID, "box-width", $_POST["box-width"] ); } if ( isset( $_POST['box-link'] ) ) { update_post_meta( $post->ID, "box-link", $_POST["box-link"] ); } if ( isset( $_POST['box-link-type'] ) ) { update_post_meta( $post->ID, "box-link-type", $_POST["box-link-type"] ); } if ( isset( $_POST['box-link-text'] ) ) { update_post_meta( $post->ID, "box-link-text", esc_attr($_POST["box-link-text"]) ); } } add_action( 'save_post', 'wpboxer_box_info_save' ); // ==================================================================================== // = OPTIONS PAGE - Used to create an options page for BOXER // ==================================================================================== function wpboxer_options_page() { add_options_page('Boxer Options', 'Boxer', 8, __FILE__, 'wpboxer_options_page_cb'); } add_action('admin_menu', 'wpboxer_options_page'); function wpboxer_options_page_cb() { include_once('wp-boxer-options.php'); } // ==================================================================================== // = SHORTCODES - Used to include shortcodes // ==================================================================================== /** * put your comment there... * * @param array $atts */ function wpboxer_box_insert( $atts ) { global $wpdb; extract( shortcode_atts( array( 'set' => '', // required 'post_type' => 'boxes', // optional 'no' => -1, // optional 'link_color' => 'light', // optional ), $atts ) ); if ( ! $set ) { return 'No Box Set specified!'; } else { $query = null; $query = new WP_Query( array( 'post_type' => $post_type, 'box-sets' => $set, 'posts_per_page' => $no, 'orderby' => 'meta_value', 'meta_key' => 'box-index', 'order' => 'ASC' )); ob_start(); require_once( 'classes/box.class.php'); $Box = new Box(); if ( $query->have_posts() ) { ?>
have_posts() ): $query->the_post(); $Box->set_type( get_post_meta( $query->post->ID, 'box-type', true ) ); $Box->set_header_color( get_post_meta( $query->post->ID, 'box-header-color', true ) ); $Box->set_image_frame( get_post_meta( $query->post->ID, 'image-frame', true ) ); $Box->set_width( get_post_meta( $query->post->ID, 'box-width', true ) ); $Box->set_alignment( get_post_meta( $query->post->ID, 'box-text-align', true ) ); $Box->set_title( $query->post->post_title ); if ( has_post_thumbnail() ) $Box->set_image( wp_get_attachment_image_src( get_post_thumbnail_id(), 'large' ) ); $Box->set_content( $query->post->post_content ); $Box->set_link( get_post_meta( $query->post->ID, 'box-link', true ) ); $Box->set_link_type( get_post_meta( $query->post->ID, 'box-link-type', true ) ); $Box->set_link_type_color( $link_color ); $Box->set_link_text( get_post_meta( $query->post->ID, 'box-link-text', true ) ); echo $Box->get_html(); endwhile; ?>
4, 'layout' => 'full',//sidebar 'cat' => '', 'max' => -1, 'title' => '', 'titlelinkable' => 'false', 'desc' => '', 'more' => '', 'moretext' => '', 'height' => '', 'nopaging' => 'false', 'sortable' => 'false', 'group' => 'true', 'lightboxtitle' => 'portfolio', //portfolio,image,imagecaption,imagedesc,none 'advancedesc'=>'false', 'ids' => '', 'order'=> 'ASC', 'orderby'=> 'menu_order', //none, id, author, title, date, modified, parent, rand, comment_count, menu_order ), $atts)); $size = array(); switch($column){ case 1: $column_class = 'one_column'; break; case 2: $column_class = 'one_half'; break; case 3: $column_class = 'one_third'; break; case 4: $column_class = 'one_fourth'; break; default: $column_class = 'four_columns'; if($layout=='sidebar'){ $size[0] = '136'; }else{ $size[0] = '217'; } $size[1] = (int)theme_get_option('portfolio','4_columns_height'); } if($height){ $size[1] = $height; } $rel_group = 'portfolio_'.rand(1,1000); //for lightbox group $output = '
'; $output .= ''; if ($nopaging == 'false') { ob_start(); theme_portfolio_pagenavi('', '', $r, $paged); $output .= ob_get_clean(); } $output .= '
'; wp_reset_postdata(); $wp_filter['the_content'] = $the_content_filter_backup; return $output; } add_shortcode('portfolio', 'theme_shortcode_portfolio'); function wpboxer_portfolio_pagenavi($before = '', $after = '',$portfolio_query, $paged) { global $wpdb, $wp_query; if (is_single()) return; $pagenavi_options = array( //'pages_text' => __('Page %CURRENT_PAGE% of %TOTAL_PAGES%','striking_front'), 'pages_text' => '', 'current_text' => '%PAGE_NUMBER%', 'page_text' => '%PAGE_NUMBER%', 'first_text' => __('« First','striking_front'), 'last_text' => __('Last »','striking_front'), 'next_text' => __('»','striking_front'), 'prev_text' => __('«','striking_front'), 'dotright_text' => __('...','striking_front'), 'dotleft_text' => __('...','striking_front'), 'style' => 1, 'num_pages' => 4, 'always_show' => 0, 'num_larger_page_numbers' => 3, 'larger_page_numbers_multiple' => 10, 'use_pagenavi_css' => 0, ); $request = $portfolio_query->request; $posts_per_page = intval(get_query_var('posts_per_page')); global $wp_version; if(is_front_page() && version_compare($wp_version, "3.1", '>=')){//fix wordpress 3.1 paged query $paged = (get_query_var('paged')) ?intval(get_query_var('paged')) : intval(get_query_var('page')); }else{ $paged = intval(get_query_var('paged')); } $numposts = $portfolio_query->found_posts; $max_page = intval($portfolio_query->max_num_pages); if (empty($paged) || $paged == 0) $paged = 1; $pages_to_show = intval($pagenavi_options['num_pages']); $larger_page_to_show = intval($pagenavi_options['num_larger_page_numbers']); $larger_page_multiple = intval($pagenavi_options['larger_page_numbers_multiple']); $pages_to_show_minus_1 = $pages_to_show - 1; $half_page_start = floor($pages_to_show_minus_1 / 2); $half_page_end = ceil($pages_to_show_minus_1 / 2); $start_page = $paged - $half_page_start; if ($start_page <= 0) $start_page = 1; $end_page = $paged + $half_page_end; if (($end_page - $start_page) != $pages_to_show_minus_1) { $end_page = $start_page + $pages_to_show_minus_1; } if ($end_page > $max_page) { $start_page = $max_page - $pages_to_show_minus_1; $end_page = $max_page; } if ($start_page <= 0) $start_page = 1; $larger_pages_array = array(); if ($larger_page_multiple) for($i = $larger_page_multiple; $i <= $max_page; $i += $larger_page_multiple) $larger_pages_array[] = $i; if ($max_page > 1 || intval($pagenavi_options['always_show'])) { $pages_text = str_replace("%CURRENT_PAGE%", number_format_i18n($paged), $pagenavi_options['pages_text']); $pages_text = str_replace("%TOTAL_PAGES%", number_format_i18n($max_page), $pages_text); echo $before . '
' . "\n"; switch(intval($pagenavi_options['style'])){ // Normal case 1: if (! empty($pages_text)) { echo '' . $pages_text . ''; } if ($start_page >= 2 && $pages_to_show < $max_page) { $first_page_text = str_replace("%TOTAL_PAGES%", number_format_i18n($max_page), $pagenavi_options['first_text']); echo '' . $first_page_text . ''; if (! empty($pagenavi_options['dotleft_text'])) { echo '' . $pagenavi_options['dotleft_text'] . ''; } } $larger_page_start = 0; foreach($larger_pages_array as $larger_page) { if ($larger_page < $start_page && $larger_page_start < $larger_page_to_show) { $page_text = str_replace("%PAGE_NUMBER%", number_format_i18n($larger_page), $pagenavi_options['page_text']); echo '' . $page_text . ''; $larger_page_start++; } } previous_posts_link($pagenavi_options['prev_text']); for($i = $start_page; $i <= $end_page; $i++) { if ($i == $paged) { $current_page_text = str_replace("%PAGE_NUMBER%", number_format_i18n($i), $pagenavi_options['current_text']); echo '' . $current_page_text . ''; } else { $page_text = str_replace("%PAGE_NUMBER%", number_format_i18n($i), $pagenavi_options['page_text']); echo '' . $page_text . ''; } } next_posts_link($pagenavi_options['next_text'], $max_page); $larger_page_end = 0; foreach($larger_pages_array as $larger_page) { if ($larger_page > $end_page && $larger_page_end < $larger_page_to_show) { $page_text = str_replace("%PAGE_NUMBER%", number_format_i18n($larger_page), $pagenavi_options['page_text']); echo '' . $page_text . ''; $larger_page_end++; } } if ($end_page < $max_page) { if (! empty($pagenavi_options['dotright_text'])) { echo '' . $pagenavi_options['dotright_text'] . ''; } $last_page_text = str_replace("%TOTAL_PAGES%", number_format_i18n($max_page), $pagenavi_options['last_text']); echo '' . $last_page_text . ''; } break; // Dropdown case 2: echo '
' . "\n"; echo '\n"; echo "
\n"; break; } echo '
' . $after . "\n"; } }