/** * category class function, categories can have a specific class, this gets that * @return string - the class of the selected category */ function wpsc_category_class() { global $wp_query; $category_nice_name = ''; if ('wpsc_product_category' == $wp_query->query_vars['taxonomy']) { $catid = wpsc_get_the_category_id($wp_query->query_vars['term'], 'slug'); } else { $catid = get_option('wpsc_default_category'); if ($catid == 'all+list') { $catid = 'all'; } } if ((int) $catid > 0) { $term = get_term($catid, 'wpsc_product_category'); $category_nice_name = $term->slug; } else { if ($catid == 'all') { $category_nice_name = 'all-categories'; } } return $category_nice_name; }
/** * wpsc_obtain_the_title function, for replaacing the page title with the category or product * @return string - the new page title */ function wpsc_obtain_the_title() { global $wpdb, $wp_query, $wpsc_title_data; $output = null; $category_id = null; if (!isset($wp_query->query_vars['wpsc_product_category']) && !isset($wp_query->query_vars['wpsc-product'])) { return; } if (!isset($wp_query->query_vars['wpsc_product_category']) && isset($wp_query->query_vars['wpsc-product'])) { $wp_query->query_vars['wpsc_product_category'] = 0; } if (isset($wp_query->query_vars['taxonomy']) && 'wpsc_product_category' == $wp_query->query_vars['taxonomy'] || isset($wp_query->query_vars['wpsc_product_category'])) { $category_id = wpsc_get_the_category_id($wp_query->query_vars['wpsc_product_category'], 'slug'); } if ($category_id > 0) { if (isset($wpsc_title_data['category'][$category_id])) { $output = $wpsc_title_data['category'][$category_id]; } else { $term = get_term($category_id, 'wpsc_product_category'); $output = $term->name; $wpsc_title_data['category'][$category_id] = $output; } } if (!isset($_GET['wpsc-product'])) { $_GET['wpsc-product'] = 0; } if (!isset($wp_query->query_vars['wpsc-product'])) { $wp_query->query_vars['wpsc-product'] = ''; } if (isset($wp_query->query_vars['wpsc-product']) || is_string($_GET['wpsc-product'])) { $product_name = $wp_query->query_vars['wpsc-product']; if (isset($wpsc_title_data['product'][$product_name])) { $product_list = array(); $full_product_name = $wpsc_title_data['product'][$product_name]; } else { if ($product_name != '') { $product_id = $wp_query->post->ID; $full_product_name = $wpdb->get_var($wpdb->prepare("SELECT `post_title` FROM `{$wpdb->posts}` WHERE `ID`= %d LIMIT 1", $product_id)); $wpsc_title_data['product'][$product_name] = $full_product_name; } else { if (isset($_REQUEST['product_id'])) { $product_id = absint($_REQUEST['product_id']); $product_name = $wpdb->get_var($wpdb->prepare("SELECT `post_title` FROM `{$wpdb->posts}` WHERE `ID`= %d LIMIT 1", $product_id)); $full_product_name = $wpdb->get_var($wpdb->prepare("SELECT `post_title` FROM `{$wpdb->posts}` WHERE `ID`= %d LIMIT 1", $product_id)); $wpsc_title_data['product'][$product_name] = $full_product_name; } else { //This has to exist, otherwise we would have bailed earlier. $category = $wp_query->query_vars['wpsc_product_category']; $cat_term = get_term_by('slug', $wp_query->query_vars['wpsc_product_category'], 'wpsc_product_category'); $full_product_name = $cat_term->name; } } } $output = $full_product_name; } if (isset($full_product_name) && $full_product_name != null) { $output = esc_html($full_product_name); } $seperator = ' | '; $seperator = apply_filters('wpsc_the_wp_title_seperator', $seperator); return $output . $seperator; }
/** * Checks the category slug for a display type, if none set returns default * << May need reworking to be more specific to the taxonomy type >> * @access public * * @since 3.8 * @param $slug(string) * @return $slug either from db or 'default' if none set */ function wpsc_get_the_category_display($slug) { global $wpdb; $default_display_type = get_option('product_view'); if (!empty($slug) && is_string($slug)) { $category_id = wpsc_get_the_category_id($slug, 'slug'); $display_type = wpsc_get_categorymeta($category_id, 'display_type'); } if (!empty($display_type)) { return $display_type; } else { return $default_display_type; } }