CTX Feed – WooCommerce Product Feed Manager Plugin - Version 3.7.3

Version Description

(2020-08-22) = * Added: Category mapping feature added. Option to map store category with merchant category

Download this release

Release Info

Developer wahid0003
Plugin Icon 128x128 CTX Feed – WooCommerce Product Feed Manager Plugin
Version 3.7.3
Comparing to
See all releases

Code changes from version 3.7.2 to 3.7.3

README.txt CHANGED
@@ -5,7 +5,7 @@ Tags:product feed,woocommerce product feed,google shopping feed,google shopping,
5
  Requires at least: 3.6
6
  Tested Up To: 5.5
7
  Requires PHP: 5.6
8
- Stable tag: 3.7.2
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -308,6 +308,9 @@ Using pro version:
308
 
309
  == Changelog ==
310
 
 
 
 
311
  = 3.7.2 (2020-08-20) =
312
  * Fixed: g:additional_image_link attribute issue fixed.
313
 
5
  Requires at least: 3.6
6
  Tested Up To: 5.5
7
  Requires PHP: 5.6
8
+ Stable tag: 3.7.3
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
308
 
309
  == Changelog ==
310
 
311
+ = 3.7.3 (2020-08-22) =
312
+ * Added: Category mapping feature added. Option to map store category with merchant category
313
+
314
  = 3.7.2 (2020-08-20) =
315
  * Fixed: g:additional_image_link attribute issue fixed.
316
 
admin/class-woo-feed-admin.php CHANGED
@@ -234,6 +234,7 @@ class Woo_Feed_Admin {
234
  add_menu_page( __( 'Woo Feed', 'woo-feed' ), __( 'Woo Feed', 'woo-feed' ), 'manage_woocommerce', 'webappick-manage-feeds', 'woo_feed_manage_feed', 'dashicons-rss' );
235
  add_submenu_page( 'webappick-manage-feeds', __( 'Manage Feeds', 'woo-feed' ), __( 'Manage Feeds', 'woo-feed' ), 'manage_woocommerce', 'webappick-manage-feeds', 'woo_feed_manage_feed' );
236
  add_submenu_page( 'webappick-manage-feeds', __( 'Make Feed', 'woo-feed' ), __( 'Make Feed', 'woo-feed' ), 'manage_woocommerce', 'webappick-new-feed', 'woo_feed_generate_new_feed' );
 
237
  add_submenu_page( 'webappick-manage-feeds', __( 'Settings', 'woo-feed' ), __( 'Settings', 'woo-feed' ), 'manage_woocommerce', 'webappick-feed-settings', 'woo_feed_config_feed' );
238
  add_submenu_page( 'webappick-manage-feeds', __( 'Documentation', 'woo-feed' ), '<span class="woo-feed-docs">' . __( 'Docs', 'woo-feed' ) . '</span>', 'manage_woocommerce', 'webappick-feed-docs', array( WooFeedDocs::getInstance(), 'woo_feed_docs' ) );
239
  }
234
  add_menu_page( __( 'Woo Feed', 'woo-feed' ), __( 'Woo Feed', 'woo-feed' ), 'manage_woocommerce', 'webappick-manage-feeds', 'woo_feed_manage_feed', 'dashicons-rss' );
235
  add_submenu_page( 'webappick-manage-feeds', __( 'Manage Feeds', 'woo-feed' ), __( 'Manage Feeds', 'woo-feed' ), 'manage_woocommerce', 'webappick-manage-feeds', 'woo_feed_manage_feed' );
236
  add_submenu_page( 'webappick-manage-feeds', __( 'Make Feed', 'woo-feed' ), __( 'Make Feed', 'woo-feed' ), 'manage_woocommerce', 'webappick-new-feed', 'woo_feed_generate_new_feed' );
237
+ add_submenu_page( 'webappick-manage-feeds', __( 'Category Mapping', 'woo-feed' ), __( 'Category Mapping', 'woo-feed' ), 'manage_woocommerce', 'webappick-feed-category-mapping', 'woo_feed_category_mapping' );
238
  add_submenu_page( 'webappick-manage-feeds', __( 'Settings', 'woo-feed' ), __( 'Settings', 'woo-feed' ), 'manage_woocommerce', 'webappick-feed-settings', 'woo_feed_config_feed' );
