CTX Feed – WooCommerce Product Feed Manager Plugin - Version 3.3.3

Version Description

(2020-03-04) = * Feature: Campaign URL Builder * Fix: Duplicate feed config on cron update.

Download this release

Release Info

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

Code changes from version 3.3.2 to 3.3.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.3.2
7
  Requires PHP: 5.6
8
- Stable tag: 3.3.2
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -305,6 +305,10 @@ Using pro version:
305
 
306
  == Changelog ==
307
 
 
 
 
 
308
  = 3.3.2 (2020-02-23) =
309
  * Fix: Duplicate content in CSV feeds.
310
 
5
  Requires at least: 3.6
6
  Tested Up To: 5.3.2
7
  Requires PHP: 5.6
8
+ Stable tag: 3.3.3
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
305
 
306
  == Changelog ==
307
 
308
+ = 3.3.3 (2020-03-04) =
309
+ * Feature: Campaign URL Builder
310
+ * Fix: Duplicate feed config on cron update.
311
+
312
  = 3.3.2 (2020-02-23) =
313
  * Fix: Duplicate content in CSV feeds.
314
 
admin/partials/woo-feed-admin-display.php CHANGED
@@ -37,26 +37,6 @@ if ( 'adroll' == $feedRules['provider'] ) {
37
  $feedRules['provider'] = 'google';
38
  }
39
  register_and_do_woo_feed_meta_boxes( $current_screen, $feedRules );
40
- $editorTabs = array(
41
- 'config' => array(
42
- 'label' => __( 'Feed Config', 'woo-feed' ),
43
- 'callback' => 'render_feed_config',
44
- ),
45
- 'filter' => array(
46
- 'label' => __( 'Filter', 'woo-feed' ),
47
- 'callback' => 'render_filter_config',
48
- ),
49
- 'advanced-filter' => array(
50
- 'label' => __( 'Advanced Filter', 'woo-feed' ),
51
- 'callback' => 'render_advanced_filter_config',
52
- ),
53
- 'ftp' => array(
54
- 'label' => __( 'FTP/SFTP', 'woo-feed' ),
55
- 'callback' => 'render_ftp_config',
56
- ),
57
- );
58
- $editorTabs = apply_filters( 'woo_feed_editor_tabs', $editorTabs );
59
- $isEdit = defined( 'WOO_FEED_EDIT_CONFIG' ) && WOO_FEED_EDIT_CONFIG;
60
  ?>
61
  <div class="wrap wapk-admin" id="Feed">
62
  <div class="wapk-section">
37
  $feedRules['provider'] = 'google';
38
  }
39
  register_and_do_woo_feed_meta_boxes( $current_screen, $feedRules );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  ?>
41
  <div class="wrap wapk-admin" id="Feed">
42
  <div class="wapk-section">
