themehybrid / mythic

Mythic is a next-generation starter theme designed to help theme authors write elegant, intelligent, and modern code.
https://themehybrid.com/themes/mythic
GNU General Public License v2.0
238 stars 43 forks source link

Plugin uses get_index_template() which returns nothing using a Mythic based theme. #81

Open david-graham opened 5 years ago

david-graham commented 5 years ago

I'm using the latest public release of the WP E-Commerce plugin and am trying to rewrite an old theme using Mythic as a base.

The plugin uses get_index_template() and get_query_template() which, as far as I can tell, return nothing using a Mythic theme.

This is the error:

Warning: include(): Filename cannot be empty in C:\Development\bookstore\wp-content\plugins\wp-e-commerce\wpsc-components\theme-engine-v1\helpers\page.php on line 1039

Warning: include(): Failed opening '' for inclusion (include_path='.;C:\php\pear') in C:\Development\bookstore\wp-content\plugins\wp-e-commerce\wpsc-components\theme-engine-v1\helpers\page.php on line 1039

This is the WP E-Commerce function in question:

// Template tags
function wpsc_all_products_on_page(){

    if ( is_404() ) {
        return;
    }

    global $wp_query,$wpsc_query;
    do_action('wpsc_swap_the_template');
    $products_page_id = wpsc_get_the_post_id_by_shortcode('[productspage]');
    $term = get_query_var( 'wpsc_product_category' );
    $tax_term = get_query_var( 'product_tag' );
    $obj = $wp_query->get_queried_object();

    $id = isset( $obj->ID ) ? $obj->ID : null;

    if( get_query_var( 'post_type' ) == 'wpsc-product' || $term || $tax_term || ( $id == $products_page_id )){

        $templates = array();

        if ( $term && ! is_single() ) {
            array_push( $templates, "taxonomy-wpsc_product_category-{$term}.php", 'taxonomy-wpsc_product_category.php' );
        }

        if ( $tax_term && ! is_single() ) {
            array_push( $templates, "taxonomy-product_tag-{$tax_term}.php", 'taxonomy-product_tag.php' );
        }

        // Attempt to use the [productspage]'s custom page template as a higher priority than the normal page.php template
        if ( false !== $productspage_page_template = get_post_meta($products_page_id, '_wp_page_template', true) )
            array_push( $templates, $productspage_page_template );

        array_push( $templates, 'page.php', 'single.php' );

        if ( is_single() )
            array_unshift( $templates, 'single-wpsc-product.php' );

        // have to pass 'page' as the template type. This is lame, btw, and needs a rewrite in 4.0
        if ( ! $template = get_query_template( 'page', $templates ) )
            $template = get_index_template();

        add_filter( 'thesis_custom_loop', 'wpsc_thesis_compat' );

        include( $template );
        exit;
    }
}

I'm going to attempt a workaround similar to https://www.sean-barton.co.uk/2011/08/wp-ecommerce-template-redirect/ and perhaps it can be added to the Plugin Support section on the wiki.

david-graham commented 5 years ago

I also noticed while working on a workaround that Hybrid\Template\hierarchy returns an empty array on product archive and single product pages.