239
  add_submenu_page( 'webappick-manage-feeds', __( 'Documentation', 'woo-feed' ), '<span class="woo-feed-docs">' . __( 'Docs', 'woo-feed' ) . '</span>', 'manage_woocommerce', 'webappick-feed-docs', array( WooFeedDocs::getInstance(), 'woo_feed_docs' ) );
240
  }
includes/class-woo-feed.php CHANGED
@@ -169,12 +169,16 @@ class Woo_Feed {
169
  * The class responsible for making list table
170
  */
171
  require_once WOO_FEED_FREE_PATH . 'includes/classes/class-woo-feed-list-table.php';
172
-
173
-
174
  /**
175
  * The class responsible for making feed list
176
  */
177
  require_once WOO_FEED_FREE_PATH . 'admin/class-woo-feed-manage-list.php';
 
 
 
 
 
178
 
179
  require_once WOO_FEED_FREE_PATH . 'includes/classes/class-woo-feed-sftp.php';
180
  require_once WOO_FEED_FREE_PATH . 'includes/widget.php';
169
  * The class responsible for making list table
170
  */
171
  require_once WOO_FEED_FREE_PATH . 'includes/classes/class-woo-feed-list-table.php';
172
+
 
173
  /**
174
  * The class responsible for making feed list
175
  */
176
  require_once WOO_FEED_FREE_PATH . 'admin/class-woo-feed-manage-list.php';
177
+
178
+ /**
179
+ * The class responsible for making category list
180
+ */
181
+ require_once WOO_FEED_FREE_PATH . 'admin/class-woo-feed-category-list.php';
182
 
183
  require_once WOO_FEED_FREE_PATH . 'includes/classes/class-woo-feed-sftp.php';
184
  require_once WOO_FEED_FREE_PATH . 'includes/widget.php';
includes/classes/class-woo-feed-dropdown.php CHANGED
@@ -266,9 +266,39 @@ class Woo_Feed_Dropdown {
266
  $attributes = $attributes + $this->getAttributeTaxonomies();
267
  $attributes['---3'] = '';
268
  }
 
 
 
 
 
 
 
 
269
 
270
  return $attributes;
271
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
272
 
273
  /**
274
  * Local Attribute List to map product value with merchant attributes
266
  $attributes = $attributes + $this->getAttributeTaxonomies();
267
  $attributes['---3'] = '';
268
  }
269
+
270
+ // Category Mapping
271
+ $_category_mappings = $this->getCustomCategoryMappedAttributes();
272
+ if ( ! empty( $_category_mappings ) && is_array( $_category_mappings ) ) {
273
+ $attributes['--4'] = esc_html__( 'Category Mappings', 'woo-feed' );
274
+ $attributes = $attributes + $_category_mappings;
275
+ $attributes['---4'] = '';
276
+ }
277
 
278
  return $attributes;
279
  }
280
+
281
+ /**
282
+ * Get Category Mappings
283
+ * @return array
284
+ */
285
+ protected function getCustomCategoryMappedAttributes() {
286
+ global $wpdb;
287
+ // Load Custom Category Mapped Attributes
288
+ $info = array();
289
+ // query cached and escaped
290
+ $data = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->options WHERE option_name LIKE %s;", Woo_Feed_Products_v3::PRODUCT_CATEGORY_MAPPING_PREFIX . '%' ) ); // phpcs:ignore
291
+ if ( count( $data ) ) {
292
+ foreach ( $data as $key => $value ) {
293
+ $opts = maybe_unserialize( $value->option_value );
294
+ $opts = maybe_unserialize( $opts );
295
+ $info[ $value->option_name ] = is_array( $opts ) && isset( $opts['mappingname'] ) ? $opts['mappingname'] : str_replace( 'wf_cmapping_',
296
+ '',
297
+ $value->option_name );
298
+ }
299
+ }
300
+ return (array) $info;
301
+ }
302
 
303
  /**
304
  * Local Attribute List to map product value with merchant attributes
includes/classes/class-woo-feed-products-v3.php CHANGED
@@ -204,6 +204,12 @@ class Woo_Feed_Products_v3
204
  * @var string
205
  */
206
  const PRODUCT_TAXONOMY_PREFIX = 'wf_taxo_';
 
 
 
 
 
 
207
 
208
  public function __construct($config)
209
  {
@@ -1179,6 +1185,9 @@ class Woo_Feed_Products_v3
1179
  } elseif (false !== strpos($attribute, self::PRODUCT_TAXONOMY_PREFIX)) {
1180
  $attribute = str_replace(self::PRODUCT_TAXONOMY_PREFIX, '', $attribute);
1181
  $output = $this->getProductTaxonomy($product, $attribute);
 
 
 
1182
  } elseif ('image_' == substr($attribute, 0, 6)) {
1183
  // For additional image method images() will be used with extra parameter - image number
1184
  $imageKey = explode('_', $attribute);
204
  * @var string
205
  */
206
  const PRODUCT_TAXONOMY_PREFIX = 'wf_taxo_';
207
+ /**
208
+ * Product Category Mapping Prefix
209
+ * @since 3.1.18
210
+ * @var string
211
+ */
212
+ const PRODUCT_CATEGORY_MAPPING_PREFIX = 'wf_cmapping_';
213
 
214
  public function __construct($config)
215
  {
1185
  } elseif (false !== strpos($attribute, self::PRODUCT_TAXONOMY_PREFIX)) {
1186
  $attribute = str_replace(self::PRODUCT_TAXONOMY_PREFIX, '', $attribute);
1187
  $output = $this->getProductTaxonomy($product, $attribute);
1188
+ }elseif ( false !== strpos( $attribute, self::PRODUCT_CATEGORY_MAPPING_PREFIX ) ) {
1189
+ $id = $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id();
1190
+ $output = woo_feed_get_category_mapping_value( $attribute, $id );
1191
  } elseif ('image_' == substr($attribute, 0, 6)) {
1192
  // For additional image method images() will be used with extra parameter - image number
1193
  $imageKey = explode('_', $attribute);
includes/helper.php CHANGED
@@ -2380,4 +2380,155 @@ if ( ! function_exists( 'woo_feed_filter_parsed_rules' ) ) {
2380
  }
2381
  }
2382
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2383
  // End of file helper.php.
2380
  }
2381
  }
