Added reports section (no content yet) and redone admin stars

This commit is contained in:
Mike Jolley 2011-09-16 09:30:16 +01:00
parent f4531a279f
commit 0d0bb3436c
7 changed files with 42 additions and 144 deletions

View File

@ -217,7 +217,7 @@ function woocommmerce_dashboard_recent_reviews() {
$rating = get_comment_meta( $comment->comment_ID, 'rating', true );
echo '<div class="star-rating" title="'.$rating.'">
<span style="width:'.($rating*16).'px">'.$rating.' '.__('out of 5', 'woothemes').'</span></div>';
<span style="width:'.($rating*10).'px">'.$rating.' '.__('out of 5', 'woothemes').'</span></div>';
echo '<h4 class="meta"><a href="'.get_permalink($comment->ID).'#comment-'.$comment->comment_ID .'">'.$comment->post_title.'</a> reviewed by ' .strip_tags($comment->comment_author) .'</h4>';
echo '<blockquote>'.strip_tags($comment->comment_excerpt).' [...]</blockquote></li>';

View File

@ -18,6 +18,7 @@ function woocommerce_admin_init() {
include_once( 'admin-dashboard.php' );
include_once( 'admin-import.php' );
include_once( 'admin-post-types.php' );
include_once( 'admin-reports.php' );
include_once( 'admin-taxonomies.php' );
include_once( 'writepanels/writepanels-init.php' );
}
@ -46,6 +47,7 @@ function woocommerce_admin_menu() {
add_menu_page(__('WooCommerce'), __('WooCommerce'), 'manage_woocommerce', 'woocommerce' , 'woocommerce_settings', $woocommerce->plugin_url() . '/assets/images/icons/menu_icons.png', 55);
add_submenu_page('woocommerce', __('General Settings', 'woothemes'), __('Settings', 'woothemes') , 'manage_woocommerce', 'woocommerce', 'woocommerce_settings');
add_submenu_page('woocommerce', __('Reports', 'woothemes'), __('Reports', 'woothemes') , 'manage_woocommerce', 'woocommerce_reports', 'woocommerce_reports');
add_submenu_page('edit.php?post_type=product', __('Attributes', 'woothemes'), __('Attributes', 'woothemes'), 'manage_woocommerce', 'attributes', 'woocommerce_attributes');
}

32
admin/admin-reports.php Normal file
View File

@ -0,0 +1,32 @@
<?php
/**
* Functions used for displaying reports in admin
*
* @author WooThemes
* @category Admin
* @package WooCommerce
*/
function woocommerce_reports() {
$current_tab = (isset($_GET['tab'])) ? $_GET['tab'] : 'orders';
?>
<div class="wrap woocommerce">
<div class="icon32 icon32-woocommerce-settings" id="icon-woocommerce"><br></div><h2 class="nav-tab-wrapper woo-nav-tab-wrapper">
<?php
$tabs = array(
'orders' => __('Orders', 'woothemes'),
'products' => __('Products', 'woothemes'),
'customers' => __('Customers', 'woothemes')
);
foreach ($tabs as $name => $label) :
echo '<a href="'.admin_url('admin.php?page=woocommerce_reports&tab='.$name).'" class="nav-tab ';
if($current_tab==$name) echo 'nav-tab-active';
echo '">'.$label.'</a>';
endforeach;
?>
<?php do_action('woocommerce_reports_tabs'); ?>
</h2>
</div>
<?php
}

View File

@ -84,7 +84,7 @@ ul.recent-orders li .refunded,ul.recent-orders li .cancelled{color:#999;}
#woocommmerce_dashboard_recent_reviews h4.meta{line-height:1.4;margin:-0.2em 0 0 0;font-weight:normal;color:#999;}
#woocommmerce_dashboard_recent_reviews blockquote{padding:0;margin:0;}
#woocommmerce_dashboard_recent_reviews .avatar{float:left;margin:0 10px 5px 0;}
#woocommmerce_dashboard_recent_reviews .star-rating{float:right;width:80px;height:16px;background:url(../images/star.png) repeat-x left 0;}#woocommmerce_dashboard_recent_reviews .star-rating span{background:url(../images/star.png) repeat-x left -32px;height:0;padding-top:16px;overflow:hidden;float:left;}
#woocommmerce_dashboard_recent_reviews .star-rating{float:right;width:50px;height:10px;margin:3px 0 0 0;background:url(../images/admin-star.png) repeat-x left -10px;}#woocommmerce_dashboard_recent_reviews .star-rating span{background:url(../images/admin-star.png) repeat-x left 0;height:0;padding-top:10px;overflow:hidden;float:left;}
.woocommerce table.shippingrows td,.woocommerce table.shippingrows th{vertical-align:middle;}
.woocommerce table.shippingrows td a.remove{margin:0 !important;}
div.taxrows .taxrow{padding-bottom:8px;}div.taxrows .taxrow select{width:125px;}

View File

@ -439,13 +439,14 @@ ul.recent-orders {
}
.star-rating {
float: right;
width: 80px;
height: 16px;
background: url(../images/star.png) repeat-x left 0;
width: 50px;
height: 10px;
margin: 3px 0 0 0;
background: url(../images/admin-star.png) repeat-x left -10px;
span {
background: url(../images/star.png) repeat-x left -32px;
background: url(../images/admin-star.png) repeat-x left 0;
height: 0;
padding-top: 16px;
padding-top: 10px;
overflow: hidden;
float: left;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 490 B

View File

@ -1,137 +0,0 @@
<?php
/**
* WooCommerce Queries
*
* Handles front end queries and loops.
*
* @package WooCommerce
* @category Core
* @author WooThemes
*/
/**
* Query the products, applying sorting/ordering etc. This applies to the main wordpress loop
*/
add_filter( 'parse_query', 'woocommerce_parse_query' );
function woocommerce_parse_query( $q ) {
global $woocommerce;
if (is_admin()) return;
// Only apply to product categories, the product post archive, the shop page, and product tags
if ( ( isset( $q->query_vars['suppress_filters'] ) && true == $q->query_vars['suppress_filters'] ) || (!$q->is_tax( 'product_cat' ) && !$q->is_post_type_archive( 'product' ) && !$q->is_page( get_option('woocommerce_shop_page_id') ) && !$q->is_tax( 'product_tag' ))) return;
$meta_query = (array) $q->get( 'meta_query' );
// Visibility
if ( is_search() ) $in = array( 'visible', 'search' ); else $in = array( 'visible', 'catalog' );
$meta_query[] = array(
'key' => 'visibility',
'value' => $in,
'compare' => 'IN'
);
// In stock
if (get_option('woocommerce_hide_out_of_stock_items')=='yes') :
$meta_query[] = array(
'key' => 'stock_status',
'value' => 'instock',
'compare' => '='
);
endif;
// Ordering
if (isset($_POST['orderby']) && $_POST['orderby'] != '') $_SESSION['orderby'] = $_POST['orderby'];
$current_order = (isset($_SESSION['orderby'])) ? $_SESSION['orderby'] : 'title';
switch ($current_order) :
case 'date' :
$orderby = 'date';
$order = 'desc';
$meta_key = '';
break;
case 'price' :
$orderby = 'meta_value_num';
$order = 'asc';
$meta_key = 'price';
break;
default :
$orderby = 'title';
$order = 'asc';
$meta_key = '';
break;
endswitch;
// Get a list of post id's which match the current filters set (in the layered nav and price filter)
$post__in = array_unique(apply_filters('loop-shop-posts-in', array()));
// Ordering query vars
$q->set( 'orderby', $orderby );
$q->set( 'order', $order );
$q->set( 'meta_key', $meta_key );
// Query vars that affect posts shown
$q->set( 'post_type', 'product' );
$q->set( 'meta_query', $meta_query );
$q->set( 'post__in', $post__in );
$q->set( 'posts_per_page', apply_filters('loop_shop_per_page', get_option('posts_per_page')) );
// Store variables
$woocommerce->query->post__in = $post__in;
$woocommerce->query->meta_query = $meta_query;
// We're on a shop page so queue the woocommerce_get_products_in_view function
add_action('wp', 'woocommerce_get_products_in_view', 2);
}
/**
* Remove parse_query so it only applies to main loop
*/
add_action('wp', 'woocommerce_remove_parse_query');
function woocommerce_remove_parse_query() {
remove_filter( 'parse_query', 'woocommerce_parse_query' );
}
/**
* Get an unpaginated list all product ID's (both filtered and unfiltered)
*/
function woocommerce_get_products_in_view() {
global $wp_query, $woocommerce;
$unfiltered_product_ids = array();
// Get all visible posts, regardless of filters
$unfiltered_product_ids = get_posts(
array_merge(
$wp_query->query,
array(
'post_type' => 'product',
'numberposts' => -1,
'post_status' => 'publish',
'meta_query' => $woocommerce->query->meta_query,
'fields' => 'ids'
)
)
);
// Store the variable
$woocommerce->query->unfiltered_product_ids = $unfiltered_product_ids;
// Also store filtered posts ids...
if (sizeof($woocommerce->query->post__in)>0) :
$woocommerce->query->filtered_product_ids = array_intersect($woocommerce->query->unfiltered_product_ids, $woocommerce->query->post__in);
else :
$woocommerce->query->filtered_product_ids = $woocommerce->query->unfiltered_product_ids;
endif;
// And filtered post ids which just take layered nav into consideration (to find max price in the price widget)
if (sizeof($woocommerce->query->layered_nav_post__in)>0) :
$woocommerce->query->layered_nav_product_ids = array_intersect($woocommerce->query->unfiltered_product_ids, $woocommerce->query->layered_nav_post__in);
else :
$woocommerce->query->layered_nav_product_ids = $woocommerce->query->unfiltered_product_ids;
endif;
}