Plugin Directory

Changeset 932945


Ignore:
Timestamp:
06/16/2014 10:18:41 AM (12 years ago)
Author:
madpixels
Message:

Implemented recent compares widget.

Location:
woocommerce-compare-list/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • woocommerce-compare-list/trunk/includes/common.php

    r932824 r932945  
    4646 * Registers scripts, styles and page endpoint.
    4747 *
    48  * @since 1.1
     48 * @since 1.1.0
    4949 * @action init
    5050 *
  • woocommerce-compare-list/trunk/includes/compare-page.php

    r932859 r932945  
    2929// register action hooks
    3030add_action( 'wp_enqueue_scripts', 'wccm_enqueue_compare_scripts' );
     31add_action( 'template_redirect', 'wccm_set_compare_page_cookie' );
    3132// register filter hooks
    3233add_filter( 'the_content', 'wccm_render_compare_page' );
     
    4243        wp_enqueue_style( 'wccm-compare' );
    4344        wp_enqueue_script( 'wccm-compare' );
     45    }
     46}
     47
     48/**
     49 * Remembers compare page to show in the widget.
     50 *
     51 * @since 1.1.0
     52 * @action template_redirect
     53 */
     54function wccm_set_compare_page_cookie() {
     55    if ( is_page() && get_option( 'wccm_compare_page' ) == get_queried_object_id() ) {
     56        $list = get_query_var( wccm_get_endpoint(), false );
     57        if ( $list ) {
     58            $parsed_list = array_filter( array_map( 'intval', explode( '-', $list ) ) );
     59            if ( !empty( $parsed_list ) ) {
     60                $cookie = isset( $_COOKIE['compare-lists'] ) ? explode( ',', $_COOKIE['compare-lists'] ) : array();
     61                if ( in_array( $list, $cookie ) ) {
     62                    unset( $cookie[array_search( $list, $cookie )] );
     63                }
     64
     65                array_unshift( $cookie, $list );
     66                $value = implode( ',', array_slice( $cookie, 0, 5 ) );
     67                $expire = current_time( 'timestamp', 1 ) + 30 * DAY_IN_SECONDS;
     68                $path = parse_url( home_url(), PHP_URL_QUERY );
     69                if ( !$path ) {
     70                    $path = '/';
     71                }
     72
     73                setcookie( 'compare-lists', $value, $expire, $path );
     74            }
     75        }
    4476    }
    4577}
  • woocommerce-compare-list/trunk/includes/shortcode.php

    r932824 r932945  
    3535 * Enqueues scripts and styles for shortcode.
    3636 *
    37  * @since 1.1
     37 * @since 1.1.0
    3838 * @action wp_enqueue_scripts
    3939 */
     
    5151 * Renders compare list shortcode.
    5252 *
    53  * @since 1.1
     53 * @since 1.1.0
    5454 * @shortcode products-compare
    5555 *
     
    7272 * Renders compare list table.
    7373 *
    74  * @since 1.1
     74 * @since 1.1.0
    7575 *
    7676 * @param array $list The array of compare products.
     
    104104 * Renders compare table header.
    105105 *
    106  * @since 1.1
     106 * @since 1.1.0
    107107 *
    108108 * @param array $products The compare items list.
     
    140140 * Renders compare table attributes.
    141141 *
    142  * @since 1.1
     142 * @since 1.1.0
    143143 *
    144144 * @param array $products The compare items list.
  • woocommerce-compare-list/trunk/index.php

    r932824 r932945  
    6161
    6262    require_once 'includes/common.php';
     63    require_once 'includes/widget.php';
    6364    if ( is_admin() ) {
    6465        require_once 'includes/settings.php';
  • woocommerce-compare-list/trunk/languages/wccm-en_US.po

    r932816 r932945  
    33"Project-Id-Version: WooCommerce Compare List\n"
    44"Report-Msgid-Bugs-To: \n"
    5 "POT-Creation-Date: 2014-06-16 08:47+0300\n"
    6 "PO-Revision-Date: 2014-06-16 08:47+0300\n"
     5"POT-Creation-Date: 2014-06-16 13:15+0300\n"
     6"PO-Revision-Date: 2014-06-16 13:15+0300\n"
    77"Last-Translator: Eugene Manuilov <eugene@manuilov.org>\n"
    88"Language-Team: MadPixels <contact@madpixels.net>\n"
     
    2020"Plural-Forms: nplurals=2; plural=n != 1;\n"
    2121"X-Poedit-SearchPath-0: .\n"
     22
     23#: includes/widget.php:57
     24msgid "WooCommerce Recent Compares"
     25msgstr "WooCommerce Recent Compares"
     26
     27#: includes/widget.php:58
     28msgid "Shows a list of user most recent compares on your site."
     29msgstr "Shows a list of user most recent compares on your site."
     30
     31#: includes/widget.php:75
     32msgid "Title:"
     33msgstr "Title:"
     34
     35#: includes/widget.php:78
     36msgid "Thumbnails Width:"
     37msgstr "Thumbnails Width:"
     38
     39#: includes/widget.php:81
     40msgid "Thumbnails Height:"
     41msgstr "Thumbnails Height:"
     42
     43#: includes/widget.php:108
     44msgid "Recent Compares"
     45msgstr "Recent Compares"
    2246
    2347#: includes/catalog.php:77 includes/buttons.php:78 includes/settings.php:90
     
    3761msgstr "View compare"
    3862
    39 #: includes/compare-page.php:84
     63#: includes/compare-page.php:101
    4064msgid "No products found to compare."
    4165msgstr "No products found to compare."
  • woocommerce-compare-list/trunk/readme.txt

    r932824 r932945  
    1515### WooCommerce Compare List Plugin ###
    1616
    17 The plugin adds a simple and easy to use and setup products compare feature. Compared products are shown on front end as an aggregate table of all products attributes. Users will easily compare products and make their choice.
     17The plugin adds a simple and easy to use and setup products compare feature. Compared products are shown on front end as an aggregate table of all products attributes. Users will easily compare products and make their choice. You can also use **products-compare** shortcode to embed compare tables and **WooCommerce Recent Compares** widget to help your users to get back to their compares.
    1818
    1919### SEO friendly ###
     
    6565
    6666* Implemented [products-compare ids="..." atts="..."] shortcode.
     67* Implemented **Recent Compares** widget.
    6768
    6869= 1.0.0 =
Note: See TracChangeset for help on using the changeset viewer.