Changeset 2826525
- Timestamp:
- 11/30/2022 01:55:46 PM (20 months ago)
- Location:
- snapplify-e-commerce
- Files:
-
- 161 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
snapplify-e-commerce/trunk/README.txt
r2825071 r2826525 4 4 Requires at least: 5.6 5 5 Tested up to: 6.0.2 6 Stable tag: 1.0. 36 Stable tag: 1.0. 7 7 Requires PHP: 7.2 8 8 License: GPLv2 or later … … 82 82 == Changelog == 83 83 84 85 84 86 = 1.0.3 = 85 87 * Add option for manually flush the pending products queue. -
snapplify-e-commerce/trunk/changelog.txt
r2825069 r2826525 1 1 *** WooCommerce Extension Template Changelog *** 2 3 4 2 5 2022-11-25 - version 1.0.3 3 6 * Add option for manually flush the pending products queue. -
snapplify-e-commerce/trunk/includes/class-snapplify-ecommerce.php
r2825069 r2826525 1 1 <?php 2 2 3 /** 3 4 * The file that defines the core plugin class … … 26 27 * @subpackage Snapplify_ECommerce/includes 27 28 */ 28 class Snapplify_ECommerce { 29 class Snapplify_ECommerce 30 { 29 31 30 32 … … 63 65 * @since 1.0.0 64 66 */ 65 public function __construct() { 66 if ( defined( 'SNAPPLIFY_CATAlog_VERSION' ) ) { 67 public function __construct() 68 { 69 if (defined('SNAPPLIFY_CATAlog_VERSION')) { 67 70 $this->version = SNAPPLIFY_CATAlog_VERSION; 68 71 } else { … … 92 95 * @since 1.0.0 93 96 */ 94 private function load_dependencies() { 97 private function load_dependencies() 98 { 95 99 /** 96 100 * The class responsible for orchestrating the actions and filters of the 97 101 * core plugin. 98 102 */ 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'; 100 104 101 105 /** … … 103 107 * of the plugin. 104 108 */ 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'; 106 110 107 111 /** 108 112 * The class responsible for defining all actions that occur in the admin area. 109 113 */ 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'; 111 115 112 116 /** … … 114 118 * side of the site. 115 119 */ 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'; 117 121 118 122 $this->loader = new Snapplify_ECommerce_Loader(); … … 127 131 * @since 1.0.0 128 132 */ 129 private function set_locale() { 133 private function set_locale() 134 { 130 135 $plugin_i18n = new Snapplify_ECommerce_I18n(); 131 136 132 $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain');137 $this->loader->add_action(); 133 138 } 134 139 … … 139 144 * @since 1.0.0 140 145 */ 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'); 156 162 157 163 // 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(); 167 173 } 168 174 … … 173 179 * @since 1.0.0 174 180 */ 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'); 180 187 181 188 // 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); 184 192 } 185 193 … … 189 197 * @since 1.0.0 190 198 */ 191 public function run() { 192 $this->loader->run(); 199 public function run() 200 { 201 $this->loader->run(); 193 202 } 194 203 … … 200 209 * @return string The name of the plugin. 201 210 */ 202 public function get_plugin_name() { 203 return $this->plugin_name; 211 public function get_plugin_name() 212 { 213 return $this->plugin_name; 204 214 } 205 215 … … 210 220 * @return Snapplify_ECommerce_Loader Orchestrates the hooks of the plugin. 211 221 */ 212 public function get_loader() { 222 public function get_loader() 223 { 213 224 return $this->loader; 214 225 } … … 220 231 * @return string The version number of the plugin. 221 232 */ 222 public function get_version() { 223 return $this->version; 233 public function get_version() 234 { 235 return $this->version; 224 236 } 225 237 } -
snapplify-e-commerce/trunk/public/class-snapplify-ecommerce-public.php
r2825069 r2826525 1 1 <?php 2 2 3 /** 3 4 * The public-facing functionality of the plugin. … … 19 20 * @subpackage Snapplify_ECommerce/public 20 21 */ 21 class Snapplify_ECommerce_Public { 22 class Snapplify_ECommerce_Public 23 { 22 24 23 25 … … 45 47 * @param string $version The version of this plugin. 46 48 */ 47 public function __construct( $plugin_name, $version ) { 49 public function __construct($plugin_name, $version) 50 { 48 51 49 52 $this->plugin_name = $plugin_name; … … 56 59 * @since 1.0.0 57 60 */ 58 public function enqueue_styles() { 61 public function enqueue_styles() 62 { 59 63 /** 60 64 * This function is provided for demonstration purposes only. … … 69 73 */ 70 74 71 wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/snapplify-ecommerce-public.css', array(), $this->version, 'all');75 wp_enqueue_style(); 72 76 } 73 77 … … 77 81 * @since 1.0.0 78 82 */ 79 public function enqueue_scripts() { 83 public function enqueue_scripts() 84 { 80 85 /** 81 86 * This function is provided for demonstration purposes only. … … 90 95 */ 91 96 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(); 93 98 } 94 99 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 { 96 102 global $post; 97 if ( get_option( 'wcsnapplify_download_product' ) !== 'yes' ){98 if (!$post_thumbnail_id) {103 if{ 104 if(!$post_thumbnail_id) { 99 105 $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{ 102 108 $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(); 104 110 $html .= '</div>'; 105 } 111 } 106 112 } 107 113 } … … 109 115 } 110 116 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); 118 122 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); 135 149 } 136 150 } 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; 138 167 } 139 168 } -
snapplify-e-commerce/trunk/snapplify-ecommerce.php
r2825069 r2826525 1 1 <?php 2 2 3 /** 3 4 * The plugin bootstrap file … … 11 12 * Plugin URI: https://www.snapplify.com/snapplify-ecommerce 12 13 * Description: Offer Snapplify products in your WooCommerce Store that can be redeemed using a voucher. 13 * Version: 1.0. 314 * Version: 1.0. 14 15 * Author: Snapplify 15 16 * Author URI: https://snapplify.com … … 21 22 22 23 // If this file is called directly, abort. 23 if ( ! defined( 'WPINC' )) {24 if () { 24 25 die; 25 26 } … … 29 30 * Start at version 1.0.0 and use SemVer - https://semver.org 30 31 */ 31 define( 'SNAPPLIFY_ECOMMERCE_VERSION', '1.0.2');32 define(); 32 33 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';34 require_once plugin_dir_path() . 'vendor/autoload.php'; 35 require_once plugin_dir_path() . 'lib/class-woometahandler.php'; 36 require_once plugin_dir_path() . 'lib/PipelineStages/class-createproduct.php'; 37 require_once plugin_dir_path() . 'lib/PipelineStages/class-extractjson.php'; 38 require_once plugin_dir_path() . 'lib/PipelineStages/class-validatejson.php'; 38 39 39 40 /** … … 41 42 * This action is documented in includes/class-snapplify-ecommerce-activator.php 42 43 */ 43 function activate_snapplify_ecommerce() { 44 require_once plugin_dir_path( __FILE__ ) . 'includes/class-snapplify-ecommerce-activator.php'; 44 function activate_snapplify_ecommerce() 45 { 46 require_once plugin_dir_path(__FILE__) . 'includes/class-snapplify-ecommerce-activator.php'; 45 47 Snapplify_ECommerce_Activator::activate(); 46 48 } … … 50 52 * This action is documented in includes/class-snapplify-ecommerce-deactivator.php 51 53 */ 52 function deactivate_snapplify_ecommerce() { 53 require_once plugin_dir_path( __FILE__ ) . 'includes/class-snapplify-ecommerce-deactivator.php'; 54 function deactivate_snapplify_ecommerce() 55 { 56 require_once plugin_dir_path(__FILE__) . 'includes/class-snapplify-ecommerce-deactivator.php'; 54 57 Snapplify_ECommerce_Deactivator::deactivate(); 55 58 } 56 59 57 register_activation_hook( __FILE__, 'activate_snapplify_ecommerce');58 register_deactivation_hook( __FILE__, 'deactivate_snapplify_ecommerce');60 register_activation_hook(); 61 register_deactivation_hook(); 59 62 60 63 /** … … 62 65 */ 63 66 64 require_once plugin_dir_path( __FILE__) . '../woocommerce/packages/action-scheduler/action-scheduler.php';67 require_once plugin_dir_path() . '../woocommerce/packages/action-scheduler/action-scheduler.php'; 65 68 66 69 … … 70 73 * admin-specific hooks, and public-facing site hooks. 71 74 */ 72 require plugin_dir_path( __FILE__) . 'includes/class-snapplify-ecommerce.php';75 require plugin_dir_path() . 'includes/class-snapplify-ecommerce.php'; 73 76 74 77 /** … … 81 84 * @since 1.0.0 82 85 */ 83 function run_snapplify_ecommerce() { 86 function run_snapplify_ecommerce() 87 { 84 88 $plugin = new Snapplify_ECommerce(); 85 89 $plugin->run();
Note: See TracChangeset
for help on using the changeset viewer.