admin/partials/woo-feed-edit-filter.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ die(); // silence
4
+ }
5
+ ?>
6
+ <table class="table tree widefat fixed woo-feed-filters">
7
+ <tbody>
8
+ <tr>
9
+ <td colspan="2"><?php _e( 'Campaign URL Builder', 'woo-feed' ); ?></td>
10
+ </tr>
11
+ <tr>
12
+ <td colspan="2">
13
+ <table class="table widefat fixed" id="wf_campaign_url_builder">
14
+ <tbody>
15
+ <tr>
16
+ <td>
17
+ <label class="screen-reader-text" for="utm_source"><?php esc_html_e( 'Campaign Source', 'woo-feed' ); ?> <span class="required" aria-label="<?php esc_attr_e( 'Required', 'woo-feed' ); ?>">*</span></label>
18
+ <input type="text" name="campaign_parameters[utm_source]" id="utm_source" class="regular-text" placeholder="*<?php esc_attr_e( 'Campaign Source', 'woo-feed' ); ?>" value="<?php echo esc_attr( $feedRules['campaign_parameters']['utm_source'] ); ?>">
19
+ <label for="utm_source">
20
+ <span class="description" style="color:#8a8a8a;"><?php esc_html_e( 'The referrer: (e.g. google, newsletter)', 'woo-feed' ); ?></span>
21
+ </label>
22
+ </td>
23
+ <td>
24
+ <label class="screen-reader-text" for="utm_medium"><?php esc_html_e( 'Campaign Medium', 'woo-feed' ); ?> <span class="required" aria-label="<?php esc_attr_e( 'Required', 'woo-feed' ); ?>">*</span></label>
25
+ <input type="text" name="campaign_parameters[utm_medium]" id="utm_medium" class="regular-text" placeholder="*<?php esc_attr_e( 'Campaign Medium', 'woo-feed' ); ?>" value="<?php echo esc_attr( $feedRules['campaign_parameters']['utm_medium'] ); ?>">
26
+ <label for="utm_medium">
27
+ <span class="description" style="color:#8a8a8a;"><?php esc_html_e( 'Marketing medium: (e.g. cpc, banner, email)', 'woo-feed' ); ?></span>
28
+ </label>
29
+ </td>
30
+ <td>
31
+ <label class="screen-reader-text" for="utm_campaign"><?php esc_html_e( 'Campaign Name', 'woo-feed' ); ?> <span class="required" aria-label="<?php esc_attr_e( 'Required', 'woo-feed' ); ?>">*</span></label>
32
+ <input type="text" name="campaign_parameters[utm_campaign]" id="utm_campaign" class="regular-text" placeholder="*<?php esc_attr_e( 'Campaign Name', 'woo-feed' ); ?>" value="<?php echo esc_attr( $feedRules['campaign_parameters']['utm_campaign'] ); ?>">
33
+ <label for="utm_campaign">
34
+ <span class="description" style="color:#8a8a8a;"><?php esc_html_e( 'Product, promo code, or slogan (e.g. spring_sale)', 'woo-feed' ); ?></span>
35
+ </label>
36
+ </td>
37
+ <td>
38
+ <label class="screen-reader-text" for="utm_term"><?php esc_html_e( 'Campaign Term', 'woo-feed' ); ?></label>
39
+ <input type="text" name="campaign_parameters[utm_term]" id="utm_term" class="regular-text" placeholder="<?php esc_attr_e( 'Campaign Term', 'woo-feed' ); ?>" value="<?php echo esc_attr( $feedRules['campaign_parameters']['utm_term'] ); ?>">
40
+ <label for="utm_term">
41
+ <span class="description" style="color:#8a8a8a;"><?php esc_html_e( 'Identify the keywords', 'woo-feed' ); ?></span>
42
+ </label>
43
+ </td>
44
+ <td>
45
+ <label class="screen-reader-text" for="utm_content"><?php esc_html_e( 'Campaign Content', 'woo-feed' ); ?></label>
46
+ <input type="text" name="campaign_parameters[utm_content]" id="utm_content" class="regular-text" placeholder="<?php esc_attr_e( 'Campaign Content', 'woo-feed' ); ?>" value="<?php echo esc_attr( $feedRules['campaign_parameters']['utm_content'] ); ?>">
47
+ <label for="utm_content">
48
+ <span class="description" style="color:#8a8a8a;"><?php esc_html_e( 'Use to differentiate ads', 'woo-feed' ); ?></span>
49
+ </label>
50
+ </td>
51
+ </tr>
52
+ <tr>
53
+ <td colspan="4">
54
+ <p>
55
+ <span class="description"><?php esc_html_e( 'Fill out the required fields (marked with *) in the form above, if any required field is empty, then the parameters will not be applied.', 'woo-feed' ); ?></span>
56
+ <a href="https://support.google.com/analytics/answer/1033863#parameters" target="_blank"><?php esc_html_e( 'Learn more about Campaign URL', 'woo-feed' ); ?></a>
57
+ </p>
58
+ </td>
59
+ </tr>
60
+ </tbody>
61
+ </table>
62
+ </td>
63
+ </tr>
64
+ </tbody>
65
+ </table>
admin/partials/woo-feed-edit-tabs.php CHANGED
@@ -16,6 +16,10 @@ $editorTabs = array(
16
  'label' => __( 'Feed Config', 'woo-feed' ),
17
  'callback' => 'render_feed_config',
18
  ),
 
 
 
 
19
  'ftp' => array(
20
  'label' => __( 'FTP/SFTP', 'woo-feed' ),
21
  'callback' => 'render_ftp_config',
16
  'label' => __( 'Feed Config', 'woo-feed' ),
17
  'callback' => 'render_feed_config',
18
  ),
19
+ 'filter' => array(
20
+ 'label' => __( 'Filter', 'woo-feed' ),
21
+ 'callback' => 'render_filter_config',
22
+ ),
23
  'ftp' => array(
24
  'label' => __( 'FTP/SFTP', 'woo-feed' ),
25
  'callback' => 'render_ftp_config',
includes/classes/class-woo-feed-engine.php CHANGED
@@ -75,22 +75,7 @@ class WF_Engine
75
  }
76
 
77
  public function stripInvalidXml($value) {
78
- $ret = '';
79
- $current='';
80
- if (empty($value)) {
81
- return $ret;
82
- }
83
- $length = strlen($value);
84
- for ($i=0; $i < $length; $i++) {
85
- $current = ord($value{$i});
86
- if (($current == 0x9) || ($current == 0xA) || ($current == 0xD) || (($current >= 0x20) && ($current <= 0xD7FF)) || (($current >= 0xE000) && ($current <= 0xFFFD)) || (($current >= 0x10000) && ($current <= 0x10FFFF))) {
87
- $ret .= chr($current);
88
- }
89
- else {
90
- $ret .= '';
91
- }
92
- }
93
- return $ret;
94
  }