2382
 
2383
+ if ( ! function_exists( 'woo_feed_category_mapping' ) ) {
2384
+ /**
2385
+ * Category Mapping
2386
+ */
2387
+ function woo_feed_category_mapping() {
2388
+ // Manage action for category mapping.
2389
+ if ( isset( $_GET['action'], $_GET['cmapping'] ) && 'edit-mapping' == $_GET['action'] ) {
2390
+ if ( count( $_POST ) && isset( $_POST['mappingname'] ) && isset( $_POST['edit-mapping'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
2391
+ check_admin_referer( 'category-mapping' );
2392
+
2393
+ $mappingOption = sanitize_text_field( $_POST['mappingname'] );
2394
+ $mappingOption = 'wf_cmapping_' . sanitize_title( $mappingOption );
2395
+ $mappingData = woo_feed_array_sanitize( $_POST );
2396
+ $oldMapping = maybe_unserialize( get_option( $mappingOption, array() ) );
2397
+
2398
+ # Delete product attribute drop-down cache
2399
+ delete_transient( '__woo_feed_cache_woo_feed_dropdown_product_attributes');
2400
+
2401
+ if ( $oldMapping === $mappingData ) {
2402
+ update_option( 'wpf_message', esc_html__( 'Mapping Not Changed', 'woo-feed' ), false );
2403
+ wp_safe_redirect( admin_url( 'admin.php?page=webappick-feed-category-mapping&wpf_message=warning' ) );
2404
+ die();
2405
+ }
2406
+
2407
+ if ( update_option( $mappingOption, serialize( $mappingData ), false ) ) { // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize
2408
+ update_option( 'wpf_message', esc_html__( 'Mapping Updated Successfully', 'woo-feed' ), false );
2409
+ wp_safe_redirect( admin_url( 'admin.php?page=webappick-feed-category-mapping&wpf_message=success' ) );
2410
+ die();
2411
+ } else {
2412
+ update_option( 'wpf_message', esc_html__( 'Failed To Updated Mapping', 'woo-feed' ), false );
2413
+ wp_safe_redirect( admin_url( 'admin.php?page=webappick-feed-category-mapping&wpf_message=error' ) );
2414
+ die();
2415
+ }
2416
+ }
2417
+ require WOO_FEED_FREE_ADMIN_PATH . 'partials/woo-feed-category-mapping.php';
2418
+ } elseif ( isset( $_GET['action'] ) && 'add-mapping' == $_GET['action'] ) {
2419
+ if ( count( $_POST ) && isset( $_POST['mappingname'] ) && isset( $_POST['add-mapping'] ) ) {
2420
+ check_admin_referer( 'category-mapping' );
2421
+
2422
+ $mappingOption = 'wf_cmapping_' . sanitize_text_field( $_POST['mappingname'] );
2423
+
2424
+ # Delete product attribute drop-down cache
2425
+ delete_transient( '__woo_feed_cache_woo_feed_dropdown_product_attributes');
2426
+
2427
+ if ( false !== get_option( $mappingOption, false ) ) {
2428
+ update_option( 'wpf_message', esc_html__( 'Another category mapping exists with the same name.', 'woo-feed' ), false );
2429
+ wp_safe_redirect( admin_url( 'admin.php?page=webappick-feed-category-mapping&wpf_message=warning' ) );
2430
+ die();
2431
+ }
2432
+ if ( update_option( $mappingOption, serialize( woo_feed_array_sanitize( $_POST ) ), false ) ) { // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize
2433
+ update_option( 'wpf_message', esc_html__( 'Mapping Added Successfully', 'woo-feed' ), false );
2434
+ wp_safe_redirect( admin_url( 'admin.php?page=webappick-feed-category-mapping&wpf_message=success' ) );
2435
+ die();
2436
+ } else {
2437
+ update_option( 'wpf_message', esc_html__( 'Failed To Add Mapping', 'woo-feed' ), false );
2438
+ wp_safe_redirect( admin_url( 'admin.php?page=webappick-feed-category-mapping&wpf_message=error' ) );
2439
+ die();
2440
+ }
2441
+ }
2442
+ require WOO_FEED_FREE_ADMIN_PATH . 'partials/woo-feed-category-mapping.php';
2443
+ } else {
2444
+ require WOO_FEED_FREE_ADMIN_PATH . 'partials/woo-feed-category-mapping-list.php';
2445
+ }
2446
+ }
2447
+ }
2448
+
2449
+ // Category mapping.
2450
+ if ( ! function_exists( 'woo_feed_render_categories' ) ) {
2451
+ /**
2452
+ * Get Product Categories
2453
+ *
2454
+ * @param int $parent Parent ID.
2455
+ * @param string $par separator.
2456
+ * @param string $value mapped values.
2457
+ */
2458
+ function woo_feed_render_categories( $parent = 0, $par = '', $value = '' ) {
2459
+ $categoryArgs = [
2460
+ 'taxonomy' => 'product_cat',
2461
+ 'parent' => $parent,
2462
+ 'orderby' => 'term_group',
2463
+ 'show_count' => 1,
2464
+ 'pad_counts' => 1,
2465
+ 'hierarchical' => 1,
2466
+ 'title_li' => '',
2467
+ 'hide_empty' => 0,
2468
+ ];
2469
+ $categories = get_categories( $categoryArgs );
2470
+ if ( ! empty( $categories ) ) {
2471
+ if ( ! empty( $par ) ) {
2472
+ $par = $par . ' > ';
2473
+ }
2474
+ foreach ( $categories as $cat ) {
2475
+ $class = $parent ? "treegrid-parent-{$parent} category-mapping" : 'treegrid-parent category-mapping';
2476
+ ?>
2477
+ <tr class="treegrid-1 ">
2478
+ <th>
2479
+ <label for="cat_mapping_<?php echo esc_attr( $cat->term_id ); ?>"><?php echo esc_html( $par . $cat->name ); ?></label>
2480
+ </th>
2481
+ <td><!--suppress HtmlUnknownAttribute -->
2482
+ <input id="cat_mapping_<?php echo esc_attr( $cat->term_id ); ?>"
2483
+ class="<?php echo esc_attr( $class ); ?> woo-feed-mapping-input"
2484
+ autocomplete="off"
2485
+ type="text"
2486
+ name="cmapping[<?php echo esc_attr( $cat->term_id ); ?>]"
2487
+ placeholder="<?php echo esc_attr( $par . $cat->name ); ?>"
2488
+ data-cat_id="<?php echo esc_attr( $cat->term_id ); ?>"
2489
+ value="<?php echo is_array( $value ) && isset( $value['cmapping'][ $cat->term_id ] ) ? esc_attr( $value['cmapping'][ $cat->term_id ] ) : ''; ?>"
2490
+ >
2491
+ </td>
2492
+ </tr>
2493
+ <?php
2494
+ // call and render the child category if any.
2495
+ woo_feed_render_categories( $cat->term_id, $par . $cat->name, $value );
2496
+ }
2497
+ }
2498
+ }
2499
+ }
2500
+
2501
+ if ( ! function_exists( 'woo_feed_get_category_mapping_value' ) ) {
2502
+ /**
2503
+ * Return Category Mapping Values by Parent Product Id
2504
+ *
2505
+ * @param string $cmappingName Category Mapping Name
2506
+ * @param int $parent Parent id of the product
2507
+ *
2508
+ * @return mixed
2509
+ */
2510
+ function woo_feed_get_category_mapping_value( $cmappingName, $parent ) {
2511
+ $getValue = maybe_unserialize( get_option( $cmappingName ) );
2512
+ if ( ! isset( $getValue['cmapping'] ) ) {
2513
+ return '';
2514
+ }
2515
+ $cmapping = is_array( $getValue['cmapping'] ) ? array_reverse( $getValue['cmapping'], true ) : $getValue['cmapping'];
2516
+ $categories = '';
2517
+ if ( get_the_terms( $parent, 'product_cat' ) ) {
2518
+ $categories = array_reverse( get_the_terms( $parent, 'product_cat' ) );
2519
+ }
2520
+ if ( ! empty( $categories ) && is_array( $categories ) && count( $categories ) ) {
2521
+ foreach ( $categories as $key => $category ) {
2522
+ if ( isset( $cmapping[ $category->term_id ] ) && ! empty( $cmapping[ $category->term_id ] ) ) {
2523
+ return $cmapping[ $category->term_id ];
2524
+ } else {
2525
+ return '';
2526
+ }
2527
+ }
2528
+ }
2529
+
2530
+ return '';
2531
+ }
2532
+ }
2533
+
2534
  // End of file helper.php.
woo-feed.php CHANGED
@@ -11,7 +11,7 @@
11
  * Plugin URI: https://webappick.com/
12
  * Description: Easily generate woocommerce product feed for any marketing channel like Google Shopping(Merchant), Facebook Remarketing, Bing, eBay & more. Support 100+ Merchants.
13
  *
14
- * Version: 3.7.2
15
  * Author: WebAppick
16
  * Author URI: https://webappick.com/
17
  * License: GPL v2
@@ -39,7 +39,7 @@ if ( ! defined( 'WOO_FEED_FREE_VERSION' ) ) {
39
  * @var string
40
  * @since 3.1.6
41
  */
42
- define( 'WOO_FEED_FREE_VERSION', '3.7.2' );
43
  }
44
 
45
  if ( ! defined( 'WOO_FEED_FREE_FILE' ) ) {
@@ -50,6 +50,7 @@ if ( ! defined( 'WOO_FEED_FREE_FILE' ) ) {
50
  */
51
  define( 'WOO_FEED_FREE_FILE', __FILE__ );
52
  }
 
53
  if ( ! defined( 'WOO_FEED_FREE_PATH' ) ) {
54
  /**
55
  * Plugin Path with trailing slash
11
  * Plugin URI: https://webappick.com/
12
  * Description: Easily generate woocommerce product feed for any marketing channel like Google Shopping(Merchant), Facebook Remarketing, Bing, eBay & more. Support 100+ Merchants.
13
  *
14
+ * Version: 3.7.3
15
  * Author: WebAppick
16
  * Author URI: https://webappick.com/
17
  * License: GPL v2
39
  * @var string
40
  * @since 3.1.6
41
  */
42
+ define( 'WOO_FEED_FREE_VERSION', '3.7.3' );
43
  }
44
 
45
  if ( ! defined( 'WOO_FEED_FREE_FILE' ) ) {
50
  */
51
  define( 'WOO_FEED_FREE_FILE', __FILE__ );
52
  }
53
+
54
  if ( ! defined( 'WOO_FEED_FREE_PATH' ) ) {
55
  /**
56
  * Plugin Path with trailing slash