Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Gary Cao
committed
Jun 11, 2013
1 parent
eeecc7f
commit 6d2881f
Showing
79 changed files
with
7,461 additions
and
7,417 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -259,6 +259,4 @@ function rewind_breadcrumbs() { | |
} | ||
} | ||
|
||
} | ||
|
||
?> | ||
} |
61 changes: 61 additions & 0 deletions
61
wpsc-components/theme-engine-v1/classes/hide-subcatsprods-in-cat.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
/** | ||
* wpsc_display_products_page class | ||
* | ||
* Shows only products from current category, but not from subcategories. | ||
* | ||
* @access public | ||
* @return void | ||
*/ | ||
|
||
class WPSC_Hide_subcatsprods_in_cat { | ||
var $q; | ||
|
||
function get_posts( &$q ) { | ||
$this->q =& $q; | ||
if ( ( !isset($q->query_vars['taxonomy']) || ( "wpsc_product_category" != $q->query_vars['taxonomy'] )) ) | ||
return false; | ||
|
||
add_action( 'posts_where', array( &$this, 'where' ) ); | ||
add_action( 'posts_join', array( &$this, 'join' ) ); | ||
} | ||
|
||
function where( $where ) { | ||
global $wpdb; | ||
|
||
remove_action( 'posts_where', array( &$this, 'where' ) ); | ||
|
||
$term_id=$wpdb->get_var($wpdb->prepare('SELECT term_id FROM '.$wpdb->terms.' WHERE slug = %s ', $this->q->query_vars['term'])); | ||
|
||
if ( !is_numeric( $term_id ) || $term_id < 1 ) | ||
return $where; | ||
|
||
$term_taxonomy_id = $wpdb->get_var($wpdb->prepare('SELECT term_taxonomy_id FROM '.$wpdb->term_taxonomy.' WHERE term_id = %d and taxonomy = %s', $term_id, $this->q->query_vars['taxonomy'])); | ||
|
||
if ( !is_numeric($term_taxonomy_id) || $term_taxonomy_id < 1) | ||
return $where; | ||
|
||
$field = preg_quote( "$wpdb->term_relationships.term_taxonomy_id", '#' ); | ||
|
||
$just_one = $wpdb->prepare( " AND $wpdb->term_relationships.term_taxonomy_id = %d ", $term_taxonomy_id ); | ||
if ( preg_match( "#AND\s+$field\s+IN\s*\(\s*(?:['\"]?\d+['\"]?\s*,\s*)*['\"]?\d+['\"]?\s*\)#", $where, $matches ) ) | ||
$where = str_replace( $matches[0], $just_one, $where ); | ||
else | ||
$where .= $just_one; | ||
|
||
return $where; | ||
} | ||
|
||
function join($join){ | ||
global $wpdb; | ||
remove_action( 'posts_where', array( &$this, 'where' ) ); | ||
remove_action( 'posts_join', array( &$this, 'join' ) ); | ||
if( strpos($join, "JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)" ) ){ | ||
return $join; | ||
} | ||
$join .= " JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)"; | ||
return $join; | ||
} | ||
} | ||
|
File renamed without changes.
130 changes: 130 additions & 0 deletions
130
wpsc-components/theme-engine-v1/classes/wpsc-products-by-category.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
<?php | ||
/** | ||
* wpsc_products_by_category class. | ||
* | ||
*/ | ||
class wpsc_products_by_category { | ||
|
||
var $sql_components = array( ); | ||
|
||
/** | ||
* wpsc_products_by_category function. | ||
* | ||
* @access public | ||
* @param mixed $query | ||
* @return void | ||
*/ | ||
function wpsc_products_by_category( $query ) { | ||
global $wpdb; | ||
$q = $query->query_vars; | ||
|
||
|
||
// Category stuff for nice URLs | ||
if ( !empty( $q['wpsc_product_category'] ) && !$query->is_singular ) { | ||
$q['taxonomy'] = 'wpsc_product_category'; | ||
$q['term'] = $q['wpsc_product_category']; | ||
$in_cats = ''; | ||
$join = " INNER JOIN $wpdb->term_relationships | ||
ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) | ||
INNER JOIN $wpdb->term_taxonomy | ||
ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id) | ||
"; | ||
if(isset($q['meta_key'])) | ||
$join .= " INNER JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) "; | ||
|
||
$whichcat = " AND $wpdb->term_taxonomy.taxonomy = '{$q['taxonomy']}' "; | ||
|
||
$term_data = get_term_by( 'slug', $q['term'], $q['taxonomy'] ); | ||
|
||
if( is_object( $term_data ) ) | ||
$in_cats = array( $term_data->term_id ); | ||
|
||
if('0' != get_option('show_subcatsprods_in_cat') && is_object($term_data)){ | ||
$term_children_data = get_term_children( $term_data->term_id, $q['taxonomy'] ); | ||
$in_cats = array_reverse( array_merge( $in_cats, $term_children_data ) ); | ||
} | ||
if( is_array( $in_cats ) ){ | ||
$in_cats = "'" . implode( "', '", $in_cats ) . "'"; | ||
$whichcat .= "AND $wpdb->term_taxonomy.term_id IN ($in_cats)"; | ||
} | ||
|
||
$post_type_object = get_post_type_object( 'wpsc-product' ); | ||
$permitted_post_statuses = current_user_can( $post_type_object->cap->edit_posts ) ? "'private', 'draft', 'pending', 'publish'" : "'publish'"; | ||
|
||
|
||
$whichcat .= " AND $wpdb->posts.post_status IN ($permitted_post_statuses) "; | ||
$groupby = "{$wpdb->posts}.ID"; | ||
|
||
$this->sql_components['join'] = $join; | ||
$this->sql_components['fields'] = "{$wpdb->posts}.*, {$wpdb->term_taxonomy}.term_id"; | ||
$this->sql_components['group_by'] = $groupby; | ||
|
||
//what about ordering by price | ||
if(isset($q['meta_key']) && '_wpsc_price' == $q['meta_key']){ | ||
$whichcat .= " AND $wpdb->postmeta.meta_key = '_wpsc_price'"; | ||
}else{ | ||
|
||
$this->sql_components['order_by'] = "{$wpdb->term_taxonomy}.term_id"; | ||
} | ||
$this->sql_components['where'] = $whichcat; | ||
add_filter( 'posts_join', array( &$this, 'join_sql' ) ); | ||
add_filter( 'posts_where', array( &$this, 'where_sql' ) ); | ||
add_filter( 'posts_fields', array( &$this, 'fields_sql' ) ); | ||
add_filter( 'posts_orderby', array( &$this, 'order_by_sql' ) ); | ||
add_filter( 'posts_groupby', array( &$this, 'group_by_sql' ) ); | ||
} | ||
} | ||
|
||
function join_sql( $sql ) { | ||
if ( isset( $this->sql_components['join'] ) ) | ||
$sql = $this->sql_components['join']; | ||
|
||
remove_filter( 'posts_join', array( &$this, 'join_sql' ) ); | ||
return $sql; | ||
} | ||
|
||
function where_sql( $sql ) { | ||
if ( isset( $this->sql_components['where'] ) ) | ||
$sql = $this->sql_components['where']; | ||
|
||
remove_filter( 'posts_where', array( &$this, 'where_sql' ) ); | ||
return $sql; | ||
} | ||
|
||
function order_by_sql( $sql ) { | ||
$order_by_parts = array( ); | ||
$order_by_parts[] = $sql; | ||
|
||
if ( isset( $this->sql_components['order_by'] ) ) | ||
$order_by_parts[] = $this->sql_components['order_by']; | ||
|
||
$order_by_parts = array_reverse( $order_by_parts ); | ||
$sql = implode( ',', $order_by_parts ); | ||
|
||
remove_filter( 'posts_orderby', array( &$this, 'order_by_sql' ) ); | ||
return $sql; | ||
} | ||
|
||
function fields_sql( $sql ) { | ||
if ( isset( $this->sql_components['fields'] ) ) | ||
$sql = $this->sql_components['fields']; | ||
|
||
remove_filter( 'posts_fields', array( &$this, 'fields_sql' ) ); | ||
return $sql; | ||
} | ||
|
||
function group_by_sql( $sql ) { | ||
if ( isset( $this->sql_components['group_by'] ) ) | ||
$sql = $this->sql_components['group_by']; | ||
|
||
remove_filter( 'posts_groupby', array( &$this, 'group_by_sql' ) ); | ||
return $sql; | ||
} | ||
|
||
function request_sql( $sql ) { | ||
echo $sql . "<br />"; | ||
remove_filter( 'posts_request', array( &$this, 'request_sql' ) ); | ||
return $sql; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
add_action( 'wpsc_register_settings_tabs', '_wpsc_te_v1_register_settings_tabs', 10, 1 ); | ||
add_action( 'wpsc_load_settings_tab_class', '_wpsc_te_v1_load_settings_tab_class', 10, 1 ); | ||
|
||
function _wpsc_te_v1_register_settings_tabs( $page_instance ) { | ||
$page_instance->register_tab( 'presentation', _x( 'Presentation', 'Presentation settings tab in Settings->Store page', 'wpsc' ) ); | ||
} | ||
|
||
function _wpsc_te_v1_load_settings_tab_class( $page_instance ) { | ||
$current_tab_id = $page_instance->get_current_tab_id(); | ||
if ( in_array( $current_tab_id, array( 'presentation' ) ) ) | ||
require_once( WPSC_TE_V1_PATH . '/classes/settings-tab-presentation.php' ); | ||
} |
Oops, something went wrong.