Plugin Directory

Changeset 2826525

Timestamp:
11/30/2022 01:55:46 PM (20 months ago)
Author:
snapplify
Message:

Some Image Bug Fixing

Location:
snapplify-e-commerce
Files:
161 added
5 edited

Legend:

Unmodified
Added
Removed
  • snapplify-e-commerce/trunk/README.txt

    r2825071 r2826525  
    44Requires at least: 5.6
    55Tested up to: 6.0.2
    6 Stable tag: 1.0.3
     6Stable tag: 1.0.
    77Requires PHP: 7.2
    88License: GPLv2 or later
     
    8282== Changelog ==
    8383
     84
     85
    8486= 1.0.3 =
    8587* Add option for manually flush the pending products queue.
  • snapplify-e-commerce/trunk/changelog.txt

    r2825069 r2826525  
    11*** WooCommerce Extension Template Changelog ***
     2
     3
     4
    252022-11-25 - version 1.0.3
    36* Add option for manually flush the pending products queue.
  • snapplify-e-commerce/trunk/includes/class-snapplify-ecommerce.php

    r2825069 r2826525  
    11<?php
     2
    23/**
    34 * The file that defines the core plugin class
     
    2627 * @subpackage Snapplify_ECommerce/includes
    2728 */
    28 class Snapplify_ECommerce {
     29class Snapplify_ECommerce
     30{
    2931
    3032
     
    6365     * @since    1.0.0
    6466     */
    65     public function __construct() {
    66         if ( defined( 'SNAPPLIFY_CATAlog_VERSION' ) ) {
     67    public function __construct()
     68    {
     69        if (defined('SNAPPLIFY_CATAlog_VERSION')) {
    6770            $this->version = SNAPPLIFY_CATAlog_VERSION;
    6871        } else {
     
    9295     * @since    1.0.0
    9396     */
    94     private function load_dependencies() {
     97    private function load_dependencies()
     98    {
    9599        /**
    96100         * The class responsible for orchestrating the actions and filters of the
    97101         * core plugin.
    98102         */
    99         require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-snapplify-ecommerce-loader.php';
     103        require_once plugin_dir_path() . 'includes/class-snapplify-ecommerce-loader.php';
    100104
    101105        /**
     
    103107         * of the plugin.
    104108         */
    105         require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-snapplify-ecommerce-i18n.php';
     109        require_once plugin_dir_path() . 'includes/class-snapplify-ecommerce-i18n.php';
    106110
    107111        /**
    108112         * The class responsible for defining all actions that occur in the admin area.
    109113         */
    110         require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-snapplify-ecommerce-admin.php';
     114        require_once plugin_dir_path() . 'admin/class-snapplify-ecommerce-admin.php';
    111115
    112116        /**
     
    114118         * side of the site.
    115119         */
    116         require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-snapplify-ecommerce-public.php';
     120        require_once plugin_dir_path() . 'public/class-snapplify-ecommerce-public.php';
    117121
    118122        $this->loader = new Snapplify_ECommerce_Loader();
     
    127131     * @since    1.0.0
    128132     */
    129     private function set_locale() {
     133    private function set_locale()
     134    {
    130135        $plugin_i18n = new Snapplify_ECommerce_I18n();
    131136
    132         $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
     137        $this->loader->add_action();
    133138    }
    134139
     
    139144     * @since    1.0.0
    140145     */
    141     private function define_admin_hooks() {
    142         $plugin_admin = new Snapplify_ECommerce_Admin( $this->get_plugin_name(), $this->get_version() );
    143 
    144         $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
    145         $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
    146         $this->loader->add_action( 'woocommerce_admin_field_auth-token', $plugin_admin, 'wcsnapplify_add_admin_field_auth_token' );
    147         $this->loader->add_action( 'woocommerce_admin_field_api-url', $plugin_admin, 'wcsnapplify_add_admin_field_api_url' );
    148         $this->loader->add_filter( 'woocommerce_get_sections_products', $plugin_admin, 'wcsnapplify_add_section' );
    149         $this->loader->add_filter( 'woocommerce_get_settings_products', $plugin_admin, 'wcsnapplify_all_settings', 10, 2 );
    150         $this->loader->add_filter( 'woocommerce_product_data_tabs', $plugin_admin, 'wcsnapplify_custom_product_tab' );
    151         $this->loader->add_action( 'woocommerce_product_data_panels', $plugin_admin, 'wcsnapplify_custom_tab_data' );
    152         $this->loader->add_filter( 'plugin_action_links_snapplify-ecommerce/snapplify-ecommerce.php', $plugin_admin, 'wcsnapplify_settings_link' );
    153         $this->loader->add_action( 'admin_menu', $plugin_admin, 'wcsnapplify_menu' );
    154         $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_drafts_admin_menu_item' );
    155         $this->loader->add_action( 'rest_api_init', $plugin_admin, 'add_snapplify_routes' );
     146    private function define_admin_hooks()
     147    {
     148        $plugin_admin = new Snapplify_ECommerce_Admin($this->get_plugin_name(), $this->get_version());
     149
     150        $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles');
     151        $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts');
     152        $this->loader->add_action('woocommerce_admin_field_auth-token', $plugin_admin, 'wcsnapplify_add_admin_field_auth_token');
     153        $this->loader->add_action('woocommerce_admin_field_api-url', $plugin_admin, 'wcsnapplify_add_admin_field_api_url');
     154        $this->loader->add_filter('woocommerce_get_sections_products', $plugin_admin, 'wcsnapplify_add_section');
     155        $this->loader->add_filter('woocommerce_get_settings_products', $plugin_admin, 'wcsnapplify_all_settings', 10, 2);
     156        $this->loader->add_filter('woocommerce_product_data_tabs', $plugin_admin, 'wcsnapplify_custom_product_tab');
     157        $this->loader->add_action('woocommerce_product_data_panels', $plugin_admin, 'wcsnapplify_custom_tab_data');
     158        $this->loader->add_filter('plugin_action_links_snapplify-ecommerce/snapplify-ecommerce.php', $plugin_admin, 'wcsnapplify_settings_link');
     159        $this->loader->add_action('admin_menu', $plugin_admin, 'wcsnapplify_menu');
     160        $this->loader->add_action('admin_menu', $plugin_admin, 'add_drafts_admin_menu_item');
     161        $this->loader->add_action('rest_api_init', $plugin_admin, 'add_snapplify_routes');
    156162
    157163        // Fulfillments
    158         $this->loader->add_action( 'init', $plugin_admin, 'register_snapplify_processing_status' );
    159         $this->loader->add_filter( 'wc_order_statuses', $plugin_admin, 'add_snapplify_processing_to_order_statuses' );
    160         $this->loader->add_action( 'admin_head', $plugin_admin, 'add_snapplify_processing_color_to_admin_order_list' );
    161         $this->loader->add_action( 'woocommerce_order_payment_status_changed', $plugin_admin, 'trigger_snapplify_fulfillment' );
    162 
    163         $this->loader->add_action( 'wc_snap_log_exec', $plugin_admin, 'wcsnapplify_eg_log_action_data' );
    164         $this->loader->add_action( 'wc_snap_process_product_exec', $plugin_admin, 'wcsnapplify_process_product_action' );
    165 
    166         $this->loader->add_action( 'doing_it_wrong_run', $plugin_admin, 'snap_verbose_trace' );
     164        $this->loader->add_action();
     165        $this->loader->add_filter();
     166        $this->loader->add_action();
     167        $this->loader->add_action();
     168
     169        $this->loader->add_action();
     170        $this->loader->add_action();
     171
     172        $this->loader->add_action();
    167173    }
    168174
     
    173179     * @since    1.0.0
    174180     */
    175     private function define_public_hooks() {
    176         $plugin_public = new Snapplify_ECommerce_Public( $this->get_plugin_name(), $this->get_version() );
    177 
    178         $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
    179         $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
     181    private function define_public_hooks()
     182    {
     183        $plugin_public = new Snapplify_ECommerce_Public($this->get_plugin_name(), $this->get_version());
     184
     185        $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles');
     186        $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts');
    180187
    181188        // display product image from cloud server
    182         $this->loader->add_filter( 'woocommerce_single_product_image_thumbnail_html', $plugin_public, 'wcsnapplify_product_image_from_cloud' , 10, 2 );
    183         $this->loader->add_filter( 'woocommerce_placeholder_img', $plugin_public, 'wcsnapplify_product_loop_image_from_cloud',10,3);
     189        $this->loader->add_filter('woocommerce_single_product_image_thumbnail_html', $plugin_public, 'wcsnapplify_product_image_from_cloud', 10, 2);
     190        $this->loader->add_filter('woocommerce_placeholder_img', $plugin_public, 'wcsnapplify_product_loop_image_from_cloud', 10, 3);
     191        $this->loader->add_filter('woocommerce_cart_item_thumbnail', $plugin_public, 'wcsnapplify_cart_product_loop_image_from_cloud', 10, 3);
    184192    }
    185193
     
    189197     * @since    1.0.0
    190198     */
    191     public function run() {
    192          $this->loader->run();
     199    public function run()
     200    {
     201        $this->loader->run();
    193202    }
    194203
     
    200209     * @return    string    The name of the plugin.
    201210     */
    202     public function get_plugin_name() {
    203          return $this->plugin_name;
     211    public function get_plugin_name()
     212    {
     213        return $this->plugin_name;
    204214    }
    205215
     
    210220     * @return    Snapplify_ECommerce_Loader    Orchestrates the hooks of the plugin.
    211221     */
    212     public function get_loader() {
     222    public function get_loader()
     223    {
    213224        return $this->loader;
    214225    }
     
    220231     * @return    string    The version number of the plugin.
    221232     */
    222     public function get_version() {
    223          return $this->version;
     233    public function get_version()
     234    {
     235        return $this->version;
    224236    }
    225237}
  • snapplify-e-commerce/trunk/public/class-snapplify-ecommerce-public.php

    r2825069 r2826525  
    11<?php
     2
    23/**
    34 * The public-facing functionality of the plugin.
     
    1920 * @subpackage Snapplify_ECommerce/public
    2021 */
    21 class Snapplify_ECommerce_Public {
     22class Snapplify_ECommerce_Public
     23{
    2224
    2325
     
    4547     * @param      string $version    The version of this plugin.
    4648     */
    47     public function __construct( $plugin_name, $version ) {
     49    public function __construct($plugin_name, $version)
     50    {
    4851
    4952        $this->plugin_name = $plugin_name;
     
    5659     * @since    1.0.0
    5760     */
    58     public function enqueue_styles() {
     61    public function enqueue_styles()
     62    {
    5963        /**
    6064         * This function is provided for demonstration purposes only.
     
    6973         */
    7074
    71         wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/snapplify-ecommerce-public.css', array(), $this->version, 'all' );
     75        wp_enqueue_style();
    7276    }
    7377
     
    7781     * @since    1.0.0
    7882     */
    79     public function enqueue_scripts() {
     83    public function enqueue_scripts()
     84    {
    8085        /**
    8186         * This function is provided for demonstration purposes only.
     
    9095         */
    9196
    92         wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/snapplify-ecommerce-public.js', array( 'jquery' ), $this->version, false );
     97        wp_enqueue_script();
    9398    }
    9499
    95     public function wcsnapplify_product_image_from_cloud($html, $post_thumbnail_id) {
     100    public function wcsnapplify_product_image_from_cloud($html, $post_thumbnail_id)
     101    {
    96102        global $post;
    97         if( get_option( 'wcsnapplify_download_product' ) !== 'yes' ){
    98             if(!$post_thumbnail_id) {
     103        if{
     104            if(!$post_thumbnail_id) {
    99105                $pID = $post->ID;
    100                 $snap_imageUrl = get_post_meta($pID,'_snap_imageUrl',true);
    101                 if($snap_imageUrl !== ''){
     106                $snap_imageUrl = get_post_meta($pID,true);
     107                if{
    102108                    $html  = '<div class="woocommerce-product-gallery__image--placeholder">';
    103                     $html .= sprintf( '<img src="%s" alt="%s" class="wp-post-image" />', esc_url( $snap_imageUrl ), esc_html__( $post->post_title, 'snapplify-ecommerce' ) );
     109                    $html .= sprintf();
    104110                    $html .= '</div>';
    105                 }               
     111                }
    106112            }
    107113        }
     
    109115    }
    110116
    111     public function wcsnapplify_product_loop_image_from_cloud( $image_html, $size, $dimensions ) {
    112         global $product;
    113         $pid = $product->get_id();
    114         if( get_option( 'wcsnapplify_download_product' ) !== 'yes' ){
    115             $snap_imageUrl = get_post_meta($pid,'_snap_imageUrl',true);
    116             if($snap_imageUrl !== ''){
    117                 $dimensions = wc_get_image_size( $size );
     117    public function get_image_html($product_id, $product_name, $size = 'woocommerce_thumbnail')
     118    {
     119        $snap_imageUrl = get_post_meta($product_id, '_snap_imageUrl', true);
     120        if ($snap_imageUrl !== '') {
     121            $dimensions = wc_get_image_size($size);
    118122
    119                 $default_attr = array(
    120                     'class' => 'woocommerce-placeholder wp-post-image',
    121                     'alt'   => __( $product->get_title(), 'woocommerce' ),
    122                 );
    123                
    124                 $attr = wp_parse_args( '', $default_attr );
    125                
    126                 $image      = $snap_imageUrl;
    127                 $hwstring   = image_hwstring( $dimensions['width'], $dimensions['height'] );
    128                 $attributes = array();
    129        
    130                 foreach ( $attr as $name => $value ) {
    131                     $attribute[] = esc_attr( $name ) . '="' . esc_attr( $value ) . '"';
    132                 }
    133        
    134                 $image_html = '<img src="' . esc_url( $image ) . '" ' . $hwstring . implode( ' ', $attribute ) . '/>';
     123            $default_attr = array(
     124                'class' => 'woocommerce-placeholder wp-post-image',
     125                'alt'   => __($product_name, 'woocommerce'),
     126            );
     127
     128            $attr = wp_parse_args('', $default_attr);
     129
     130            $image      = $snap_imageUrl;
     131            $hwstring   = image_hwstring($dimensions['width'], $dimensions['height']);
     132            $attributes = array();
     133
     134            foreach ($attr as $name => $value) {
     135                $attribute[] = esc_attr($name) . '="' . esc_attr($value) . '"';
     136            }
     137
     138            return '<img src="' . esc_url($image) . '" ' . $hwstring . implode(' ', $attribute) . '/>';
     139        }
     140        return false;
     141    }
     142
     143    public function wcsnapplify_product_loop_image_from_cloud($image_html, $size, $dimensions)
     144    {
     145        if (!is_cart()) {
     146            global $product;
     147            if (get_option('wcsnapplify_download_product') !== 'yes') {
     148                $newImageHtml = $this->get_image_html($product->get_id(), $product->get_title(), $size);
    135149            }
    136150        }
    137         return $image_html;
     151        if (!$newImageHtml) {
     152            $newImageHtml = $image_html;
     153        }
     154        return $newImageHtml;
     155    }
     156
     157    public function wcsnapplify_cart_product_loop_image_from_cloud($image_html, $cart_item, $cart_item_key)
     158    {
     159        if (get_option('wcsnapplify_download_product') !== 'yes') {
     160            $product = $cart_item['data'];
     161            $newImageHtml = $this->get_image_html($product->get_id(), $product->get_title());
     162        }
     163        if (!$newImageHtml) {
     164            $newImageHtml = $image_html;
     165        }
     166        return $newImageHtml;
    138167    }
    139168}
  • snapplify-e-commerce/trunk/snapplify-ecommerce.php

    r2825069 r2826525  
    11<?php
     2
    23/**
    34 * The plugin bootstrap file
     
    1112 * Plugin URI:        https://www.snapplify.com/snapplify-ecommerce
    1213 * Description:       Offer Snapplify products in your WooCommerce Store that can be redeemed using a voucher.
    13  * Version:           1.0.3
     14 * Version:           1.0.
    1415 * Author:            Snapplify
    1516 * Author URI:        https://snapplify.com
     
    2122
    2223// If this file is called directly, abort.
    23 if ( ! defined( 'WPINC' ) ) {
     24if () {
    2425    die;
    2526}
     
    2930 * Start at version 1.0.0 and use SemVer - https://semver.org
    3031 */
    31 define( 'SNAPPLIFY_ECOMMERCE_VERSION', '1.0.2' );
     32define();
    3233
    33 require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php';
    34 require_once plugin_dir_path( __FILE__ ) . 'lib/class-woometahandler.php';
    35 require_once plugin_dir_path( __FILE__ ) . 'lib/PipelineStages/class-createproduct.php';
    36 require_once plugin_dir_path( __FILE__ ) . 'lib/PipelineStages/class-extractjson.php';
    37 require_once plugin_dir_path( __FILE__ ) . 'lib/PipelineStages/class-validatejson.php';
     34require_once plugin_dir_path() . 'vendor/autoload.php';
     35require_once plugin_dir_path() . 'lib/class-woometahandler.php';
     36require_once plugin_dir_path() . 'lib/PipelineStages/class-createproduct.php';
     37require_once plugin_dir_path() . 'lib/PipelineStages/class-extractjson.php';
     38require_once plugin_dir_path() . 'lib/PipelineStages/class-validatejson.php';
    3839
    3940/**
     
    4142 * This action is documented in includes/class-snapplify-ecommerce-activator.php
    4243 */
    43 function activate_snapplify_ecommerce() {
    44     require_once plugin_dir_path( __FILE__ ) . 'includes/class-snapplify-ecommerce-activator.php';
     44function activate_snapplify_ecommerce()
     45{
     46    require_once plugin_dir_path(__FILE__) . 'includes/class-snapplify-ecommerce-activator.php';
    4547    Snapplify_ECommerce_Activator::activate();
    4648}
     
    5052 * This action is documented in includes/class-snapplify-ecommerce-deactivator.php
    5153 */
    52 function deactivate_snapplify_ecommerce() {
    53     require_once plugin_dir_path( __FILE__ ) . 'includes/class-snapplify-ecommerce-deactivator.php';
     54function deactivate_snapplify_ecommerce()
     55{
     56    require_once plugin_dir_path(__FILE__) . 'includes/class-snapplify-ecommerce-deactivator.php';
    5457    Snapplify_ECommerce_Deactivator::deactivate();
    5558}
    5659
    57 register_activation_hook( __FILE__, 'activate_snapplify_ecommerce' );
    58 register_deactivation_hook( __FILE__, 'deactivate_snapplify_ecommerce' );
     60register_activation_hook();
     61register_deactivation_hook();
    5962
    6063/**
     
    6265 */
    6366
    64 require_once plugin_dir_path( __FILE__ ) . '../woocommerce/packages/action-scheduler/action-scheduler.php';
     67require_once plugin_dir_path() . '../woocommerce/packages/action-scheduler/action-scheduler.php';
    6568
    6669
     
    7073 * admin-specific hooks, and public-facing site hooks.
    7174 */
    72 require plugin_dir_path( __FILE__ ) . 'includes/class-snapplify-ecommerce.php';
     75require plugin_dir_path() . 'includes/class-snapplify-ecommerce.php';
    7376
    7477/**
     
    8184 * @since    1.0.0
    8285 */
    83 function run_snapplify_ecommerce() {
     86function run_snapplify_ecommerce()
     87{
    8488    $plugin = new Snapplify_ECommerce();
    8589    $plugin->run();
Note: See TracChangeset for help on using the changeset viewer.