Plugin Directory

Changeset 1812372


Ignore:
Timestamp:
01/31/2018 03:58:58 AM (8 years ago)
Author:
tazziedave
Message:

Fix required due to WooCommerce changes

Location:
wysiwyg-custom-products
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • wysiwyg-custom-products/tags/1.1/common/utilities.php

    r1677949 r1812372  
    77 *
    88 * @since   1.0.0
     9 * @updated 1.1.3
    910 */
    1011
     
    5152 *
    5253 * @since   1.0.0
     54 * @updated 1.1.3
    5355 */
    5456function maybe_get( $array, $field, $default = false, $trim = true ) {
     
    6466    if ( is_string( $result ) && $trim ) {
    6567        return trim( $result );
    66     } else {
    67         return $result;
    6868    }
     69
     70    return $result;
    6971}
    7072
  • wysiwyg-custom-products/tags/1.1/frontend/class-frontend.php

    r1677949 r1812372  
    1919 *
    2020 * @since      1.0.0
    21  * @updated    1.1.2
     21 * @updated    1.1.3
    2222 */
    2323class Frontend {
    2424
    25     const HANDLED_SIZES = 'shop_single;shop_catalog;';
     25    const SINGLE_SIZES = 'shop_single;woocommerce_single;';
     26
     27    const CATALOG_SIZES = 'shop_catalog;woocommerce_thumbnail;';
    2628
    2729    /**
     
    7274     *
    7375     * @since   1.0.0
    74      * @updated 1.1.0
     76     * @updated 1.1.3
    7577     */
    7678    public function product_thumbnail(
     
    8284    ) {
    8385
    84         if ( false === stripos( self::HANDLED_SIZES, $size . ';' ) ) {
     86        if ( (false === stripos( self::SINGLE_SIZES, $size . ';' ))
     87        && (false === stripos( self::CATALOG_SIZES, $size . ';' ))) {
    8588            return $html;
    8689        }
     
    121124            '1.1.0' ); // for catalog images, whether on product page or in catalog
    122125
    123         if ( 'shop_single' === $size ) {
     126        if ( false !== stripos( self::SINGLE_SIZES, $size . ';' )) {
    124127            /* Add live update javascript */
    125128            register_script( 'attrchange', [ 'jquery' ], '1.0' );
     
    131134
    132135            return apply_filters( 'frontend_shop_single', $newHtml, $post_id, $post_thumbnail_id, $size, $attr );
    133         } elseif ( 'shop_catalog' === $size ) {
     136        }
     137
     138        if ( false !== stripos( self::CATALOG_SIZES, $size . ';' ) ) {
    134139            $newHtml = $this->product_shop_catalog( $html, $post_id );
    135140
    136141            return apply_filters( 'frontend_shop_catalog', $newHtml, $post_id, $post_thumbnail_id, $size, $attr );
    137         } else {
    138             return $html;
    139         }
     142        }
     143
     144        return $html;
    140145    }
    141146
  • wysiwyg-custom-products/tags/1.1/readme.txt

    r1771891 r1812372  
    44Tags: WYSIWYG, wysiwyg, custom, customised, customized, preview, live, update, view, woocommerce
    55Requires at least: 4.5.4
    6 Tested up to: 4.9.0
     6Tested up to: 4.9.2
    77Stable tag: 1.1
    88License: GPLv3 or later
     
    123123* Premium - Select/Dropdown fields can now have option list overridden on a per product basis
    124124
     125= 1.1.3 =
     126* Added workaround for changes in woocommerce core functions and image size names.
     127
    125128== Upgrade Notice ==
    126 Layout data can now be saved when uninstalling to allow for easier upgrade.
     129Fixed for WooCommerce 3.3.0 changes.
    127130
    128131== Creating Layouts - Instructions ==
     
    160163    apply_filters( 'wcp_frontend_shop_single', string $html, int $post_id, string $post_thumbnail_id, string|array $size, string $attr )
    161164    apply_filters( 'wcp_frontend_shop_catalog', string $html, int $post_id, string $post_thumbnail_id, string|array $size, string $attr )
    162     These filter the generated product page and catalog images respectively. They hook into filter 'post_thumbnail_html'.
     165    These filter the generated product page and catalog/thumbnail images respectively. They hook into filter 'post_thumbnail_html'.
    163166
    164167###Source: common/class-layout.php###
  • wysiwyg-custom-products/tags/1.1/wysiwyg-custom-products.php

    r1677949 r1812372  
    44 * Plugin URI: https://tazziedave.com/wp-plugins/wysiwyg-custom-products
    55 * Description: Enables a live WYSIWYG preview of custom products where text is edited in text area or text field in woo commerce.
    6  * Version: 1.1.2
     6 * Version: 1.1.3
    77 * Author: Tazziedave
    88 * Author URI: https://tazziedave.com
     
    6262 *
    6363 * @since   1.0.0
    64  * @updated 1.0.7
     64 * @updated 1.1.3
    6565 */
    6666class Wcp_Plugin {
     
    7474     *  Plug in version
    7575     */
    76     const VER = '1.1.2';
     76    const VER = '1.1.3';
    7777    /**
    7878     * Database version. Used in class-plugin to run updates as necessary
     
    147147     *
    148148     * @since   1.0.0
     149     * @updated 1.1.3
    149150     */
    150151    public function __construct( $locale = null ) {
     
    162163        // Add callback for WP to get our locale
    163164        add_filter( 'plugin_locale', [ $this, 'get_plugin_locale_callback' ], $priority = 10, $accepted_args = 2 );
     165        add_filter( 'woocommerce_get_image_size_shop_single', [ $this, 'woocommerce_get_image_size' ], $priority =
     166            10, $accepted_args = 1 );
     167        add_filter( 'woocommerce_get_image_size_shop_catalog', [ $this, 'woocommerce_get_image_size' ], $priority =
     168            10, $accepted_args = 1 );
     169        add_filter( 'woocommerce_get_image_size_single', [ $this, 'woocommerce_get_image_size' ], $priority =
     170            10, $accepted_args = 1 );
     171        add_filter( 'woocommerce_get_image_size_thumbnail', [ $this, 'woocommerce_get_image_size' ], $priority =
     172            10, $accepted_args = 1 );
    164173
    165174        // translators: Name of plugin - free version
     
    310319        $layout->save_defaults();
    311320        $settings = get_option( 'settings', [] );
    312         if ( count( $settings ) === 0 ) {
     321        if ( \count( $settings ) === 0 ) {
    313322            $settings['CurrentLayout'] = $layout->getName();
    314323            add_option( 'settings', $settings, false );
     
    344353        return $locale;
    345354    }
     355
     356    /**
     357     * Called when WooCommerce is processing wc_get_image_size
     358     * Added to make height value sensible again after 3.3.0 update.
     359     *
     360     * @param array $size
     361     *
     362     * @return array
     363     *
     364     * @since   1.1.3
     365     */
     366    public function woocommerce_get_image_size(array $size): array {
     367
     368        if ( \is_array($size) && (9999999999 === $size['height'])) {
     369            $size['height'] = $size['width'];
     370        }
     371
     372        return $size;
     373    }
    346374}
    347375
    348376$wysiwygCP = new Wcp_Plugin();
    349377
    350 if ( ! defined( 'WP_UNINSTALL_PLUGIN ' ) ) { // Check to see if being instantiated for uninstall purposes
     378if ( ! \defined( 'WP_UNINSTALL_PLUGIN ' ) ) { // Check to see if being instantiated for uninstall purposes
    351379    if ( is_admin() ) {
    352380        $wysiwygCP->admin();
  • wysiwyg-custom-products/trunk/common/utilities.php

    r1677949 r1812372  
    77 *
    88 * @since   1.0.0
     9 * @updated 1.1.3
    910 */
    1011
     
    5152 *
    5253 * @since   1.0.0
     54 * @updated 1.1.3
    5355 */
    5456function maybe_get( $array, $field, $default = false, $trim = true ) {
     
    6466    if ( is_string( $result ) && $trim ) {
    6567        return trim( $result );
    66     } else {
    67         return $result;
    6868    }
     69
     70    return $result;
    6971}
    7072
  • wysiwyg-custom-products/trunk/frontend/class-frontend.php

    r1677949 r1812372  
    1919 *
    2020 * @since      1.0.0
    21  * @updated    1.1.2
     21 * @updated    1.1.3
    2222 */
    2323class Frontend {
    2424
    25     const HANDLED_SIZES = 'shop_single;shop_catalog;';
     25    const SINGLE_SIZES = 'shop_single;woocommerce_single;';
     26
     27    const CATALOG_SIZES = 'shop_catalog;woocommerce_thumbnail;';
    2628
    2729    /**
     
    7274     *
    7375     * @since   1.0.0
    74      * @updated 1.1.2
     76     * @updated 1.1.3
    7577     */
    7678    public function product_thumbnail(
     
    8284    ) {
    8385
    84         if ( false === stripos( self::HANDLED_SIZES, $size . ';' ) ) {
     86        if ( (false === stripos( self::SINGLE_SIZES, $size . ';' ))
     87        && (false === stripos( self::CATALOG_SIZES, $size . ';' ))) {
    8588            return $html;
    8689        }
     
    121124            '1.1.0' ); // for catalog images, whether on product page or in catalog
    122125
    123         if ( 'shop_single' === $size ) {
     126        if ( false !== stripos( self::SINGLE_SIZES, $size . ';' )) {
    124127            /* Add live update javascript */
    125128            register_script( 'attrchange', [ 'jquery' ], '1.0' );
     
    133136        }
    134137
    135         if ( 'shop_catalog' === $size ) {
     138        if ( false !== stripos( self::CATALOG_SIZES, $size . ';' ) ) {
    136139            $newHtml = $this->product_shop_catalog( $html, $post_id );
    137140
  • wysiwyg-custom-products/trunk/readme.txt

    r1771891 r1812372  
    44Tags: WYSIWYG, wysiwyg, custom, customised, customized, preview, live, update, view, woocommerce
    55Requires at least: 4.5.4
    6 Tested up to: 4.9.0
     6Tested up to: 4.9.2
    77Stable tag: 1.1
    88License: GPLv3 or later
     
    123123* Premium - Select/Dropdown fields can now have option list overridden on a per product basis
    124124
     125= 1.1.3 =
     126* Added workaround for changes in woocommerce core functions and image size names.
     127
    125128== Upgrade Notice ==
    126 Layout data can now be saved when uninstalling to allow for easier upgrade.
     129Fixed for WooCommerce 3.3.0 changes.
    127130
    128131== Creating Layouts - Instructions ==
     
    160163    apply_filters( 'wcp_frontend_shop_single', string $html, int $post_id, string $post_thumbnail_id, string|array $size, string $attr )
    161164    apply_filters( 'wcp_frontend_shop_catalog', string $html, int $post_id, string $post_thumbnail_id, string|array $size, string $attr )
    162     These filter the generated product page and catalog images respectively. They hook into filter 'post_thumbnail_html'.
     165    These filter the generated product page and catalog/thumbnail images respectively. They hook into filter 'post_thumbnail_html'.
    163166
    164167###Source: common/class-layout.php###
  • wysiwyg-custom-products/trunk/wysiwyg-custom-products.php

    r1677949 r1812372  
    44 * Plugin URI: https://tazziedave.com/wp-plugins/wysiwyg-custom-products
    55 * Description: Enables a live WYSIWYG preview of custom products where text is edited in text area or text field in woo commerce.
    6  * Version: 1.1.2
     6 * Version: 1.1.3
    77 * Author: Tazziedave
    88 * Author URI: https://tazziedave.com
     
    6262 *
    6363 * @since   1.0.0
    64  * @updated 1.0.7
     64 * @updated 1.1.3
    6565 */
    6666class Wcp_Plugin {
     
    7474     *  Plug in version
    7575     */
    76     const VER = '1.1.2';
     76    const VER = '1.1.3';
    7777    /**
    7878     * Database version. Used in class-plugin to run updates as necessary
     
    147147     *
    148148     * @since   1.0.0
     149     * @updated 1.1.3
    149150     */
    150151    public function __construct( $locale = null ) {
     
    162163        // Add callback for WP to get our locale
    163164        add_filter( 'plugin_locale', [ $this, 'get_plugin_locale_callback' ], $priority = 10, $accepted_args = 2 );
     165        add_filter( 'woocommerce_get_image_size_shop_single', [ $this, 'woocommerce_get_image_size' ], $priority =
     166            10, $accepted_args = 1 );
     167        add_filter( 'woocommerce_get_image_size_shop_catalog', [ $this, 'woocommerce_get_image_size' ], $priority =
     168            10, $accepted_args = 1 );
     169        add_filter( 'woocommerce_get_image_size_single', [ $this, 'woocommerce_get_image_size' ], $priority =
     170            10, $accepted_args = 1 );
     171        add_filter( 'woocommerce_get_image_size_thumbnail', [ $this, 'woocommerce_get_image_size' ], $priority =
     172            10, $accepted_args = 1 );
    164173
    165174        // translators: Name of plugin - free version
     
    310319        $layout->save_defaults();
    311320        $settings = get_option( 'settings', [] );
    312         if ( count( $settings ) === 0 ) {
     321        if ( \count( $settings ) === 0 ) {
    313322            $settings['CurrentLayout'] = $layout->getName();
    314323            add_option( 'settings', $settings, false );
     
    344353        return $locale;
    345354    }
     355
     356    /**
     357     * Called when WooCommerce is processing wc_get_image_size
     358     * Added to make height value sensible again after 3.3.0 update.
     359     *
     360     * @param array $size
     361     *
     362     * @return array
     363     *
     364     * @since   1.1.3
     365     */
     366    public function woocommerce_get_image_size(array $size): array {
     367
     368        if ( \is_array($size) && (9999999999 === $size['height'])) {
     369            $size['height'] = $size['width'];
     370        }
     371
     372        return $size;
     373    }
    346374}
    347375
    348376$wysiwygCP = new Wcp_Plugin();
    349377
    350 if ( ! defined( 'WP_UNINSTALL_PLUGIN ' ) ) { // Check to see if being instantiated for uninstall purposes
     378if ( ! \defined( 'WP_UNINSTALL_PLUGIN ' ) ) { // Check to see if being instantiated for uninstall purposes
    351379    if ( is_admin() ) {
    352380        $wysiwygCP->admin();
Note: See TracChangeset for help on using the changeset viewer.