Changeset 2406268
- Timestamp:
- 10/25/2020 03:23:57 PM (5 years ago)
- Location:
- product-gtin-ean-upc-isbn-for-woocommerce
- Files:
-
- 18 added
- 2 edited
-
tags/1.1.0 (added)
-
tags/1.1.0/LICENSE.txt (added)
-
tags/1.1.0/assets (added)
-
tags/1.1.0/assets/js (added)
-
tags/1.1.0/assets/js/product-gtin-wc-frontend.js (added)
-
tags/1.1.0/assets/js/product-gtin-wc-frontend.min.js (added)
-
tags/1.1.0/includes (added)
-
tags/1.1.0/includes/admin (added)
-
tags/1.1.0/includes/admin/settings (added)
-
tags/1.1.0/includes/admin/settings/settings-wpm-product-gtin-wc.php (added)
-
tags/1.1.0/includes/class.product-gtin-wc-admin.php (added)
-
tags/1.1.0/includes/class.product-gtin-wc-frontend.php (added)
-
tags/1.1.0/includes/class.product-gtin-wc.php (added)
-
tags/1.1.0/index.php (added)
-
tags/1.1.0/languages (added)
-
tags/1.1.0/languages/product-gtin-ean-upc-isbn-for-woocommerce.pot (added)
-
tags/1.1.0/product-gtin-ean-upc-isbn-for-woocommerce.php (added)
-
tags/1.1.0/readme.txt (added)
-
trunk/product-gtin-ean-upc-isbn-for-woocommerce.php (modified) (5 diffs)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
product-gtin-ean-upc-isbn-for-woocommerce/trunk/product-gtin-ean-upc-isbn-for-woocommerce.php
r2291765 r2406268 1 1 <?php 2 2 3 /** 3 4 * Plugin Name: Product GTIN (EAN, UPC, ISBN) for WooCommerce 4 5 * Author URI: https://emanuelacastorina.com/ 5 6 * Description: Add a Global Trade Item Number (EAN, UPC, ISBN, JAN, ITF-14) field to WooCommerce 6 * Version: 1. 0.97 * Version: 1.1.0 7 8 * Author: Emanuela Castorina 8 9 * Text Domain: product-gtin-ean-upc-isbn-for-woocommerce 9 10 * Domain Path: /languages 10 * WC tested up to: 4. 111 * WC tested up to: 4.7 11 12 * WC requires at least: 3.0 12 13 */ 13 14 14 15 15 if ( ! defined( 'ABSPATH' )) {16 if (!defined('ABSPATH')) { 16 17 exit; // Exit if accessed directly 17 18 } … … 20 21 * Currently plugin version. 21 22 */ 22 if ( ! defined( 'WPM_PRODUCT_GTIN_WC_VERSION' )) {23 define( 'WPM_PRODUCT_GTIN_WC_VERSION', '1.0.9');23 if (!defined('WPM_PRODUCT_GTIN_WC_VERSION')) { 24 define('WPM_PRODUCT_GTIN_WC_VERSION', '1.1.0'); 24 25 } 25 26 26 27 // Define WPM_PRODUCT_GTIN_WC_FILE. 27 if ( ! defined( 'WPM_PRODUCT_GTIN_WC_FILE' )) {28 define( 'WPM_PRODUCT_GTIN_WC_FILE', __FILE__);28 if (!defined('WPM_PRODUCT_GTIN_WC_FILE')) { 29 define('WPM_PRODUCT_GTIN_WC_FILE', __FILE__); 29 30 } 30 31 31 32 // Define WPM_PRODUCT_GTIN_WC_DIR. 32 if ( ! defined( 'WPM_PRODUCT_GTIN_WC_DIR' )) {33 define( 'WPM_PRODUCT_GTIN_WC_DIR', plugin_dir_path( __FILE__ ));33 if (!defined('WPM_PRODUCT_GTIN_WC_DIR')) { 34 define('WPM_PRODUCT_GTIN_WC_DIR', plugin_dir_path(__FILE__)); 34 35 } 35 36 36 37 // Define WPM_PRODUCT_GTIN_WC_URL. 37 if ( ! defined( 'WPM_PRODUCT_GTIN_WC_URL' )) {38 define( 'WPM_PRODUCT_GTIN_WC_URL', plugins_url( '/', __FILE__ ));38 if (!defined('WPM_PRODUCT_GTIN_WC_URL')) { 39 define('WPM_PRODUCT_GTIN_WC_URL', plugins_url('/', __FILE__)); 39 40 } 40 41 41 42 // Define WPM_PRODUCT_GTIN_WC_ASSETS_URL. 42 if ( ! defined( 'WPM_PRODUCT_GTIN_WC_ASSETS_URL' )) {43 define( 'WPM_PRODUCT_GTIN_WC_ASSETS_URL', WPM_PRODUCT_GTIN_WC_URL . 'assets');43 if (!defined('WPM_PRODUCT_GTIN_WC_ASSETS_URL')) { 44 define('WPM_PRODUCT_GTIN_WC_ASSETS_URL', WPM_PRODUCT_GTIN_WC_URL . 'assets'); 44 45 } 45 46 46 47 // Include the main class. 47 if ( ! class_exists( 'WPM_Product_GTIN_WC' )) {48 include_once dirname( __FILE__) . '/includes/class.product-gtin-wc.php';48 if (!class_exists('WPM_Product_GTIN_WC')) { 49 include_once dirname(__FILE__) . '/includes/class.product-gtin-wc.php'; 49 50 } 50 51 /** … … 53 54 * @return WPM_Product_GTIN_WC 54 55 */ 55 if ( ! function_exists( 'wpm_product_gtin_wc' )) {56 if (!function_exists('wpm_product_gtin_wc')) { 56 57 57 58 /** … … 60 61 * @return WPM_Free_Gift_Coupons 61 62 */ 62 function wpm_product_gtin_wc() { 63 function wpm_product_gtin_wc() 64 { 63 65 return WPM_Product_GTIN_WC::instance(); 64 66 } … … 66 68 $GLOBALS['wpm_product_gtin_wc'] = wpm_product_gtin_wc(); 67 69 } 70 71 72 /** 73 * Return instance of WPM_Product_GTIN_WC. 74 * 75 * @return WPM_Product_GTIN_WC 76 */ 77 if (!function_exists('wpm_get_code_gtin_by_product')) { 78 79 /** 80 * Return the code of the product. 81 * 82 * @return string 83 */ 84 function wpm_get_code_gtin_by_product($product) 85 { 86 if (is_numeric($product)) { 87 $product = wc_get_product($product); 88 } 89 90 if ($product instanceof WC_Product) { 91 $code = $product->get_meta('_wpm_gtin_code'); 92 $parent_id = $product->get_parent_id(); 93 if (empty($code) && $parent_id) { 94 return wpm_get_code_gtin_by_product($parent_id); 95 } else { 96 return $code; 97 } 98 } 99 100 return ''; 101 } 102 } -
product-gtin-ean-upc-isbn-for-woocommerce/trunk/readme.txt
r2291767 r2406268 6 6 Requires at least: 4.0.0 7 7 Requires PHP: 7.0 8 Tested up to: 5. 49 Stable tag: 1. 0.98 Tested up to: 5.5 9 Stable tag: 1.1.0 10 10 License: GPLv2 or later 11 11 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 66 66 If your product is variable, you can set a GTIN code for each variation; you can fill out the GTIN field that you'll find inside the variation detail panel. 67 67 68 = How can I get a GTIN code for a product? = 69 70 Since version 1.1.0 it is possible use the function wpm_get_code_gtin_by_product that need the product id or the product object. 71 The function returns the GTIN code as string. 72 73 `$gtin = wpm_get_code_gtin_by_product($product_id);` 74 68 75 = Where is stored the GTIN code ? = 69 76 The GTIN code is a private custom field of product with *meta_key* `_wpm_gtin_code` … … 114 121 115 122 == Changelog == 123 = 1.1.0 - Released: 25 Oct, 2020 = 124 * New: Support for WordPress 5.5 125 * New: Support for WooCommerce 4.7 126 * Dev: New function wpm_get_code_gtin_by_product to get the GTIN code by product id or product 127 116 128 = 1.0.9 - Released: 25 April, 2020 = 117 129 * New: Support for WooCommerce 4.1
Note: See TracChangeset
for help on using the changeset viewer.