95
 
96
  /**
75
  }
76
 
77
  public function stripInvalidXml($value) {
78
+ return woo_feed_stripInvalidXml( $value );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  }
80
 
81
  /**
includes/classes/class-woo-feed-products-v3.php CHANGED
@@ -1118,6 +1118,17 @@ class Woo_Feed_Products_v3 {
1118
  * @return mixed
1119
  */
1120
  private function link( $product ) {
 
 
 
 
 
 
 
 
 
 
 
1121
  return $product->get_permalink();
1122
  }
1123
 
@@ -1544,7 +1555,7 @@ class Woo_Feed_Products_v3 {
1544
  return $this->getGroupProductPrice( $product, 'sale' );
1545
  }
1546
 
1547
- return $price;
1548
  }
1549
 
1550
  /**
@@ -1623,7 +1634,7 @@ class Woo_Feed_Products_v3 {
1623
  $price = $this->get_price_with_tax( $product, $price );
1624
  }
1625
 
1626
- return $price;
1627
  }
1628
 
1629
  /**
@@ -1991,47 +2002,48 @@ class Woo_Feed_Products_v3 {
1991
  * @return float|int|string
1992
  */
1993
  public function format_output( $output, $outputTypes ) {
1994
- if ( ! empty($outputTypes) && is_array($outputTypes) ) {
1995
-
1996
  # Format Output According to output type
1997
  if ( in_array( 2, $outputTypes ) ) { // Strip Tags
1998
  $output = wp_strip_all_tags( html_entity_decode( $output ) );
1999
  }
2000
-
2001
- if ( in_array(3, $outputTypes) ) { # UTF-8 Encode
2002
- $output = utf8_encode($output);
2003
  }
2004
-
2005
- if ( in_array(4, $outputTypes) ) { # htmlentities
2006
- $output = htmlentities($output, ENT_QUOTES, 'UTF-8');
2007
  }
2008
-
2009
- if ( in_array(5, $outputTypes) ) { # Integer
2010
- $output = absint($output);
2011
  }
2012
-
2013
- if ( in_array(6, $outputTypes) ) { # Format Price
2014
- $output = (float)$output;
2015
- $output = number_format($output, 2, '.', '');
2016
  }
2017
-
2018
- if ( in_array(7, $outputTypes) ) { # Delete Space
2019
- $output = trim($output);
2020
- $output = preg_replace('!\s+!', ' ', $output);
2021
  }
2022
-
2023
- if ( in_array(9, $outputTypes) ) { # Remove Invalid Character
2024
- $output = woo_feed_stripInvalidXml($output);
2025
  }
2026
-
2027
- if ( in_array(10, $outputTypes) ) { # Remove ShortCodes
2028
- $output = $this->remove_short_codes($output);
2029
  }
2030
-
2031
- if ( in_array(8, $outputTypes) ) { # Add CDATA
2032
  $output = '<![CDATA[' . $output . ']]>';
2033
  }
2034
  }
 
2035
  return $output;
2036
  }
2037
 
1118
  * @return mixed
1119
  */
1120
  private function link( $product ) {
1121
+ $utm = $this->config['campaign_parameters'];
1122
+ if ( ! empty( $utm['utm_source'] ) && ! empty( $utm['utm_medium'] ) && ! empty( $utm['utm_campaign'] ) ) {
1123
+ $utm = [
1124
+ 'utm_source' => $utm['utm_source'],
1125
+ 'utm_medium' => $utm['utm_medium'],
1126
+ 'utm_campaign' => $utm['utm_campaign'],
1127
+ 'utm_term' => $utm['utm_term'],
1128
+ 'utm_content' => $utm['utm_content'],
1129
+ ];
1130
+ return add_query_arg( array_filter( $utm ), $product->get_permalink() );
1131
+ }
1132
  return $product->get_permalink();
1133
  }
1134
 
1555
  return $this->getGroupProductPrice( $product, 'sale' );
1556
  }
1557
 
1558
+ return $price > 0 ? $price : '';
1559
  }
1560
 
1561
  /**
1634
  $price = $this->get_price_with_tax( $product, $price );
1635
  }
1636
 
1637
+ return $price > 0 ? $price : '';
1638
  }
1639
 
1640
  /**
2002
  * @return float|int|string
2003
  */
