Plugin Directory

Changeset 1270367


Ignore:
Timestamp:
10/21/2015 02:15:40 PM (10 years ago)
Author:
tywayne
Message:

fix for undefined notices, better queries for exchange products, update text domain

Location:
category-related-products-for-ithemes-exchange/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • category-related-products-for-ithemes-exchange/trunk/exchange-addon-category-related-products.php

    r1036807 r1270367  
    22/*
    33 * Plugin Name: iThemes Exchange - Category Related Products
    4  * Version: 1.0.1
     4 * Version: 1.0.2
    55 * Description: Display related products based on categories
    66 * Plugin URI: http://tywayne.com
    77 * Author: Ty Carlson
    88 * Author URI: http://tywayne.com
    9  * Text Domain: exchange-addon-category-related-products
     9 * Text Domain: category-related-products-for-ithemes-exchange
    1010*/
    1111
     
    1515 * @since 1.0.0
    1616*/
    17 define( 'IT_Exchange_Category_Related_Products_Version', '1.0.1' );
     17define( 'IT_Exchange_Category_Related_Products_Version', '1.0.2' );
    1818
    1919/**
     
    2626function it_exchange_register_category_related_products_addon() {
    2727    $options = array(
    28         'name'              => __( 'Category Related Products', 'exchange-addon-category-related-products' ),
    29         'description'       => __( 'Display related products based on iThemes Exchange product categories.', 'exchange-addon-category-related-products' ),
     28        'name'              => __( 'Category Related Products', 'category-related-products-for-ithemes-exchange' ),
     29        'description'       => __( 'Display related products based on iThemes Exchange product categories.', 'category-related-products-for-ithemes-exchange' ),
    3030        'author'            => 'Ty Carlson',
    3131        'author_url'        => 'http://tywayne.com/',
  • category-related-products-for-ithemes-exchange/trunk/lib/functions.php

    r1036806 r1270367  
    1515function it_exchange_get_product_categories() {
    1616    // get the exchange product
    17     global $post;
    18     $exchange_product = it_exchange_get_product( $post->ID );
     17    $exchange_product = $GLOBALS['it_exchange']['product'];
    1918
    2019    // get terms for the it_exchange_category taxonomy
  • category-related-products-for-ithemes-exchange/trunk/lib/hooks.php

    r1036788 r1270367  
    2929      so that we can exclude it from the related product list
    3030    */
    31     global $post;
    32     $current_product_id = $post->ID;
     31    $current_exchange_product = $GLOBALS['it_exchange']['product'];
    3332
    3433    // get the settings for display
    3534    $settings  = it_exchange_get_option( 'category_related_products' );
    36     $count     = $settings['count'];
     35    $count     = !empty($settings['count']) ? $settings['count'] : '5';
    3736
    38     if ( $settings['width-int'] && $settings['width-unit'] ) {
     37    if ( !empty($settings['width-int']) && !empty($settings['width-unit']) ) {
    3938        $width = $settings['width-int'] . $settings['width-unit'];
    4039    } else {
     
    4746        'post_type'    => 'it_exchange_prod',
    4847        'orderby'      => 'rand',
    49         'post__not_in' => array( $current_product_id ),
     48        'post__not_in' => array( $current_exchange_product->ID ),
    5049        'tax_query'    => array(
    5150            array(
     
    5857    );
    5958
    60     $the_query = new WP_Query( $args );
     59    $products = get_posts( $args );
    6160?>
    6261
    6362    <?php // the loop for related products ?>
    64     <?php if ( $the_query->have_posts() ) : ?>
     63    <?php if ( !empty( $products ) ) { ?>
    6564   
    6665        <?php // Heading above the related products list. The heading text is filterable with it_exchange_category_related_product_heading ?>
    6766        <?php do_action( 'it_exchange_category_related_product_before_heading' ); ?>
    6867        <h3 class="it-exchange-category-related-products-heading">
    69             <?php $heading = apply_filters( 'it_exchange_category_related_product_heading', __( 'Related Products', 'exchange-addon-category-related-products' ) ); ?>
     68            <?php $heading = apply_filters( 'it_exchange_category_related_product_heading', __( 'Related Products', 'category-related-products-for-ithemes-exchange' ) ); ?>
    7069            <?php echo $heading; ?>
    7170        </h3>
     
    7473        <?php do_action( 'it_exchange_category_related_product_before_product_list' ); ?>
    7574        <ul class="it-exchange-category-related-product-list">
    76         <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
     75        <?php foreach ( $products as $product ) { ?>
    7776       
    7877            <?php // setup the exchange product so we have access to the API ?>
    79             <?php $exchange_product = it_exchange_get_product( $post->ID ); ?>
     78            <?php $exchange_product = it_exchange_get_product( $product->ID ); ?>
    8079            <?php $GLOBALS['it_exchange']['product'] = $exchange_product; ?>
    8180            <li class="it-exchange-category-related-product <?php echo ( ! it_exchange( 'product', 'has-images' ) ) ? ' no-images' : 'has-images'; ?>" style="max-width:<?php echo $width; ?>">
     
    9392            </li>
    9493           
    95         <?php endwhile; ?>
     94        <?php } ?>
    9695        </ul>
    9796        <?php do_action( 'it_exchange_category_related_product_after_product_list' ); ?>
    98         <?php wp_reset_postdata(); ?>
    99     <?php endif; ?>
     97        <?php $GLOBALS['it_exchange']['product'] = $current_exchange_product; ?>
     98    <?php } ?>
    10099   
    101100<?php
  • category-related-products-for-ithemes-exchange/trunk/lib/settings.php

    r1036788 r1270367  
    4949    <div class="wrap">
    5050        <?php ITUtility::screen_icon( 'it-exchange' ); ?>
    51         <h2><?php _e( 'Category Related Products Settings', 'exchange-addon-category-related-products' ); ?></h2>
     51        <h2><?php _e( 'Category Related Products Settings', 'category-related-products-for-ithemes-exchange' ); ?></h2>
    5252
    5353        <?php do_action( 'it_exchange_category_related_products_settings_page_top' ); ?>
     
    5959        do_action( 'it_exchange_category_related_products_settings_form_top' );
    6060        if ( ! empty( $_POST['__it-form-prefix'] ) && 'it-exchange-addon-category-related-products' == $_POST['__it-form-prefix'] )
    61             ITUtility::show_status_message( __( 'Options Saved', 'exchange-addon-category-related-products' ) );
     61            ITUtility::show_status_message( __( 'Options Saved', 'category-related-products-for-ithemes-exchange' ) );
    6262
    6363        ?>
     
    6666            <tbody>
    6767                <tr valign="top">
    68                     <th scope="row"><label for="category-related-products-count"><?php _e( 'Related Products Count', 'exchange-addon-category-related-products' ) ?></label></th>
     68                    <th scope="row"><label for="category-related-products-count"><?php _e( 'Related Products Count', 'category-related-products-for-ithemes-exchange' ) ?></label></th>
    6969                    <td>
    7070                        <?php
     
    7878           
    7979                        <label for="category-related-products-count">
    80                             <span class="description"><?php _e( 'How many related products would you like to display?', 'exchange-addon-category-related-products' ); ?></span>
     80                            <span class="description"><?php _e( 'How many related products would you like to display?', 'category-related-products-for-ithemes-exchange' ); ?></span>
    8181                        </label>
    8282                    </td>
    8383                </tr>
    8484                <tr valign="top">
    85                     <th scope="row"><label for="category-related-products-width"><?php _e( 'Related Product Width', 'exchange-addon-category-related-products' ) ?></label></th>
     85                    <th scope="row"><label for="category-related-products-width"><?php _e( 'Related Product Width', 'category-related-products-for-ithemes-exchange' ) ?></label></th>
    8686                    <td>
    8787                        <?php
     
    123123                       
    124124                        <label for="category-related-products-width">
    125                             <span class="description"><?php _e( 'Width of each product in the related products list', 'exchange-addon-category-related-products' ); ?></span>
     125                            <span class="description"><?php _e( 'Width of each product in the related products list', 'category-related-products-for-ithemes-exchange' ); ?></span>
    126126                        </label>
    127127                    </td>
  • category-related-products-for-ithemes-exchange/trunk/readme.txt

    r1217649 r1270367  
    33Tags: iThemes Exchange, addon, ecommerce
    44Requires at least: 3.9
    5 Tested up to: 4.3
    6 Stable tag: 1.0.1
     5Tested up to: 4.3.1
     6Stable tag: 1.0.2
    77License: GPLv2 or later
    88
     
    3030== Changelog ==
    3131
     32= 1.0.2 =
     33* Bugfix: resolve undefined index notices when options have not been saved yet
     34* Bugfix: better handling of querying exchange products so we don't mess up other queries
     35* Enhancement: Update text domain to match wp.org slug so it can be translated
     36
    3237= 1.0.1 =
    3338* Removed php notice from front end do to undefined variable
Note: See TracChangeset for help on using the changeset viewer.