Changeset 3217050
- Timestamp:
- 01/05/2025 02:03:37 AM (12 months ago)
- Location:
- image-flip-for-woocommerce/trunk
- Files:
-
- 2 added
- 3 edited
-
. (modified) (1 prop)
-
composer.json (added)
-
composer.lock (added)
-
image-flip-for-woocommerce.php (modified) (2 diffs)
-
uninstall.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
image-flip-for-woocommerce/trunk
-
Property
svn:ignore
set to
vendor
-
Property
svn:ignore
set to
-
image-flip-for-woocommerce/trunk/image-flip-for-woocommerce.php
r2603897 r3217050 8 8 * Text Domain: image-flip-for-woocommerce 9 9 * Domain Path: /languages 10 * Version: 0.1.9 10 * Version: 0.2.0 11 * Tested up to: 6.7.1 11 12 * License: GNU General Public License v3.0 12 13 * License URI: http://www.gnu.org/licenses/gpl-3.0.html 13 14 * Based on plugin by jameskoster (https://jameskoster.co.uk) 14 15 * 15 * @package Image_Flip_For_Woocommerce16 * @package Image_Flip_For_Woocommerce 16 17 */ 17 18 … … 19 20 * Check if WooCommerce is active 20 21 */ 21 if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true) ) {22 if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')), true) ) { 22 23 23 /**24 * Image Flipper class exists.25 */26 if ( ! class_exists( 'Image_Flip_WooCommerce') ) {24 /** 25 * Image Flipper class exists. 26 */ 27 if (! class_exists('Image_Flip_WooCommerce') ) { 27 28 28 /** 29 * Image_Flip_WooCommerce class. 30 */ 31 class Image_Flip_WooCommerce { 29 /** 30 * Image_Flip_WooCommerce class. 31 */ 32 class Image_Flip_WooCommerce 33 { 32 34 33 /** 34 * __construct function. 35 * 36 * @access public 37 * @return void 38 */ 39 public function __construct() { 40 add_action( 'init', array( $this, 'init' ) ); 41 add_action( 'wp_enqueue_scripts', array( $this, 'image_flip_styles' ) ); 42 add_action( 'woocommerce_before_shop_loop_item_title', array( $this, 'woocommerce_template_loop_second_product_thumbnail' ), 11 ); 43 add_filter( 'post_class', array( $this, 'product_has_gallery' ) ); 44 } 35 /** 36 * __construct function. 37 * 38 * @access public 39 * @return void 40 */ 41 public function __construct() 42 { 43 add_action('init', array( $this, 'init' )); 44 add_action('wp_enqueue_scripts', array( $this, 'image_flip_styles' )); 45 add_action('woocommerce_before_shop_loop_item_title', array( $this, 'woocommerce_template_loop_second_product_thumbnail' ), 11); 46 add_filter('post_class', array( $this, 'product_has_gallery' )); 47 } 45 48 46 /** 47 * Init. 48 * 49 * @access public 50 */ 51 public function init() { 52 load_plugin_textdomain( 'image-flip-for-woocommerce', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); 53 } 49 /** 50 * Init. 51 * 52 * @access public 53 */ 54 public function init() 55 { 56 load_plugin_textdomain('image-flip-for-woocommerce', false, dirname(plugin_basename(__FILE__)) . '/languages'); 57 } 54 58 55 /** 56 * Styles. 57 * 58 * @access public 59 */ 60 public function image_flip_styles() { 61 if( is_product_category() ) { 62 if ( apply_filters( 'image_flip_styles', true ) ) { 63 wp_enqueue_style( 'image-flip-styles', plugins_url( '/assets/css/image-flip.min.css', __FILE__ ), array(), '0.0.1', 'all' ); 64 } 65 } 66 } 59 /** 60 * Styles. 61 * 62 * @access public 63 */ 64 public function image_flip_styles() 65 { 66 if(is_product_category() ) { 67 if (apply_filters('image_flip_styles', true) ) { 68 wp_enqueue_style('image-flip-styles', plugins_url('/assets/css/image-flip.min.css', __FILE__), array(), '0.0.1', 'all'); 69 } 70 } 71 } 67 72 68 /** 69 * Add class if Product has Gallery. 70 * 71 * @access public 72 * @param mixed $classes Classes. 73 */ 74 public function product_has_gallery( $classes ) { 73 /** 74 * Add class if Product has Gallery. 75 * 76 * @access public 77 * @param mixed $classes Classes. 78 */ 79 public function product_has_gallery( $classes ) 80 { 75 81 76 global $product;82 global $product; 77 83 78 $post_type = get_post_type( get_the_ID());84 $post_type = get_post_type(get_the_ID()); 79 85 80 if (! is_admin() ) {86 if (! is_admin() ) { 81 87 82 if ('product' === $post_type && is_product_category() ) {88 if ('product' === $post_type && is_product_category() ) { 83 89 84 $attachment_ids = $this->get_gallery_image_ids( $product);90 $attachment_ids = $this->get_gallery_image_ids($product); 85 91 86 if ($attachment_ids ) {87 $classes[] = 'pif-has-gallery';88 }89 }90 }92 if ($attachment_ids ) { 93 $classes[] = 'pif-has-gallery'; 94 } 95 } 96 } 91 97 92 return $classes;98 return $classes; 93 99 94 }100 } 95 101 96 /** 97 * Loop Second Product Thumbnail. 98 * 99 * @access public 100 */ 101 public function woocommerce_template_loop_second_product_thumbnail() { 102 /** 103 * Loop Second Product Thumbnail. 104 * 105 * @access public 106 */ 107 public function woocommerce_template_loop_second_product_thumbnail() 108 { 102 109 103 if(is_product_category() ) {110 if(is_product_category() ) { 104 111 105 global $product, $woocommerce;112 global $product, $woocommerce; 106 113 107 $attachment_ids = $this->get_gallery_image_ids( $product);114 $attachment_ids = $this->get_gallery_image_ids($product); 108 115 109 if ($attachment_ids ) {110 $attachment_ids = array_values( $attachment_ids);111 $secondary_image_id = $attachment_ids['0'];116 if ($attachment_ids ) { 117 $attachment_ids = array_values($attachment_ids); 118 $secondary_image_id = $attachment_ids['0']; 112 119 113 $secondary_image_alt = get_post_meta( $secondary_image_id, '_wp_attachment_image_alt', true);114 $secondary_image_title = get_the_title( $secondary_image_id);120 $secondary_image_alt = get_post_meta($secondary_image_id, '_wp_attachment_image_alt', true); 121 $secondary_image_title = get_the_title($secondary_image_id); 115 122 116 echo wp_get_attachment_image(117 $secondary_image_id,118 'shop_catalog',119 '',120 array(121 'class' => 'secondary-image attachment-shop-catalog wp-post-image wp-post-image--secondary',122 'alt' => $secondary_image_alt,123 'title' => $secondary_image_title,124 )125 );126 }123 echo wp_get_attachment_image( 124 $secondary_image_id, 125 'shop_catalog', 126 '', 127 array( 128 'class' => 'secondary-image attachment-shop-catalog wp-post-image wp-post-image--secondary', 129 'alt' => $secondary_image_alt, 130 'title' => $secondary_image_title, 131 ) 132 ); 133 } 127 134 128 }129 }135 } 136 } 130 137 131 /** 132 * Get Gallery Image IDs. 133 * 134 * @access public 135 * @param mixed $product Product. 136 */ 137 public function get_gallery_image_ids( $product ) { 138 /** 139 * Get Gallery Image IDs. 140 * 141 * @access public 142 * @param mixed $product Product. 143 */ 144 public function get_gallery_image_ids( $product ) 145 { 138 146 139 if(is_product_category() ) {147 if(is_product_category() ) { 140 148 141 if ( ! is_a( $product, 'WC_Product') ) {142 return;143 }149 if (! is_a($product, 'WC_Product') ) { 150 return; 151 } 144 152 145 if ( is_callable( 'WC_Product::get_gallery_image_ids') ) {146 return $product->get_gallery_image_ids();147 } else {148 return $product->get_gallery_attachment_ids();149 }153 if (is_callable('WC_Product::get_gallery_image_ids') ) { 154 return $product->get_gallery_image_ids(); 155 } else { 156 return $product->get_gallery_attachment_ids(); 157 } 150 158 151 }152 }159 } 160 } 153 161 154 }162 } 155 163 156 $image_flip_woocommerce = new Image_Flip_WooCommerce();157 }164 $image_flip_woocommerce = new Image_Flip_WooCommerce(); 165 } 158 166 } -
image-flip-for-woocommerce/trunk/uninstall.php
r2121753 r3217050 7 7 8 8 // Exit if accessed directly. 9 defined( 'ABSPATH') || exit;9 defined('ABSPATH') || exit; 10 10 11 if ( ! defined( 'WP_UNINSTALL_PLUGIN') ) {12 exit();11 if (! defined('WP_UNINSTALL_PLUGIN') ) { 12 exit(); 13 13 } 14 14
Note: See TracChangeset
for help on using the changeset viewer.