2004
  public function format_output( $output, $outputTypes ) {
2005
+ if ( ! empty( $outputTypes ) && is_array( $outputTypes ) ) {
2006
+
2007
  # Format Output According to output type
2008
  if ( in_array( 2, $outputTypes ) ) { // Strip Tags
2009
  $output = wp_strip_all_tags( html_entity_decode( $output ) );
2010
  }
2011
+
2012
+ if ( in_array( 3, $outputTypes ) ) { # UTF-8 Encode
2013
+ $output = utf8_encode( $output );
2014
  }
2015
+
2016
+ if ( in_array( 4, $outputTypes ) ) { # htmlentities
2017
+ $output = htmlentities( $output, ENT_QUOTES, 'UTF-8' );
2018
  }
2019
+
2020
+ if ( in_array( 5, $outputTypes ) ) { # Integer
2021
+ $output = absint( $output );
2022
  }
2023
+
2024
+ if ( in_array( 6, $outputTypes ) ) { # Format Price
2025
+ $output = (float) $output;
2026
+ $output = number_format( $output, 2, '.', '' );
2027
  }
2028
+
2029
+ if ( in_array( 7, $outputTypes ) ) { # Delete Space
2030
+ $output = trim( $output );
2031
+ $output = preg_replace( '!\s+!', ' ', $output );
2032
  }
2033
+
2034
+ if ( in_array( 9, $outputTypes ) ) { # Remove Invalid Character
2035
+ $output = woo_feed_stripInvalidXml( $output );
2036
  }
2037
+
2038
+ if ( in_array( 10, $outputTypes ) ) { # Remove ShortCodes
2039
+ $output = $this->remove_short_codes( $output );
2040
  }
2041
+
2042
+ if ( in_array( 8, $outputTypes ) ) { # Add CDATA
2043
  $output = '<![CDATA[' . $output . ']]>';
2044
  }
2045
  }
2046
+
2047
  return $output;
2048
  }
2049
 
includes/classes/class-woo-feed-products.php CHANGED
@@ -1445,22 +1445,7 @@ class Woo_Feed_Products {
1445
  * @return string
1446
  */
1447
  public function stripInvalidXml( $value ) {
1448
- $ret = '';
1449
- if ( empty( $value ) ) {
1450
- return $ret;
1451
- }
1452
- $length = strlen( $value );
1453
- for ( $i = 0; $i < $length; $i++ ) {
1454
- $current = ord($value[ $i ]);
1455
- if ( ( 0x9 == $current ) || ( 0xA == $current ) || ( 0xD == $current ) || ( ( $current >= 0x20 ) && ( $current <= 0xD7FF ) ) || ( ( $current >= 0xE000 ) && ( $current <= 0xFFFD ) ) || ( ( $current >= 0x10000 ) && ( $current <= 0x10FFFF ) ) ) {
1456
- $ret .= chr($current);
1457
- }
1458
- else {
1459
- $ret .= "";
1460
- }
1461
- }
1462
-
1463
- return $ret;
1464
  }
1465
 
1466
  /**
1445
  * @return string
1446
  */
1447
  public function stripInvalidXml( $value ) {
1448
+ return woo_feed_stripInvalidXml( $value );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1449
  }
1450
 
1451
  /**
includes/cron-helper.php CHANGED
@@ -43,7 +43,7 @@ if ( ! function_exists( 'woo_feed_cron_update_feed' ) ) {
43
  // woo_feed_log_feed_process( $feedInfo['feedrules']['filename'], 'Current Limit is ---.' );
44
  // woo_feed_log( $feedInfo['feedrules']['filename'], 'Feed Config::' . PHP_EOL . print_r( $feedInfo['feedrules'], true ), 'info' );
45
  // }
46
- woo_feed_generate_feed( $feedInfo['feedrules'] );
47
  // } catch ( Exception $e ) {
48
  // $message = 'Error Updating Feed Via CRON Job' . PHP_EOL . 'Caught Exception :: ' . $e->getMessage();
49
  // woo_feed_log( $feedInfo['feedrules']['filename'], $message, 'critical', $e, true );
@@ -78,7 +78,7 @@ if ( ! function_exists( 'woo_feed_cron_update_single_feed' ) ) {
78
  if ( ! isset( $feedInfo['feedrules'] ) || isset( $feedInfo['status'] ) && "0" == $feedInfo['status'] ) {
79
  continue;
80
  }
81
- woo_feed_generate_feed( $feedInfo['feedrules'] );
82
  }
83
  }
84
  }
43
  // woo_feed_log_feed_process( $feedInfo['feedrules']['filename'], 'Current Limit is ---.' );
44
  // woo_feed_log( $feedInfo['feedrules']['filename'], 'Feed Config::' . PHP_EOL . print_r( $feedInfo['feedrules'], true ), 'info' );
45
  // }
46
+ woo_feed_generate_feed( $feedInfo['feedrules'], $option['option_name'] );
47
  // } catch ( Exception $e ) {
48
  // $message = 'Error Updating Feed Via CRON Job' . PHP_EOL . 'Caught Exception :: ' . $e->getMessage();
49
  // woo_feed_log( $feedInfo['feedrules']['filename'], $message, 'critical', $e, true );
78
  if ( ! isset( $feedInfo['feedrules'] ) || isset( $feedInfo['status'] ) && "0" == $feedInfo['status'] ) {
79
  continue;
80
  }
81
+ woo_feed_generate_feed( $feedInfo['feedrules'], $value['option_name'] );
82
  }
83
  }
84
  }
includes/helper.php CHANGED
@@ -409,23 +409,35 @@ if ( ! function_exists( 'woo_feed_parse_feed_rules' ) ) {
409
  'categories' => [],
410
  'post_status' => [ 'publish' ],
411
  'filter_mode' => [],
 
412
  'is_outOfStock' => 'n',
413
- 'product_visibility' => 0,
414
- // include hidden ? 1 yes 0 no
415
- 'outofstock_visibility' => 0,
416
- // override wc global option for out-of-stock product hidden from catalog? 1 yes 0 no
417
  'ptitle_show' => '',
418
  'decimal_separator' => wc_get_price_decimal_separator(),
419
  'thousand_separator' => wc_get_price_thousand_separator(),
420
  'decimals' => wc_get_price_decimals(),
421
  ];
422
  $rules = wp_parse_args( $rules, $defaults );
423
- $rules['filter_mode'] = wp_parse_args( $rules['filter_mode'],
 
424
  [
425
  'product_ids' => 'include',
426
  'categories' => 'include',
427
  'post_status' => 'include',
428
- ] );
 
 
 
 
 
 
 
 
 
 
 
 
429
 
430
  return apply_filters( 'woo_feed_parsed_rules', $rules );
431
  }
@@ -649,6 +661,17 @@ if ( ! function_exists( 'render_feed_config' ) ) {
649
  }
650
  }
651
  }
 
 
 
 
 
 
 
 
 
 
 
652
  if ( ! function_exists( 'render_ftp_config' ) ) {
653
  /**
654
  * @param string $tabId
@@ -747,7 +770,8 @@ if ( ! function_exists( 'woo_feed_sanitize_form_fields' ) ) {
747
  if ( ! function_exists( 'woo_feed_unique_feed_slug' ) ) {
748
  /**
749
  * Generate Unique slug for feed.
750
- *
 
751
  * @param string $slug
752
  * @param string $prefix
753
  * @param int $feedId
@@ -786,6 +810,15 @@ if ( ! function_exists( 'woo_feed_unique_feed_slug' ) ) {
786
  }
787
  }
788
  if ( ! function_exists( 'generate_unique_feed_file_name' ) ) {
 
 
 
 
 
 
 
 
 
789
  function generate_unique_feed_file_name( $filename, $type, $provider ) {
790
 
791
  $feedDir = woo_feed_get_file_dir( $provider, $type );
@@ -796,7 +829,7 @@ if ( ! function_exists( 'generate_unique_feed_file_name' ) ) {
796
  $raw_filename = wp_unique_filename( $feedDir, $raw_filename );
797
  $raw_filename = str_replace( '.' . $type, '', $raw_filename );
798
 
799
- return $raw_filename;
800
  }
801
  }
802
 
@@ -842,36 +875,84 @@ if ( ! function_exists( 'woo_feed_save_feed_config_data' ) ) {
842
  // Sanitize Fields
843
  $data = woo_feed_sanitize_form_fields( $data );
844
  if ( empty( $feed_option_name ) ) {
845
- $feed_option_name = generate_unique_feed_file_name( $data['filename'],
846
- $data['feedType'],
847
- $data['provider'] );
848
  } else {
849
  $feed_option_name = woo_feed_extract_feed_option_name( $feed_option_name );
850
  }
 
 
 
 
 
 
 
 
 
851
  /**
852
- * Before Updating Config to db
 
 
853
  *
854
- * @param array $config sanitized config
855
- * @param string $feed_option_name option name
 
856
  */
857
- do_action( 'woo_feed_before_update_config', $data, "wf_config" . $feed_option_name );
858
- # Store Config
859
- $update = update_option( "wf_config" . $feed_option_name, $data, false );
860
- // save if config update ok...
861
- if ( $update && false === $configOnly ) {
862
- $oldFeed = maybe_unserialize( get_option( "wf_feed_" . $feed_option_name ) );
863
- $feedData = array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
864
  'feedrules' => $data,
865
  'url' => woo_feed_get_file_url( $feed_option_name, $data['provider'], $data['feedType'] ),
866
- 'last_updated' => gmdate( "Y-m-d H:i:s" ),
867
- 'status' => isset( $oldFeed['status'] ) && 1 == $oldFeed['status'] ? 1 : 0,
868
- // set old status or disable auto update.
869
  );
870
- $update = update_option( 'wf_feed_' . $feed_option_name, maybe_serialize( $feedData ), false );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
871
  }
872
 
873
  // return filename on success or update status
874
- return $feed_option_name;
875
  }
876
  }
877
  if ( ! function_exists( 'woo_feed_extract_feed_option_name' ) ) {
@@ -1209,29 +1290,25 @@ if ( ! function_exists( 'woo_feed_generate_feed' ) ) {
1209
  /**
1210
  * Update Feed Information
1211
  *
1212
- * @param array $info
 
1213
  *
1214
  * @return string|bool
1215
  */
1216
- function woo_feed_generate_feed( $info ) {
1217
- if ( false === $info ) {
1218
  return false;
1219
  }
1220
  // parse rules.
1221
  $info = woo_feed_parse_feed_rules( isset( $info['feedrules'] ) ? $info['feedrules'] : $info );
 
1222
  if ( ! empty( $info['provider'] ) ) {
1223
  do_action( 'before_woo_feed_generate_feed', $info );
1224
- // Get Post data
1225
- $feedService = sanitize_text_field( $info['provider'] );
1226
- $fileName = woo_feed_extract_feed_option_name( sanitize_text_field( $info['filename'] ) );
1227
- $type = sanitize_text_field( $info['feedType'] );
1228
- $feedRules = $info;
1229
- //$feedRules['Limit']='-1';
1230
- //$feedRules['Offset']='0';
1231
- // Get Feed info
1232
- $products = new Woo_Generate_Feed( $feedService, $feedRules );
1233
  $getString = $products->getProducts();
1234
- if ( 'csv' == $type ) {
1235
  $csvHead[0] = $getString['header'];
1236
  if ( ! empty( $csvHead ) && ! empty( $getString['body'] ) ) {
1237
  $string = array_merge( $csvHead, $getString['body'] );
@@ -1246,37 +1323,32 @@ if ( ! function_exists( 'woo_feed_generate_feed' ) ) {
1246
  // Check If any products founds
1247
  if ( $string && ! empty( $string ) ) {
1248
  // Save File
1249
- $path = woo_feed_get_file_path( $feedService, $type );
1250
- $file = woo_feed_get_file( $fileName, $feedService, $type );
1251
  $save = new Woo_Feed_Savefile();
1252
- if ( 'csv' == $type ) {
1253
  $saveFile = $save->saveCSVFile( $path, $file, $string, $info );
1254
  } else {
1255
  $saveFile = $save->saveFile( $path, $file, $string );
1256
  }
1257
 
1258
- if ( 'json' == $type ) {
1259
- $type = 'csv';
1260
- }
1261
  // Upload file to ftp server
1262
  if ( 1 == (int) $info['ftpenabled'] ) {
1263
- woo_feed_handle_file_transfer( $file, $fileName . '.' . $type, $info );
1264
  }
1265
  }
 
1266
  // Save Info into database
1267
  $feedInfo = array(
1268
- 'feedrules' => $feedRules,
1269
- 'url' => woo_feed_get_file_url( $fileName, $feedService, $type ),
1270
  'last_updated' => gmdate( 'Y-m-d H:i:s' ),
1271
  'status' => 1,
1272
  );
1273
- update_option( 'wf_feed_' . $fileName, serialize( $feedInfo ), false );
1274
  do_action( 'after_woo_feed_generate_feed', $info );
1275
  if ( $saveFile ) {
1276
- $getInfo = maybe_unserialize( get_option( 'wf_feed_' . $fileName ) );
1277
- $url = $getInfo['url'];
1278
-
1279
- return $url;
1280
  } else {
1281
  return false;
1282
  }
409
  'categories' => [],
410
  'post_status' => [ 'publish' ],
411
  'filter_mode' => [],
412
+ 'campaign_parameters' => [],
413
  'is_outOfStock' => 'n',
414
+ 'product_visibility' => 0, // include hidden ? 1 yes 0 no
415
+ 'outofstock_visibility' => 0, // override wc global option for out-of-stock product hidden from catalog? 1 yes 0 no
 
 
416
  'ptitle_show' => '',
417
  'decimal_separator' => wc_get_price_decimal_separator(),
418
  'thousand_separator' => wc_get_price_thousand_separator(),
419
  'decimals' => wc_get_price_decimals(),
420
  ];
421
  $rules = wp_parse_args( $rules, $defaults );
422
+ $rules['filter_mode'] = wp_parse_args(
423
+ $rules['filter_mode'],
424
  [
425
  'product_ids' => 'include',
426
  'categories' => 'include',
427
  'post_status' => 'include',
428
+ ]
429
+ );
430
+
431
+ $rules['campaign_parameters'] = wp_parse_args(
432
+ $rules['campaign_parameters'],
433
+ [
434
+ 'utm_source' => '',
435
+ 'utm_medium' => '',
436
+ 'utm_campaign' => '',
437
+ 'utm_term' => '',
438
+ 'utm_content' => '',
439
+ ]
440
+ );
441
 
442
  return apply_filters( 'woo_feed_parsed_rules', $rules );
443
  }
661
  }
662
  }
663
  }
664
+ if ( ! function_exists( 'render_filter_config' ) ) {
665
+ /**
666
+ * @param string $tabId
667
+ * @param array $feedRules
668
+ * @param bool $idEdit
669
+ */
670
+ function render_filter_config( $tabId, $feedRules, $idEdit ) {
671
+ global $provider, $wooFeedDropDown, $wooFeedProduct;
672
+ include WOO_FEED_FREE_ADMIN_PATH . 'partials/woo-feed-edit-filter.php';
673
+ }
674
+ }
675
  if ( ! function_exists( 'render_ftp_config' ) ) {
676
  /**
677
  * @param string $tabId
770
  if ( ! function_exists( 'woo_feed_unique_feed_slug' ) ) {
771
  /**
772
  * Generate Unique slug for feed.
773
+ * This function only check database for existing feed for generating unique slug.
774
+ * Use generate_unique_feed_file_name() for complete unique slug name.
775
  * @param string $slug
776
  * @param string $prefix
777
  * @param int $feedId
810
  }
811
  }
812
  if ( ! function_exists( 'generate_unique_feed_file_name' ) ) {
813
+ /**
814
+ * Generate Unique file Name.
815
+ * This will insure unique slug and file name for a single feed.
816
+ * @param string $filename
817
+ * @param string $type
818
+ * @param string $provider
819
+ *
820
+ * @return string|string[]
821
+ */
822
  function generate_unique_feed_file_name( $filename, $type, $provider ) {
823
 
824
  $feedDir = woo_feed_get_file_dir( $provider, $type );
829
  $raw_filename = wp_unique_filename( $feedDir, $raw_filename );
830
  $raw_filename = str_replace( '.' . $type, '', $raw_filename );
831
 
832
+ return -1 != $raw_filename ? $raw_filename : false;
833
  }
834
  }
835
 
875
  // Sanitize Fields
876
  $data = woo_feed_sanitize_form_fields( $data );
877
  if ( empty( $feed_option_name ) ) {
878
+ $feed_option_name = generate_unique_feed_file_name( $data['filename'], $data['feedType'], $data['provider'] );
 
 
879
  } else {
880
  $feed_option_name = woo_feed_extract_feed_option_name( $feed_option_name );
881
  }
882
+
883
+ // get old config
884
+ $old_data = get_option( 'wf_config' . $feed_option_name, array() );
885
+ $update = false;
886
+ $updated = false;
887
+ if ( is_array( $old_data ) && ! empty( $old_data ) ) {
888
+ $update = true;
889
+ }
890
+
891
  /**
892
+ * Filters feed data just before it is inserted into the database.
893
+ *
894
+ * @since 3.3.3
895
  *
896
+ * @param array $data An array of sanitized config
897
+ * @param array $old_data An array of old feed data
898
+ * @param string $feed_option_name Option name
899
  */
900
+ $data = apply_filters( 'woo_feed_insert_feed_data', $data, $old_data, 'wf_config' . $feed_option_name );
901
+
902
+ if ( $update ) {
903
+ /**
904
+ * Before Updating Config to db
905
+ *
906
+ * @param array $data An array of sanitized config
907
+ * @param string $feed_option_name Option name
908
+ */
909
+ do_action( 'woo_feed_before_update_config', $data, 'wf_config' . $feed_option_name );
910
+ } else {
911
+ /**
912
+ * Before inserting Config to db
913
+ *
914
+ * @param array $data An array of sanitized config
915
+ * @param string $feed_option_name Option name
916
+ */
917
+ do_action( 'woo_feed_before_insert_config', $data, 'wf_config' . $feed_option_name );
918
+ }
919
+ $updated = ( $data === $old_data );
920
+ if ( false === $updated ) {
921
+ // Store Config.
922
+ $updated = update_option( 'wf_config' . $feed_option_name, $data, false );
923
+ }
924
+ // update wf_feed if wp_config update ok...
925
+ if ( $updated && false === $configOnly ) {
926
+ $old_feed = maybe_unserialize( get_option( 'wf_feed_' . $feed_option_name ) );
927
+ $feed_data = array(
928
  'feedrules' => $data,
929
  'url' => woo_feed_get_file_url( $feed_option_name, $data['provider'], $data['feedType'] ),
930
+ 'last_updated' => gmdate( 'Y-m-d H:i:s' ),
931
+ 'status' => isset( $oldFeed['status'] ) && 1 == $old_feed['status'] ? 1 : 0, // set old status or disable auto update.
 
932
  );
933
+ $saved2 = update_option( 'wf_feed_' . $feed_option_name, maybe_serialize( $feed_data ), false );
934
+ }
935
+
936
+ if ( $update ) {
937
+ /**
938
+ * After Updating Config to db
939
+ *
940
+ * @param array $data An array of sanitized config
941
+ * @param string $feed_option_name Option name
942
+ */
943
+ do_action( 'woo_feed_after_update_config', $data, 'wf_config' . $feed_option_name );
944
+ } else {
945
+ /**
946
+ * After inserting Config to db
947
+ *
948
+ * @param array $data An array of sanitized config
949
+ * @param string $feed_option_name Option name
950
+ */
951
+ do_action( 'woo_feed_after_insert_config', $data, 'wf_config' . $feed_option_name );
952
  }
953
 
954
  // return filename on success or update status
955
+ return $updated ? $feed_option_name : $updated;
956
  }
957
  }
958
  if ( ! function_exists( 'woo_feed_extract_feed_option_name' ) ) {
1290
  /**
1291
  * Update Feed Information
1292
  *
1293
+ * @param array $info feed config array
1294
+ * @param string $feed_option_name feed option/file name
1295
  *
1296
  * @return string|bool
1297
  */
1298
+ function woo_feed_generate_feed( $info, $feed_option_name ) {
1299
+ if ( false === $info || empty( $info ) ) {
1300
  return false;
1301
  }
1302
  // parse rules.
1303
  $info = woo_feed_parse_feed_rules( isset( $info['feedrules'] ) ? $info['feedrules'] : $info );
1304
+ $feed_option_name = woo_feed_extract_feed_option_name( $feed_option_name );
1305
  if ( ! empty( $info['provider'] ) ) {
1306
  do_action( 'before_woo_feed_generate_feed', $info );
1307
+
1308
+ // Generate Feed Data
1309
+ $products = new Woo_Generate_Feed( $info['provider'], $info );
 
 
 
 
 
 
1310
  $getString = $products->getProducts();
1311
+ if ( 'csv' == $info['feedType'] ) {
1312
  $csvHead[0] = $getString['header'];
1313
  if ( ! empty( $csvHead ) && ! empty( $getString['body'] ) ) {
1314
  $string = array_merge( $csvHead, $getString['body'] );
1323
  // Check If any products founds
1324
  if ( $string && ! empty( $string ) ) {
1325
  // Save File
1326
+ $path = woo_feed_get_file_path( $info['provider'], $info['feedType'] );
1327
+ $file = woo_feed_get_file( $feed_option_name, $info['provider'], $info['feedType'] );
1328
  $save = new Woo_Feed_Savefile();
1329
+ if ( 'csv' == $info['feedType'] ) {
1330
  $saveFile = $save->saveCSVFile( $path, $file, $string, $info );
1331
  } else {
1332
  $saveFile = $save->saveFile( $path, $file, $string );
1333
  }
1334
 
 
 
 
1335
  // Upload file to ftp server
1336
  if ( 1 == (int) $info['ftpenabled'] ) {
1337
+ woo_feed_handle_file_transfer( $file, $feed_option_name . '.' . $info['feedType'], $info );
1338
  }
1339
  }
1340
+ $feed_URL = woo_feed_get_file_url( $feed_option_name, $info['provider'], $info['feedType'] );
1341
  // Save Info into database
1342
  $feedInfo = array(
1343
+ 'feedrules' => $info,
1344
+ 'url' => $feed_URL,
1345
  'last_updated' => gmdate( 'Y-m-d H:i:s' ),
1346
  'status' => 1,
1347
  );
1348
+ update_option( 'wf_feed_' . $feed_option_name, serialize( $feedInfo ), false );
1349
  do_action( 'after_woo_feed_generate_feed', $info );
1350
  if ( $saveFile ) {
1351
+ return $feed_URL;
 
 
 
1352
  } else {
1353
  return false;
1354
  }
woo-feed.php CHANGED
@@ -12,7 +12,7 @@
12
  * Description: This plugin generate WooCommerce product feed for Shopping Engines
13
  * like Google Shopping, Facebook Product Feed, eBay, Amazon, Idealo and many more.
14
  *
15
- * Version: 3.3.2
16
  * Author: WebAppick
17
  * Author URI: https://webappick.com/
18
  * License: GPL v2
@@ -40,7 +40,7 @@ if ( ! defined( 'WOO_FEED_FREE_VERSION' ) ) {
40
  * @var string
41
  * @since 3.1.6
42
  */
43
- define( 'WOO_FEED_FREE_VERSION', '3.3.2' );
44
  }
45
 
46
  if ( ! defined( 'WOO_FEED_FREE_FILE' ) ) {
12
  * Description: This plugin generate WooCommerce product feed for Shopping Engines
13
  * like Google Shopping, Facebook Product Feed, eBay, Amazon, Idealo and many more.
14
  *
15
+ * Version: 3.3.3
16
  * Author: WebAppick
17
  * Author URI: https://webappick.com/
18
  * License: GPL v2
40
  * @var string
41
  * @since 3.1.6
42
  */
43
+ define( 'WOO_FEED_FREE_VERSION', '3.3.3' );
44
  }
45
 
46
  if ( ! defined( 'WOO_FEED_FREE_FILE' ) ) {