CTX Feed – WooCommerce Product Feed Manager Plugin - Version 3.2.18

Version Description

(2020-02-12) = * Fix User can't hide review and related notice. * Fix Some WPCS Related Warnings * Add ability to hide Product-Limit warning notice * String translation update.

Download this release

Release Info

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

Code changes from version 3.2.17 to 3.2.18

Files changed (48) hide show
  1. README.txt +9 -3
  2. admin/class-woo-feed-admin.php +20 -18
  3. admin/class-woo-feed-manage-list.php +60 -76
  4. admin/css/woo-feed-admin.css +18 -1
  5. admin/js/pro.js +21 -2
  6. admin/js/woo-feed-admin.js +0 -18
  7. admin/partials/templates/facebook_add-feed.php +5 -5
  8. admin/partials/templates/google_add-feed.php +5 -5
  9. admin/partials/templates/pinterest_add-feed.php +5 -5
  10. admin/partials/woo-feed-admin-display.php +15 -15
  11. admin/partials/woo-feed-config.php +98 -93
  12. admin/partials/woo-feed-content-settings.php +24 -13
  13. admin/partials/woo-feed-edit-template.php +26 -26
  14. admin/partials/woo-feed-ftp-sftp-template.php +1 -1
  15. admin/partials/woo-feed-manage-list.php +16 -115
  16. admin/partials/woo-feed-pro-vs-free.php +145 -135
  17. admin/partials/woo-feed-search-category.php +4 -4
  18. includes/class-woo-feed-activator.php +1 -2
  19. includes/class-woo-feed-docs.php +10 -10
  20. includes/class-woo-feed-installer.php +10 -10
  21. includes/class-woo-feed-loader.php +1 -1
  22. includes/class-woo-feed.php +6 -11
  23. includes/classes/class-woo-feed-admin-message.php +304 -18
  24. includes/classes/class-woo-feed-auto-update.php +142 -144
  25. includes/classes/class-woo-feed-default-attributes.php +1031 -1049
  26. includes/classes/class-woo-feed-dropdown.php +260 -341
  27. includes/classes/class-woo-feed-list-table.php +2 -2
  28. includes/classes/class-woo-feed-log-handler-file.php +2 -2
  29. includes/classes/class-woo-feed-merchant.php +225 -225
  30. includes/classes/class-woo-feed-products-v3.php +290 -343
  31. includes/classes/class-woo-feed-products.php +281 -304
  32. includes/classes/class-woo-feed-savefile.php +10 -10
  33. includes/classes/class-woo-feed-sftp.php +8 -12
  34. includes/classes/class-woo-feed-webappick-api.php +202 -18
  35. includes/feeds/class-woo-feed-custom.php +64 -68
  36. includes/feeds/class-woo-feed-facebook.php +227 -240
  37. includes/feeds/class-woo-feed-generate.php +2 -4
  38. includes/feeds/class-woo-feed-google.php +274 -290
  39. includes/feeds/class-woo-feed-pinterest.php +274 -290
  40. includes/helper.php +174 -181
  41. libs/WebAppick/AppServices/Client.php +49 -33
  42. libs/WebAppick/AppServices/Insights.php +224 -153
  43. libs/WebAppick/AppServices/License.php +267 -163
  44. libs/WebAppick/AppServices/Promotions.php +91 -58
  45. libs/WebAppick/AppServices/Updater.php +81 -56
  46. libs/WebAppick/phpcs.xml +71 -0
  47. uninstall.php +1 -1
  48. woo-feed.php +290 -366
README.txt CHANGED
@@ -1,11 +1,11 @@
1
  === WooCommerce Product Feed for Google, Bing, eBay and Many More ===
2
- Contributors: wahid0003,webappick,mhamudul_hk,shuvo586
3
  Donate link: https://webappick.com
4
  Tags:product feed,woocommerce product feed,google shopping feed,google shopping, XML CSV TXT product feed
5
  Requires at least: 3.6
6
  Tested Up To: 5.3.2
7
  Requires PHP: 5.6
8
- Stable tag: 3.2.17
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -305,9 +305,15 @@ Using pro version:
305
 
306
  == Changelog ==
307
 
 
 
 
 
 
 
308
  = 3.2.17 (2020-02-09) =
309
  * Fix Tax calculation based on store address.
310
- * Localize Javascript based Messages.
311
 
312
  = 3.2.16 (2020-02-02) =
313
  * Tested upto current WordPress and WooCommerce
1
  === WooCommerce Product Feed for Google, Bing, eBay and Many More ===
2
+ Contributors: wahid0003, webappick, mhamudul_hk, shuvo586
3
  Donate link: https://webappick.com
4
  Tags:product feed,woocommerce product feed,google shopping feed,google shopping, XML CSV TXT product feed
5
  Requires at least: 3.6
6
  Tested Up To: 5.3.2
7
  Requires PHP: 5.6
8
+ Stable tag: 3.2.18
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
305
 
306
  == Changelog ==
307
 
308
+ = 3.2.18 (2020-02-12) =
309
+ * Fix User can't hide review and related notice.
310
+ * Fix Some WPCS Related Warnings
311
+ * Add ability to hide Product-Limit warning notice
312
+ * String translation update.
313
+
314
  = 3.2.17 (2020-02-09) =
315
  * Fix Tax calculation based on store address.
316
+ * Localize JavaScript based Messages.
317
 
318
  = 3.2.16 (2020-02-02) =
319
  * Tested upto current WordPress and WooCommerce
admin/class-woo-feed-admin.php CHANGED
@@ -39,7 +39,7 @@ class Woo_Feed_Admin
39
  * @param string $woo_feed The name of this plugin.
40
  * @param string $version The version of this plugin.
41
  */
42
- public function __construct($woo_feed, $version) {
43
 
44
  $this->woo_feed = $woo_feed;
45
  $this->version = $version;
@@ -65,13 +65,13 @@ class Woo_Feed_Admin
65
  * class.
66
  */
67
  $mainDeps = [];
68
- if( false !== strpos( $hook, 'webappick' ) && false !== strpos( $hook, 'feed' ) ) {
69
  wp_register_style( 'selectize', plugin_dir_url(__FILE__) . 'css/selectize.css', array(),$this->version );
70
  wp_register_style( 'slick', plugin_dir_url(__FILE__) . 'css/slick.css', array(),$this->version );
71
  wp_register_style( 'slick-theme', plugin_dir_url(__FILE__) . 'css/slick-theme.css', array(),$this->version );
72
  $mainDeps = array( 'selectize' );
73
- if( $hook == 'woo-feed_page_webappick-feed-pro-vs-free' ) {
74
- $mainDeps = array_merge( $mainDeps, array('slick', 'slick-theme') );
75
  }
76
  }
77
  wp_register_style( $this->woo_feed, plugin_dir_url(__FILE__) . 'css/woo-feed-admin.css', $mainDeps, $this->version, 'all' );
@@ -101,10 +101,7 @@ class Woo_Feed_Admin
101
  wp_register_script( 'jquery-validate', plugin_dir_url( __FILE__ ) . 'js/jquery.validate.min.js', array( 'jquery' ), $this->version, false );
102
  wp_register_script( 'jquery-validate-additional-methods', plugin_dir_url( __FILE__ ) . 'js/additional-methods.min.js', array( 'jquery', 'jquery-validate' ), $this->version, false );
103
  wp_register_script( 'jquery-sortable', plugin_dir_url( __FILE__ ) . 'js/jquery-sortable.js', array( 'jquery' ), $this->version, false );
104
-
105
- wp_register_script( 'jquery-slick', plugin_dir_url( __FILE__ ) . 'js/slick.js', array( 'jquery' ), $this->version, false );
106
- wp_register_script( 'feed-pro', plugin_dir_url( __FILE__ ) . 'js/pro.js', array( 'jquery', 'jquery-slick' ), $this->version, false );
107
-
108
  if ( ! wp_script_is( 'clipboard', 'registered' ) ) {
109
  wp_register_script( 'clipboard', plugin_dir_url( __FILE__ ) . 'js/clipboard.min.js', [], '2.0.4', false );
110
  }
@@ -124,10 +121,6 @@ class Woo_Feed_Admin
124
  // 'underscore', 'word-count', 'jquery-ui-autocomplete',
125
  'jquery-touch-punch',
126
  ];
127
- if ( 'woo-feed_page_webappick-feed-pro-vs-free' === $hook ) {
128
- $feedScriptDependency[] = 'jquery-slick';
129
- $feedScriptDependency[] = 'feed-pro';
130
- }
131
 
132
  wp_register_script($this->woo_feed, plugin_dir_url(__FILE__) . 'js/woo-feed-admin.js', $feedScriptDependency, $this->version, false);
133
  wp_localize_script(
@@ -156,7 +149,17 @@ class Woo_Feed_Admin
156
  ],
157
  )
158
  );
159
- wp_enqueue_script($this->woo_feed);
 
 
 
 
 
 
 
 
 
 
160
  }
161
  }
162
 
@@ -198,7 +201,6 @@ class Woo_Feed_Admin
198
  add_submenu_page( 'webappick-manage-feeds', __('Make Feed', 'woo-feed'), __('Make Feed', 'woo-feed'), 'manage_woocommerce', 'webappick-new-feed', 'woo_feed_generate_feed' );
199
  add_submenu_page( 'webappick-manage-feeds', __('Settings', 'woo-feed'), __('Settings', 'woo-feed'), 'manage_woocommerce', 'webappick-feed-settings', 'woo_feed_config_feed' );
200
  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' ) );
201
- add_submenu_page( 'webappick-manage-feeds', __('Premium', 'woo-feed'), '<span class="woo-feed-premium">' . __('Premium', 'woo-feed') . '</span>', 'manage_woocommerce', 'webappick-feed-pro-vs-free', 'woo_feed_pro_vs_free' );
202
  }
203
  }
204
 
@@ -216,10 +218,10 @@ class Woo_Feed_Admin
216
  'woo_feed_config_feed' => 'webappick-feed-settings',
217
  'woo_feed_pro_vs_free' => 'webappick-feed-pro-vs-free',
218
  );
219
- if( $pagenow === 'admin.php' && isset( $_GET['page'] ) && ! empty( $_GET['page'] ) ) {
220
- foreach( $redirect_to as $from => $to ) {
221
- if( $_GET['page'] !== $from ) continue;
222
- wp_redirect( admin_url( 'admin.php?page=' . $to ), 301 );
223
  die();
224
  }
225
  }
39
  * @param string $woo_feed The name of this plugin.
40
  * @param string $version The version of this plugin.
41
  */
42
+ public function __construct( $woo_feed, $version ) {
43
 
44
  $this->woo_feed = $woo_feed;
45
  $this->version = $version;
65
  * class.
66
  */
67
  $mainDeps = [];
68
+ if ( false !== strpos( $hook, 'webappick' ) && false !== strpos( $hook, 'feed' ) ) {
69
  wp_register_style( 'selectize', plugin_dir_url(__FILE__) . 'css/selectize.css', array(),$this->version );
70
  wp_register_style( 'slick', plugin_dir_url(__FILE__) . 'css/slick.css', array(),$this->version );
71
  wp_register_style( 'slick-theme', plugin_dir_url(__FILE__) . 'css/slick-theme.css', array(),$this->version );
72
  $mainDeps = array( 'selectize' );
73
+ if ( $hook == 'woo-feed_page_webappick-feed-pro-vs-free' ) {
74
+ $mainDeps = array_merge( $mainDeps, array( 'slick', 'slick-theme' ) );
75
  }
76
  }
77
  wp_register_style( $this->woo_feed, plugin_dir_url(__FILE__) . 'css/woo-feed-admin.css', $mainDeps, $this->version, 'all' );
101
  wp_register_script( 'jquery-validate', plugin_dir_url( __FILE__ ) . 'js/jquery.validate.min.js', array( 'jquery' ), $this->version, false );
102
  wp_register_script( 'jquery-validate-additional-methods', plugin_dir_url( __FILE__ ) . 'js/additional-methods.min.js', array( 'jquery', 'jquery-validate' ), $this->version, false );
103
  wp_register_script( 'jquery-sortable', plugin_dir_url( __FILE__ ) . 'js/jquery-sortable.js', array( 'jquery' ), $this->version, false );
104
+
 
 
 
105
  if ( ! wp_script_is( 'clipboard', 'registered' ) ) {
106
  wp_register_script( 'clipboard', plugin_dir_url( __FILE__ ) . 'js/clipboard.min.js', [], '2.0.4', false );
107
  }
121
  // 'underscore', 'word-count', 'jquery-ui-autocomplete',
122
  'jquery-touch-punch',
123
  ];
 
 
 
 
124
 
125
  wp_register_script($this->woo_feed, plugin_dir_url(__FILE__) . 'js/woo-feed-admin.js', $feedScriptDependency, $this->version, false);
126
  wp_localize_script(
149
  ],
150
  )
151
  );
152
+ wp_enqueue_script( $this->woo_feed );
153
+ $feedProScriptDependency = [
154
+ 'jquery',
155
+ $this->woo_feed,
156
+ ];
157
+ if ( 'woo-feed_page_webappick-feed-pro-vs-free' === $hook ) {
158
+ $feedProScriptDependency = 'jquery-slick';
159
+ wp_register_script( 'jquery-slick', plugin_dir_url( __FILE__ ) . 'js/slick.js', array( 'jquery' ), $this->version, false );
160
+ }
161
+ wp_register_script( 'feed-pro', plugin_dir_url( __FILE__ ) . 'js/pro.js', $feedProScriptDependency, $this->version, false );
162
+ wp_enqueue_script( 'feed-pro' );
163
  }
164
  }
165
 
201
  add_submenu_page( 'webappick-manage-feeds', __('Make Feed', 'woo-feed'), __('Make Feed', 'woo-feed'), 'manage_woocommerce', 'webappick-new-feed', 'woo_feed_generate_feed' );
202
  add_submenu_page( 'webappick-manage-feeds', __('Settings', 'woo-feed'), __('Settings', 'woo-feed'), 'manage_woocommerce', 'webappick-feed-settings', 'woo_feed_config_feed' );
203
  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' ) );
 
204
  }
205
  }
206
 
218
  'woo_feed_config_feed' => 'webappick-feed-settings',
219
  'woo_feed_pro_vs_free' => 'webappick-feed-pro-vs-free',
220
  );
221
+ if ( $pagenow === 'admin.php' && isset( $_GET['page'] ) && ! empty( $_GET['page'] ) ) {
222
+ foreach ( $redirect_to as $from => $to ) {
223
+ if ( $_GET['page'] !== $from ) continue;
224
+ wp_safe_redirect( admin_url( 'admin.php?page=' . $to ), 301 );
225
  die();
226
  }
227
  }
admin/class-woo-feed-manage-list.php CHANGED
@@ -29,15 +29,14 @@ class Woo_Feed_Manage_list extends Woo_Feed_List_Table
29
  * REQUIRED. Set up a constructor that references the parent constructor. We
30
  * use the parent reference to set some default configs.
31
  ***************************************************************************/
32
- function __construct()
33
- {
34
  global $status, $page;
35
 
36
  //Set parent defaults
37
  parent::__construct(array(
38
  'singular' => __('feed'), //singular name of the listed records
39
- 'plural' => __('feeds'), //plural name of the listed records
40
- 'ajax' => false //does this table support ajax?
41
  ));
42
 
43
  }
@@ -65,7 +64,7 @@ class Woo_Feed_Manage_list extends Woo_Feed_List_Table
65
  * @return string Text or HTML to be placed inside the column <td>
66
  *
67
  **************************************************************************/
68
- function column_default($item, $column_name) {
69
  $getItem = $item['option_name'];
70
  $statusId = $item['option_id'];
71
  $itemInfo = unserialize(get_option($getItem));
@@ -73,14 +72,14 @@ class Woo_Feed_Manage_list extends Woo_Feed_List_Table
73
  $optionName = str_replace("wf_feed_", "", $getItem );
74
  $spinIcon = ( $regenerating === true && $optionName === $regeneratingName ) ? ' wpf_spin_reverse' : '';
75
  $disableBtn = $regenerating === true ? ' disabled' : '';
76
- switch ($column_name) {
77
  case 'option_name':
78
  return $optionName;
79
  case 'status':
80
- if(!isset($itemInfo['status']) || $itemInfo['status'] == 1){
81
  return ' <div class="wf_status_wrap"><input style="display: none;" data-index='.$statusId.' id='.$statusId.' checked class="woo_feed_status_input" type="checkbox" value="'.$getItem.'"/>
82
  <label for='.$statusId.' class= "woo-feed_active_status"></label></div>';
83
- }else{
84
  return ' <div class="wf_status_wrap"> <input style="display: none;" data-index='.$statusId.' id='.$statusId.' class="woo_feed_status_input" type="checkbox" value="'.$getItem.'"/>
85
  <label for='.$statusId.' class= "woo-feed_active_status"></label> </div>';
86
  }
@@ -100,11 +99,11 @@ class Woo_Feed_Manage_list extends Woo_Feed_List_Table
100
  $itemInfo[ $column_name ],
101
  '<img src="data:image/svg+xml,%0A%3Csvg height=\'1024\' width=\'896\' xmlns=\'http://www.w3.org/2000/svg\'%3E%3Cpath d=\'M128 768h256v64H128v-64z m320-384H128v64h320v-64z m128 192V448L384 640l192 192V704h320V576H576z m-288-64H128v64h160v-64zM128 704h160v-64H128v64z m576 64h64v128c-1 18-7 33-19 45s-27 18-45 19H64c-35 0-64-29-64-64V192c0-35 29-64 64-64h192C256 57 313 0 384 0s128 57 128 128h192c35 0 64 29 64 64v320h-64V320H64v576h640V768zM128 256h512c0-35-29-64-64-64h-64c-35 0-64-29-64-64s-29-64-64-64-64 29-64 64-29 64-64 64h-64c-35 0-64 29-64 64z\' /%3E%3C/svg%3E%0A" alt="' . __( 'Copy To Clipboard') . '" class="clippy">' );
102
  case 'last_updated':
103
- return $itemInfo[$column_name];
104
  case 'view':
105
  $view = $itemInfo['url'];
106
  /** @noinspection HtmlUnknownTarget */
107
- return sprintf(
108
  '<a href="%1$s" title="%2$s" aria-label="%2$s" target="_blank"><span class="dashicons dashicons-external" aria-hidden="true"></span></a>
109
  <a id="%3$s" class="wpf_regenerate%6$s" href="#" title="%4$s" aria-label="%4$s"><span class="dashicons dashicons-update-alt%7$s" aria-hidden="true"></span></a>
110
  <a href="%1$s" title="%5$s" aria-label="%5$s" download><span class="dashicons dashicons-download" aria-hidden="true"></span></a>',
@@ -131,16 +130,15 @@ class Woo_Feed_Manage_list extends Woo_Feed_List_Table
131
  * @param array $item A singular item (one full row's worth of data)
132
  * @return string Text to be placed inside the column <td> (movie title only)
133
  **************************************************************************/
134
- function column_option_name($item)
135
- {
136
  //Build row actions
137
  $edit_nonce = wp_create_nonce('wf_edit_feed');
138
  $delete_nonce = wp_create_nonce('wf_delete_feed');
139
  //$title = '<strong>' . $item['option_name'] . '</strong>';
140
 
141
  $actions = array(
142
- 'edit' => sprintf('<a href="?page=%s&action=%s&feed=%s&_wpnonce=%s">' . __('Edit', 'woo-feed') . '</a>', esc_attr($_REQUEST['page']), 'edit-feed', $item['option_name'], $edit_nonce),
143
- 'delete' => sprintf('<a val="?page=%s&action=%s&feed=%s&_wpnonce=%s" class="single-feed-delete" style="cursor: pointer;">' . __('Delete', 'woo-feed') . '</a>', esc_attr($_REQUEST['page']), 'delete-feed', absint($item['option_id']), $delete_nonce)
144
  );
145
 
146
  //Return the title contents
@@ -155,8 +153,7 @@ class Woo_Feed_Manage_list extends Woo_Feed_List_Table
155
  );
156
  }
157
 
158
- public static function get_feeds($search = "")
159
- {
160
  global $wpdb;
161
  $query = $wpdb->prepare("SELECT * FROM $wpdb->options WHERE option_name LIKE %s ORDER BY option_id DESC;", "wf_feed_%");
162
  $result = $wpdb->get_results($query, 'ARRAY_A');
@@ -170,12 +167,11 @@ class Woo_Feed_Manage_list extends Woo_Feed_List_Table
170
  * @param int $id Feed ID
171
  * @return false|int
172
  */
173
- public static function delete_feed($id)
174
- {
175
  global $wpdb;
176
  self::delete_feed_file($id);
177
  return $wpdb->delete(
178
- "{$wpdb->prefix}options",array('option_id'=>$id), array('%d')
179
  );
180
  }
181
 
@@ -185,8 +181,7 @@ class Woo_Feed_Manage_list extends Woo_Feed_List_Table
185
  * @param int $id customer ID
186
  * @return false|int
187
  */
188
- public static function delete_feed_file($id)
189
- {
190
  global $wpdb;
191
  $mylink = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->options WHERE option_id = %d", $id ) );
192
  $option_name = $mylink->option_name;
@@ -204,16 +199,14 @@ class Woo_Feed_Manage_list extends Woo_Feed_List_Table
204
  *
205
  * @return null|string
206
  */
207
- public static function record_count()
208
- {
209
  global $wpdb;
210
  $sql = "SELECT * FROM $wpdb->options WHERE option_name like 'wf_feed_%'";
211
  return $wpdb->get_var($sql);
212
  }
213
 
214
  /** Text displayed when no data is available */
215
- public function no_items()
216
- {
217
  _e('No feed available.', 'woo-feed');
218
  }
219
 
@@ -227,8 +220,7 @@ class Woo_Feed_Manage_list extends Woo_Feed_List_Table
227
  * @param array $item A singular item (one full row's worth of data)
228
  * @return string Text to be placed inside the column <td> (movie title only)
229
  **************************************************************************/
230
- function column_cb($item)
231
- {
232
  return sprintf(
233
  '<input type="checkbox" name="%1$s[]" value="%2$s" />',
234
  /*$1%s*/
@@ -239,14 +231,13 @@ class Woo_Feed_Manage_list extends Woo_Feed_List_Table
239
  }
240
 
241
 
242
- function column_name($item)
243
- {
244
  $edit_nonce = wp_create_nonce('wf_edit_feed');
245
  $delete_nonce = wp_create_nonce('wf_delete_feed');
246
  $title = '<strong>' . $item['option_name'] . '</strong>';
247
  $actions = array(
248
- 'edit' => sprintf('<a href="?page=%s&action=%s&feed=%s&_wpnonce=%s">' . __('Edit', 'woo-feed') . '</a>', esc_attr($_REQUEST['page']), 'edit-feed', absint($item['option_id']), $edit_nonce),
249
- 'delete' => sprintf('<a val="?page=%s&action=%s&feed=%s&_wpnonce=%s" class="single-feed-delete" style="cursor: pointer;">' . __('Delete', 'woo-feed') . '</a>', esc_attr($_REQUEST['page']), 'delete-feed', absint($item['option_id']), $delete_nonce)
250
  );
251
  return $title . $this->row_actions($actions);
252
  }
@@ -264,17 +255,16 @@ class Woo_Feed_Manage_list extends Woo_Feed_List_Table
264
  * @see WP_List_Table::::single_row_columns()
265
  * @return array An associative array containing column information: 'slugs'=>'Visible Titles'
266
  **************************************************************************/
267
- function get_columns()
268
- {
269
  $columns = array(
270
- 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
271
- 'status' => __('Auto Update'),
272
- 'option_name' => __('File Name'),
273
- 'provider' => __('Provider'),
274
- 'type' => __('Type'),
275
- 'url' => __("Feed URL"),
276
  'last_updated' => __("Last Updated"),
277
- 'view' => __("Action")
278
  );
279
  return $columns;
280
  }
@@ -294,10 +284,9 @@ class Woo_Feed_Manage_list extends Woo_Feed_List_Table
294
  *
295
  * @return array An associative array containing all the columns that should be sortable: 'slugs'=>array('data_values',bool)
296
  **************************************************************************/
297
- function get_sortable_columns()
298
- {
299
  $sortable_columns = array(
300
- 'option_name' => array('option_name', false)
301
  );
302
  return $sortable_columns;
303
  }
@@ -317,10 +306,9 @@ class Woo_Feed_Manage_list extends Woo_Feed_List_Table
317
  *
318
  * @return array An associative array containing all the bulk actions: 'slugs'=>'Visible Titles'
319
  **************************************************************************/
320
- function get_bulk_actions()
321
- {
322
  $actions = array(
323
- 'bulk-delete' => __('Delete')
324
  );
325
  return $actions;
326
  }
@@ -333,31 +321,29 @@ class Woo_Feed_Manage_list extends Woo_Feed_List_Table
333
  *
334
  * @see $this->prepare_items()
335
  **************************************************************************/
336
- public function process_bulk_action()
337
- {
338
  //Detect when a bulk action is being triggered...
339
  if ( 'delete-feed' === $this->current_action() ) {
340
  // In our file that handles the request, verify the nonce.
341
  $nonce = esc_attr($_REQUEST['_wpnonce']);
342
- if (!wp_verify_nonce($nonce, 'wf_delete_feed')) {
343
  update_option('wpf_message', esc_html__( 'Failed To Delete Feed. You do not have sufficient permission to delete.', 'woo-feed' ), false );
344
- wp_redirect(admin_url("admin.php?page=webappick-manage-feeds&wpf_message=error"));
345
- wp_die();
346
  } else {
347
- if (self::delete_feed(absint($_GET['feed']))) {
348
  update_option( 'wpf_message', esc_html__( 'Feed Deleted Successfully', 'woo-feed' ), false );
349
- wp_redirect(admin_url("admin.php?page=webappick-manage-feeds&wpf_message=success"));
350
- wp_die();
351
  } else {
352
  update_option( 'wpf_message', esc_html__( 'Failed To Delete Feed', 'woo-feed' ), false );
353
- wp_redirect(admin_url("admin.php?page=webappick-manage-feeds&wpf_message=error"));
354
- wp_die();
355
- }
356
-
357
- }
358
  }
359
  //Detect when a bulk action is being triggered...
360
- if ('edit-feed' === $this->current_action()) {
361
  // In our file that handles the request, verify the nonce.
362
  $nonce = esc_attr( $_REQUEST['_wpnonce'] );
363
  if ( ! wp_verify_nonce( $nonce, 'wf_edit_feed' ) ) {
@@ -367,12 +353,12 @@ class Woo_Feed_Manage_list extends Woo_Feed_List_Table
367
 
368
 
369
  // If the delete bulk action is triggered
370
- if ((isset($_POST['feed'])) && (isset($_POST['action']) && $_POST['action'] == 'bulk-delete')
371
  || (isset($_POST['action2']) && $_POST['action2'] == 'bulk-delete')
372
  ) {
373
- if ('bulk-delete' === $this->current_action()) {
374
  $nonce = esc_attr($_REQUEST['_wpnonce']);
375
- if (!wp_verify_nonce($nonce, "bulk-" . $this->_args['plural'])) {
376
  wp_die( esc_html__( 'You do not have sufficient permission to delete!', 'woo-feed' ) );
377
  } else {
378
  $delete_ids = array_map( 'absint', $_POST['feed'] );
@@ -389,8 +375,8 @@ class Woo_Feed_Manage_list extends Woo_Feed_List_Table
389
  $count
390
  );
391
  update_option( 'wpf_message', $message );
392
- wp_redirect(admin_url("admin.php?page=webappick-manage-feeds&wpf_message=success"));
393
- wp_die();
394
  }
395
  }
396
  }
@@ -413,8 +399,7 @@ class Woo_Feed_Manage_list extends Woo_Feed_List_Table
413
  * @uses $this->get_pagenum()
414
  * @uses $this->set_pagination_args()
415
  **************************************************************************/
416
- function prepare_items()
417
- {
418
  global $wpdb; //This is used only if making any database queries
419
 
420
  /**
@@ -441,7 +426,7 @@ class Woo_Feed_Manage_list extends Woo_Feed_List_Table
441
  * 3 other arrays. One for all columns, one for hidden columns, and one
442
  * for sortable columns.
443
  */
444
- $this->_column_headers = array($columns, $hidden, $sortable);
445
 
446
 
447
  /**
@@ -460,7 +445,7 @@ class Woo_Feed_Manage_list extends Woo_Feed_List_Table
460
  * use sort and pagination data to build a custom query instead, as you'll
461
  * be able to use your precisely-queried data immediately.
462
  */
463
- if (isset($_POST['s'])) {
464
  $data = $this->get_feeds( sanitize_text_field( $_POST['s'] ) );
465
  } else {
466
  $data = $this->get_feeds();
@@ -475,11 +460,10 @@ class Woo_Feed_Manage_list extends Woo_Feed_List_Table
475
  * to a custom query. The returned data will be pre-sorted, and this array
476
  * sorting technique would be unnecessary.
477
  */
478
- function usort_reorder($a, $b)
479
- {
480
- $orderby = (!empty($_REQUEST['orderby'])) ? sanitize_text_field( $_REQUEST['orderby'] ) : 'option_name'; //If no sort, default to title
481
- $order = (!empty($_REQUEST['order'])) ? sanitize_text_field( $_REQUEST['order'] ) : 'asc'; //If no order, default to asc
482
- $result = strcmp($a[$orderby], $b[$orderby]); //Determine sort order
483
  return ($order === 'asc') ? $result : -$result; //Send final sort direction to usort
484
  }
485
 
@@ -529,8 +513,8 @@ class Woo_Feed_Manage_list extends Woo_Feed_List_Table
529
  */
530
  $this->set_pagination_args(array(
531
  'total_items' => $total_items, //WE have to calculate the total number of items
532
- 'per_page' => $per_page, //WE have to determine how many items to show on a page
533
- 'total_pages' => ceil($total_items / $per_page) //WE have to calculate the total number of pages
534
  ));
535
 
536
  // $this->set_pagination_args( array(
29
  * REQUIRED. Set up a constructor that references the parent constructor. We
30
  * use the parent reference to set some default configs.
31
  ***************************************************************************/
32
+ function __construct() {
 
33
  global $status, $page;
34
 
35
  //Set parent defaults
36
  parent::__construct(array(
37
  'singular' => __('feed'), //singular name of the listed records
38
+ 'plural' => __('feeds'), //plural name of the listed records
39
+ 'ajax' => false, //does this table support ajax?
40
  ));
41
 
42
  }
64
  * @return string Text or HTML to be placed inside the column <td>
65
  *
66
  **************************************************************************/
67
+ function column_default( $item, $column_name ) {
68
  $getItem = $item['option_name'];
69
  $statusId = $item['option_id'];
70
  $itemInfo = unserialize(get_option($getItem));
72
  $optionName = str_replace("wf_feed_", "", $getItem );
73
  $spinIcon = ( $regenerating === true && $optionName === $regeneratingName ) ? ' wpf_spin_reverse' : '';
74
  $disableBtn = $regenerating === true ? ' disabled' : '';
75
+ switch ( $column_name ) {
76
  case 'option_name':
77
  return $optionName;
78
  case 'status':
79
+ if ( ! isset($itemInfo['status']) || $itemInfo['status'] == 1 ) {
80
  return ' <div class="wf_status_wrap"><input style="display: none;" data-index='.$statusId.' id='.$statusId.' checked class="woo_feed_status_input" type="checkbox" value="'.$getItem.'"/>
81
  <label for='.$statusId.' class= "woo-feed_active_status"></label></div>';
82
+ }else {
83
  return ' <div class="wf_status_wrap"> <input style="display: none;" data-index='.$statusId.' id='.$statusId.' class="woo_feed_status_input" type="checkbox" value="'.$getItem.'"/>
84
  <label for='.$statusId.' class= "woo-feed_active_status"></label> </div>';
85
  }
99
  $itemInfo[ $column_name ],
100
  '<img src="data:image/svg+xml,%0A%3Csvg height=\'1024\' width=\'896\' xmlns=\'http://www.w3.org/2000/svg\'%3E%3Cpath d=\'M128 768h256v64H128v-64z m320-384H128v64h320v-64z m128 192V448L384 640l192 192V704h320V576H576z m-288-64H128v64h160v-64zM128 704h160v-64H128v64z m576 64h64v128c-1 18-7 33-19 45s-27 18-45 19H64c-35 0-64-29-64-64V192c0-35 29-64 64-64h192C256 57 313 0 384 0s128 57 128 128h192c35 0 64 29 64 64v320h-64V320H64v576h640V768zM128 256h512c0-35-29-64-64-64h-64c-35 0-64-29-64-64s-29-64-64-64-64 29-64 64-29 64-64 64h-64c-35 0-64 29-64 64z\' /%3E%3C/svg%3E%0A" alt="' . __( 'Copy To Clipboard') . '" class="clippy">' );
101
  case 'last_updated':
102
+ return $itemInfo[ $column_name ];
103
  case 'view':
104
  $view = $itemInfo['url'];
105
  /** @noinspection HtmlUnknownTarget */
106
+ return sprintf(
107
  '<a href="%1$s" title="%2$s" aria-label="%2$s" target="_blank"><span class="dashicons dashicons-external" aria-hidden="true"></span></a>
108
  <a id="%3$s" class="wpf_regenerate%6$s" href="#" title="%4$s" aria-label="%4$s"><span class="dashicons dashicons-update-alt%7$s" aria-hidden="true"></span></a>
109
  <a href="%1$s" title="%5$s" aria-label="%5$s" download><span class="dashicons dashicons-download" aria-hidden="true"></span></a>',
130
  * @param array $item A singular item (one full row's worth of data)
131
  * @return string Text to be placed inside the column <td> (movie title only)
132
  **************************************************************************/
133
+ function column_option_name( $item ) {
 
134
  //Build row actions
135
  $edit_nonce = wp_create_nonce('wf_edit_feed');
136
  $delete_nonce = wp_create_nonce('wf_delete_feed');
137
  //$title = '<strong>' . $item['option_name'] . '</strong>';
138
 
139
  $actions = array(
140
+ 'edit' => sprintf('<a href="?page=%s&action=%s&feed=%s&_wpnonce=%s">' . __('Edit', 'woo-feed') . '</a>', esc_attr($_REQUEST['page']), 'edit-feed', $item['option_name'], $edit_nonce),
141
+ 'delete' => sprintf('<a val="?page=%s&action=%s&feed=%s&_wpnonce=%s" class="single-feed-delete" style="cursor: pointer;">' . __('Delete', 'woo-feed') . '</a>', esc_attr($_REQUEST['page']), 'delete-feed', absint($item['option_id']), $delete_nonce),
142
  );
143
 
144
  //Return the title contents
153
  );
154
  }
155
 
156
+ public static function get_feeds( $search = "" ) {
 
157
  global $wpdb;
158
  $query = $wpdb->prepare("SELECT * FROM $wpdb->options WHERE option_name LIKE %s ORDER BY option_id DESC;", "wf_feed_%");
159
  $result = $wpdb->get_results($query, 'ARRAY_A');
167
  * @param int $id Feed ID
168
  * @return false|int
169
  */
170
+ public static function delete_feed( $id ) {
 
171
  global $wpdb;
172
  self::delete_feed_file($id);
173
  return $wpdb->delete(
174
+ "{$wpdb->prefix}options",array( 'option_id' => $id ), array( '%d' )
175
  );
176
  }
177
 
181
  * @param int $id customer ID
182
  * @return false|int
183
  */
184
+ public static function delete_feed_file( $id ) {
 
185
  global $wpdb;
186
  $mylink = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->options WHERE option_id = %d", $id ) );
187
  $option_name = $mylink->option_name;
199
  *
200
  * @return null|string
201
  */
202
+ public static function record_count() {
 
203
  global $wpdb;
204
  $sql = "SELECT * FROM $wpdb->options WHERE option_name like 'wf_feed_%'";
205
  return $wpdb->get_var($sql);
206
  }
207
 
208
  /** Text displayed when no data is available */
209
+ public function no_items() {
 
210
  _e('No feed available.', 'woo-feed');
211
  }
212
 
220
  * @param array $item A singular item (one full row's worth of data)
221
  * @return string Text to be placed inside the column <td> (movie title only)
222
  **************************************************************************/
223
+ function column_cb( $item ) {
 
224
  return sprintf(
225
  '<input type="checkbox" name="%1$s[]" value="%2$s" />',
226
  /*$1%s*/
231
  }
232
 
233
 
234
+ function column_name( $item ) {
 
235
  $edit_nonce = wp_create_nonce('wf_edit_feed');
236
  $delete_nonce = wp_create_nonce('wf_delete_feed');
237
  $title = '<strong>' . $item['option_name'] . '</strong>';
238
  $actions = array(
239
+ 'edit' => sprintf('<a href="?page=%s&action=%s&feed=%s&_wpnonce=%s">' . __('Edit', 'woo-feed') . '</a>', esc_attr($_REQUEST['page']), 'edit-feed', absint($item['option_id']), $edit_nonce),
240
+ 'delete' => sprintf('<a val="?page=%s&action=%s&feed=%s&_wpnonce=%s" class="single-feed-delete" style="cursor: pointer;">' . __('Delete', 'woo-feed') . '</a>', esc_attr($_REQUEST['page']), 'delete-feed', absint($item['option_id']), $delete_nonce),
241
  );
242
  return $title . $this->row_actions($actions);
243
  }
255
  * @see WP_List_Table::::single_row_columns()
256
  * @return array An associative array containing column information: 'slugs'=>'Visible Titles'
257
  **************************************************************************/
258
+ function get_columns() {
 
259
  $columns = array(
260
+ 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
261
+ 'status' => __('Auto Update'),
262
+ 'option_name' => __('File Name'),
263
+ 'provider' => __('Provider'),
264
+ 'type' => __('Type'),
265
+ 'url' => __("Feed URL"),
266
  'last_updated' => __("Last Updated"),
267
+ 'view' => __("Action"),
268
  );
269
  return $columns;
270
  }
284
  *
285
  * @return array An associative array containing all the columns that should be sortable: 'slugs'=>array('data_values',bool)
286
  **************************************************************************/
287
+ function get_sortable_columns() {
 
288
  $sortable_columns = array(
289
+ 'option_name' => array( 'option_name', false ),
290
  );
291
  return $sortable_columns;
292
  }
306
  *
307
  * @return array An associative array containing all the bulk actions: 'slugs'=>'Visible Titles'
308
  **************************************************************************/
309
+ function get_bulk_actions() {
 
310
  $actions = array(
311
+ 'bulk-delete' => __('Delete'),
312
  );
313
  return $actions;
314
  }
321
  *
322
  * @see $this->prepare_items()
323
  **************************************************************************/
324
+ public function process_bulk_action() {
 
325
  //Detect when a bulk action is being triggered...
326
  if ( 'delete-feed' === $this->current_action() ) {
327
  // In our file that handles the request, verify the nonce.
328
  $nonce = esc_attr($_REQUEST['_wpnonce']);
329
+ if ( ! wp_verify_nonce($nonce, 'wf_delete_feed') ) {
330
  update_option('wpf_message', esc_html__( 'Failed To Delete Feed. You do not have sufficient permission to delete.', 'woo-feed' ), false );
331
+ wp_safe_redirect(admin_url("admin.php?page=webappick-manage-feeds&wpf_message=error"));
332
+ die();
333
  } else {
334
+ if ( self::delete_feed(absint($_GET['feed'])) ) {
335
  update_option( 'wpf_message', esc_html__( 'Feed Deleted Successfully', 'woo-feed' ), false );
336
+ wp_safe_redirect(admin_url("admin.php?page=webappick-manage-feeds&wpf_message=success"));
337
+ die();
338
  } else {
339
  update_option( 'wpf_message', esc_html__( 'Failed To Delete Feed', 'woo-feed' ), false );
340
+ wp_safe_redirect(admin_url("admin.php?page=webappick-manage-feeds&wpf_message=error"));
341
+ die();
342
+ }
343
+ }
 
344
  }
345
  //Detect when a bulk action is being triggered...
346
+ if ( 'edit-feed' === $this->current_action() ) {
347
  // In our file that handles the request, verify the nonce.
348
  $nonce = esc_attr( $_REQUEST['_wpnonce'] );
349
  if ( ! wp_verify_nonce( $nonce, 'wf_edit_feed' ) ) {
353
 
354
 
355
  // If the delete bulk action is triggered
356
+ if ( (isset($_POST['feed'])) && (isset($_POST['action']) && $_POST['action'] == 'bulk-delete')
357
  || (isset($_POST['action2']) && $_POST['action2'] == 'bulk-delete')
358
  ) {
359
+ if ( 'bulk-delete' === $this->current_action() ) {
360
  $nonce = esc_attr($_REQUEST['_wpnonce']);
361
+ if ( ! wp_verify_nonce($nonce, "bulk-" . $this->_args['plural']) ) {
362
  wp_die( esc_html__( 'You do not have sufficient permission to delete!', 'woo-feed' ) );
363
  } else {
364
  $delete_ids = array_map( 'absint', $_POST['feed'] );
375
  $count
376
  );
377
  update_option( 'wpf_message', $message );
378
+ wp_safe_redirect(admin_url("admin.php?page=webappick-manage-feeds&wpf_message=success"));
379
+ die();
380
  }
381
  }
382
  }
399
  * @uses $this->get_pagenum()
400
  * @uses $this->set_pagination_args()
401
  **************************************************************************/
402
+ function prepare_items() {
 
403
  global $wpdb; //This is used only if making any database queries
404
 
405
  /**
426
  * 3 other arrays. One for all columns, one for hidden columns, and one
427
  * for sortable columns.
428
  */
429
+ $this->_column_headers = array( $columns, $hidden, $sortable );
430
 
431
 
432
  /**
445
  * use sort and pagination data to build a custom query instead, as you'll
446
  * be able to use your precisely-queried data immediately.
447
  */
448
+ if ( isset($_POST['s']) ) {
449
  $data = $this->get_feeds( sanitize_text_field( $_POST['s'] ) );
450
  } else {
451
  $data = $this->get_feeds();
460
  * to a custom query. The returned data will be pre-sorted, and this array
461
  * sorting technique would be unnecessary.
462
  */
463
+ function usort_reorder( $a, $b ) {
464
+ $orderby = ( ! empty($_REQUEST['orderby'])) ? sanitize_text_field( $_REQUEST['orderby'] ) : 'option_name'; //If no sort, default to title
465
+ $order = ( ! empty($_REQUEST['order'])) ? sanitize_text_field( $_REQUEST['order'] ) : 'asc'; //If no order, default to asc
466
+ $result = strcmp($a[ $orderby ], $b[ $orderby ]); //Determine sort order
 
467
  return ($order === 'asc') ? $result : -$result; //Send final sort direction to usort
468
  }
469
 
513
  */
514
  $this->set_pagination_args(array(
515
  'total_items' => $total_items, //WE have to calculate the total number of items
516
+ 'per_page' => $per_page, //WE have to determine how many items to show on a page
517
+ 'total_pages' => ceil($total_items / $per_page), //WE have to calculate the total number of pages
518
  ));
519
 
520
  // $this->set_pagination_args( array(
admin/css/woo-feed-admin.css CHANGED
@@ -660,9 +660,9 @@ table.wf-info-table th a.documentation { color: #0073aa;}
660
  table.wf-info-table th a.tutorial { color: #ee264a; }
661
  table.wf-info-table th a.support { color: #0DD41E; }
662
  table.wf-rate-table a.review-star:after {
663
- content: "\f155\f155\f155\f155\f155" !important;
664
  /*noinspection CssNoGenericFontName*/
665
  font-family: dashicons;
 
666
  font-size: 10px;
667
  font-weight: 100;
668
  text-rendering: auto;
@@ -673,6 +673,23 @@ table.wf-rate-table a.review-star:after {
673
  color:#0073aa;text-decoration: underline;
674
  }
675
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
676
  /** Admin Menu Icon **/
677
  #adminmenu #toplevel_page_webappick-manage-feeds div.wp-menu-image::before {
678
  content: "";
660
  table.wf-info-table th a.tutorial { color: #ee264a; }
661
  table.wf-info-table th a.support { color: #0DD41E; }
662
  table.wf-rate-table a.review-star:after {
 
663
  /*noinspection CssNoGenericFontName*/
664
  font-family: dashicons;
665
+ content: "\f155\f155\f155\f155\f155" !important;
666
  font-size: 10px;
667
  font-weight: 100;
668
  text-rendering: auto;
673
  color:#0073aa;text-decoration: underline;
674
  }
675
 
676
+ /** Admin Notices **/
677
+
678
+ .woo-feed-notice[data-which="rating"] [data-response] {
679
+ border-width: 2px;
680
+ font-weight: 600;
681
+ text-transform: capitalize;
682
+ }
683
+ .woo-feed-notice[data-which="rating"] [data-response="given"] {
684
+ background: #FFEB3B;
685
+ border-color: #464646;
686
+ color: #000000;
687
+ }
688
+ .woo-feed-notice[data-which="rating"] [data-response="given"]:hover {
689
+ background: #f6de09;
690
+ border-color: #2e2e2e;
691
+ }
692
+
693
  /** Admin Menu Icon **/
694
  #adminmenu #toplevel_page_webappick-manage-feeds div.wp-menu-image::before {
695
  content: "";
admin/js/pro.js CHANGED
@@ -1,5 +1,5 @@
1
  // noinspection JSUnresolvedVariable,ES6ConvertVarToLetConst,SpellCheckingInspection
2
- (function ($, window, document) {
3
  /* global ajaxurl, wpAjax, postboxes, pagenow, alert, deleteUserSetting, typenow, adminpage, thousandsSeparator, decimalPoint, isRtl */
4
  $(window).load(function () {
5
  // noinspection ES6ConvertVarToLetConst,SpellCheckingInspection
@@ -16,4 +16,23 @@
16
  });
17
  }
18
  } );
19
- }( jQuery, window, document ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  // noinspection JSUnresolvedVariable,ES6ConvertVarToLetConst,SpellCheckingInspection
2
+ (function ($, window, document, wpAjax, opts) {
3
  /* global ajaxurl, wpAjax, postboxes, pagenow, alert, deleteUserSetting, typenow, adminpage, thousandsSeparator, decimalPoint, isRtl */
4
  $(window).load(function () {
5
  // noinspection ES6ConvertVarToLetConst,SpellCheckingInspection
16
  });
17
  }
18
  } );
19
+ $(document)
20
+ .on('click', '.woo-feed-notice a.button', function (e) {
21
+ e.preventDefault();
22
+ // noinspection ES6ConvertVarToLetConst
23
+ var self = $(this), notice = self.attr('data-response');
24
+ if ( 'given' === notice ) {
25
+ window.open('https://wordpress.org/support/plugin/webappick-product-feed-for-woocommerce/reviews/?rate=5#new-post', '_blank');
26
+ }
27
+ self.closest(".woo-feed-notice").slideUp( 200, 'linear' );
28
+ // noinspection JSUnresolvedVariable
29
+ wpAjax.post( 'woo_feed_save_review_notice', { _ajax_nonce: opts.nonce, notice: notice } );
30
+ })
31
+ .on('click', '.woo-feed-notice .notice-dismiss', function (e) {
32
+ e.preventDefault();
33
+ // noinspection ES6ConvertVarToLetConst
34
+ var self = $(this), feed_notice = self.closest('.woo-feed-notice'), which = feed_notice.attr('data-which');
35
+ // noinspection JSUnresolvedVariable
36
+ wpAjax.post( 'woo_feed_hide_notice', { _wpnonce: opts.nonce, which: which } );
37
+ });
38
+ }( jQuery, window, document, wp.ajax, wpf_ajax_obj ));
admin/js/woo-feed-admin.js CHANGED
@@ -474,22 +474,4 @@
474
  }
475
  });
476
  });
477
-
478
- $(document).on('click', '.woo-feed-notice ul li a', function (e) {
479
- e.preventDefault();
480
- // noinspection ES6ConvertVarToLetConst
481
- var self = $(this), notice = self.attr('data-response');
482
- if( notice === "given" ) {
483
- window.open('https://wordpress.org/support/plugin/webappick-product-feed-for-woocommerce/reviews/?rate=5#new-post','_blank');
484
- }
485
- self.closest( ".woo-feed-notice" ).slideUp( 200, "linear");
486
- // noinspection JSUnresolvedVariable
487
- wpAjax.post( 'woo_feed_save_review_notice', { _ajax_nonce: opts.nonce, notice: notice } );
488
- });
489
- $(document).on('click', '.woo-feed-notice .notice-dismiss', function (e) {
490
- e.preventDefault();
491
- // noinspection JSUnresolvedVariable
492
- var which = $(this).parent().data('which');
493
- which && wpAjax.post( 'woo_feed_hide_notice', { _wpnonce: opts.nonce, which: which, } );
494
- });
495
  }( jQuery, window, document, wp.ajax, wpf_ajax_obj ));
474
  }
475
  });
476
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
477
  }( jQuery, window, document, wp.ajax, wpf_ajax_obj ));
admin/partials/templates/facebook_add-feed.php CHANGED
@@ -635,15 +635,15 @@
635
  </select>
636
  <?php
637
  $url = site_url();
638
- $WABrand="";
639
  // Remove all illegal characters from a url
640
  $url = filter_var($url, FILTER_SANITIZE_URL);
641
  // Validate url
642
- if (filter_var($url, FILTER_VALIDATE_URL) !== false) {
643
- $url=parse_url($url);
644
- if(array_key_exists('host',$url)){
645
  $arr = explode('.',$url['host']);
646
- $WABrand = $arr[count($arr) - 2];
647
  }
648
  }
649
 
635
  </select>
636
  <?php
637
  $url = site_url();
638
+ $WABrand = "";
639
  // Remove all illegal characters from a url
640
  $url = filter_var($url, FILTER_SANITIZE_URL);
641
  // Validate url
642
+ if ( filter_var($url, FILTER_VALIDATE_URL) !== false ) {
643
+ $url = parse_url($url);
644
+ if ( array_key_exists('host',$url) ) {
645
  $arr = explode('.',$url['host']);
646
+ $WABrand = $arr[ count($arr) - 2 ];
647
  }
648
  }
649
 
admin/partials/templates/google_add-feed.php CHANGED
@@ -633,15 +633,15 @@
633
  </select>
634
  <?php
635
  $url = site_url();
636
- $WABrand="";
637
  // Remove all illegal characters from a url
638
  $url = filter_var($url, FILTER_SANITIZE_URL);
639
  // Validate url
640
- if (filter_var($url, FILTER_VALIDATE_URL) !== false) {
641
- $url=parse_url($url);
642
- if(array_key_exists('host',$url)){
643
  $arr = explode('.',$url['host']);
644
- $WABrand = $arr[count($arr) - 2];
645
  }
646
  }
647
 
633
  </select>
634
  <?php
635
  $url = site_url();
636
+ $WABrand = "";
637
  // Remove all illegal characters from a url
638
  $url = filter_var($url, FILTER_SANITIZE_URL);
639
  // Validate url
640
+ if ( filter_var($url, FILTER_VALIDATE_URL) !== false ) {
641
+ $url = parse_url($url);
642
+ if ( array_key_exists('host',$url) ) {
643
  $arr = explode('.',$url['host']);
644
+ $WABrand = $arr[ count($arr) - 2 ];
645
  }
646
  }
647
 
admin/partials/templates/pinterest_add-feed.php CHANGED
@@ -632,15 +632,15 @@
632
  </select>
633
  <?php
634
  $url = site_url();
635
- $WABrand="";
636
  // Remove all illegal characters from a url
637
  $url = filter_var($url, FILTER_SANITIZE_URL);
638
  // Validate url
639
- if (filter_var($url, FILTER_VALIDATE_URL) !== false) {
640
- $url=parse_url($url);
641
- if(array_key_exists('host',$url)){
642
  $arr = explode('.',$url['host']);
643
- $WABrand = $arr[count($arr) - 2];
644
  }
645
  }
646
 
632
  </select>
633
  <?php
634
  $url = site_url();
635
+ $WABrand = "";
636
  // Remove all illegal characters from a url
637
  $url = filter_var($url, FILTER_SANITIZE_URL);
638
  // Validate url
639
+ if ( filter_var($url, FILTER_VALIDATE_URL) !== false ) {
640
+ $url = parse_url($url);
641
+ if ( array_key_exists('host',$url) ) {
642
  $arr = explode('.',$url['host']);
643
+ $WABrand = $arr[ count($arr) - 2 ];
644
  }
645
  }
646
 
admin/partials/woo-feed-admin-display.php CHANGED
@@ -17,31 +17,31 @@ $page = $current_screen->id;
17
  $dropDown = new Woo_Feed_Dropdown();
18
  $wooFeedProduct = $product = new Woo_Feed_Products();
19
  $product->load_attributes();
20
- if( is_null( $feedRules ) ) {
21
  $feedRules = [
22
- 'provider' => '',
23
- 'ftporsftp' => 'ftp',
24
- 'filename' => '',
25
- 'feedType' => '',
26
- 'is_outOfStock' => 'n',
27
- 'is_variations' => 'n',
28
- 'variable_price' => 'first',
29
  'variable_quantity' => 'first',
30
- 'feedLanguage' => '',
31
- 'feedCurrency' => '',
32
- 'delimiter' => ',',
33
- 'enclosure' => 'double',
34
- 'extraHeader' => '',
35
  ];
36
  }
37
- if( $feedRules['provider'] == 'adroll' ) $feedRules['provider'] = 'google';
38
  register_and_do_woo_feed_meta_boxes( $current_screen, $feedRules );
39
  ?>
40
  <div class="wrap wapk-admin" id="Feed">
41
  <div class="wapk-section">
42
  <h1 class="wp-heading-inline"><?php _e('New WooCommerce Product Feed', 'woo-feed'); ?></h1>
43
  </div>
44
- <div class="wapk-section"><?php echo WPFFWMessage()->infoMessage1(); ?></div>
45
  <hr class="wp-header-end">
46
  <div class="wapk-section">
47
  <form action="" name="feed" id="generateFeed" class="generateFeed add-new" method="post" autocomplete="off">
17
  $dropDown = new Woo_Feed_Dropdown();
18
  $wooFeedProduct = $product = new Woo_Feed_Products();
19
  $product->load_attributes();
20
+ if ( is_null( $feedRules ) ) {
21
  $feedRules = [
22
+ 'provider' => '',
23
+ 'ftporsftp' => 'ftp',
24
+ 'filename' => '',
25
+ 'feedType' => '',
26
+ 'is_outOfStock' => 'n',
27
+ 'is_variations' => 'n',
28
+ 'variable_price' => 'first',
29
  'variable_quantity' => 'first',
30
+ 'feedLanguage' => '',
31
+ 'feedCurrency' => '',
32
+ 'delimiter' => ',',
33
+ 'enclosure' => 'double',
34
+ 'extraHeader' => '',
35
  ];
36
  }
37
+ if ( $feedRules['provider'] == 'adroll' ) $feedRules['provider'] = 'google';
38
  register_and_do_woo_feed_meta_boxes( $current_screen, $feedRules );
39
  ?>
40
  <div class="wrap wapk-admin" id="Feed">
41
  <div class="wapk-section">
42
  <h1 class="wp-heading-inline"><?php _e('New WooCommerce Product Feed', 'woo-feed'); ?></h1>
43
  </div>
44
+ <div class="wapk-section"><?php WPFFWMessage()->displayMessages(); ?></div>
45
  <hr class="wp-header-end">
46
  <div class="wapk-section">
47
  <form action="" name="feed" id="generateFeed" class="generateFeed add-new" method="post" autocomplete="off">
admin/partials/woo-feed-config.php CHANGED
@@ -12,104 +12,109 @@
12
  */
13
  $batch_limit = (int) get_option( 'woo_feed_per_batch', 200 );
14
  $queryType = get_option('woo_feed_product_query_type' );
15
- if( ! $queryType || ! in_array( $queryType, [ 'wc', 'wp', 'both' ] ) ) {
16
  $queryType = 'wc';
17
  }
18
  if ( ! $batch_limit || $batch_limit <= 0 ) {
19
  $batch_limit = 200;
20
  }
21
  ?>
22
- <div class="wrap">
23
- <h2><?php _e( 'Settings', 'woo-feed' ); ?></h2>
24
- <?php echo WPFFWMessage()->infoMessage1(); ?>
25
- <form action="" method="post" autocomplete="off">
26
- <?php wp_nonce_field( 'woo-feed-config' ); ?>
27
- <table class="widefat fixed" role="presentation">
28
- <thead>
29
- <tr>
30
- <th colspan="2"><b><?php _e( 'Common Settings', 'woo-feed' ); ?></b></th>
31
- </tr>
32
- </thead>
33
- <tbody>
34
- <?php do_action( 'woo_feed_before_settings_page_fields' ); ?>
35
- <tr>
36
- <th scope="row"><label for="batch_limit"><?php _e( 'Product per batch', 'woo-feed' ); ?></label></th>
37
- <td>
38
- <input class="regular-text" type="number" min="1" name="batch_limit" id="batch_limit" value="<?php echo esc_attr( $batch_limit ); ?>">
39
- <p class="description"><?php _e( 'Don\'t change the value if you are not sure about this. Plugin may fail to make feed.', 'woo-feed' ); ?></p>
40
- </td>
41
- </tr>
42
- <tr>
43
- <th scope="row"><label for="woo_feed_product_query_type"><?php _e( 'Product Query Type', 'woo-feed'); ?></label></th>
44
- <td>
45
- <select name="woo_feed_product_query_type" id="woo_feed_product_query_type">
46
- <option value="wc" <?php selected( $queryType, 'wc' ); ?> ><?php esc_html_e( 'WC_Product_Query', 'woo-feed' ); ?></option>
47
- <option value="wp" <?php selected( $queryType, 'wp' ); ?> ><?php esc_html_e( 'WP_Query', 'woo-feed' ); ?></option>
48
- <option value="both" <?php selected( $queryType, 'both' ); ?>><?php esc_html_e( 'Both', 'woo-feed' ); ?></option>
49
- </select>
50
- <p class="description"><?php _e( 'Don\'t change the value if you are not sure about this. Plugin may fail to make feed.', 'woo-feed' ); ?></p>
51
- </td>
52
- </tr>
53
- <?php
54
- /*
55
- <tr>
56
- <th scope="row"><label for="enable_error_debugging"><?php _e( 'Debug Mode', 'woo-feed' ); ?></label>
57
- </th>
58
- <td>
59
- <label for="enable_error_debugging">
60
- <input type="checkbox" name="enable_error_debugging" id="enable_error_debugging" value="on" <?php checked( woo_feed_is_debugging_enabled(), true ); ?> >
61
- <?php _e( 'Enable Logging', 'woo-feed' ); ?>
62
- </label>
63
- <p class="description"
64
- style="font-size: smaller;color: #ea3d3d;font-weight: bold;"><?php _e( 'Enabling Logging will decrease performance of feed generation.', 'woo-feed' ); ?></p>
65
- </td>
66
- </tr>
67
- <tr>
68
- <th scope="row"><label for="clear_all_logs"><?php _e( 'Clear Logs', 'woo-feed' ); ?></label></th>
69
- <td>
70
- <label for="clear_all_logs">
71
- <input type="checkbox" name="clear_all_logs" id="clear_all_logs" value="on">
72
- <?php _e( 'Clear All Log Data', 'woo-feed' ); ?>
73
- </label>
74
- <p class="description"
75
- style="font-size: smaller;color: #ea3d3d;font-weight: bold;"><?php _e( 'This will clear all log files generated by this plugin.', 'woo-feed' ); ?></p>
76
- </td>
77
- </tr>
78
- */
79
- ?>
80
- <tr>
81
- <td><label for="opt_in"><?php _e( 'Send Debug Info', 'woo-feed' ); ?></label></td>
82
- <td>
83
- <label for="opt_in">
84
- <input type="checkbox" name="opt_in" id="opt_in"
85
- value="on" <?php checked( WooFeedWebAppickAPI::getInstance()->is_tracking_allowed(),
86
- true ); ?>>
87
- <?php _e( 'Allow WooFeed To Collect Debug Info.', 'woo-feed' ); ?>
88
- </label>
89
- <p class="description"><?php
90
- _e( 'To opt out, leave this box unchecked. Your Feed Data remains un-tracked, and no data will be collected. No sensitive data is tracked.',
91
- 'woo-feed' );
92
- ?> <a href="#"
93
- data-toggle_slide=".tracker_collection_list"><?php esc_html_e( 'See What We Collect',
94
- 'webappick' ); ?></a>
95
- </p>
96
- <ul class="tracker_collection_list" style="display: none;">
97
- <li><?php echo implode( '</li><li>',
98
- WooFeedWebAppickAPI::getInstance()->get_data_collection_description() ); ?></li>
99
- </ul>
100
- </td>
101
- </tr>
102
- <?php do_action( 'woo_feed_after_settings_page_fields' ); ?>
103
- <tr>
104
- <td colspan="2">
105
- <p class="submit" style="text-align: center">
106
- <input type="submit" class="button button-primary" name="wa_woo_feed_config"
107
- value="<?php esc_attr_e( 'Save Changes', 'woo-feed' ); ?>">
108
- </p>
109
- </td>
110
- </tr>
111
- </tbody>
112
- </table>
113
- </form>
 
 
 
 
 
114
  </div>
115
 
12
  */
13
  $batch_limit = (int) get_option( 'woo_feed_per_batch', 200 );
14
  $queryType = get_option('woo_feed_product_query_type' );
15
+ if ( ! $queryType || ! in_array( $queryType, [ 'wc', 'wp', 'both' ] ) ) {
16
  $queryType = 'wc';
17
  }
18
  if ( ! $batch_limit || $batch_limit <= 0 ) {
19
  $batch_limit = 200;
20
  }
21
  ?>
22
+ <div class="wrap wapk-admin">
23
+ <div class="wapk-section">
24
+ <h1 class="wp-heading-inline"><?php _e( 'Settings', 'woo-feed' ); ?></h1>
25
+ </div>
26
+ <hr class="wp-header-end">
27
+ <div class="wapk-section"><?php WPFFWMessage()->displayMessages(); ?></div>
28
+ <div class="wapk-section">
29
+ <form action="" method="post" autocomplete="off">
30
+ <?php wp_nonce_field( 'woo-feed-config' ); ?>
31
+ <table class="widefat fixed" role="presentation">
32
+ <thead>
33
+ <tr>
34
+ <th colspan="2"><b><?php _e( 'Common Settings', 'woo-feed' ); ?></b></th>
35
+ </tr>
36
+ </thead>
37
+ <tbody>
38
+ <?php do_action( 'woo_feed_before_settings_page_fields' ); ?>
39
+ <tr>
40
+ <th scope="row"><label for="batch_limit"><?php _e( 'Product per batch', 'woo-feed' ); ?></label></th>
41
+ <td>
42
+ <input class="regular-text" type="number" min="1" name="batch_limit" id="batch_limit" value="<?php echo esc_attr( $batch_limit ); ?>">
43
+ <p class="description"><?php _e( 'Don\'t change the value if you are not sure about this. Plugin may fail to make feed.', 'woo-feed' ); ?></p>
44
+ </td>
45
+ </tr>
46
+ <tr>
47
+ <th scope="row"><label for="woo_feed_product_query_type"><?php _e( 'Product Query Type', 'woo-feed'); ?></label></th>
48
+ <td>
49
+ <select name="woo_feed_product_query_type" id="woo_feed_product_query_type">
50
+ <option value="wc" <?php selected( $queryType, 'wc' ); ?> ><?php esc_html_e( 'WC_Product_Query', 'woo-feed' ); ?></option>
51
+ <option value="wp" <?php selected( $queryType, 'wp' ); ?> ><?php esc_html_e( 'WP_Query', 'woo-feed' ); ?></option>
52
+ <option value="both" <?php selected( $queryType, 'both' ); ?>><?php esc_html_e( 'Both', 'woo-feed' ); ?></option>
53
+ </select>
54
+ <p class="description"><?php _e( 'Don\'t change the value if you are not sure about this. Plugin may fail to make feed.', 'woo-feed' ); ?></p>
55
+ </td>
56
+ </tr>
57
+ <?php
58
+ /*
59
+ <tr>
60
+ <th scope="row"><label for="enable_error_debugging"><?php _e( 'Debug Mode', 'woo-feed' ); ?></label>
61
+ </th>
62
+ <td>
63
+ <label for="enable_error_debugging">
64
+ <input type="checkbox" name="enable_error_debugging" id="enable_error_debugging" value="on" <?php checked( woo_feed_is_debugging_enabled(), true ); ?> >
65
+ <?php _e( 'Enable Logging', 'woo-feed' ); ?>
66
+ </label>
67
+ <p class="description"
68
+ style="font-size: smaller;color: #ea3d3d;font-weight: bold;"><?php _e( 'Enabling Logging will decrease performance of feed generation.', 'woo-feed' ); ?></p>
69
+ </td>
70
+ </tr>
71
+ <tr>
72
+ <th scope="row"><label for="clear_all_logs"><?php _e( 'Clear Logs', 'woo-feed' ); ?></label></th>
73
+ <td>
74
+ <label for="clear_all_logs">
75
+ <input type="checkbox" name="clear_all_logs" id="clear_all_logs" value="on">
76
+ <?php _e( 'Clear All Log Data', 'woo-feed' ); ?>
77
+ </label>
78
+ <p class="description"
79
+ style="font-size: smaller;color: #ea3d3d;font-weight: bold;"><?php _e( 'This will clear all log files generated by this plugin.', 'woo-feed' ); ?></p>
80
+ </td>
81
+ </tr>
82
+ */
83
+ ?>
84
+ <tr>
85
+ <td><label for="opt_in"><?php _e( 'Send Debug Info', 'woo-feed' ); ?></label></td>
86
+ <td>
87
+ <label for="opt_in">
88
+ <input type="checkbox" name="opt_in" id="opt_in"
89
+ value="on" <?php checked( WooFeedWebAppickAPI::getInstance()->is_tracking_allowed(),
90
+ true ); ?>>
91
+ <?php _e( 'Allow WooFeed To Collect Debug Info.', 'woo-feed' ); ?>
92
+ </label>
93
+ <p class="description"><?php
94
+ _e( 'To opt out, leave this box unchecked. Your Feed Data remains un-tracked, and no data will be collected. No sensitive data is tracked.',
95
+ 'woo-feed' );
96
+ ?> <a href="#"
97
+ data-toggle_slide=".tracker_collection_list"><?php esc_html_e( 'See What We Collect',
98
+ 'webappick' ); ?></a>
99
+ </p>
100
+ <ul class="tracker_collection_list" style="display: none;">
101
+ <li><?php echo implode( '</li><li>',
102
+ WooFeedWebAppickAPI::getInstance()->get_data_collection_description() ); ?></li>
103
+ </ul>
104
+ </td>
105
+ </tr>
106
+ <?php do_action( 'woo_feed_after_settings_page_fields' ); ?>
107
+ <tr>
108
+ <td colspan="2">
109
+ <p class="submit" style="text-align: center">
110
+ <input type="submit" class="button button-primary" name="wa_woo_feed_config"
111
+ value="<?php esc_attr_e( 'Save Changes', 'woo-feed' ); ?>">
112
+ </p>
113
+ </td>
114
+ </tr>
115
+ </tbody>
116
+ </table>
117
+ </form>
118
+ </div>
119
  </div>
120
 
admin/partials/woo-feed-content-settings.php CHANGED
@@ -8,7 +8,7 @@
8
  * @author KD <mhamudul.hk@gmail.com>
9
  * @copyright 2019 WebAppick <support@webappick.com>
10
  */
11
- if( ! defined( 'ABSPATH' ) ) die(); // silence
12
  /**
13
  * @global array $feedRules
14
  * @global Woo_Feed_Dropdown $dropDown
@@ -16,8 +16,8 @@ if( ! defined( 'ABSPATH' ) ) die(); // silence
16
  */
17
  global $feedRules, $dropDown, $wooFeedProduct;
18
 
19
- if( empty( $feedRules['feedLanguage'] ) ) $feedRules['feedLanguage'] = apply_filters('wpml_current_language', NULL);
20
- if( empty( $feedRules['feedCurrency'] ) ) $feedRules['feedCurrency'] = get_woocommerce_currency();
21
 
22
 
23
  ?>
@@ -48,7 +48,11 @@ if( empty( $feedRules['feedCurrency'] ) ) $feedRules['feedCurrency'] = get_wooco
48
  <select name="feedType" id="feedType" class="generalInput" required>
49
  <option value=""></option>
50
  <?php
51
- $feedTypes = [ 'xml' => 'XML', 'csv' => 'CSV', 'txt' => 'TXT', ];
 
 
 
 
52
  foreach ( $feedTypes as $type => $label ) {
53
  /** @noinspection HtmlUnknownAttribute */
54
  printf( '<option value="%1$s" %3$s>%2$s</option>', esc_attr( $type ), esc_html( $label ), selected( $feedRules['feedType'], $type, false ) );
@@ -70,24 +74,31 @@ if( empty( $feedRules['feedCurrency'] ) ) $feedRules['feedCurrency'] = get_wooco
70
  <input name="itemWrapper" id="itemWrapper" type="text" value="<?php echo ($feedRules['feedType'] == "xml") && isset($feedRules['itemWrapper']) ? esc_attr($feedRules['itemWrapper']) : 'product'; ?>" class="generalInput" required="required"/>
71
  </td>
72
  </tr>
73
- <tr class="itemWrapper" >
74
- <th><label for="extraHeader"><?php _e('Extra Header', 'woo-feed'); ?> </label></th>
 
 
75
  <td>
76
- <textarea name="extraHeader" id="extraHeader" style="width: 100%" placeholder="Insert Extra Header value. Press enter at the end of each line." rows="3"><?php echo isset($feedRules['extraHeader']) ? $feedRules['extraHeader'] : ''; ?></textarea>
 
 
 
77
  </td>
78
  </tr>
 
 
79
  <tr class="wf_csvtxt" style="display: none;">
80
  <th><label for="delimiter"><?php _e('Delimiter', 'woo-feed'); ?> <span class="requiredIn">*</span></label></th>
81
  <td>
82
  <select name="delimiter" id="delimiter" class="generalInput">
83
  <?php
84
  $delimiters = [
85
- ',' => 'Comma',
86
  'tab' => 'Tab',
87
- ':' => 'Colon',
88
- ' ' => 'Space',
89
- '|' => 'Pipe',
90
- ';' => 'Semi Colon',
91
  ];
92
  foreach ( $delimiters as $k => $v ) {
93
  /** @noinspection HtmlUnknownAttribute */
@@ -105,7 +116,7 @@ if( empty( $feedRules['feedCurrency'] ) ) $feedRules['feedCurrency'] = get_wooco
105
  $enclosures = [
106
  'double' => '"',
107
  'single' => '\'',
108
- ' ' => 'None',
109
  ];
110
  foreach ( $enclosures as $k => $v ) {
111
  /** @noinspection HtmlUnknownAttribute */
8
  * @author KD <mhamudul.hk@gmail.com>
9
  * @copyright 2019 WebAppick <support@webappick.com>
10
  */
11
+ if ( ! defined( 'ABSPATH' ) ) die(); // silence
12
  /**
13
  * @global array $feedRules
14
  * @global Woo_Feed_Dropdown $dropDown
16
  */
17
  global $feedRules, $dropDown, $wooFeedProduct;
18
 
19
+ if ( empty( $feedRules['feedLanguage'] ) ) $feedRules['feedLanguage'] = apply_filters('wpml_current_language', NULL);
20
+ if ( empty( $feedRules['feedCurrency'] ) ) $feedRules['feedCurrency'] = get_woocommerce_currency();
21
 
22
 
23
  ?>
48
  <select name="feedType" id="feedType" class="generalInput" required>
49
  <option value=""></option>
50
  <?php
51
+ $feedTypes = [
52
+ 'xml' => 'XML',
53
+ 'csv' => 'CSV',
54
+ 'txt' => 'TXT',
55
+ ];
56
  foreach ( $feedTypes as $type => $label ) {
57
  /** @noinspection HtmlUnknownAttribute */
58
  printf( '<option value="%1$s" %3$s>%2$s</option>', esc_attr( $type ), esc_html( $label ), selected( $feedRules['feedType'], $type, false ) );
74
  <input name="itemWrapper" id="itemWrapper" type="text" value="<?php echo ($feedRules['feedType'] == "xml") && isset($feedRules['itemWrapper']) ? esc_attr($feedRules['itemWrapper']) : 'product'; ?>" class="generalInput" required="required"/>
75
  </td>
76
  </tr>
77
+ <?php
78
+ /*
79
+ <tr class="itemWrapper" style="display: none;">
80
+ <th><label for="extraHeader"><?php _e( 'Extra Header', 'woo-feed' ); ?> </label></th>
81
  <td>
82
+ <textarea name="extraHeader" id="extraHeader" style="width: 100%" placeholder="<?php esc_html_e( 'Insert Extra Header value. Press enter at the end of each line.', 'woo-feed' ); ?>" rows="3"><?php
83
+ // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
84
+ echo isset( $feedRules['extraHeader'] ) ? $feedRules['extraHeader'] : '';
85
+ ?></textarea>
86
  </td>
87
  </tr>
88
+ */
89
+ ?>
90
  <tr class="wf_csvtxt" style="display: none;">
91
  <th><label for="delimiter"><?php _e('Delimiter', 'woo-feed'); ?> <span class="requiredIn">*</span></label></th>
92
  <td>
93
  <select name="delimiter" id="delimiter" class="generalInput">
94
  <?php
95
  $delimiters = [
96
+ ',' => 'Comma',
97
  'tab' => 'Tab',
98
+ ':' => 'Colon',
99
+ ' ' => 'Space',
100
+ '|' => 'Pipe',
101
+ ';' => 'Semi Colon',
102
  ];
103
  foreach ( $delimiters as $k => $v ) {
104
  /** @noinspection HtmlUnknownAttribute */
116
  $enclosures = [
117
  'double' => '"',
118
  'single' => '\'',
119
+ ' ' => 'None',
120
  ];
121
  foreach ( $enclosures as $k => $v ) {
122
  /** @noinspection HtmlUnknownAttribute */
admin/partials/woo-feed-edit-template.php CHANGED
@@ -16,11 +16,11 @@ $dropDown = new Woo_Feed_Dropdown();
16
  $wooFeedProduct = $product = new Woo_Feed_Products();
17
  $product->load_attributes();
18
  # Condition is for those merchants which support another merchant feed requirements.
19
- if($feedRules['provider']=='adroll'){
20
- $feedRules['provider']='google';
21
  }
22
- if(!isset($feedRules['ftporsftp'])){
23
- $feedRules['ftporsftp']="ftp";
24
  }
25
  $AttributesDropdown = $feedRules['provider'] . "AttributesDropdown";
26
  register_and_do_woo_feed_meta_boxes( $current_screen, $feedRules );
@@ -30,7 +30,7 @@ register_and_do_woo_feed_meta_boxes( $current_screen, $feedRules );
30
  <div class="wapk-section">
31
  <h2><?php _e('Edit WooCommerce Product Feed', 'woo-feed'); ?></h2>
32
  </div>
33
- <div class="wapk-section"><?php echo WPFFWMessage()->infoMessage1(); ?></div>
34
  <div class="wapk-section">
35
  <form action="" name="feed" id="updatefeed" class="generateFeed" method="post" autocomplete="off">
36
  <input type="hidden" name="original_feed_name" value="<?php echo esc_attr( str_replace( [ 'wf_feed_', 'wf_config' ], '', $fname ) ); ?>">
@@ -82,7 +82,7 @@ register_and_do_woo_feed_meta_boxes( $current_screen, $feedRules );
82
  $outputType = $feedRules['output_type'];
83
  $limit = $feedRules['limit'];
84
  $counter = 0;
85
- foreach ($mAttributes as $merchant => $mAttribute) {
86
  ?>
87
  <tr>
88
 
@@ -90,7 +90,7 @@ register_and_do_woo_feed_meta_boxes( $current_screen, $feedRules );
90
  <i class="wf_sortedtable dashicons dashicons-menu"></i>
91
  </td>
92
  <td>
93
- <?php if (method_exists($dropDown, $AttributesDropdown)) { ?>
94
  <select name="mattributes[]" class="wf_mattributes">
95
  <?php echo $dropDown->$AttributesDropdown(esc_attr($mAttribute)); ?>
96
  </select>
@@ -102,40 +102,40 @@ register_and_do_woo_feed_meta_boxes( $current_screen, $feedRules );
102
  <?php } ?>
103
  </td>
104
  <td>
105
- <input type="text" name="prefix[]" value="<?php echo stripslashes($prefix[$merchant]); ?>" autocomplete="off" class="wf_ps"/>
106
  </td>
107
  <td>
108
  <select name="type[]" class="attr_type wfnoempty">
109
- <option <?php echo ($type[$merchant] == "attribute") ? 'selected="selected"' : ''; ?>value="attribute"><?php _e('Attribute', 'woo-feed'); ?></option>
110
- <option <?php echo ($type[$merchant] == "pattern") ? 'selected="selected"' : ''; ?>value="pattern"><?php _e('Pattern', 'woo-feed'); ?></option>
111
  </select>
112
  </td>
113
  <td>
114
- <select <?php echo ($type[$merchant] == "attribute") ? '' : 'style=" display: none;" '; ?>name="attributes[]" class="wf_attr wf_attributes">
115
- <?php echo $product->attributeDropdown(esc_attr($wooAttributes[$merchant])); ?>
116
  </select>
117
- <?php if( in_array( $feedRules['provider'], array( 'google', 'facebook', 'pinterest') ) && $mAttribute=="current_category") { ?>
118
- <span <?php echo ($type[$merchant] == "pattern") ? '' : 'style=" display: none;"'; ?>class="wf_default wf_attributes">
119
  <select name="default[]" class="selectize">
120
- <?php echo $dropDown->googleTaxonomy( esc_attr($default[$merchant]) ); ?>
121
  </select>
122
  </span>
123
  <span style="font-size:x-small;"><a style="color: red" href="http://webappick.helpscoutdocs.com/article/19-how-to-map-store-category-with-merchant-category" target="_blank">Learn More..</a></span>
124
- <?php }else{ ?>
125
- <input <?php echo ($type[$merchant] == "pattern") ? '' : 'style=" display: none;"'; ?>autocomplete="off" class="wf_default wf_attributes " type="text" name="default[]" value="<?php echo esc_attr( $default[$merchant] ); ?>"/>
126
  <?php } ?>
127
  </td>
128
  <td>
129
- <input type="text" name="suffix[]" value="<?php echo stripslashes($suffix[$merchant]); ?>" autocomplete="off" class="wf_ps"/>
130
  </td>
131
  <td>
132
- <select name="output_type[<?php echo $counter; ?>][]" class="outputType wfnoempty" <?php echo ( isset( $outputType[$counter] ) && is_array( $outputType[$counter] ) && count($outputType[$counter]) > 1) ? 'multiple="multiple"' : ''; ?>><?php
133
  foreach ( woo_feed_get_field_output_type_options() as $key => $option ) {
134
- if ( isset( $outputType[$counter] ) ) {
135
- if ( is_array( $outputType[$counter] ) ) {
136
- $selected = selected( in_array( $key, $outputType[$counter] ), true, false );
137
  } else {
138
- $selected = selected( $outputType[$counter], $key, false );
139
  }
140
  } else $selected = selected( '1', $key, false );
141
  printf( '<option value="%s"%s>%s</option>', $key, $selected, $option );
@@ -145,7 +145,7 @@ register_and_do_woo_feed_meta_boxes( $current_screen, $feedRules );
145
  <i style="display: none;" class="dashicons dashicons-editor-contract contractType"></i>
146
  </td>
147
  <td>
148
- <input type="text" name="limit[]" value="<?php echo esc_attr($limit[$merchant]); ?>" autocomplete="off" class="wf_ps"/>
149
  </td>
150
  <td>
151
  <i class="delRow dashicons dashicons-trash"></i>
@@ -192,7 +192,7 @@ register_and_do_woo_feed_meta_boxes( $current_screen, $feedRules );
192
 
193
  <div id="wf-tab-content3" class="wf-tab-content">
194
  <table class="table widefat fixed mtable" width="100%">
195
- <?php if( ! checkFTP_connection() && ! checkSFTP_connection() ) { ?>
196
  <tbody>
197
  <tr>
198
  <th><?php esc_attr_e( 'FTP/SFTP module is not found in your server. Please contact your service provider or system administrator to install/enable FTP/SFTP module.', 'woo-feed' ); ?></th>
@@ -240,7 +240,7 @@ register_and_do_woo_feed_meta_boxes( $current_screen, $feedRules );
240
  </tr>
241
  <tr>
242
  <td><?php _e('Port', 'woo-feed'); ?></td>
243
- <td><input type="text" value="<?php echo isset($feedRules['ftpport'])?esc_attr($feedRules['ftpport']):21; ?>"
244
  name="ftpport" autocomplete="off"/></td>
245
  </tr>
246
  <tr>
16
  $wooFeedProduct = $product = new Woo_Feed_Products();
17
  $product->load_attributes();
18
  # Condition is for those merchants which support another merchant feed requirements.
19
+ if ( $feedRules['provider'] == 'adroll' ) {
20
+ $feedRules['provider'] = 'google';
21
  }
22
+ if ( ! isset($feedRules['ftporsftp']) ) {
23
+ $feedRules['ftporsftp'] = "ftp";
24
  }
25
  $AttributesDropdown = $feedRules['provider'] . "AttributesDropdown";
26
  register_and_do_woo_feed_meta_boxes( $current_screen, $feedRules );
30
  <div class="wapk-section">
31
  <h2><?php _e('Edit WooCommerce Product Feed', 'woo-feed'); ?></h2>
32
  </div>
33
+ <div class="wapk-section"><?php WPFFWMessage()->displayMessages(); ?></div>
34
  <div class="wapk-section">
35
  <form action="" name="feed" id="updatefeed" class="generateFeed" method="post" autocomplete="off">
36
  <input type="hidden" name="original_feed_name" value="<?php echo esc_attr( str_replace( [ 'wf_feed_', 'wf_config' ], '', $fname ) ); ?>">
82
  $outputType = $feedRules['output_type'];
83
  $limit = $feedRules['limit'];
84
  $counter = 0;
85
+ foreach ( $mAttributes as $merchant => $mAttribute ) {
86
  ?>
87
  <tr>
88
 
90
  <i class="wf_sortedtable dashicons dashicons-menu"></i>
91
  </td>
92
  <td>
93
+ <?php if ( method_exists($dropDown, $AttributesDropdown) ) { ?>
94
  <select name="mattributes[]" class="wf_mattributes">
95
  <?php echo $dropDown->$AttributesDropdown(esc_attr($mAttribute)); ?>
96
  </select>
102
  <?php } ?>
103
  </td>
104
  <td>
105
+ <input type="text" name="prefix[]" value="<?php echo stripslashes($prefix[ $merchant ]); ?>" autocomplete="off" class="wf_ps"/>
106
  </td>
107
  <td>
108
  <select name="type[]" class="attr_type wfnoempty">
109
+ <option <?php echo ($type[ $merchant ] == "attribute") ? 'selected="selected"' : ''; ?>value="attribute"><?php _e('Attribute', 'woo-feed'); ?></option>
110
+ <option <?php echo ($type[ $merchant ] == "pattern") ? 'selected="selected"' : ''; ?>value="pattern"><?php _e('Pattern', 'woo-feed'); ?></option>
111
  </select>
112
  </td>
113
  <td>
114
+ <select <?php echo ($type[ $merchant ] == "attribute") ? '' : 'style=" display: none;" '; ?>name="attributes[]" class="wf_attr wf_attributes">
115
+ <?php echo $product->attributeDropdown(esc_attr($wooAttributes[ $merchant ])); ?>
116
  </select>
117
+ <?php if ( in_array( $feedRules['provider'], array( 'google', 'facebook', 'pinterest' ) ) && $mAttribute == "current_category" ) { ?>
118
+ <span <?php echo ($type[ $merchant ] == "pattern") ? '' : 'style=" display: none;"'; ?>class="wf_default wf_attributes">
119
  <select name="default[]" class="selectize">
120
+ <?php echo $dropDown->googleTaxonomy( esc_attr($default[ $merchant ]) ); ?>
121
  </select>
122
  </span>
123
  <span style="font-size:x-small;"><a style="color: red" href="http://webappick.helpscoutdocs.com/article/19-how-to-map-store-category-with-merchant-category" target="_blank">Learn More..</a></span>
124
+ <?php }else { ?>
125
+ <input <?php echo ($type[ $merchant ] == "pattern") ? '' : 'style=" display: none;"'; ?>autocomplete="off" class="wf_default wf_attributes " type="text" name="default[]" value="<?php echo esc_attr( $default[ $merchant ] ); ?>"/>
126
  <?php } ?>
127
  </td>
128
  <td>
129
+ <input type="text" name="suffix[]" value="<?php echo stripslashes($suffix[ $merchant ]); ?>" autocomplete="off" class="wf_ps"/>
130
  </td>
131
  <td>
132
+ <select name="output_type[<?php echo $counter; ?>][]" class="outputType wfnoempty" <?php echo ( isset( $outputType[ $counter ] ) && is_array( $outputType[ $counter ] ) && count($outputType[ $counter ]) > 1) ? 'multiple="multiple"' : ''; ?>><?php
133
  foreach ( woo_feed_get_field_output_type_options() as $key => $option ) {
134
+ if ( isset( $outputType[ $counter ] ) ) {
135
+ if ( is_array( $outputType[ $counter ] ) ) {
136
+ $selected = selected( in_array( $key, $outputType[ $counter ] ), true, false );
137
  } else {
138
+ $selected = selected( $outputType[ $counter ], $key, false );
139
  }
140
  } else $selected = selected( '1', $key, false );
141
  printf( '<option value="%s"%s>%s</option>', $key, $selected, $option );
145
  <i style="display: none;" class="dashicons dashicons-editor-contract contractType"></i>
146
  </td>
147
  <td>
148
+ <input type="text" name="limit[]" value="<?php echo esc_attr($limit[ $merchant ]); ?>" autocomplete="off" class="wf_ps"/>
149
  </td>
150
  <td>
151
  <i class="delRow dashicons dashicons-trash"></i>
192
 
193
  <div id="wf-tab-content3" class="wf-tab-content">
194
  <table class="table widefat fixed mtable" width="100%">
195
+ <?php if ( ! checkFTP_connection() && ! checkSFTP_connection() ) { ?>
196
  <tbody>
197
  <tr>
198
  <th><?php esc_attr_e( 'FTP/SFTP module is not found in your server. Please contact your service provider or system administrator to install/enable FTP/SFTP module.', 'woo-feed' ); ?></th>
240
  </tr>
241
  <tr>
242
  <td><?php _e('Port', 'woo-feed'); ?></td>
243
+ <td><input type="text" value="<?php echo isset($feedRules['ftpport']) ? esc_attr($feedRules['ftpport']) : 21; ?>"
244
  name="ftpport" autocomplete="off"/></td>
245
  </tr>
246
  <tr>
admin/partials/woo-feed-ftp-sftp-template.php CHANGED
@@ -4,7 +4,7 @@
4
 
5
  <div id="wf-tab-content3" class="wf-tab-content">
6
  <table class="table widefat fixed mtable" width="100%">
7
- <?php if( ! checkFTP_connection() && ! checkSFTP_connection() ) { ?>
8
  <tbody>
9
  <tr>
10
  <th><?php esc_attr_e( 'FTP/SFTP module is not found in your server. Please contact your service provider or system administrator to install/enable FTP/SFTP module.', 'woo-feed' ); ?></th>
4
 
5
  <div id="wf-tab-content3" class="wf-tab-content">
6
  <table class="table widefat fixed mtable" width="100%">
7
+ <?php if ( ! checkFTP_connection() && ! checkSFTP_connection() ) { ?>
8
  <tbody>
9
  <tr>
10
  <th><?php esc_attr_e( 'FTP/SFTP module is not found in your server. Please contact your service provider or system administrator to install/enable FTP/SFTP module.', 'woo-feed' ); ?></th>
admin/partials/woo-feed-manage-list.php CHANGED
@@ -10,124 +10,35 @@
10
  * @author Ohidul Islam <wahid@webappick.com>
11
  */
12
  $myListTable = new Woo_Feed_Manage_list();
 
13
  $limit = get_option( "woo_feed_per_batch", 200 );
14
  $fileName = '';
15
  $message = [];
16
  global $regenerating, $regeneratingName;
17
  $regenerating = false;
18
- if( ( isset( $_GET['feed_updated'] ) || isset( $_GET['feed_created'] ) ) && isset( $_GET['feed_regenerate'], $_GET['feed_name'] ) ) {
19
- $canBeRegenerated = false;
20
- if( isset( $_GET['feed_created'] ) ) {
21
- $message[] = [
22
- 'notice' => esc_html__( 'Feed Config Created Successfully.', 'woo-feed' ),
23
- 'type' => 'success',
24
- 'dismissible' => true,
25
- ];
26
- $canBeRegenerated = true;
27
- }
28
- if( isset( $_GET['feed_updated'] ) ) {
29
- $message[] = [
30
- 'notice' => esc_html__( 'Feed Config Updated Successfully.', 'woo-feed' ),
31
- 'type' => 'updated',
32
- 'dismissible' => true,
33
- ];
34
- $canBeRegenerated = true;
35
- }
36
- if( $canBeRegenerated && $_GET['feed_regenerate'] == 1 ) {
37
- // filename must be wf_config+xxxx format
38
- $fileName = sanitize_text_field( $_GET['feed_name'] ); //trigger feed regenerate...
39
- $fileName = str_replace( [ 'wf_feed_', 'wf_config' ], '', $fileName );
40
- $regeneratingName = $fileName;
41
- $fileName = 'wf_config' . $fileName; // to be safe...
42
- $regenerating = true;
43
- }
44
- }
45
- // schedule updated
46
- if( isset( $_GET['schedule_updated'] ) && ! empty( $_GET['schedule_updated'] ) ) {
47
- if( $_GET['schedule_updated'] == 1 ) {
48
- $message[] = [
49
- 'notice' => esc_html__( 'Feed auto update interval updated.', 'woo-feed' ),
50
- 'type' => 'updated',
51
- 'dismissible' => true,
52
- ];
53
- }
54
- if( $_GET['schedule_updated'] == 2 ) {
55
- $message[] = [
56
- 'notice' => esc_html__( 'Unable to save auto update interval.', 'woo-feed' ),
57
- 'type' => 'warning',
58
- 'dismissible' => true,
59
- ];
60
- }
61
- if( $_GET['schedule_updated'] == 3 ) {
62
- $message[] = [
63
- 'notice' => esc_html__( 'Invalid interval value.', 'woo-feed' ),
64
- 'type' => 'error',
65
- 'dismissible' => true,
66
- ];
67
- }
68
- if( $_GET['schedule_updated'] == 4 ) {
69
- $message[] = [
70
- 'notice' => esc_html__( 'Invalid request.', 'woo-feed' ),
71
- 'type' => 'error',
72
- 'dismissible' => true,
73
- ];
74
- }
75
- }
76
- // get updated link
77
- if( isset( $_GET['link'] ) && ! empty( $_GET['link'] ) ) {
78
- $link = filter_input( INPUT_GET, 'link', FILTER_VALIDATE_URL );
79
- /**
80
- * @TODO use session/cookies/localstorage or transient api for this message
81
- * @see settings_errors()
82
- */
83
- if( isset( $link ) && ! empty( $link ) ) {
84
- /** @noinspection HtmlUnknownTarget */
85
- $link = sprintf( '<a href="%1$s" target="_blank">%1$s</a>', esc_url( $link ) );
86
- $notice = sprintf( esc_html__( 'Feed Generated Successfully. Feed URL: %s', 'woo-feed' ), $link );
87
- $notice = '<b style="color: #008779;">' . $notice . '</b>';
88
- if ( isset( $_GET['cat'] ) && $_GET['cat'] == 'no' ) {
89
- $notice .= sprintf( '<br/><br/><b style="color: #f49242;">%s</b>', esc_html__( 'Warning:', 'woo-feed' ) );
90
- $link = 'https://webappick.helpscoutdocs.com/article/19-how-to-map-store-category-with-merchant-category';
91
- $link = sprintf( '<a href="%s" target="_blank">%s</a>', esc_url( $link ), esc_html__( 'Learn more...', 'woo-feed' ) );
92
- $notice .= sprintf( '<ul><li>%s %s</li></ul>', esc_html__( 'Google Product category is not selected. Your AdWords CPC rate will be high. Add proper Google Product Category to each product & reduce CPC rate.', 'woo-feed' ), $link );
93
- }
94
- $message[] = [
95
- 'notice' => $notice,
96
- 'type' => 'updated',
97
- 'dismissible' => true,
98
- ];
99
- }
100
- }
101
- // get error messages
102
- if ( isset( $_GET['wpf_message'] ) && ! empty( $_GET['wpf_message'] ) ) {
103
- $type = sanitize_text_field( $_GET['wpf_message'] );
104
- $error = esc_html( get_option('wpf_message') );
105
- delete_option( 'wpf_message' ); // empty message cache
106
- if( $dir = get_option("WPF_DIRECTORY_PERMISSION_CHECK", false ) ) {
107
- $error .= ' ' . esc_html( $dir );
108
- delete_option( 'WPF_DIRECTORY_PERMISSION_CHECK' ); // empty message cache
109
- }
110
- $error = trim( $error );
111
- if( ! empty( $error ) ) {
112
- $message[] = [
113
- 'notice' => $error,
114
- 'type' => $type,
115
- 'dismissible' => true,
116
- ];
117
- }
118
  }
 
119
  # Checking woo version to run different version of feed processing
120
  $woo32 = "no";
121
- if (woo_feed_wc_version_check(3.2)) {
122
  $woo32 = 'yes';
123
  }
124
  ?>
125
  <div class="wrap wapk-admin">
126
  <div class="wapk-section">
127
  <h1 class="wp-heading-inline"><?php _e('Manage Feed', 'woo-feed'); ?></h1>
128
- <a href="<?php echo admin_url('admin.php?page=webappick-new-feed'); ?>" class="page-title-action"><?php _e('New Feed', 'woo-feed'); ?></a>
129
  <hr class="wp-header-end">
130
- <?php echo WPFFWMessage()->infoMessage1(); ?>
131
  <div id="feed_progress_table" style="display: none;">
132
  <table class="table widefat fixed">
133
  <thead>
@@ -156,16 +67,6 @@ if (woo_feed_wc_version_check(3.2)) {
156
  </table>
157
  <br>
158
  </div>
159
- <?php
160
- if( ! empty( $message ) ) {
161
- foreach ( $message as $notice ) {
162
- if( ! isset( $notice['notice'] ) || ! isset( $notice['type'] ) ) {continue;}
163
- $isDismissible = isset( $notice['dismissible'] ) && $notice['dismissible'] == true ? ' is-dismissible' : '';
164
- printf( '<div class="notice notice-%1$s %1$s%3$s"><p>%2$s</p></div>', $notice['type'], $notice['notice'], $isDismissible );
165
- }
166
- }
167
- $myListTable->prepare_items();
168
- ?>
169
  <table class=" widefat fixed">
170
  <thead>
171
  <tr>
@@ -180,7 +81,7 @@ if (woo_feed_wc_version_check(3.2)) {
180
  <label for="wf_schedule"><b><?php esc_html_e( 'Interval', 'woo-feed' ); ?></b></label>
181
  <select name="wf_schedule" id="wf_schedule"><?php
182
  $interval = get_option('wf_schedule');
183
- foreach( woo_feed_get_schedule_interval_options() as $k=>$v ) {
184
  printf( '<option value="%s" %s>%s</option>', $k, selected( $interval, $k, false ), $v );
185
  }
186
  ?></select>
@@ -230,7 +131,7 @@ if (woo_feed_wc_version_check(3.2)) {
230
  },
231
  isRegenerating = false,
232
  regenerateBtn = $( '.wpf_regenerate' ),
233
- fileName = "<?php echo isset( $fileName )? $fileName : ''; ?>", // wf_config+xxxx
234
  limit = <?php echo ( $limit ) ? $limit : 200; ?>;
235
  let woo32 = "<?php echo $woo32; ?>";
236
  // feed delete alert
10
  * @author Ohidul Islam <wahid@webappick.com>
11
  */
12
  $myListTable = new Woo_Feed_Manage_list();
13
+ $myListTable->prepare_items();
14
  $limit = get_option( "woo_feed_per_batch", 200 );
15
  $fileName = '';
16
  $message = [];
17
  global $regenerating, $regeneratingName;
18
  $regenerating = false;
19
+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended
20
+ if ( ( isset( $_GET['feed_created'] ) || isset( $_GET['feed_updated'] ) ) && isset( $_GET['feed_regenerate'] ) && 1 == $_GET['feed_regenerate'] ) {
21
+ // filename must be wf_config+XXX format
22
+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended
23
+ $fileName = isset( $_GET['feed_name'] ) && ! empty( $_GET['feed_name']) ? sanitize_text_field( $_GET['feed_name'] ) : ''; // trigger feed regenerate...
24
+ $fileName = str_replace( array( 'wf_feed_', 'wf_config' ), '', $fileName );
25
+ $regeneratingName = $fileName;
26
+ $fileName = 'wf_config' . $fileName; // to be safe...
27
+ $regenerating = true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  }
29
+
30
  # Checking woo version to run different version of feed processing
31
  $woo32 = "no";
32
+ if ( woo_feed_wc_version_check(3.2) ) {
33
  $woo32 = 'yes';
34
  }
35
  ?>
36
  <div class="wrap wapk-admin">
37
  <div class="wapk-section">
38
  <h1 class="wp-heading-inline"><?php _e('Manage Feed', 'woo-feed'); ?></h1>
39
+ <a href="<?php echo esc_url( admin_url('admin.php?page=webappick-new-feed') ); ?>" class="page-title-action"><?php _e('New Feed', 'woo-feed'); ?></a>
40
  <hr class="wp-header-end">
41
+ <?php WPFFWMessage()->displayMessages(); ?>
42
  <div id="feed_progress_table" style="display: none;">
43
  <table class="table widefat fixed">
44
  <thead>
67
  </table>
68
  <br>
69
  </div>
 
 
 
 
 
 
 
 
 
 
70
  <table class=" widefat fixed">
71
  <thead>
72
  <tr>
81
  <label for="wf_schedule"><b><?php esc_html_e( 'Interval', 'woo-feed' ); ?></b></label>
82
  <select name="wf_schedule" id="wf_schedule"><?php
83
  $interval = get_option('wf_schedule');
84
+ foreach ( woo_feed_get_schedule_interval_options() as $k => $v ) {
85
  printf( '<option value="%s" %s>%s</option>', $k, selected( $interval, $k, false ), $v );
86
  }
87
  ?></select>
131
  },
132
  isRegenerating = false,
133
  regenerateBtn = $( '.wpf_regenerate' ),
134
+ fileName = "<?php echo isset( $fileName ) ? $fileName : ''; ?>", // wf_config+xxxx
135
  limit = <?php echo ( $limit ) ? $limit : 200; ?>;
136
  let woo32 = "<?php echo $woo32; ?>";
137
  // feed delete alert
admin/partials/woo-feed-pro-vs-free.php CHANGED
@@ -10,63 +10,63 @@
10
  * @author Ohidul Islam <wahid@webappick.com>
11
  * @version 1.0.2
12
  */
13
- if( ! function_exists( 'add_action' ) ) die();
14
  // ### REF > utm parameters http://bit.ly/2KIwvTt
15
  $features = array(
16
  array(
17
- 'thumb' => esc_url( WOO_FEED_PLUGIN_URL ) . 'admin/images/features/smart-filter-conditions.svg',
18
- 'title' => 'Smart Filter & Conditions',
19
- 'description' => 'Exclude unwanted product from feed with the help of advanced filtration',
20
  ),
21
  array(
22
- 'thumb' => esc_url( WOO_FEED_PLUGIN_URL ) . 'admin/images/features/dynamic-attributes.svg',
23
- 'title' => 'Dynamic Attributes',
24
- 'description' => 'Make new attribute by combine multiple attributes with condition',
25
  ),
26
  array(
27
- 'thumb' => esc_url( WOO_FEED_PLUGIN_URL ) . 'admin/images/features/category-mapping.svg',
28
- 'title' => 'Category Mapping',
29
- 'description' => 'Automatically map product category with merchant category',
30
  ),
31
  array(
32
- 'thumb' => esc_url( WOO_FEED_PLUGIN_URL ) . 'admin/images/features/multilingual-feed.svg',
33
- 'title' => 'Multilingual Feed',
34
- 'description' => 'WPML Support for Multilingual Product Feed',
35
  ),
36
  array(
37
- 'thumb' => esc_url( WOO_FEED_PLUGIN_URL ) . 'admin/images/features/custom-taxonomy.svg',
38
- 'title' => 'Custom Taxonomy',
39
- 'description' => 'Use any taxonomies attached to the product',
40
  ),
41
  array(
42
- 'thumb' => esc_url( WOO_FEED_PLUGIN_URL ) . 'admin/images/features/product-title-customization.svg',
43
- 'title' => 'Product Title Customization',
44
- 'description' => 'Customize product title with different attributes',
45
  ),
46
  array(
47
- 'thumb' => esc_url( WOO_FEED_PLUGIN_URL ) . 'admin/images/features/conditional-pricing.svg',
48
- 'title' => 'Conditional Pricing',
49
- 'description' => 'Change Product Price display as per your need',
50
  ),
51
  array(
52
- 'thumb' => esc_url( WOO_FEED_PLUGIN_URL ) . 'admin/images/features/output-customization.svg',
53
- 'title' => 'Output Customization',
54
- 'description' => 'Advanced Commands to customize every thing',
55
  ),
56
  array(
57
- 'thumb' => esc_url( WOO_FEED_PLUGIN_URL ) . 'admin/images/features/tax-calculation.svg',
58
- 'title' => 'Tax Calculation',
59
- 'description' => 'Include tax field or include tax with price as per your need',
60
  ),
61
  array(
62
- 'thumb' => esc_url( WOO_FEED_PLUGIN_URL ) . 'admin/images/features/3rd-party-plugin-support.svg',
63
- 'title' => '3<sup>rd</sup> Party Plugin Support',
64
- 'description' => 'Supports WooCommerce addons and <a href="https://webappick.com/plugin/woocommerce-product-feed-pro/" target="_blank">popular plugin</a>'
65
  ),
66
  array(
67
- 'thumb' => esc_url( WOO_FEED_PLUGIN_URL ) . 'admin/images/features/customer-support.svg',
68
- 'title' => 'Premium customer support',
69
- 'description' => 'Priority support to ensure error free feed generation',
70
  ),
71
  );
72
 
@@ -88,36 +88,46 @@ $pricingFeatures = array(
88
  );
89
  $pricing = array(
90
  array(
91
- 'title' => __( 'Personal', 'woo-feed' ),
92
- 'currency' => '$',
93
- 'amount' => 119,
94
- 'period' => __( 'Yearly', 'woo-feed' ),
95
- 'allowed_domain' => 1,
96
- 'featured' => __( 'Popular', 'woo-feed' ),
97
- 'cart_url' => 'https://webappick.com/plugin/woocommerce-product-feed-pro/?add-to-cart=45657&variation_id=45660&attribute_pa_license=single-site-119-usd',
98
  ),
99
  array(
100
- 'title' => __( 'Plus', 'woo-feed' ),
101
- 'currency' => '$',
102
- 'amount' => 199,
103
- 'period' => __( 'Yearly', 'woo-feed' ),
104
- 'allowed_domain' => 2,
105
- 'featured' => null,
106
- 'cart_url' => 'https://webappick.com/plugin/woocommerce-product-feed-pro/?add-to-cart=45657&variation_id=45659&attribute_pa_license=two-site-199-usd',
107
  ),
108
  array(
109
- 'title' => __( 'Expert', 'woo-feed' ),
110
- 'currency' => '$',
111
- 'amount' => 299,
112
- 'period' => __( 'Yearly', 'woo-feed' ),
113
- 'allowed_domain' => 5,
114
- 'featured' => null,
115
- 'cart_url' => 'https://webappick.com/plugin/woocommerce-product-feed-pro/?add-to-cart=45657&variation_id=45658&attribute_pa_license=five-site-229-usd',
 
 
 
 
 
 
 
 
 
 
 
116
  ),
117
  );
118
- $allowedHtml = array( 'br' => array(), 'code' => array(), 'sub' => array(), 'sup' => array(), 'span' => array(), 'a' => array( 'href' => array(), 'target' => array() ), );
119
  ob_start();
120
- foreach( $pricingFeatures as $feature ) { ?>
121
  <li class="item">
122
  <span class="wapk-price__table__feature">
123
  <span class="dashicons dashicons-yes" aria-hidden="true"></span>
@@ -128,178 +138,178 @@ foreach( $pricingFeatures as $feature ) { ?>
128
  $pricingFeatures = ob_get_clean();
129
  $compareTable = array(
130
  array(
131
- 'title' => __( 'Export Product Variations', 'woo-feed' ),
132
  'free' => true,
133
  ),
134
  array(
135
- 'title' => __( 'Custom Feed Template', 'woo-feed' ),
136
  'free' => true,
137
  ),
138
  array(
139
- 'title' => __( 'Support All Comparison Shopping Engines', 'woo-feed' ),
140
  'free' => true,
141
  ),
142
  array(
143
- 'title' => __( 'Support All Affiliate Networks', 'woo-feed' ),
144
  'free' => true,
145
  ),
146
  array(
147
- 'title' => __( 'Auto Feed Update', 'woo-feed' ),
148
  'free' => true,
149
  ),
150
  array(
151
- 'title' => __( 'Product Attributes', 'woo-feed' ),
152
  'free' => true,
153
  ),
154
  array(
155
- 'title' => __( 'Unlimited Feed', 'woo-feed' ),
156
  'free' => true,
157
  ),
158
  array(
159
- 'title' => __( 'CSV, TXT and XML Feed', 'woo-feed' ),
160
  'free' => true,
161
  ),
162
  array(
163
- 'title' => __( 'Pre Configured Feed Template', 'woo-feed' ),
164
  'free' => true,
165
  ),
166
  array(
167
- 'title' => __( 'Variations & Custom Attribute Value', 'woo-feed' ),
168
  'free' => true,
169
  ),
170
  array(
171
- 'title' => __( 'Upload Feed via FTP', 'woo-feed' ),
172
  'free' => true,
173
  ),
174
  array(
175
- 'title' => __( 'Unlimited Products', 'woo-feed' ),
176
  'free' => false,
177
  ),
178
  array(
179
- 'title' => __( 'Product Filtering by Id,SKU, Title, Category and Others Attributes.', 'woo-feed' ),
180
  'free' => false,
181
  ),
182
  array(
183
- 'title' => __( 'Feed By Category', 'woo-feed' ),
184
  'free' => false,
185
  ),
186
  array(
187
- 'title' => __( 'Customized Product Title', 'woo-feed' ),
188
  'free' => false,
189
  ),
190
  array(
191
- 'title' => __( 'Multilingual Feed With WPML', 'woo-feed' ),
192
  'free' => false,
193
  ),
194
  array(
195
- 'title' => __( 'Product Taxonomy value like Brand or Others Plugin data', 'woo-feed' ),
196
  'free' => false,
197
  ),
198
  array(
199
- 'title' => __( 'WooCommerce Composite Products', 'woo-feed' ),
200
  'free' => false,
201
  ),
202
  array(
203
- 'title' => __( 'WooCommerce Bundle Products', 'woo-feed' ),
204
  'free' => false,
205
  ),
206
  array(
207
- 'title' => __( 'Remove Variation Products', 'woo-feed' ),
208
  'free' => false,
209
  ),
210
  array(
211
- 'title' => __( 'Remove Parent Products', 'woo-feed' ),
212
  'free' => false,
213
  ),
214
  array(
215
- 'title' => __( 'Category Mapping', 'woo-feed' ),
216
  'free' => false,
217
  ),
218
  array(
219
- 'title' => __( 'Dynamic Attributes', 'woo-feed' ),
220
  'free' => false,
221
  ),
222
  array(
223
- 'title' => __( 'Price With Tax', 'woo-feed' ),
224
  'free' => false,
225
  ),
226
  array(
227
- 'title' => __( 'Conditional Pricing', 'woo-feed' ),
228
  'free' => false,
229
  ),
230
  array(
231
- 'title' => __( 'WP Post Meta Value', 'woo-feed' ),
232
  'free' => false,
233
  ),
234
  array(
235
- 'title' => __( 'WP Options Value', 'woo-feed' ),
236
  'free' => false,
237
  ),
238
  array(
239
- 'title' => __( 'Output Customization', 'woo-feed' ),
240
  'free' => false,
241
  ),
242
  );
243
  $compareTableFreeFeatures = $compareTableProFeatures = '';
244
- foreach( $compareTable as $feature ) {
245
  $compareTableFreeFeatures .= sprintf( '<li class="%s"><span class="dashicons dashicons-%s" aria-hidden="true"></span><span>%s</span></li>', $feature['free'] ? 'available' : 'unavailable', $feature['free'] ? 'yes' : 'no', wp_kses( $feature['title'], $allowedHtml ) );
246
  $compareTableProFeatures .= sprintf( '<li class="available"><span class="dashicons dashicons-yes" aria-hidden="true"></span><span>%s</span></li>', wp_kses( $feature['title'], $allowedHtml ) );
247
  }
248
  $testimonials = array(
249
  array(
250
- 'comment' => 'We\'ve been using the WooCommerce Product Feed Pro for several months. It really helps us to build good feeds and boost our sale.',
251
- 'name' => 'Miraclewaresocial',
252
- 'meta' => '',
253
- 'avatar' => '',
254
  ),
255
  array(
256
- 'comment' => 'Using the premium version since few months. Tried many different feeds for WooCommerce, but this one is the best by far! Use it for Bonanza, eBid, eCrater, and others. All work perfectly. I highly recommend.',
257
- 'name' => 'Sandeep',
258
- 'meta' => '',
259
- 'avatar' => '',
260
  ),
261
  array(
262
- 'comment' => 'Easy and powerful<br>Only in woocommerce product feed pro i finding solution to works with vendor shops.<br>Friendly support. Original service.',
263
- 'name' => 'Ireneusz A.',
264
- 'meta' => '',
265
- 'avatar' => '',
266
  ),
267
  array(
268
- 'comment' => 'In my multilingual and multicurrency shop I needed really flexible feed generator. I tried couple of them but none of them was able to deal with WPML and WooCommerce Multilingual in 100%.',
269
- 'name' => 'Ireneusz A.',
270
- 'meta' => '',
271
- 'avatar' => '',
272
  ),
273
  array(
274
- 'comment' => 'Works perfectly as stated<br>Works perfectly as stated. Very easy to use, very straightforward. What is complex is using it on the many platforms but this plugin does the job.',
275
- 'name' => 'Alex',
276
- 'meta' => '',
277
- 'avatar' => '',
278
  ),
279
  array(
280
- 'comment' => 'Very good plugin that has worked perfectly for the feeds I needed. Some feeds are very specific and Webappick have been great at helping me with existing and non-existing functions. Nice, professional and quick support. Great work!',
281
- 'name' => 'Anna',
282
- 'meta' => '',
283
- 'avatar' => '',
284
  ),
285
  array(
286
- 'comment' => 'This is one of the most useful plugin I use for all my clients. WebAppick Support is always so willing to go the extra mile to help me get my clients up and going. Thanks WebAppick!',
287
- 'name' => 'Mathias',
288
- 'meta' => '',
289
- 'avatar' => '',
290
  ),
291
 
292
  array(
293
- 'comment' => 'WooCommerce Product Feed Pro is the most powerful and flexible feed generation plugin we have seen. We spent many hours researching Feed generation plugin for WooCommerce and quickly found WebAppick\'s WooCommerce Product Feed Pro to be the best fit for our business.',
294
- 'name' => 'Anfrage',
295
- 'meta' => '',
296
- 'avatar' => '',
297
  ),
298
  array(
299
- 'comment' => 'The paid version is worth the purchase. This plugin can handle all of my product feeds, complete with category filtering, etc. It\'s easy to start with a preset template and then tweak it from there. The initial purchase had me worried. My credit card was processed but I didn\'۪t get my key. Support fixed this pretty quickly. ',
300
- 'name' => 'Les-imprimeurs',
301
- 'meta' => '',
302
- 'avatar' => '',
303
  ),
304
  );
305
  ?>
@@ -318,7 +328,7 @@ $testimonials = array(
318
  <span class="section-sub-title"><?php esc_html_e( 'Super charge your Store with awesome features', 'woo-feed' ); ?></span>
319
  </div>
320
  <div class="feed-feature__list">
321
- <?php foreach( $features as $feature ) { ?>
322
  <div class="feed-feature__item">
323
  <div class="feed-feature__thumb">
324
  <img src="<?php echo esc_url( $feature['thumb'] ); ?>" alt="<?php echo esc_attr( $feature['title'] ); ?>" title="<?php echo esc_attr( $feature['title'] ); ?>">
@@ -366,9 +376,9 @@ $testimonials = array(
366
  <span class="section-sub-title" id="pricing_sub_header"><?php esc_html_e( 'Choose your subscription plan and get started', 'woo-feed' ); ?></span>
367
  </div>
368
  <div class="wapk-pricing__table">
369
- <?php foreach( $pricing as $price ) {
370
  $integer = $decimal = 0;
371
- if( false !== strpos( $price['amount'], '.' ) ) list( $integer, $decimal ) = array_map( 'intval', explode( '.', (string) $price['amount'] ) );
372
  else $integer = $price['amount'];
373
  ?>
374
  <div class="wapk-pricing__table__item">
@@ -378,17 +388,17 @@ $testimonials = array(
378
  <h3 class="wapk-price__table__heading"><?php echo esc_html( $price['title'] ); ?></h3>
379
  </div>
380
  <div class="wapk-price__table__price">
381
- <?php if( $integer > 0 || $decimal > 0 ) { ?>
382
  <span class="wapk-price__table__currency"><?php echo esc_html( $price['currency'] ); ?></span>
383
  <?php } ?>
384
  <span class="wapk-price__table__amount"><?php
385
- if( $integer == 0 && $decimal == 0 ) printf( '<span class="free">%s</span>', esc_html_x( 'Free', 'Free Package Price Display', 'woo-feed' ) );
386
- if( $integer > 0 || $decimal > 0 ) printf( '<span class="integer-part">%d</span>', esc_html( $integer ) );
387
- if( $decimal > 0 ) printf( '<span class="decimal-part">.%d</span>', esc_html( $integer ) );
388
- if( ! empty( $price['period'] ) ) printf( '<span class="period">/%s</span>', $price['period'] );
389
  ?></span>
390
- <?php if( ! empty( $price['allowed_domain'] ) ) {
391
- if( is_numeric( $price['allowed_domain'] ) ) {
392
  $allowed = sprintf(
393
  _n( 'For %d Site', 'For %d Sites', $price['allowed_domain'], 'woo-feed' ),
394
  $price['allowed_domain']
@@ -402,7 +412,7 @@ $testimonials = array(
402
  <a href="<?php echo esc_url( $price['cart_url'] . '&utm_source=freePlugin&utm_medium=go_premium&utm_campaign=free_to_pro&utm_term=wooFeed' ); ?>" class="wapk-button wapk-button-primary wapk-button-hero" target="_blank"><?php esc_html_e( 'Buy Now', 'woo-feed' ); ?></a>
403
  </div>
404
  </div>
405
- <?php if( ! empty( $price['featured'] ) ) { ?>
406
  <div class="wapk-price__table__ribbon">
407
  <div class="wapk-price__table__ribbon__inner"><?php echo esc_html( $price['featured'] ); ?></div>
408
  </div>
@@ -447,7 +457,7 @@ $testimonials = array(
447
  </div>
448
  <div class="wapk-testimonial-wrapper">
449
  <div class="wapk-slider">
450
- <?php foreach( $testimonials as $testimonial ) { ?>
451
  <div class="testimonial-item">
452
  <div class="testimonial-item__comment">
453
  <p><?php echo wp_kses( $testimonial['comment'], $allowedHtml ); ?></p>
@@ -457,7 +467,7 @@ $testimonials = array(
457
  <img src="<?php echo esc_url( $testimonial['avatar'] ); ?>" alt="<?php echo esc_attr( $testimonial['name'] ); ?>">
458
  </div>*/ ?>
459
  <h4 class="author-name"><?php echo esc_html( $testimonial['name'] ); ?></h4>
460
- <?php if( isset( $testimonial['meta'] ) && ! empty( $testimonial['meta'] ) ) { ?>
461
  <span class="author-meta"><?php echo esc_html( $testimonial['meta'] ); ?></span>
462
  <?php } ?>
463
  </div>
10
  * @author Ohidul Islam <wahid@webappick.com>
11
  * @version 1.0.2
12
  */
13
+ if ( ! function_exists( 'add_action' ) ) die();
14
  // ### REF > utm parameters http://bit.ly/2KIwvTt
15
  $features = array(
16
  array(
17
+ 'thumb' => esc_url( WOO_FEED_PLUGIN_URL ) . 'admin/images/features/smart-filter-conditions.svg',
18
+ 'title' => 'Smart Filter & Conditions',
19
+ 'description' => 'Exclude unwanted product from feed with the help of advanced filtration',
20
  ),
21
  array(
22
+ 'thumb' => esc_url( WOO_FEED_PLUGIN_URL ) . 'admin/images/features/dynamic-attributes.svg',
23
+ 'title' => 'Dynamic Attributes',
24
+ 'description' => 'Make new attribute by combine multiple attributes with condition',
25
  ),
26
  array(
27
+ 'thumb' => esc_url( WOO_FEED_PLUGIN_URL ) . 'admin/images/features/category-mapping.svg',
28
+ 'title' => 'Category Mapping',
29
+ 'description' => 'Automatically map product category with merchant category',
30
  ),
31
  array(
32
+ 'thumb' => esc_url( WOO_FEED_PLUGIN_URL ) . 'admin/images/features/multilingual-feed.svg',
33
+ 'title' => 'Multilingual Feed',
34
+ 'description' => 'WPML Support for Multilingual Product Feed',
35
  ),
36
  array(
37
+ 'thumb' => esc_url( WOO_FEED_PLUGIN_URL ) . 'admin/images/features/custom-taxonomy.svg',
38
+ 'title' => 'Custom Taxonomy',
39
+ 'description' => 'Use any taxonomies attached to the product',
40
  ),
41
  array(
42
+ 'thumb' => esc_url( WOO_FEED_PLUGIN_URL ) . 'admin/images/features/product-title-customization.svg',
43
+ 'title' => 'Product Title Customization',
44
+ 'description' => 'Customize product title with different attributes',
45
  ),
46
  array(
47
+ 'thumb' => esc_url( WOO_FEED_PLUGIN_URL ) . 'admin/images/features/conditional-pricing.svg',
48
+ 'title' => 'Conditional Pricing',
49
+ 'description' => 'Change Product Price display as per your need',
50
  ),
51
  array(
52
+ 'thumb' => esc_url( WOO_FEED_PLUGIN_URL ) . 'admin/images/features/output-customization.svg',
53
+ 'title' => 'Output Customization',
54
+ 'description' => 'Advanced Commands to customize every thing',
55
  ),
56
  array(
57
+ 'thumb' => esc_url( WOO_FEED_PLUGIN_URL ) . 'admin/images/features/tax-calculation.svg',
58
+ 'title' => 'Tax Calculation',
59
+ 'description' => 'Include tax field or include tax with price as per your need',
60
  ),
61
  array(
62
+ 'thumb' => esc_url( WOO_FEED_PLUGIN_URL ) . 'admin/images/features/3rd-party-plugin-support.svg',
63
+ 'title' => '3<sup>rd</sup> Party Plugin Support',
64
+ 'description' => 'Supports WooCommerce addons and <a href="https://webappick.com/plugin/woocommerce-product-feed-pro/" target="_blank">popular plugin</a>',
65
  ),
66
  array(
67
+ 'thumb' => esc_url( WOO_FEED_PLUGIN_URL ) . 'admin/images/features/customer-support.svg',
68
+ 'title' => 'Premium customer support',
69
+ 'description' => 'Priority support to ensure error free feed generation',
70
  ),
71
  );
72
 
88
  );
89
  $pricing = array(
90
  array(
91
+ 'title' => __( 'Personal', 'woo-feed' ),
92
+ 'currency' => '$',
93
+ 'amount' => 119,
94
+ 'period' => __( 'Yearly', 'woo-feed' ),
95
+ 'allowed_domain' => 1,
96
+ 'featured' => __( 'Popular', 'woo-feed' ),
97
+ 'cart_url' => 'https://webappick.com/plugin/woocommerce-product-feed-pro/?add-to-cart=45657&variation_id=45660&attribute_pa_license=single-site-119-usd',
98
  ),
99
  array(
100
+ 'title' => __( 'Plus', 'woo-feed' ),
101
+ 'currency' => '$',
102
+ 'amount' => 199,
103
+ 'period' => __( 'Yearly', 'woo-feed' ),
104
+ 'allowed_domain' => 2,
105
+ 'featured' => null,
106
+ 'cart_url' => 'https://webappick.com/plugin/woocommerce-product-feed-pro/?add-to-cart=45657&variation_id=45659&attribute_pa_license=two-site-199-usd',
107
  ),
108
  array(
109
+ 'title' => __( 'Expert', 'woo-feed' ),
110
+ 'currency' => '$',
111
+ 'amount' => 299,
112
+ 'period' => __( 'Yearly', 'woo-feed' ),
113
+ 'allowed_domain' => 5,
114
+ 'featured' => null,
115
+ 'cart_url' => 'https://webappick.com/plugin/woocommerce-product-feed-pro/?add-to-cart=45657&variation_id=45658&attribute_pa_license=five-site-229-usd',
116
+ ),
117
+ );
118
+ $allowedHtml = array(
119
+ 'br' => array(),
120
+ 'code' => array(),
121
+ 'sub' => array(),
122
+ 'sup' => array(),
123
+ 'span' => array(),
124
+ 'a' => array(
125
+ 'href' => array(),
126
+ 'target' => array(),
127
  ),
128
  );
 
129
  ob_start();
130
+ foreach ( $pricingFeatures as $feature ) { ?>
131
  <li class="item">
132
  <span class="wapk-price__table__feature">
133
  <span class="dashicons dashicons-yes" aria-hidden="true"></span>
138
  $pricingFeatures = ob_get_clean();
139
  $compareTable = array(
140
  array(
141
+ 'title' => __( 'Export Product Variations', 'woo-feed' ),
142
  'free' => true,
143
  ),
144
  array(
145
+ 'title' => __( 'Custom Feed Template', 'woo-feed' ),
146
  'free' => true,
147
  ),
148
  array(
149
+ 'title' => __( 'Support All Comparison Shopping Engines', 'woo-feed' ),
150
  'free' => true,
151
  ),
152
  array(
153
+ 'title' => __( 'Support All Affiliate Networks', 'woo-feed' ),
154
  'free' => true,
155
  ),
156
  array(
157
+ 'title' => __( 'Auto Feed Update', 'woo-feed' ),
158
  'free' => true,
159
  ),
160
  array(
161
+ 'title' => __( 'Product Attributes', 'woo-feed' ),
162
  'free' => true,
163
  ),
164
  array(
165
+ 'title' => __( 'Unlimited Feed', 'woo-feed' ),
166
  'free' => true,
167
  ),
168
  array(
169
+ 'title' => __( 'CSV, TXT and XML Feed', 'woo-feed' ),
170
  'free' => true,
171
  ),
172
  array(
173
+ 'title' => __( 'Pre Configured Feed Template', 'woo-feed' ),
174
  'free' => true,
175
  ),
176
  array(
177
+ 'title' => __( 'Variations & Custom Attribute Value', 'woo-feed' ),
178
  'free' => true,
179
  ),
180
  array(
181
+ 'title' => __( 'Upload Feed via FTP', 'woo-feed' ),
182
  'free' => true,
183
  ),
184
  array(
185
+ 'title' => __( 'Unlimited Products', 'woo-feed' ),
186
  'free' => false,
187
  ),
188
  array(
189
+ 'title' => __( 'Product Filtering by Id,SKU, Title, Category and Others Attributes.', 'woo-feed' ),
190
  'free' => false,
191
  ),
192
  array(
193
+ 'title' => __( 'Feed By Category', 'woo-feed' ),
194
  'free' => false,
195
  ),
196
  array(
197
+ 'title' => __( 'Customized Product Title', 'woo-feed' ),
198
  'free' => false,
199
  ),
200
  array(
201
+ 'title' => __( 'Multilingual Feed With WPML', 'woo-feed' ),
202
  'free' => false,
203
  ),
204
  array(
205
+ 'title' => __( 'Product Taxonomy value like Brand or Others Plugin data', 'woo-feed' ),
206
  'free' => false,
207
  ),
208
  array(
209
+ 'title' => __( 'WooCommerce Composite Products', 'woo-feed' ),
210
  'free' => false,
211
  ),
212
  array(
213
+ 'title' => __( 'WooCommerce Bundle Products', 'woo-feed' ),
214
  'free' => false,
215
  ),
216
  array(
217
+ 'title' => __( 'Remove Variation Products', 'woo-feed' ),
218
  'free' => false,
219
  ),
220
  array(
221
+ 'title' => __( 'Remove Parent Products', 'woo-feed' ),
222
  'free' => false,
223
  ),
224
  array(
225
+ 'title' => __( 'Category Mapping', 'woo-feed' ),
226
  'free' => false,
227
  ),
228
  array(
229
+ 'title' => __( 'Dynamic Attributes', 'woo-feed' ),
230
  'free' => false,
231
  ),
232
  array(
233
+ 'title' => __( 'Price With Tax', 'woo-feed' ),
234
  'free' => false,
235
  ),
236
  array(
237
+ 'title' => __( 'Conditional Pricing', 'woo-feed' ),
238
  'free' => false,
239
  ),
240
  array(
241
+ 'title' => __( 'WP Post Meta Value', 'woo-feed' ),
242
  'free' => false,
243
  ),
244
  array(
245
+ 'title' => __( 'WP Options Value', 'woo-feed' ),
246
  'free' => false,
247
  ),
248
  array(
249
+ 'title' => __( 'Output Customization', 'woo-feed' ),
250
  'free' => false,
251
  ),
252
  );
253
  $compareTableFreeFeatures = $compareTableProFeatures = '';
254
+ foreach ( $compareTable as $feature ) {
255
  $compareTableFreeFeatures .= sprintf( '<li class="%s"><span class="dashicons dashicons-%s" aria-hidden="true"></span><span>%s</span></li>', $feature['free'] ? 'available' : 'unavailable', $feature['free'] ? 'yes' : 'no', wp_kses( $feature['title'], $allowedHtml ) );
256
  $compareTableProFeatures .= sprintf( '<li class="available"><span class="dashicons dashicons-yes" aria-hidden="true"></span><span>%s</span></li>', wp_kses( $feature['title'], $allowedHtml ) );
257
  }
258
  $testimonials = array(
259
  array(
260
+ 'comment' => 'We\'ve been using the WooCommerce Product Feed Pro for several months. It really helps us to build good feeds and boost our sale.',
261
+ 'name' => 'Miraclewaresocial',
262
+ 'meta' => '',
263
+ 'avatar' => '',
264
  ),
265
  array(
266
+ 'comment' => 'Using the premium version since few months. Tried many different feeds for WooCommerce, but this one is the best by far! Use it for Bonanza, eBid, eCrater, and others. All work perfectly. I highly recommend.',
267
+ 'name' => 'Sandeep',
268
+ 'meta' => '',
269
+ 'avatar' => '',
270
  ),
271
  array(
272
+ 'comment' => 'Easy and powerful<br>Only in woocommerce product feed pro i finding solution to works with vendor shops.<br>Friendly support. Original service.',
273
+ 'name' => 'Ireneusz A.',
274
+ 'meta' => '',
275
+ 'avatar' => '',
276
  ),
277
  array(
278
+ 'comment' => 'In my multilingual and multicurrency shop I needed really flexible feed generator. I tried couple of them but none of them was able to deal with WPML and WooCommerce Multilingual in 100%.',
279
+ 'name' => 'Ireneusz A.',
280
+ 'meta' => '',
281
+ 'avatar' => '',
282
  ),
283
  array(
284
+ 'comment' => 'Works perfectly as stated<br>Works perfectly as stated. Very easy to use, very straightforward. What is complex is using it on the many platforms but this plugin does the job.',
285
+ 'name' => 'Alex',
286
+ 'meta' => '',
287
+ 'avatar' => '',
288
  ),
289
  array(
290
+ 'comment' => 'Very good plugin that has worked perfectly for the feeds I needed. Some feeds are very specific and Webappick have been great at helping me with existing and non-existing functions. Nice, professional and quick support. Great work!',
291
+ 'name' => 'Anna',
292
+ 'meta' => '',
293
+ 'avatar' => '',
294
  ),
295
  array(
296
+ 'comment' => 'This is one of the most useful plugin I use for all my clients. WebAppick Support is always so willing to go the extra mile to help me get my clients up and going. Thanks WebAppick!',
297
+ 'name' => 'Mathias',
298
+ 'meta' => '',
299
+ 'avatar' => '',
300
  ),
301
 
302
  array(
303
+ 'comment' => 'WooCommerce Product Feed Pro is the most powerful and flexible feed generation plugin we have seen. We spent many hours researching Feed generation plugin for WooCommerce and quickly found WebAppick\'s WooCommerce Product Feed Pro to be the best fit for our business.',
304
+ 'name' => 'Anfrage',
305
+ 'meta' => '',
306
+ 'avatar' => '',
307
  ),
308
  array(
309
+ 'comment' => 'The paid version is worth the purchase. This plugin can handle all of my product feeds, complete with category filtering, etc. It\'s easy to start with a preset template and then tweak it from there. The initial purchase had me worried. My credit card was processed but I didn\'۪t get my key. Support fixed this pretty quickly. ',
310
+ 'name' => 'Les-imprimeurs',
311
+ 'meta' => '',
312
+ 'avatar' => '',
313
  ),
314
  );
315
  ?>
328
  <span class="section-sub-title"><?php esc_html_e( 'Super charge your Store with awesome features', 'woo-feed' ); ?></span>
329
  </div>
330
  <div class="feed-feature__list">
331
+ <?php foreach ( $features as $feature ) { ?>
332
  <div class="feed-feature__item">
333
  <div class="feed-feature__thumb">
334
  <img src="<?php echo esc_url( $feature['thumb'] ); ?>" alt="<?php echo esc_attr( $feature['title'] ); ?>" title="<?php echo esc_attr( $feature['title'] ); ?>">
376
  <span class="section-sub-title" id="pricing_sub_header"><?php esc_html_e( 'Choose your subscription plan and get started', 'woo-feed' ); ?></span>
377
  </div>
378
  <div class="wapk-pricing__table">
379
+ <?php foreach ( $pricing as $price ) {
380
  $integer = $decimal = 0;
381
+ if ( false !== strpos( $price['amount'], '.' ) ) list( $integer, $decimal ) = array_map( 'intval', explode( '.', (string) $price['amount'] ) );
382
  else $integer = $price['amount'];
383
  ?>
384
  <div class="wapk-pricing__table__item">
388
  <h3 class="wapk-price__table__heading"><?php echo esc_html( $price['title'] ); ?></h3>
389
  </div>
390
  <div class="wapk-price__table__price">
391
+ <?php if ( $integer > 0 || $decimal > 0 ) { ?>
392
  <span class="wapk-price__table__currency"><?php echo esc_html( $price['currency'] ); ?></span>
393
  <?php } ?>
394
  <span class="wapk-price__table__amount"><?php
395
+ if ( $integer == 0 && $decimal == 0 ) printf( '<span class="free">%s</span>', esc_html_x( 'Free', 'Free Package Price Display', 'woo-feed' ) );
396
+ if ( $integer > 0 || $decimal > 0 ) printf( '<span class="integer-part">%d</span>', esc_html( $integer ) );
397
+ if ( $decimal > 0 ) printf( '<span class="decimal-part">.%d</span>', esc_html( $integer ) );
398
+ if ( ! empty( $price['period'] ) ) printf( '<span class="period">/%s</span>', $price['period'] );
399
  ?></span>
400
+ <?php if ( ! empty( $price['allowed_domain'] ) ) {
401
+ if ( is_numeric( $price['allowed_domain'] ) ) {
402
  $allowed = sprintf(
403
  _n( 'For %d Site', 'For %d Sites', $price['allowed_domain'], 'woo-feed' ),
404
  $price['allowed_domain']
412
  <a href="<?php echo esc_url( $price['cart_url'] . '&utm_source=freePlugin&utm_medium=go_premium&utm_campaign=free_to_pro&utm_term=wooFeed' ); ?>" class="wapk-button wapk-button-primary wapk-button-hero" target="_blank"><?php esc_html_e( 'Buy Now', 'woo-feed' ); ?></a>
413
  </div>
414
  </div>
415
+ <?php if ( ! empty( $price['featured'] ) ) { ?>
416
  <div class="wapk-price__table__ribbon">
417
  <div class="wapk-price__table__ribbon__inner"><?php echo esc_html( $price['featured'] ); ?></div>
418
  </div>
457
  </div>
458
  <div class="wapk-testimonial-wrapper">
459
  <div class="wapk-slider">
460
+ <?php foreach ( $testimonials as $testimonial ) { ?>
461
  <div class="testimonial-item">
462
  <div class="testimonial-item__comment">
463
  <p><?php echo wp_kses( $testimonial['comment'], $allowedHtml ); ?></p>
467
  <img src="<?php echo esc_url( $testimonial['avatar'] ); ?>" alt="<?php echo esc_attr( $testimonial['name'] ); ?>">
468
  </div>*/ ?>
469
  <h4 class="author-name"><?php echo esc_html( $testimonial['name'] ); ?></h4>
470
+ <?php if ( isset( $testimonial['meta'] ) && ! empty( $testimonial['meta'] ) ) { ?>
471
  <span class="author-meta"><?php echo esc_html( $testimonial['meta'] ); ?></span>
472
  <?php } ?>
473
  </div>
admin/partials/woo-feed-search-category.php CHANGED
@@ -6,16 +6,16 @@
6
  * @since 1.0.0
7
  * @author Ohidul Islam <wahid@webappick.com>
8
  */
9
- if (isset($_POST['q'])) {
10
  $searchfor = sanitize_text_field( $_POST['q'] );
11
  $provider = sanitize_text_field( $_POST['provider'] );
12
- if ($provider != 'custom') {
13
  $file = "$provider/categories.txt";
14
  $matches = array();
15
 
16
  $handle = @fopen($file, "r");
17
- if ($handle) {
18
- while (!feof($handle)) {
19
  $buffer = fgets($handle);
20
  if (strpos($buffer, $searchfor) !== FALSE)
21
  $matches[] = $buffer;
6
  * @since 1.0.0
7
  * @author Ohidul Islam <wahid@webappick.com>
8
  */
9
+ if ( isset($_POST['q']) ) {
10
  $searchfor = sanitize_text_field( $_POST['q'] );
11
  $provider = sanitize_text_field( $_POST['provider'] );
12
+ if ( $provider != 'custom' ) {
13
  $file = "$provider/categories.txt";
14
  $matches = array();
15
 
16
  $handle = @fopen($file, "r");
17
+ if ( $handle ) {
18
+ while ( ! feof($handle) ) {
19
  $buffer = fgets($handle);
20
  if (strpos($buffer, $searchfor) !== FALSE)
21
  $matches[] = $buffer;
includes/class-woo-feed-activator.php CHANGED
@@ -30,8 +30,7 @@ class Woo_Feed_Activator
30
  *
31
  * @since 1.0.0
32
  */
33
- public static function activate()
34
- {
35
  # Schedule Update Interval
36
  update_option('wf_schedule', '86400');
37
  # Schedule Cron
30
  *
31
  * @since 1.0.0
32
  */
33
+ public static function activate() {
 
34
  # Schedule Update Interval
35
  update_option('wf_schedule', '86400');
36
  # Schedule Cron
includes/class-woo-feed-docs.php CHANGED
@@ -5,10 +5,10 @@
5
  * @package WooFeed
6
  * @since 3.1.36
7
  */
8
- if( ! function_exists( 'add_action' ) ) {
9
  die();
10
  }
11
- if( ! class_exists( 'WooFeedDocs' ) ) {
12
  class WooFeedDocs {
13
  /**
14
  * Singleton instance holder
@@ -21,7 +21,7 @@ if( ! class_exists( 'WooFeedDocs' ) ) {
21
  * @return WooFeedDocs
22
  */
23
  public static function getInstance() {
24
- if( self::$instance === null ) self::$instance = new self();
25
  return self::$instance;
26
  }
27
  private function __construct() {
@@ -43,9 +43,9 @@ if( ! class_exists( 'WooFeedDocs' ) ) {
43
  <div class="wapk-section">
44
  <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
45
  </div>
46
- <?php if( ! empty( $faqs ) ) { ?>
47
  <div class="wapk-section">
48
- <?php foreach( $faqs as $faq ) {
49
  $boxId = ( isset( $faq->id ) ) ? $faq->id : sanitize_title( $faq->title );
50
  ?>
51
  <div id="<?php echo esc_attr( $boxId ); ?>" class="postbox <?php echo esc_attr( postbox_classes( $boxId, $current_screen->id ) ); ?>">
@@ -53,7 +53,7 @@ if( ! class_exists( 'WooFeedDocs' ) ) {
53
  <span class="screen-reader-text"><?php printf( esc_html__( 'Toggle panel: %s', 'woo-feed' ), $faq->title ) ?></span>
54
  <span class="toggle-indicator" aria-hidden="true"></span>
55
  </button>
56
- <h2 class="hndle"><?php if( isset( $faq->icon ) && ! empty( $faq->icon ) ) {
57
  ?><span class="<?php printf( '%s%s',
58
  ( strpos( $faq->icon, 'dashicons' ) !== false ) ? 'dashicons ' : '',
59
  esc_attr( $faq->icon ) ); ?>" aria-hidden="true"></span> <?php
@@ -61,9 +61,9 @@ if( ! class_exists( 'WooFeedDocs' ) ) {
61
  <div class="inside">
62
  <div class="main">
63
  <ul>
64
- <?php foreach( $faq->questions as $qa ) { ?>
65
  <li>
66
- <span class="<?php if( isset( $qa->icon ) ) {
67
  printf( '%s%s',
68
  ( strpos( $qa->icon, 'dashicons' ) !== false ) ? 'dashicons ' : '',
69
  esc_attr( $qa->icon ) );
@@ -111,7 +111,7 @@ if( ! class_exists( 'WooFeedDocs' ) ) {
111
  */
112
  private function __get_feed_help() {
113
  // force fetch docs json.
114
- if( isset( $_GET['reload'], $_GET['_nonce'] ) && wp_verify_nonce( $_GET['_nonce'], 'webappick-feed-docs' ) ) {
115
  $help_docs = false;
116
  } else $help_docs = get_transient( 'webappick_feed_help_docs' );
117
  if ( false === $help_docs ) {
@@ -133,7 +133,7 @@ if( ! class_exists( 'WooFeedDocs' ) ) {
133
  */
134
  function filter_removable_query_args( $removable_query_args ) {
135
  global $pagenow, $plugin_page;
136
- if( $pagenow === 'admin.php' && $plugin_page === 'webappick-feed-docs' ) {
137
  $removable_query_args = array_merge( $removable_query_args, array( 'reload', '_nonce' ) );
138
  }
139
  return $removable_query_args;
5
  * @package WooFeed
6
  * @since 3.1.36
7
  */
8
+ if ( ! function_exists( 'add_action' ) ) {
9
  die();
10
  }
11
+ if ( ! class_exists( 'WooFeedDocs' ) ) {
12
  class WooFeedDocs {
13
  /**
14
  * Singleton instance holder
21
  * @return WooFeedDocs
22
  */
23
  public static function getInstance() {
24
+ if ( self::$instance === null ) self::$instance = new self();
25
  return self::$instance;
26
  }
27
  private function __construct() {
43
  <div class="wapk-section">
44
  <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
45
  </div>
46
+ <?php if ( ! empty( $faqs ) ) { ?>
47
  <div class="wapk-section">
48
+ <?php foreach ( $faqs as $faq ) {
49
  $boxId = ( isset( $faq->id ) ) ? $faq->id : sanitize_title( $faq->title );
50
  ?>
51
  <div id="<?php echo esc_attr( $boxId ); ?>" class="postbox <?php echo esc_attr( postbox_classes( $boxId, $current_screen->id ) ); ?>">
53
  <span class="screen-reader-text"><?php printf( esc_html__( 'Toggle panel: %s', 'woo-feed' ), $faq->title ) ?></span>
54
  <span class="toggle-indicator" aria-hidden="true"></span>
55
  </button>
56
+ <h2 class="hndle"><?php if ( isset( $faq->icon ) && ! empty( $faq->icon ) ) {
57
  ?><span class="<?php printf( '%s%s',
58
  ( strpos( $faq->icon, 'dashicons' ) !== false ) ? 'dashicons ' : '',
59
  esc_attr( $faq->icon ) ); ?>" aria-hidden="true"></span> <?php
61
  <div class="inside">
62
  <div class="main">
63
  <ul>
64
+ <?php foreach ( $faq->questions as $qa ) { ?>
65
  <li>
66
+ <span class="<?php if ( isset( $qa->icon ) ) {
67
  printf( '%s%s',
68
  ( strpos( $qa->icon, 'dashicons' ) !== false ) ? 'dashicons ' : '',
69
  esc_attr( $qa->icon ) );
111
  */
112
  private function __get_feed_help() {
113
  // force fetch docs json.
114
+ if ( isset( $_GET['reload'], $_GET['_nonce'] ) && wp_verify_nonce( $_GET['_nonce'], 'webappick-feed-docs' ) ) {
115
  $help_docs = false;
116
  } else $help_docs = get_transient( 'webappick_feed_help_docs' );
117
  if ( false === $help_docs ) {
133
  */
134
  function filter_removable_query_args( $removable_query_args ) {
135
  global $pagenow, $plugin_page;
136
+ if ( $pagenow === 'admin.php' && $plugin_page === 'webappick-feed-docs' ) {
137
  $removable_query_args = array_merge( $removable_query_args, array( 'reload', '_nonce' ) );
138
  }
139
  return $removable_query_args;
includes/class-woo-feed-installer.php CHANGED
@@ -8,7 +8,7 @@
8
  * @author KD <mhaudul.hk@gmail.com>
9
  *
10
  */
11
- if( ! defined( 'ABSPATH' ) ) die(); // Silence...
12
  class Woo_Feed_installer {
13
 
14
  public static function init() {
@@ -23,7 +23,7 @@ class Woo_Feed_installer {
23
  */
24
  public static function check_version() {
25
  if ( ! defined( 'IFRAME_REQUEST' ) && version_compare( get_option( 'woo_feed_free_version' ), WOO_FEED_FREE_VERSION, '<' ) ) {
26
- if( ! defined( 'WOO_FEED_UPDATING' ) ) {
27
  define( 'WOO_FEED_UPDATING', TRUE );
28
  }
29
  self::install();
@@ -41,7 +41,7 @@ class Woo_Feed_installer {
41
  public static function cron_schedules( $schedules ) {
42
  $interval = get_option('wf_schedule');
43
  $schedules['woo_feed_corn'] = array(
44
- 'display' => __( 'Woo Feed Update Interval', 'woo-feed' ),
45
  'interval' => $interval,
46
  );
47
  return $schedules;
@@ -56,8 +56,8 @@ class Woo_Feed_installer {
56
  }
57
 
58
  // Bail if unsupported php version
59
- if( ! wooFeed_is_supported_php() ) {
60
- echo '<div class="notice error"><p>'. sprintf( __( 'The Minimum PHP Version Requirement for <b>WooCommerce Product Feed</b> is %s. You are Running PHP %s', 'woo-feed' ), WOO_FEED_MIN_PHP_VERSION, phpversion() ) .'</p></div>';
61
  die();
62
  }
63
 
@@ -79,7 +79,7 @@ class Woo_Feed_installer {
79
 
80
  private static function deactivate_free_version() {
81
  // Deactivate Free version if pro already available.
82
- if( wooFeed_is_plugin_active( "webappick-product-feed-for-woocommerce-pro/webappick-product-feed-for-woocommerce-pro.php" ) ) {
83
  echo '<div class="notice error"><p>'. __( 'Please deactivate the <b>WooCommerce Product Feed Pro</b> version to activate free version again.', 'woo-feed' ) .'</p></div>';
84
  die();
85
  }
@@ -90,7 +90,7 @@ class Woo_Feed_installer {
90
  */
91
  private static function create_cron_jobs() {
92
  # Schedule Update Interval
93
- if( ! get_option( 'wf_schedule', false ) ) {
94
  update_option('wf_schedule', HOUR_IN_SECONDS );
95
  }
96
  // clear previous scheduled cron jobs
@@ -141,13 +141,13 @@ class Woo_Feed_installer {
141
  delete_option( 'woo_feed_free_version' );
142
  delete_option( 'woo_feed_version' );
143
  add_option( 'woo_feed_free_version', WOO_FEED_FREE_VERSION );
144
- if( ! defined( 'WOO_FEED_UPDATING' ) ) {
145
  // check for old version time.
146
  $oldActivation = get_option( 'woo-feed-activation-time', false );
147
- if( ! $oldActivation ) $oldActivation = time();
148
  update_option( "woo-feed-free-activation-time", $oldActivation );
149
  } else {
150
- if( $oldActivation = get_option( 'woo-feed-activation-time', false ) ) {
151
  update_option( "woo-feed-free-activation-time", $oldActivation );
152
  }
153
  }
8
  * @author KD <mhaudul.hk@gmail.com>
9
  *
10
  */
11
+ if ( ! defined( 'ABSPATH' ) ) die(); // Silence...
12
  class Woo_Feed_installer {
13
 
14
  public static function init() {
23
  */
24
  public static function check_version() {
25
  if ( ! defined( 'IFRAME_REQUEST' ) && version_compare( get_option( 'woo_feed_free_version' ), WOO_FEED_FREE_VERSION, '<' ) ) {
26
+ if ( ! defined( 'WOO_FEED_UPDATING' ) ) {
27
  define( 'WOO_FEED_UPDATING', TRUE );
28
  }
29
  self::install();
41
  public static function cron_schedules( $schedules ) {
42
  $interval = get_option('wf_schedule');
43
  $schedules['woo_feed_corn'] = array(
44
+ 'display' => __( 'Woo Feed Update Interval', 'woo-feed' ),
45
  'interval' => $interval,
46
  );
47
  return $schedules;
56
  }
57
 
58
  // Bail if unsupported php version
59
+ if ( ! wooFeed_is_supported_php() ) {
60
+ echo '<div class="notice error"><p>'. sprintf( __( 'The Minimum PHP Version Requirement for <b>WooCommerce Product Feed</b> is %1$s. You are Running PHP %2$s', 'woo-feed' ), WOO_FEED_MIN_PHP_VERSION, phpversion() ) .'</p></div>';
61
  die();
62
  }
63
 
79
 
80
  private static function deactivate_free_version() {
81
  // Deactivate Free version if pro already available.
82
+ if ( wooFeed_is_plugin_active( "webappick-product-feed-for-woocommerce-pro/webappick-product-feed-for-woocommerce-pro.php" ) ) {
83
  echo '<div class="notice error"><p>'. __( 'Please deactivate the <b>WooCommerce Product Feed Pro</b> version to activate free version again.', 'woo-feed' ) .'</p></div>';
84
  die();
85
  }
90
  */
91
  private static function create_cron_jobs() {
92
  # Schedule Update Interval
93
+ if ( ! get_option( 'wf_schedule', false ) ) {
94
  update_option('wf_schedule', HOUR_IN_SECONDS );
95
  }
96
  // clear previous scheduled cron jobs
141
  delete_option( 'woo_feed_free_version' );
142
  delete_option( 'woo_feed_version' );
143
  add_option( 'woo_feed_free_version', WOO_FEED_FREE_VERSION );
144
+ if ( ! defined( 'WOO_FEED_UPDATING' ) ) {
145
  // check for old version time.
146
  $oldActivation = get_option( 'woo-feed-activation-time', false );
147
+ if ( ! $oldActivation ) $oldActivation = time();
148
  update_option( "woo-feed-free-activation-time", $oldActivation );
149
  } else {
150
+ if ( $oldActivation = get_option( 'woo-feed-activation-time', false ) ) {
151
  update_option( "woo-feed-free-activation-time", $oldActivation );
152
  }
153
  }
includes/class-woo-feed-loader.php CHANGED
@@ -102,7 +102,7 @@ class Woo_Feed_Loader {
102
  'component' => $component,
103
  'callback' => $callback,
104
  'priority' => $priority,
105
- 'accepted_args' => $accepted_args
106
  );
107
 
108
  return $hooks;
102
  'component' => $component,
103
  'callback' => $callback,
104
  'priority' => $priority,
105
+ 'accepted_args' => $accepted_args,
106
  );
107
 
108
  return $hooks;
includes/class-woo-feed.php CHANGED
@@ -197,8 +197,7 @@ class Woo_Feed
197
  * @since 1.0.0
198
  * @access private
199
  */
200
- private function set_locale()
201
- {
202
 
203
  $plugin_i18n = new Woo_Feed_i18n();
204
  $plugin_i18n->set_domain($this->get_woo_feed());
@@ -230,9 +229,8 @@ class Woo_Feed
230
  *
231
  * @since 1.0.0
232
  */
233
- public function run()
234
- {
235
- if( wooFeed_check_WC() && wooFeed_is_WC_supported() ) {
236
  $this->load_dependencies();
237
  $this->set_locale();
238
  $this->define_admin_hooks();
@@ -247,8 +245,7 @@ class Woo_Feed
247
  * @since 1.0.0
248
  * @return string The name of the plugin.
249
  */
250
- public function get_woo_feed()
251
- {
252
  return $this->woo_feed;
253
  }
254
 
@@ -258,8 +255,7 @@ class Woo_Feed
258
  * @since 1.0.0
259
  * @return Woo_Feed_Loader Orchestrates the hooks of the plugin.
260
  */
261
- public function get_loader()
262
- {
263
  return $this->loader;
264
  }
265
 
@@ -269,8 +265,7 @@ class Woo_Feed
269
  * @since 1.0.0
270
  * @return string The version number of the plugin.
271
  */
272
- public function get_version()
273
- {
274
  return $this->version;
275
  }
276
 
197
  * @since 1.0.0
198
  * @access private
199
  */
200
+ private function set_locale() {
 
201
 
202
  $plugin_i18n = new Woo_Feed_i18n();
203
  $plugin_i18n->set_domain($this->get_woo_feed());
229
  *
230
  * @since 1.0.0
231
  */
232
+ public function run() {
233
+ if ( wooFeed_check_WC() && wooFeed_is_WC_supported() ) {
 
234
  $this->load_dependencies();
235
  $this->set_locale();
236
  $this->define_admin_hooks();
245
  * @since 1.0.0
246
  * @return string The name of the plugin.
247
  */
248
+ public function get_woo_feed() {
 
249
  return $this->woo_feed;
250
  }
251
 
255
  * @since 1.0.0
256
  * @return Woo_Feed_Loader Orchestrates the hooks of the plugin.
257
  */
258
+ public function get_loader() {
 
259
  return $this->loader;
260
  }
261
 
265
  * @since 1.0.0
266
  * @return string The version number of the plugin.
267
  */
268
+ public function get_version() {
 
269
  return $this->version;
270
  }
271
 
includes/classes/class-woo-feed-admin-message.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /**
4
  * A class definition responsible for processing and mapping product according to feed rules and make the feed
5
  *
@@ -10,27 +9,114 @@
10
  * @subpackage Woo_Feed/includes
11
  * @author Ohidul Islam <wahid@webappick.com>
12
  */
13
- class Woo_Feed_Message {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
- public function infoMessage1() {
16
- $reviewURL = 'https://wordpress.org/support/plugin/webappick-product-feed-for-woocommerce/reviews/?rate=5#new-post';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  ?>
18
  <table class="wf-info-table widefat fixed">
19
  <tbody>
20
  <tr>
21
  <th>
22
- <a class="get-woo-feed-pro" href="http://bit.ly/2KIwvTt" target="_blank" aria-label="<?php esc_attr_e( 'Get Woo Feed Pro', 'woo-feed' ); ?>">
23
- <img src="<?php echo esc_url( WOO_FEED_PLUGIN_URL ); ?>admin/images/get-woo-feed-pro.svg" alt="<?php esc_attr_e( 'Get Woo Feed Pro', 'woo-feed' ); ?>">
24
- </a>
 
 
25
  </th>
26
  <th>
27
- <a class="documentation button button-secondary button-hero" href="http://webappick.helpscoutdocs.com/" target="_blank" ><?php _e( 'Documentation', 'woo-feed' ); ?></a>
 
 
28
  </th>
29
  <th>
30
- <a class="tutorial button button-secondary button-hero" href="http://bit.ly/2u6giNz" target="_blank"><?php _e( 'Video Tutorials', 'woo-feed' ); ?></a>
 
 
31
  </th>
32
  <th>
33
- <a class="support button button-secondary button-hero" href="https://wordpress.org/support/plugin/webappick-product-feed-for-woocommerce/#new-topic-0" target="_blank"><?php _e( 'Get Free Support', 'woo-feed' ); ?></a>
 
 
34
  </th>
35
  </tr>
36
  </tbody>
@@ -39,20 +125,220 @@ class Woo_Feed_Message {
39
  <tbody>
40
  <tr>
41
  <th><?php
42
- /** @noinspection HtmlUnknownTarget */
43
  printf(
44
- __( 'If you like <strong>WooCommerce Product Feed</strong>, Please leave us a <a class="review-star" href="%1$s" target="_blank" aria-label="5 Star"><span aria-hidden="true"></span></a> rating <a href="%1$s" target="_blank">here.</a>', 'woo-feed' ),
45
- $reviewURL
 
 
 
46
  );
47
- ?></th>
48
  </tr>
49
  </tbody>
50
  </table><br>
51
  <?php
52
- return ob_get_clean();
53
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  }
55
 
56
- function WPFFWMessage(){
57
- return new Woo_Feed_Message();
 
 
 
 
 
58
  }
1
  <?php
 
2
  /**
3
  * A class definition responsible for processing and mapping product according to feed rules and make the feed
4
  *
9
  * @subpackage Woo_Feed/includes
10
  * @author Ohidul Islam <wahid@webappick.com>
11
  */
12
+ final class Woo_Feed_Message {
13
+
14
+ /**
15
+ * @var Woo_Feed_Message
16
+ */
17
+ protected static $instance;
18
+
19
+ /**
20
+ * Holds Messages & Notices
21
+ *
22
+ * @var array
23
+ */
24
+ private $messages = array();
25
+
26
+ /**
27
+ * Is Output Sent Flag
28
+ *
29
+ * @var bool
30
+ */
31
+ private $is_displayed = false;
32
+
33
+ /**
34
+ * Get Woo_Feed_Message Singleton Instance
35
+ *
36
+ * @return Woo_Feed_Message
37
+ */
38
+ public static function getInstance() {
39
+ if ( is_null( self::$instance ) ) {
40
+ self::$instance = new self();
41
+ }
42
+ return self::$instance;
43
+ }
44
+
45
+ /**
46
+ * Woo_Feed_Message constructor.
47
+ * Initialize default messages and notices
48
+ *
49
+ * @return void
50
+ */
51
+ private function __construct() {
52
+ $this->set_saved_messages();
53
+ $this->set_feed_edit_update_messages();
54
+ $this->set_schedule_update_messages();
55
+ $this->set_settings_messages();
56
+ }
57
+
58
+ /**
59
+ * Display Admin Messages & Notices
60
+ *
61
+ * @return void
62
+ */
63
+ public function displayMessages() {
64
+ $this->is_displayed = true;
65
+ $this->display_support_links();
66
+ $this->display_admin_messages();
67
+ }
68
 
69
+ /**
70
+ * Set Message/Notice to be displayed in admin area within WooFeed Pages.
71
+ *
72
+ * @param array $message message data.
73
+ * @return void
74
+ */
75
+ public function setMessage( $message = array() ) {
76
+ if ( true === $this->is_displayed ) {
77
+ /* translators: 1: Method Name 2: Method Name */
78
+ woo_feed_doing_it_wrong( __METHOD__, sprintf( esc_html__( '%1$s Should be called before %2$s', 'woo-feed' ), __METHOD__, 'Woo_Feed_Message::displayMessages()' ), '3.2.12' );
79
+ }
80
+ if ( is_array( $message ) && isset( $message['notice'], $message['type'], $message['dismissible'] ) ) {
81
+ $this->messages[] = array(
82
+ 'notice' => $message['notice'],
83
+ 'type' => $message['type'],
84
+ 'dismissible' => (bool) $message['dismissible'],
85
+ );
86
+ }
87
+ }
88
+
89
+ /**
90
+ * Display The tob bar (support and documentation links)
91
+ *
92
+ * @return void
93
+ */
94
+ private function display_support_links() {
95
  ?>
96
  <table class="wf-info-table widefat fixed">
97
  <tbody>
98
  <tr>
99
  <th>
100
+ <strong>
101
+ <a class="get-woo-feed-pro" href="http://bit.ly/2KIwvTt" target="_blank" aria-label="<?php esc_attr_e( 'Get Woo Feed Pro', 'woo-feed' ); ?>">
102
+ <img src="<?php echo esc_url( WOO_FEED_PLUGIN_URL ); ?>admin/images/get-woo-feed-pro.svg" alt="<?php esc_attr_e( 'Get Woo Feed Pro', 'woo-feed' ); ?>">
103
+ </a>
104
+ </strong>
105
  </th>
106
  <th>
107
+ <strong>
108
+ <a class="documentation button button-secondary button-hero" href="http://webappick.helpscoutdocs.com/" target="_blank" ><?php _e( 'Documentation', 'woo-feed' ); ?></a>
109
+ </strong>
110
  </th>
111
  <th>
112
+ <strong>
113
+ <a class="tutorial button button-secondary button-hero" href="http://bit.ly/2u6giNz" target="_blank"><?php _e( 'Video Tutorials', 'woo-feed' ); ?></a>
114
+ </strong>
115
  </th>
116
  <th>
117
+ <strong>
118
+ <a class="support button button-secondary button-hero" href="https://wordpress.org/support/plugin/webappick-product-feed-for-woocommerce/#new-topic-0" target="_blank"><?php _e( 'Get Free Support', 'woo-feed' ); ?></a>
119
+ </strong>
120
  </th>
121
  </tr>
122
  </tbody>
125
  <tbody>
126
  <tr>
127
  <th><?php
 
128
  printf(
129
+ /* translators: 1: This plugin name, 2: Rating page link with star, 3: Rating page link */
130
+ esc_html__( 'If you like %1$s, Please leave us a %2$s rating %3$s', 'woo-feed' ),
131
+ '<strong>'.esc_html__( 'WooCommerce Product Feed', 'woo-feed' ).'</strong>',
132
+ '<a class="review-star" href="https://wordpress.org/support/plugin/webappick-product-feed-for-woocommerce/reviews/?rate=5#new-post" target="_blank" aria-label="5 Star"><span aria-hidden="true"></span></a>',
133
+ '<a href="https://wordpress.org/support/plugin/webappick-product-feed-for-woocommerce/reviews/?rate=5#new-post" target="_blank">' . esc_html__( 'here.', 'woo-feed' ) . '</a>'
134
  );
135
+ ?></th>
136
  </tr>
137
  </tbody>
138
  </table><br>
139
  <?php
140
+ }
141
+
142
+ /**
143
+ * Prints Admin Messages & Notices
144
+ *
145
+ * @return void
146
+ */
147
+ private function display_admin_messages() {
148
+ if ( ! empty( $this->messages ) ) {
149
+ foreach ( $this->messages as $notice ) {
150
+ if ( ! isset( $notice['notice'] ) || ! isset( $notice['type'] ) ) {
151
+ continue;
152
+ }
153
+ $isDismissible = isset( $notice['dismissible'] ) && true === $notice['dismissible'] ? ' is-dismissible' : '';
154
+ printf(
155
+ '<div class="notice notice-%1$s %1$s%3$s"><p>%2$s</p></div>',
156
+ esc_attr( $notice['type'] ),
157
+ wp_kses_post( $notice['notice'] ),
158
+ esc_attr( $isDismissible )
159
+ );
160
+ }
161
+ }
162
+ }
163
+
164
+ /**
165
+ * Set Messages From DB
166
+ *
167
+ * @return void
168
+ */
169
+ private function set_saved_messages() {
170
+ // phpcs:disable WordPress.Security.NonceVerification.Recommended
171
+ if ( isset( $_GET['wpf_message'] ) && ! empty( $_GET['wpf_message'] ) ) {
172
+ $type = sanitize_text_field( $_GET['wpf_message'] );
173
+ $message = esc_html( get_option( 'wpf_message' ) );
174
+ delete_option( 'wpf_message' ); // empty message cache.
175
+ $dir = get_option( 'WPF_DIRECTORY_PERMISSION_CHECK', false );
176
+ if ( $dir ) {
177
+ $message .= ' ' . esc_html( $dir );
178
+ delete_option( 'WPF_DIRECTORY_PERMISSION_CHECK' ); // empty message cache.
179
+ }
180
+ $message = trim( $message );
181
+ if ( ! empty( $message ) ) {
182
+ $this->setMessage(
183
+ array(
184
+ 'notice' => $message,
185
+ 'type' => $type,
186
+ 'dismissible' => true,
187
+ )
188
+ );
189
+ }
190
+ }
191
+ // phpcs:enable
192
+ }
193
+
194
+ /**
195
+ * Set Feed Edit/Update Messages
196
+ *
197
+ * @return void
198
+ */
199
+ private function set_feed_edit_update_messages() {
200
+ global $plugin_page;
201
+ // phpcs:disable WordPress.Security.NonceVerification.Recommended
202
+ if ( 'webappick-manage-feeds' == $plugin_page ) {
203
+ if ( ( isset( $_GET['feed_updated'] ) || isset( $_GET['feed_created'] ) ) && isset( $_GET['feed_name'] ) ) {
204
+ if ( isset( $_GET['feed_created'] ) ) {
205
+ $this->setMessage(
206
+ array(
207
+ 'notice' => esc_html__( 'Feed Config Created Successfully.', 'woo-feed' ),
208
+ 'type' => 'success',
209
+ 'dismissible' => true,
210
+ )
211
+ );
212
+ }
213
+ if ( isset( $_GET['feed_updated'] ) ) {
214
+ $this->setMessage(
215
+ array(
216
+ 'notice' => esc_html__( 'Feed Config Updated Successfully.', 'woo-feed' ),
217
+ 'type' => 'updated',
218
+ 'dismissible' => true,
219
+ )
220
+ );
221
+ }
222
+ }
223
+ // get updated link.
224
+ if ( isset( $_GET['link'] ) && ! empty( $_GET['link'] ) ) {
225
+ $link = filter_input( INPUT_GET, 'link', FILTER_VALIDATE_URL );
226
+ /**
227
+ * @TODO use session/cookies/localstorage or transient api for this message
228
+ * @see settings_errors()
229
+ */
230
+ if ( isset( $link ) && ! empty( $link ) ) {
231
+ /** @noinspection HtmlUnknownTarget */
232
+ $link = sprintf( '<a href="%1$s" target="_blank">%1$s</a>', esc_url( $link ) );
233
+ /* translators: Feed URL */
234
+ $notice = sprintf( esc_html__( 'Feed Generated Successfully. Feed URL: %s', 'woo-feed' ), $link );
235
+ $notice = '<b style="color: #008779;">' . $notice . '</b>';
236
+ if ( isset( $_GET['cat'] ) && 'no' == $_GET['cat'] ) {
237
+ $notice .= sprintf( '<br/><br/><b style="color: #f49242;">%s</b>', esc_html__( 'Warning:', 'woo-feed' ) );
238
+ $link = 'https://webappick.helpscoutdocs.com/article/19-how-to-map-store-category-with-merchant-category';
239
+ /** @noinspection HtmlUnknownTarget */
240
+ $link = sprintf( '<a href="%s" target="_blank">%s</a>', esc_url( $link ), esc_html__( 'Learn more...', 'woo-feed' ) );
241
+ $notice .= sprintf( '<ul><li>%s %s</li></ul>', esc_html__( 'Google Product category is not selected. Your AdWords CPC rate will be high. Add proper Google Product Category to each product & reduce CPC rate.', 'woo-feed' ), $link );
242
+ }
243
+ $this->setMessage(
244
+ array(
245
+ 'notice' => $notice,
246
+ 'type' => 'updated',
247
+ 'dismissible' => true,
248
+ )
249
+ );
250
+ }
251
+ }
252
+ }
253
+ // phpcs:enable
254
+ }
255
+
256
+ /**
257
+ * Set Schedule Update Response Message
258
+ *
259
+ * @return void
260
+ */
261
+ private function set_schedule_update_messages() {
262
+ global $plugin_page;
263
+ // phpcs:disable WordPress.Security.NonceVerification.Recommended
264
+ if ( 'webappick-manage-feeds' == $plugin_page ) {
265
+ if ( isset( $_GET['schedule_updated'] ) && ! empty( $_GET['schedule_updated'] ) ) {
266
+ if ( 1 == $_GET['schedule_updated'] ) {
267
+ $this->setMessage(
268
+ array(
269
+ 'notice' => esc_html__( 'Feed auto update interval updated.', 'woo-feed' ),
270
+ 'type' => 'updated',
271
+ 'dismissible' => true,
272
+ )
273
+ );
274
+ }
275
+ if ( 2 == $_GET['schedule_updated'] ) {
276
+ $this->setMessage(
277
+ array(
278
+ 'notice' => esc_html__( 'Unable to save auto update interval.', 'woo-feed' ),
279
+ 'type' => 'warning',
280
+ 'dismissible' => true,
281
+ )
282
+ );
283
+ }
284
+ if ( 3 == $_GET['schedule_updated'] ) {
285
+ $this->setMessage(
286
+ array(
287
+ 'notice' => esc_html__( 'Invalid interval value.', 'woo-feed' ),
288
+ 'type' => 'error',
289
+ 'dismissible' => true,
290
+ )
291
+ );
292
+ }
293
+ if ( 4 == $_GET['schedule_updated'] ) {
294
+ $this->setMessage(
295
+ array(
296
+ 'notice' => esc_html__( 'Invalid request.', 'woo-feed' ),
297
+ 'type' => 'error',
298
+ 'dismissible' => true,
299
+ )
300
+ );
301
+ }
302
+ }
303
+ }
304
+ // phpcs:enable
305
+ }
306
+
307
+ /**
308
+ * Set Settings Notices
309
+ *
310
+ * @return void
311
+ */
312
+ private function set_settings_messages() {
313
+ global $plugin_page;
314
+ // phpcs:disable WordPress.Security.NonceVerification.Recommended
315
+ if ( 'webappick-feed-settings' == $plugin_page ) {
316
+ if ( isset( $_GET['settings_updated'] ) && '1' == $_GET['settings_updated'] ) {
317
+ $this->setMessage(
318
+ array(
319
+ 'notice' => esc_html__( 'Settings Updated.', 'woo-feed' ),
320
+ 'type' => 'updated',
321
+ 'dismissible' => true,
322
+ )
323
+ );
324
+ }
325
+ }
326
+ // phpcs:enable
327
+ }
328
+
329
+ /**
330
+ * Define private clone method to disallow cloning
331
+ */
332
+ private function __clone() {
333
+ // cloning isn't allowed.
334
+ }
335
  }
336
 
337
+ /**
338
+ * Get Woo_Feed_message Instance
339
+ *
340
+ * @return Woo_Feed_Message
341
+ */
342
+ function WPFFWMessage() {
343
+ return Woo_Feed_Message::getInstance();
344
  }
includes/classes/class-woo-feed-auto-update.php CHANGED
@@ -23,123 +23,120 @@ class WOO_FEED_AUTO_UPDATE{
23
  private $executionTime;
24
 
25
  public function __construct(){
26
- $this->feedNames=$this->get_feed_names();
27
- $this->executionTime=$this->getExecutionTime();
28
  $this->executeUpdate();
29
  $this->executeUpdate();
30
  }
31
 
32
 
33
- public function get_feed_names()
34
- {
35
  global $wpdb;
36
  $query = $wpdb->prepare("SELECT * FROM $wpdb->options WHERE option_name LIKE %s;", "wf_feed_%");
37
  $result = $wpdb->get_results($query, 'ARRAY_A');
38
- $feeds=array();
39
- $i=1;
40
- foreach ($result as $key => $value) {
41
  $feedInfo = unserialize(get_option($value['option_name']));
42
- $feeds[$i]['last_updated']=$feedInfo['last_updated'];
43
- $feeds[$i]['feed_name']=$value['option_name'];
44
  $i++;
45
  }
46
 
47
  return $feeds;
48
  }
49
 
50
- public function getExecutionTime()
51
- {
52
  return ini_get("max_execution_time");
53
  }
54
 
55
- public function getFeedInfo($feedName)
56
- {
57
- $feedInfo=get_option("wf_cron_info_".$feedName);
58
- if($feedInfo){
59
  return $feedInfo;
60
- }else{
61
- $totalProducts=$this->getTotalProducts($feedName);
62
- $batches=ceil($totalProducts/200);
63
- $feedInfo=array(
64
- "totalProducts"=>$totalProducts,
65
- "batches"=>$batches,
66
- );
67
  update_option("wf_cron_info_".$feedName,$feedInfo);
68
  return $feedInfo;
69
  }
70
  }
71
 
72
- public function getTotalProducts($feedName){
73
- $feedName=sanitize_text_field(str_replace("wf_feed_","wf_config",$feedName));
74
- $feedInfo=get_option($feedName);
75
 
76
- if(!$feedInfo){
77
- $getFeedConfig=unserialize(get_option($feedName));
78
- $feedInfo=$getFeedConfig['feedrules'];
79
  }
80
  $arg = array(
81
- 'post_type' => array('product','product_variation'),
82
- 'post_status' => 'publish',
83
  'ignore_sticky_posts' => 1,
84
- 'posts_per_page' => -1,
85
- 'orderby' => 'date',
86
- 'order' => 'desc',
87
- 'fields' => 'ids',
88
  );
89
 
90
- if (get_option('woocommerce_product_feed_pro_activated') && get_option('woocommerce_product_feed_pro_activated') == "Activated") {
91
 
92
  # Argument for Product search by ID
93
- if (isset($feedInfo['fattribute']) && is_array($feedInfo['fattribute'])) {
94
- if(count($feedInfo['fattribute'])){
95
- $condition=$feedInfo['condition'];
96
- $compare=$feedInfo['filterCompare'];
97
- $ids_in=array();
98
- $ids_not_in=array();
99
- foreach($feedInfo['fattribute'] as $key=>$rule){
100
- if($rule=='id' && in_array($condition[$key],array("==","contain"))){
101
- unset($feedInfo['fattribute'][$key]);
102
- unset($feedInfo['condition'][$key]);
103
- unset($feedInfo['filterCompare'][$key]);
104
- if (strpos($compare[$key],',') !== false) {
105
- foreach(explode(",",$compare[$key]) as $key=>$id){
106
  array_push($ids_in,$id);
107
  }
108
- }else{
109
- array_push($ids_in,$compare[$key]);
110
  }
111
- }elseif($rule=='id' && in_array($condition[$key],array("!=","nContains"))){
112
- unset($feedInfo['fattribute'][$key]);
113
- unset($feedInfo['condition'][$key]);
114
- unset($feedInfo['filterCompare'][$key]);
115
- if (strpos($compare[$key],',') !== false) {
116
- foreach(explode(",",$compare[$key]) as $key=>$id){
117
  array_push($ids_not_in,$id);
118
  }
119
- }else{
120
- array_push($ids_not_in,$compare[$key]);
121
  }
122
  }
123
  }
124
 
125
- if(count($ids_in)){
126
- $arg['post__in']=$ids_in;
127
  }
128
 
129
- if(count($ids_not_in)){
130
- $arg['post__not_in']=$ids_not_in;
131
  }
132
  }
133
  }
134
 
135
- if (isset($feedInfo['categories']) && is_array($feedInfo['categories']) && !empty($feedInfo['categories'][0])) {
136
  $i = 0;
137
  $arg['tax_query']['relation'] = "OR";
138
- foreach ($feedInfo['categories'] as $key => $value) {
139
- if (!empty($value)) {
140
- $arg['tax_query'][$i]["taxonomy"] = "product_cat";
141
- $arg['tax_query'][$i]["field"] = "slug";
142
- $arg['tax_query'][$i]["terms"] = $value;
143
  $i++;
144
  }
145
  }
@@ -152,38 +149,36 @@ class WOO_FEED_AUTO_UPDATE{
152
  return $loop->post_count;
153
  }
154
 
155
- public function updateBatchInfo($feedName,$Info,$lastBatch,$status)
156
- {
157
- $feedInfo=get_option("wf_cron_info_".$feedName);
158
- if($feedInfo){
159
- $feedInfo['lastBatch']=$lastBatch;
160
- $feedInfo['completed']=$status;
161
  update_option("wf_cron_info_".$feedName,$feedInfo);
162
- }else{
163
- $nInfo=array(
164
- "totalProducts"=>$Info['totalProducts'],
165
- "batches"=>$Info['batches'],
166
- "lastBatch"=>$lastBatch,
167
- "completed"=>$status,
168
  );
169
  update_option("wf_cron_info_".$feedName,$nInfo);
170
  }
171
 
172
  }
173
 
174
- public function executeUpdate()
175
- {
176
- if(!empty($this->feedNames)){
177
- foreach($this->feedNames as $name){
178
- $info=$this->getFeedInfo($name['feed_name']);
179
- if(isset($info['update'])){
180
 
181
- }else if(!empty($info['batches']) && $info['batches']>0){
182
- $offset=0;
183
- $limit=200;
184
- for ($i=1;$i<$info['batches'];$i++){
185
  $this->woo_feed_make_batch_feed($name['feed_name'],200,$offset);
186
- $offset=$offset+$limit;
187
  }
188
  $this->woo_feed_save_feed_file($name['feed_name']);
189
  }
@@ -191,16 +186,16 @@ class WOO_FEED_AUTO_UPDATE{
191
  }
192
  }
193
 
194
- public function woo_feed_generate_feed_data($info){
195
- if (count($info) && isset($info['provider'])) {
196
  # GEt Post data
197
- if ($info['provider'] == 'google') {
198
  $merchant = "Woo_Feed_Google";
199
- } elseif ($info['provider'] == 'facebook') {
200
  $merchant = "Woo_Feed_Facebook";
201
- }elseif (strpos($info['provider'],'amazon') !==FALSE) {
202
  $merchant = "Woo_Feed_Amazon";
203
- }elseif ($info['provider'] == 'custom2') {
204
  $merchant = "Woo_Feed_Custom2";
205
  } else {
206
  $merchant = "Woo_Feed_Custom";
@@ -215,20 +210,20 @@ class WOO_FEED_AUTO_UPDATE{
215
  # Get Feed info
216
  $products = new Woo_Generate_Feed($merchant, $feedRules);
217
  $feed = $products->getProducts();
218
- if(!empty($feed['body'])){
219
- $feedHeader="wf_cron_feed_header_info_".$fileName;
220
- $feedBody="wf_cron_feed_body_info_".$fileName;
221
- $feedFooter="wf_cron_feed_footer_info_".$fileName;
222
- $prevFeed= woo_feed_get_batch_feed_info($feedService,$type,$feedBody);//get_option($feedBody);
223
- if($prevFeed){
224
- if($type=='csv'){
225
- $newFeed=array_merge($prevFeed, $feed['body']);
226
- }else{
227
- $newFeed=$prevFeed.$feed['body'];
228
  }
229
  //update_option($feedBody,$newFeed);
230
  woo_feed_save_batch_feed_info($feedService,$type,$newFeed,$feedBody,$info);
231
- }else{
232
  //update_option($feedBody,$feed['body']);
233
  woo_feed_save_batch_feed_info($feedService,$type,$feed['body'],$feedBody,$info);
234
  }
@@ -238,7 +233,7 @@ class WOO_FEED_AUTO_UPDATE{
238
  woo_feed_save_batch_feed_info($feedService,$type,$feed['footer'],$feedFooter,$info);
239
 
240
  return true;
241
- }else{
242
  return false;
243
  }
244
  }
@@ -246,48 +241,48 @@ class WOO_FEED_AUTO_UPDATE{
246
  }
247
 
248
 
249
- public function woo_feed_make_batch_feed($feedName,$limit,$offset){
250
- $limit=sanitize_text_field($limit);
251
- $offset=sanitize_text_field($offset);
252
- $feedName=sanitize_text_field(str_replace("wf_feed_","wf_config",$feedName));
253
- $feedInfo=get_option($feedName);
254
-
255
- if(!$feedInfo){
256
- $getFeedConfig=unserialize(get_option($feedName));
257
- $feedInfo=$getFeedConfig['feedrules'];
258
  }
259
 
260
- $feedInfo['Limit']=$limit;
261
- $feedInfo['Offset']=$offset;
262
  return $this->woo_feed_generate_feed_data($feedInfo);
263
  }
264
 
265
 
266
- public function woo_feed_save_feed_file($feedName){
267
 
268
- $feed=str_replace("wf_feed_", "",$feedName);
269
- $info=get_option($feed);
270
- if(!$info){
271
- $getInfo=unserialize(get_option($feedName));
272
- $info=$getInfo['feedrules'];
273
  }
274
  $feedService = $info['provider'];
275
  $fileName = str_replace(" ", "",$info['filename']);
276
  $type = $info['feedType'];
277
 
278
  //$feedHeader=get_option("wf_store_feed_header_info_".$fileName);
279
- $feedHeader=woo_feed_get_batch_feed_info($feedService,$type,"wf_cron_feed_header_info_".$fileName);
280
  //$feedBody=get_option("wf_store_feed_body_info_".$fileName);
281
- $feedBody=woo_feed_get_batch_feed_info($feedService,$type,"wf_cron_feed_body_info_".$fileName);
282
  //$feedFooter=get_option("wf_store_feed_footer_info_".$fileName);
283
- $feedFooter=woo_feed_get_batch_feed_info($feedService,$type,"wf_cron_feed_footer_info_".$fileName);
284
 
285
  // echo "<pre>"; print_r($feedHeader); print_r($feedBody);
286
- if($type=='csv'){
287
- $csvHead[0]=$feedHeader;
288
- $string=array_merge($csvHead,$feedBody);
289
- }else{
290
- $string=$feedHeader.$feedBody.$feedFooter;
291
  }
292
  // print_r($string);
293
  // $data=array($string);
@@ -299,30 +294,33 @@ class WOO_FEED_AUTO_UPDATE{
299
  $path = $base . "/woo-feed/" . $feedService . "/" . $type;
300
  $saveFile = false;
301
  # Check If any products founds
302
- if ($string) {
303
  # Save File
304
 
305
  $file = $path . "/" . $fileName . "." . $type;
306
  $save = new Woo_Feed_Savefile();
307
- if ($type == "csv") {
308
  $saveFile = $save->saveCSVFile($path, $file, $string, $info);
309
  } else {
310
  $saveFile = $save->saveFile($path, $file, $string);
311
  }
312
- }else{
313
- $data=array("success"=>false,"message"=>"No Product Found with your feed configuration. Please Update & Generate the feed again.");
 
 
 
314
  }
315
 
316
 
317
  # Save Info into database
318
  $url = $upload_dir['baseurl'] . "/woo-feed/" . $feedService . "/" . $type . "/" . $fileName . "." . $type;
319
  $feedInfo = array(
320
- 'feedrules' => $info,
321
- 'url' => $url,
322
- 'last_updated' => date("Y-m-d H:i:s"),
323
  );
324
 
325
- if (!empty($name) && $name != "wf_feed_" . $fileName) {
326
  delete_option($name);
327
  }
328
 
@@ -330,8 +328,8 @@ class WOO_FEED_AUTO_UPDATE{
330
  delete_option("wf_store_feed_header_info_".$fileName);
331
  delete_option("wf_store_feed_body_info_".$fileName);
332
  delete_option("wf_store_feed_footer_info_".$fileName);
333
- if ($type == "csv") {
334
- $type="json";
335
  }
336
  // unlink($path . "/" . "wf_cron_feed_header_info_".$fileName . "." . $type);
337
  // unlink($path . "/" . "wf_cron_feed_body_info_".$fileName . "." . $type);
23
  private $executionTime;
24
 
25
  public function __construct(){
26
+ $this->feedNames = $this->get_feed_names();
27
+ $this->executionTime = $this->getExecutionTime();
28
  $this->executeUpdate();
29
  $this->executeUpdate();
30
  }
31
 
32
 
33
+ public function get_feed_names() {
 
34
  global $wpdb;
35
  $query = $wpdb->prepare("SELECT * FROM $wpdb->options WHERE option_name LIKE %s;", "wf_feed_%");
36
  $result = $wpdb->get_results($query, 'ARRAY_A');
37
+ $feeds = array();
38
+ $i = 1;
39
+ foreach ( $result as $key => $value ) {
40
  $feedInfo = unserialize(get_option($value['option_name']));
41
+ $feeds[ $i ]['last_updated'] = $feedInfo['last_updated'];
42
+ $feeds[ $i ]['feed_name'] = $value['option_name'];
43
  $i++;
44
  }
45
 
46
  return $feeds;
47
  }
48
 
49
+ public function getExecutionTime() {
 
50
  return ini_get("max_execution_time");
51
  }
52
 
53
+ public function getFeedInfo( $feedName ) {
54
+ $feedInfo = get_option("wf_cron_info_".$feedName);
55
+ if ( $feedInfo ) {
 
56
  return $feedInfo;
57
+ }else {
58
+ $totalProducts = $this->getTotalProducts($feedName);
59
+ $batches = ceil($totalProducts / 200);
60
+ $feedInfo = array(
61
+ "totalProducts" => $totalProducts,
62
+ "batches" => $batches,
63
+ );
64
  update_option("wf_cron_info_".$feedName,$feedInfo);
65
  return $feedInfo;
66
  }
67
  }
68
 
69
+ public function getTotalProducts( $feedName ) {
70
+ $feedName = sanitize_text_field(str_replace("wf_feed_","wf_config",$feedName));
71
+ $feedInfo = get_option($feedName);
72
 
73
+ if ( ! $feedInfo ) {
74
+ $getFeedConfig = unserialize(get_option($feedName));
75
+ $feedInfo = $getFeedConfig['feedrules'];
76
  }
77
  $arg = array(
78
+ 'post_type' => array( 'product', 'product_variation' ),
79
+ 'post_status' => 'publish',
80
  'ignore_sticky_posts' => 1,
81
+ 'posts_per_page' => -1,
82
+ 'orderby' => 'date',
83
+ 'order' => 'desc',
84
+ 'fields' => 'ids',
85
  );
86
 
87
+ if ( get_option('woocommerce_product_feed_pro_activated') && get_option('woocommerce_product_feed_pro_activated') == "Activated" ) {
88
 
89
  # Argument for Product search by ID
90
+ if ( isset($feedInfo['fattribute']) && is_array($feedInfo['fattribute']) ) {
91
+ if ( count($feedInfo['fattribute']) ) {
92
+ $condition = $feedInfo['condition'];
93
+ $compare = $feedInfo['filterCompare'];
94
+ $ids_in = array();
95
+ $ids_not_in = array();
96
+ foreach ( $feedInfo['fattribute'] as $key => $rule ) {
97
+ if ( $rule == 'id' && in_array($condition[ $key ],array( "==", "contain" )) ) {
98
+ unset($feedInfo['fattribute'][ $key ]);
99
+ unset($feedInfo['condition'][ $key ]);
100
+ unset($feedInfo['filterCompare'][ $key ]);
101
+ if ( strpos($compare[ $key ],',') !== false ) {
102
+ foreach ( explode(",",$compare[ $key ]) as $key => $id ) {
103
  array_push($ids_in,$id);
104
  }
105
+ }else {
106
+ array_push($ids_in,$compare[ $key ]);
107
  }
108
+ }elseif ( $rule == 'id' && in_array($condition[ $key ],array( "!=", "nContains" )) ) {
109
+ unset($feedInfo['fattribute'][ $key ]);
110
+ unset($feedInfo['condition'][ $key ]);
111
+ unset($feedInfo['filterCompare'][ $key ]);
112
+ if ( strpos($compare[ $key ],',') !== false ) {
113
+ foreach ( explode(",",$compare[ $key ]) as $key => $id ) {
114
  array_push($ids_not_in,$id);
115
  }
116
+ }else {
117
+ array_push($ids_not_in,$compare[ $key ]);
118
  }
119
  }
120
  }
121
 
122
+ if ( count($ids_in) ) {
123
+ $arg['post__in'] = $ids_in;
124
  }
125
 
126
+ if ( count($ids_not_in) ) {
127
+ $arg['post__not_in'] = $ids_not_in;
128
  }
129
  }
130
  }
131
 
132
+ if ( isset($feedInfo['categories']) && is_array($feedInfo['categories']) && ! empty($feedInfo['categories'][0]) ) {
133
  $i = 0;
134
  $arg['tax_query']['relation'] = "OR";
135
+ foreach ( $feedInfo['categories'] as $key => $value ) {
136
+ if ( ! empty($value) ) {
137
+ $arg['tax_query'][ $i ]["taxonomy"] = "product_cat";
138
+ $arg['tax_query'][ $i ]["field"] = "slug";
139
+ $arg['tax_query'][ $i ]["terms"] = $value;
140
  $i++;
141
  }
142
  }
149
  return $loop->post_count;
150
  }
151
 
152
+ public function updateBatchInfo( $feedName,$Info,$lastBatch,$status ) {
153
+ $feedInfo = get_option("wf_cron_info_".$feedName);
154
+ if ( $feedInfo ) {
155
+ $feedInfo['lastBatch'] = $lastBatch;
156
+ $feedInfo['completed'] = $status;
 
157
  update_option("wf_cron_info_".$feedName,$feedInfo);
158
+ }else {
159
+ $nInfo = array(
160
+ "totalProducts" => $Info['totalProducts'],
161
+ "batches" => $Info['batches'],
162
+ "lastBatch" => $lastBatch,
163
+ "completed" => $status,
164
  );
165
  update_option("wf_cron_info_".$feedName,$nInfo);
166
  }
167
 
168
  }
169
 
170
+ public function executeUpdate() {
171
+ if ( ! empty($this->feedNames) ) {
172
+ foreach ( $this->feedNames as $name ) {
173
+ $info = $this->getFeedInfo($name['feed_name']);
174
+ if ( isset($info['update']) ) {
 
175
 
176
+ }elseif ( ! empty($info['batches']) && $info['batches'] > 0 ) {
177
+ $offset = 0;
178
+ $limit = 200;
179
+ for ( $i = 1;$i < $info['batches'];$i++ ) {
180
  $this->woo_feed_make_batch_feed($name['feed_name'],200,$offset);
181
+ $offset = $offset + $limit;
182
  }
183
  $this->woo_feed_save_feed_file($name['feed_name']);
184
  }
186
  }
187
  }
188
 
189
+ public function woo_feed_generate_feed_data( $info ) {
190
+ if ( count($info) && isset($info['provider']) ) {
191
  # GEt Post data
192
+ if ( $info['provider'] == 'google' ) {
193
  $merchant = "Woo_Feed_Google";
194
+ } elseif ( $info['provider'] == 'facebook' ) {
195
  $merchant = "Woo_Feed_Facebook";
196
+ }elseif ( strpos($info['provider'],'amazon') !== FALSE ) {
197
  $merchant = "Woo_Feed_Amazon";
198
+ }elseif ( $info['provider'] == 'custom2' ) {
199
  $merchant = "Woo_Feed_Custom2";
200
  } else {
201
  $merchant = "Woo_Feed_Custom";
210
  # Get Feed info
211
  $products = new Woo_Generate_Feed($merchant, $feedRules);
212
  $feed = $products->getProducts();
213
+ if ( ! empty($feed['body']) ) {
214
+ $feedHeader = "wf_cron_feed_header_info_".$fileName;
215
+ $feedBody = "wf_cron_feed_body_info_".$fileName;
216
+ $feedFooter = "wf_cron_feed_footer_info_".$fileName;
217
+ $prevFeed = woo_feed_get_batch_feed_info($feedService,$type,$feedBody);//get_option($feedBody);
218
+ if ( $prevFeed ) {
219
+ if ( $type == 'csv' ) {
220
+ $newFeed = array_merge($prevFeed, $feed['body']);
221
+ }else {
222
+ $newFeed = $prevFeed.$feed['body'];
223
  }
224
  //update_option($feedBody,$newFeed);
225
  woo_feed_save_batch_feed_info($feedService,$type,$newFeed,$feedBody,$info);
226
+ }else {
227
  //update_option($feedBody,$feed['body']);
228
  woo_feed_save_batch_feed_info($feedService,$type,$feed['body'],$feedBody,$info);
229
  }
233
  woo_feed_save_batch_feed_info($feedService,$type,$feed['footer'],$feedFooter,$info);
234
 
235
  return true;
236
+ }else {
237
  return false;
238
  }
239
  }
241
  }
242
 
243
 
244
+ public function woo_feed_make_batch_feed( $feedName,$limit,$offset ) {
245
+ $limit = sanitize_text_field($limit);
246
+ $offset = sanitize_text_field($offset);
247
+ $feedName = sanitize_text_field(str_replace("wf_feed_","wf_config",$feedName));
248
+ $feedInfo = get_option($feedName);
249
+
250
+ if ( ! $feedInfo ) {
251
+ $getFeedConfig = unserialize(get_option($feedName));
252
+ $feedInfo = $getFeedConfig['feedrules'];
253
  }
254
 
255
+ $feedInfo['Limit'] = $limit;
256
+ $feedInfo['Offset'] = $offset;
257
  return $this->woo_feed_generate_feed_data($feedInfo);
258
  }
259
 
260
 
261
+ public function woo_feed_save_feed_file( $feedName ) {
262
 
263
+ $feed = str_replace("wf_feed_", "",$feedName);
264
+ $info = get_option($feed);
265
+ if ( ! $info ) {
266
+ $getInfo = unserialize(get_option($feedName));
267
+ $info = $getInfo['feedrules'];
268
  }
269
  $feedService = $info['provider'];
270
  $fileName = str_replace(" ", "",$info['filename']);
271
  $type = $info['feedType'];
272
 
273
  //$feedHeader=get_option("wf_store_feed_header_info_".$fileName);
274
+ $feedHeader = woo_feed_get_batch_feed_info($feedService,$type,"wf_cron_feed_header_info_".$fileName);
275
  //$feedBody=get_option("wf_store_feed_body_info_".$fileName);
276
+ $feedBody = woo_feed_get_batch_feed_info($feedService,$type,"wf_cron_feed_body_info_".$fileName);
277
  //$feedFooter=get_option("wf_store_feed_footer_info_".$fileName);
278
+ $feedFooter = woo_feed_get_batch_feed_info($feedService,$type,"wf_cron_feed_footer_info_".$fileName);
279
 
280
  // echo "<pre>"; print_r($feedHeader); print_r($feedBody);
281
+ if ( $type == 'csv' ) {
282
+ $csvHead[0] = $feedHeader;
283
+ $string = array_merge($csvHead,$feedBody);
284
+ }else {
285
+ $string = $feedHeader.$feedBody.$feedFooter;
286
  }
287
  // print_r($string);
288
  // $data=array($string);
294
  $path = $base . "/woo-feed/" . $feedService . "/" . $type;
295
  $saveFile = false;
296
  # Check If any products founds
297
+ if ( $string ) {
298
  # Save File
299
 
300
  $file = $path . "/" . $fileName . "." . $type;
301
  $save = new Woo_Feed_Savefile();
302
+ if ( $type == "csv" ) {
303
  $saveFile = $save->saveCSVFile($path, $file, $string, $info);
304
  } else {
305
  $saveFile = $save->saveFile($path, $file, $string);
306
  }
307
+ }else {
308
+ $data = array(
309
+ "success" => false,
310
+ "message" => "No Product Found with your feed configuration. Please Update & Generate the feed again.",
311
+ );
312
  }
313
 
314
 
315
  # Save Info into database
316
  $url = $upload_dir['baseurl'] . "/woo-feed/" . $feedService . "/" . $type . "/" . $fileName . "." . $type;
317
  $feedInfo = array(
318
+ 'feedrules' => $info,
319
+ 'url' => $url,
320
+ 'last_updated' => gmdate("Y-m-d H:i:s"),
321
  );
322
 
323
+ if ( ! empty($name) && $name != "wf_feed_" . $fileName ) {
324
  delete_option($name);
325
  }
326
 
328
  delete_option("wf_store_feed_header_info_".$fileName);
329
  delete_option("wf_store_feed_body_info_".$fileName);
330
  delete_option("wf_store_feed_footer_info_".$fileName);
331
+ if ( $type == "csv" ) {
332
+ $type = "json";
333
  }
334
  // unlink($path . "/" . "wf_cron_feed_header_info_".$fileName . "." . $type);
335
  // unlink($path . "/" . "wf_cron_feed_body_info_".$fileName . "." . $type);
includes/classes/class-woo-feed-default-attributes.php CHANGED
@@ -20,543 +20,541 @@ class Woo_Feed_Default_Attributes
20
  public $wooAttributes = array();
21
 
22
  public $googleXMLAttribute = array(
23
- "id" => array("g:id", false),
24
- "title" => array("title", true),
25
- "description" => array("description", true),
26
- "link" => array("link", true),
27
- "mobile_link" => array("mobile_link", true),
28
- "product_type" => array("g:product_type", true),
29
- "current_category" => array("g:google_product_category", true),
30
- "image" => array("g:image_link", true),
31
- "images" => array("g:additional_image_link", false),
32
- "images_1" => array("g:additional_image_link_1", true),
33
- "images_2" => array("g:additional_image_link_2", true),
34
- "images_3" => array("g:additional_image_link_3", true),
35
- "images_4" => array("g:additional_image_link_4", true),
36
- "images_5" => array("g:additional_image_link_5", true),
37
- "images_6" => array("g:additional_image_link_6", true),
38
- "images_7" => array("g:additional_image_link_7", true),
39
- "images_8" => array("g:additional_image_link_8", true),
40
- "images_9" => array("g:additional_image_link_9", true),
41
- "images_10" => array("g:additional_image_link_10", true),
42
- "condition" => array("g:condition", false),
43
- "availability" => array("g:availability", false),
44
- "availability_date" => array("g:availability_date", false),
45
- "inventory" => array("g:inventory", false),
46
- "price" => array("g:price", true),
47
- "sale_price" => array("g:sale_price", true),
48
- "sale_price_effective_date" => array("g:sale_price_effective_date", true),
49
- "brand" => array("g:brand", true),
50
- "sku" => array("g:mpn", true),
51
- "upc" => array("g:gtin", true),
52
- "identifier_exists" => array("g:identifier_exists", true),
53
- "item_group_id" => array("g:item_group_id", false),
54
- "color" => array("g:color", true),
55
- "gender" => array("g:gender", true),
56
- "age_group" => array("g:age_group", true),
57
- "material" => array("g:material", true),
58
- "pattern" => array("g:pattern", true),
59
- "size" => array("g:size", true),
60
- "size_type" => array("g:size_type", true),
61
- "size_system" => array("g:size_system", true),
62
- "tax" => array("tax", true),
63
- "tax_country" => array("g:tax_country", true),
64
- "tax_region" => array("g:tax_region", true),
65
- "tax_rate" => array("g:tax_rate", true),
66
- "tax_ship" => array("g:tax_ship", true),
67
- "tax_category" => array("g:tax_category", true),
68
- "weight" => array("g:shipping_weight", false),
69
- "length" => array("g:shipping_length", false),
70
- "width" => array("g:shipping_width", false),
71
- "height" => array("g:shipping_height", false),
72
- "shipping_label" => array("g:shipping_label", false),
73
- "shipping_country" => array("g:shipping_country", false),
74
- "shipping_service" => array("g:shipping_service", false),
75
- "shipping_price" => array("g:shipping_price", false),
76
- "shipping_region" => array("g:shipping_region", false),
77
- "multipack" => array("g:multipack", true),
78
- "is_bundle" => array("g:is_bundle", true),
79
- "adult" => array("g:adult", true),
80
- "adwords_redirect" => array("g:adwords_redirect", true),
81
- "custom_label_0" => array("g:custom_label_0", true),
82
- "custom_label_1" => array("g:custom_label_1", true),
83
- "custom_label_2" => array("g:custom_label_2", true),
84
- "custom_label_3" => array("g:custom_label_3", true),
85
- "custom_label_4" => array("g:custom_label_4", true),
86
- "excluded_destination" => array("g:excluded_destination", true),
87
- "included_destination" => array("g:included_destination", true),
88
- "expiration_date" => array("g:expiration_date", true),
89
- "unit_pricing_measure" => array("g:unit_pricing_measure", true),
90
- "unit_pricing_base_measure" => array("g:unit_pricing_base_measure", true),
91
- "energy_efficiency_class" => array("g:energy_efficiency_class", true),
92
- "loyalty_points" => array("g:loyalty_points", true),
93
- "installment" => array("g:installment", true),
94
- "promotion_id" => array("g:promotion_id", true),
95
- "cost_of_goods_sold" => array("g:cost_of_goods_sold", true),
96
  );
97
  public $googleCSVTXTAttribute = array(
98
- "id" => array("id", false),
99
- "title" => array("title", true),
100
- "description" => array("description", true),
101
- "link" => array("link", true),
102
- "mobile_link" => array("mobile_link", true),
103
- "product_type" => array("product type", true),
104
- "current_category" => array("google product category", true),
105
- "image" => array("image link", true),
106
- "images" => array("additional image link", true),
107
- "images_1" => array("additional image link 1", true),
108
- "images_2" => array("additional image link 2", true),
109
- "images_3" => array("additional image link 3", true),
110
- "images_4" => array("additional image link 4", true),
111
- "images_5" => array("additional image link 5", true),
112
- "images_6" => array("additional image link 6", true),
113
- "images_7" => array("additional image link 7", true),
114
- "images_8" => array("additional image link 8", true),
115
- "images_9" => array("additional image link 9", true),
116
- "images_10" => array("additional image link 10", true),
117
- "condition" => array("condition", false),
118
- "availability" => array("availability", false),
119
- "availability_date" => array("availability date", false),
120
- "inventory" => array("inventory", false),
121
- "price" => array("price", true),
122
- "sale_price" => array("sale price", true),
123
- "sale_price_effective_date" => array("sale price effective date", true),
124
- "brand" => array("brand", true),
125
- "sku" => array("mpn", true),
126
- "upc" => array("gtin", true),
127
- "identifier_exists" => array("identifier exists", true),
128
- "item_group_id" => array("item group id", false),
129
- "color" => array("color", true),
130
- "gender" => array("gender", true),
131
- "age_group" => array("age group", true),
132
- "material" => array("material", true),
133
- "pattern" => array("pattern", true),
134
- "size" => array("size", true),
135
- "size_type" => array("size type", true),
136
- "size_system" => array("size system", true),
137
- "tax" => array("tax", true),
138
- "tax_country" => array("tax country", true),
139
- "tax_region" => array("tax region", true),
140
- "tax_rate" => array("tax rate", true),
141
- "tax_ship" => array("tax ship", true),
142
- "tax_category" => array("tax category", true),
143
- "weight" => array("shipping weight", false),
144
- "length" => array("shipping length", false),
145
- "width" => array("shipping width", false),
146
- "height" => array("shipping height", false),
147
- "shipping_label" => array("shipping label", false),
148
- "shipping_country" => array("shipping country", false),
149
- "shipping_service" => array("shipping service", false),
150
- "shipping_price" => array("shipping price", false),
151
- "shipping_region" => array("shipping region", false),
152
- "multipack" => array("multipack", true),
153
- "is_bundle" => array("is bundle", true),
154
- "adult" => array("adult", true),
155
- "adwords_redirect" => array("adwords redirect", true),
156
- "custom_label_0" => array("custom label 0", true),
157
- "custom_label_1" => array("custom label 1", true),
158
- "custom_label_2" => array("custom label 2", true),
159
- "custom_label_3" => array("custom label 3", true),
160
- "custom_label_4" => array("custom label 4", true),
161
- "excluded_destination" => array("excluded destination", true),
162
- "included_destination" => array("included destination", true),
163
- "expiration_date" => array("expiration date", true),
164
- "unit_pricing_measure" => array("unit pricing measure", true),
165
- "unit_pricing_base_measure" => array("unit pricing base measure", true),
166
- "energy_efficiency_class" => array("energy efficiency class", true),
167
- "loyalty_points" => array("loyalty points", true),
168
- "installment" => array("installment", true),
169
- "promotion_id" => array("promotion id", true),
170
- "cost_of_goods_sold" => array("cost of goods sold", true),
171
  );
172
  public $facebookXMLAttribute = array(
173
- "id" => array("g:id", false),
174
- "title" => array("g:title", true),
175
- "description" => array("g:description", true),
176
- "link" => array("g:link", true),
177
- "mobile_link" => array("g:mobile_link", true),
178
- "product_type" => array("g:product_type", true),
179
- "current_category" => array("g:google_product_category", true),
180
- "image" => array("g:image_link", true),
181
- "images" => array("g:additional_image_link", false),
182
- "images_1" => array("g:additional_image_link_1", true),
183
- "images_2" => array("g:additional_image_link_2", true),
184
- "images_3" => array("g:additional_image_link_3", true),
185
- "images_4" => array("g:additional_image_link_4", true),
186
- "images_5" => array("g:additional_image_link_5", true),
187
- "images_6" => array("g:additional_image_link_6", true),
188
- "images_7" => array("g:additional_image_link_7", true),
189
- "images_8" => array("g:additional_image_link_8", true),
190
- "images_9" => array("g:additional_image_link_9", true),
191
- "images_10" => array("g:additional_image_link_10", true),
192
- "condition" => array("g:condition", false),
193
- "availability" => array("g:availability", false),
194
- "inventory" => array("g:inventory", false),
195
- "override" => array("g:override", false),
196
- "price" => array("g:price", true),
197
- "sale_price" => array("g:sale_price", true),
198
- "sale_price_effective_date" => array("g:sale_price_effective_date", true),
199
- "brand" => array("g:brand", true),
200
- "sku" => array("g:mpn", true),
201
- "upc" => array("g:gtin", true),
202
- "identifier_exists" => array("g:identifier_exists", true),
203
- "item_group_id" => array("g:item_group_id", false),
204
- "color" => array("g:color", true),
205
- "gender" => array("g:gender", true),
206
- "age_group" => array("g:age_group", true),
207
- "material" => array("g:material", true),
208
- "pattern" => array("g:pattern", true),
209
- "size" => array("g:size", true),
210
- "size_type" => array("g:size_type", true),
211
- "size_system" => array("g:size_system", true),
212
- "tax" => array("tax", true),
213
- "weight" => array("g:shipping_weight", false),
214
- "length" => array("g:shipping_length", false),
215
- "width" => array("g:shipping_width", false),
216
- "height" => array("g:shipping_height", false),
217
- "shipping_label" => array("g:shipping_label", false),
218
- "shipping_country" => array("g:shipping_country", false),
219
- "shipping_service" => array("g:shipping_service", false),
220
- "shipping_price" => array("g:shipping_price", false),
221
- "shipping_region" => array("g:shipping_region", false),
222
- "multipack" => array("g:multipack", true),
223
- "is_bundle" => array("g:is_bundle", true),
224
- "adult" => array("g:adult", true),
225
- "adwords_redirect" => array("g:adwords_redirect", true),
226
- "custom_label_0" => array("g:custom_label_0", true),
227
- "custom_label_1" => array("g:custom_label_1", true),
228
- "custom_label_2" => array("g:custom_label_2", true),
229
- "custom_label_3" => array("g:custom_label_3", true),
230
- "custom_label_4" => array("g:custom_label_4", true),
231
- "excluded_destination" => array("g:excluded_destination", true),
232
- "expiration_date" => array("g:expiration_date", true),
233
- "unit_pricing_measure" => array("g:unit_pricing_measure", true),
234
- "unit_pricing_base_measure" => array("g:unit_pricing_base_measure", true),
235
- "energy_efficiency_class" => array("g:energy_efficiency_class", true),
236
- "loyalty_points" => array("g:loyalty_points", true),
237
- "installment" => array("g:installment", true),
238
- "promotion_id" => array("g:promotion_id", true),
239
- "cost_of_goods_sold" => array("g:cost_of_goods_sold", true),
240
- "availability_date" => array("g:availability_date", true),
241
- "tax_category" => array("g:tax_category", true),
242
- "included_destination" => array("g:included_destination", true),
243
  );
244
  public $facebookCSVTXTAttribute = array(
245
- "id" => array("id", false),
246
- "title" => array("title", true),
247
- "description" => array("description", true),
248
- "link" => array("link", true),
249
- "mobile_link" => array("mobile_link", true),
250
- "product_type" => array("product type", true),
251
- "current_category" => array("google product category", true),
252
- "image" => array("image link", true),
253
- "images" => array("additional image link", true),
254
- "images_1" => array("additional image link 1", true),
255
- "images_2" => array("additional image link 2", true),
256
- "images_3" => array("additional image link 3", true),
257
- "images_4" => array("additional image link 4", true),
258
- "images_5" => array("additional image link 5", true),
259
- "images_6" => array("additional image link 6", true),
260
- "images_7" => array("additional image link 7", true),
261
- "images_8" => array("additional image link 8", true),
262
- "images_9" => array("additional image link 9", true),
263
- "images_10" => array("additional image link 10", true),
264
- "condition" => array("condition", false),
265
- "availability" => array("availability", false),
266
- "inventory" => array("inventory", false),
267
- "override" => array("override", false),
268
- "price" => array("price", true),
269
- "sale_price" => array("sale price", true),
270
- "sale_price_effective_date" => array("sale price effective date", true),
271
- "brand" => array("brand", true),
272
- "sku" => array("mpn", true),
273
- "upc" => array("gtin", true),
274
- "identifier_exists" => array("identifier exists", true),
275
- "item_group_id" => array("item group id", false),
276
- "color" => array("color", true),
277
- "gender" => array("gender", true),
278
- "age_group" => array("age group", true),
279
- "material" => array("material", true),
280
- "pattern" => array("pattern", true),
281
- "size" => array("size", true),
282
- "size_type" => array("size type", true),
283
- "size_system" => array("size system", true),
284
- "tax" => array("tax", true),
285
- "weight" => array("shipping weight", false),
286
- "length" => array("shipping length", false),
287
- "width" => array("shipping width", false),
288
- "height" => array("shipping height", false),
289
- "shipping_label" => array("shipping label", false),
290
- "shipping_country" => array("shipping country", false),
291
- "shipping_service" => array("shipping service", false),
292
- "shipping_price" => array("shipping price", false),
293
- "shipping_region" => array("shipping region", false),
294
- "multipack" => array("multipack", true),
295
- "is_bundle" => array("is bundle", true),
296
- "adult" => array("adult", true),
297
- "adwords_redirect" => array("adwords redirect", true),
298
- "custom_label_0" => array("custom label 0", true),
299
- "custom_label_1" => array("custom label 1", true),
300
- "custom_label_2" => array("custom label 2", true),
301
- "custom_label_3" => array("custom label 3", true),
302
- "custom_label_4" => array("custom label 4", true),
303
- "excluded_destination" => array("excluded destination", true),
304
- "expiration_date" => array("expiration date", true),
305
- "unit_pricing_measure" => array("unit pricing measure", true),
306
- "unit_pricing_base_measure" => array("unit pricing base measure", true),
307
- "energy_efficiency_class" => array("energy efficiency class", true),
308
- "loyalty_points" => array("loyalty points", true),
309
- "installment" => array("installment", true),
310
- "promotion_id" => array("promotion id", true),
311
- "cost_of_goods_sold" => array("cost of goods sold", true),
312
- "availability_date" => array("availability date", true),
313
- "tax_category" => array("tax category", true),
314
- "included_destination" => array("included destination", true),
315
  );
316
  public $pinterestXMLAttribute = array(
317
- "id" => array("g:id", false),
318
- "title" => array("title", true),
319
- "description" => array("description", true),
320
- "link" => array("link", true),
321
- "mobile_link" => array("mobile_link", true),
322
- "product_type" => array("g:product_type", true),
323
- "current_category" => array("g:google_product_category", true),
324
- "image" => array("g:image_link", true),
325
- "images" => array("g:additional_image_link", false),
326
- "images_1" => array("g:additional_image_link_1", true),
327
- "images_2" => array("g:additional_image_link_2", true),
328
- "images_3" => array("g:additional_image_link_3", true),
329
- "images_4" => array("g:additional_image_link_4", true),
330
- "images_5" => array("g:additional_image_link_5", true),
331
- "images_6" => array("g:additional_image_link_6", true),
332
- "images_7" => array("g:additional_image_link_7", true),
333
- "images_8" => array("g:additional_image_link_8", true),
334
- "images_9" => array("g:additional_image_link_9", true),
335
- "images_10" => array("g:additional_image_link_10", true),
336
- "condition" => array("g:condition", false),
337
- "availability" => array("g:availability", false),
338
- "availability_date" => array("g:availability_date", false),
339
- "inventory" => array("g:inventory", false),
340
- "price" => array("g:price", true),
341
- "sale_price" => array("g:sale_price", true),
342
- "sale_price_effective_date" => array("g:sale_price_effective_date", true),
343
- "brand" => array("g:brand", true),
344
- "sku" => array("g:mpn", true),
345
- "upc" => array("g:gtin", true),
346
- "identifier_exists" => array("g:identifier_exists", true),
347
- "item_group_id" => array("g:item_group_id", false),
348
- "color" => array("g:color", true),
349
- "gender" => array("g:gender", true),
350
- "age_group" => array("g:age_group", true),
351
- "material" => array("g:material", true),
352
- "pattern" => array("g:pattern", true),
353
- "size" => array("g:size", true),
354
- "size_type" => array("g:size_type", true),
355
- "size_system" => array("g:size_system", true),
356
- "tax" => array("tax", true),
357
- "tax_country" => array("g:tax_country", true),
358
- "tax_region" => array("g:tax_region", true),
359
- "tax_rate" => array("g:tax_rate", true),
360
- "tax_ship" => array("g:tax_ship", true),
361
- "tax_category" => array("g:tax_category", true),
362
- "weight" => array("g:shipping_weight", false),
363
- "length" => array("g:shipping_length", false),
364
- "width" => array("g:shipping_width", false),
365
- "height" => array("g:shipping_height", false),
366
- "shipping_label" => array("g:shipping_label", false),
367
- "shipping_country" => array("g:shipping_country", false),
368
- "shipping_service" => array("g:shipping_service", false),
369
- "shipping_price" => array("g:shipping_price", false),
370
- "shipping_region" => array("g:shipping_region", false),
371
- "multipack" => array("g:multipack", true),
372
- "is_bundle" => array("g:is_bundle", true),
373
- "adult" => array("g:adult", true),
374
- "adwords_redirect" => array("g:adwords_redirect", true),
375
- "custom_label_0" => array("g:custom_label_0", true),
376
- "custom_label_1" => array("g:custom_label_1", true),
377
- "custom_label_2" => array("g:custom_label_2", true),
378
- "custom_label_3" => array("g:custom_label_3", true),
379
- "custom_label_4" => array("g:custom_label_4", true),
380
- "excluded_destination" => array("g:excluded_destination", true),
381
- "included_destination" => array("g:included_destination", true),
382
- "expiration_date" => array("g:expiration_date", true),
383
- "unit_pricing_measure" => array("g:unit_pricing_measure", true),
384
- "unit_pricing_base_measure" => array("g:unit_pricing_base_measure", true),
385
- "energy_efficiency_class" => array("g:energy_efficiency_class", true),
386
- "loyalty_points" => array("g:loyalty_points", true),
387
- "installment" => array("g:installment", true),
388
- "promotion_id" => array("g:promotion_id", true),
389
- "cost_of_goods_sold" => array("g:cost_of_goods_sold", true),
390
  );
391
  public $pinterestCSVTXTAttribute = array(
392
- "id" => array("id", false),
393
- "title" => array("title", true),
394
- "description" => array("description", true),
395
- "link" => array("link", true),
396
- "mobile_link" => array("mobile_link", true),
397
- "product_type" => array("product_type", true),
398
- "current_category" => array("google_product_category", true),
399
- "image" => array("image_link", true),
400
- "images" => array("additional_image_link", true),
401
- "images_1" => array("additional_image_link_1", true),
402
- "images_2" => array("additional_image_link_2", true),
403
- "images_3" => array("additional_image_link_3", true),
404
- "images_4" => array("additional_image_link_4", true),
405
- "images_5" => array("additional_image_link_5", true),
406
- "images_6" => array("additional_image_link_6", true),
407
- "images_7" => array("additional_image_link_7", true),
408
- "images_8" => array("additional_image_link_8", true),
409
- "images_9" => array("additional_image_link_9", true),
410
- "images_10" => array("additional_image_link_10", true),
411
- "condition" => array("condition", false),
412
- "availability" => array("availability", false),
413
- "availability_date" => array("availability_date", false),
414
- "inventory" => array("inventory", false),
415
- "price" => array("price", true),
416
- "sale_price" => array("sale_price", true),
417
- "sale_price_effective_date" => array("sale_price_effective_date", true),
418
- "brand" => array("brand", true),
419
- "sku" => array("mpn", true),
420
- "upc" => array("gtin", true),
421
- "identifier_exists" => array("identifier exists", true),
422
- "item_group_id" => array("item_group_id", false),
423
- "color" => array("color", true),
424
- "gender" => array("gender", true),
425
- "age_group" => array("age_group", true),
426
- "material" => array("material", true),
427
- "pattern" => array("pattern", true),
428
- "size" => array("size", true),
429
- "size_type" => array("size_type", true),
430
- "size_system" => array("size_system", true),
431
- "tax" => array("tax", true),
432
- "tax_country" => array("tax_country", true),
433
- "tax_region" => array("tax_region", true),
434
- "tax_rate" => array("tax_rate", true),
435
- "tax_ship" => array("tax_ship", true),
436
- "tax_category" => array("tax_category", true),
437
- "weight" => array("shipping_weight", false),
438
- "length" => array("shipping_length", false),
439
- "width" => array("shipping_width", false),
440
- "height" => array("shipping_height", false),
441
- "shipping_label" => array("shipping_label", false),
442
- "shipping_country" => array("shipping_country", false),
443
- "shipping_service" => array("shipping_service", false),
444
- "shipping_price" => array("shipping_price", false),
445
- "shipping_region" => array("shipping_region", false),
446
- "multipack" => array("multipack", true),
447
- "is_bundle" => array("is_bundle", true),
448
- "adult" => array("adult", true),
449
- "adwords_redirect" => array("adwords_redirect", true),
450
- "custom_label_0" => array("custom_label_0", true),
451
- "custom_label_1" => array("custom_label_1", true),
452
- "custom_label_2" => array("custom_label_2", true),
453
- "custom_label_3" => array("custom_label_3", true),
454
- "custom_label_4" => array("custom_label_4", true),
455
- "excluded_destination" => array("excluded_destination", true),
456
- "included_destination" => array("included_destination", true),
457
- "expiration_date" => array("expiration_date", true),
458
- "unit_pricing_measure" => array("unit_pricing_measure", true),
459
- "unit_pricing_base_measure" => array("unit_pricing_base_measure", true),
460
- "energy_efficiency_class" => array("energy_efficiency_class", true),
461
- "loyalty_points" => array("loyalty_points", true),
462
- "installment" => array("installment", true),
463
- "promotion_id" => array("promotion_id", true),
464
- "cost_of_goods_sold" => array("cost_of_goods_sold", true),
465
  );
466
 
467
- public function __construct()
468
- {
469
 
470
  }
471
 
472
- public function merchants()
473
- {
474
 
475
  $feed_engine = array(
476
- "--1" => "Custom Template",
477
  "custom" => "Custom Feed",
478
- "---1" => "",
479
  );
480
 
481
  $popular_template = array(
482
- "--2" => "Popular Templates",
483
- "google" => "Google Shopping",
484
- "google_local" => "Google Local Product",
485
  "google_local_inventory" => "Google Local Product Inventory",
486
- "adwords" => "Google Adwords",
487
- "facebook" => "Facebook",
488
- "pinterest" => "Pinterest",
489
- "---2" => "",
490
  );
491
 
492
  $others_temp = array(
493
- "shopping" => "eBay (Shopping.com)",
494
- "adroll" => "AdRoll",
495
- "adform" => "AdForm",
496
- "nextag" => "Nextag",
497
- "pricegrabber" => "Price Grabber",
498
- "polyvore" => "Polyvore",
499
- "pricerunner" => "PriceRunner",
500
- "kelkoo" => "Kelkoo",
501
- "shopzilla" => "Shopzilla",
502
- "shopmania" => "Shopmania",
503
- "shopbot" => "Shopbot",
504
- "bing" => "Bing",
505
- "become" => "Become",
506
- "connexity" => "Connexity",
507
 
508
- "pricespy" => "PriceSpy",
509
- "prisjakt" => "Prisjakt",
510
- "twenga" => "Twenga",
511
- "fruugo" => "Fruugo",
512
- "fruugo.au" => "Fruugoaustralia.com",
513
- "bonanza" => "Bonanza",
514
- "bol" => "Bol.com",
515
- "leguide" => "LeGuide",
516
- "real" => "Real",
517
- "crowdfox" => "Crowdfox",
518
- "jet" => "Jet.com",
519
- "wish" => "Wish.com",
520
- "zap.co.il" => "Zap.co.il",
521
- "myshopping.com.au" => "Myshopping.com.au",
522
- "smartly.io" => "Smartly.io",
523
- "stylight.com" => "Stylight.com",
524
- "nextad" => "TheNextAd",
525
- "skinflint.co.uk" => "SkinFlint.co.uk",
526
- "yahoo_nfa" => "Yahoo NFA",
527
- "hintaseuranta.fi" => "Hintaseuranta.fi",
528
- "incurvy" => "Incurvy",
529
- "kijiji.ca" => "Kijiji.ca",
530
- "marktplaats.nl" => "Marktplaats.nl",
531
- "rakuten.de" => "Rakuten",
532
- "shopalike.fr" => "Shopalike.fr",
533
- "spartoo.fi" => "Spartoo.fi",
534
- "webmarchand" => "Webmarchand",
535
- "fashiola" => "Fashiola",
536
  "vergelijk_comparer" => "Vergelijk.be & Comparer.be",
537
- "kieskeurig.nl" => "Kieskeurig.nl",
538
- "beslist.nl" => "Beslist.nl",
539
- "billiger.de" => "Billiger.de",
540
- "vertaa.fi" => "Vertaa.fi",
541
- "cdiscount.fr" => "CDiscount.fr",
542
- "fnac.fr" => "Fnac.fr",
543
- "idealo" => "Idealo",
544
- "miinto.nl" => "Miinto.nl",
545
- 'fyndiq.se' => "Fyndiq.se",
546
- "criteo" => "Criteo",
547
- "avantlink" => "Avantlink",
548
- 'shareasale' => "ShareASale",
549
- "walmart" => "Walmart",
550
- "modina.de" => "Modina.de",
551
- "yandex_csv" => "Yandex (CSV)",
552
  );
553
 
554
  asort($others_temp);
555
  $newTemplate = array();
556
  $newTemplate['--3'] = "Templates";
557
- foreach ($others_temp as $key => $val) {
558
  // echo "$key = $val <br>";
559
- $newTemplate[$key] = $val;
560
  }
561
  $newTemplate['---3'] = "";
562
 
@@ -572,671 +570,655 @@ class Woo_Feed_Default_Attributes
572
  * @return string
573
  */
574
 
575
- public function getAttributeDropDown($merchant, $selected = "")
576
- {
577
  $str = "<option></option>";
578
  $method = $merchant . "Attribute";
579
- foreach ($this->$method() as $key => $value) {
580
- if (substr($key, 0, 2) == "--") {
581
  $str .= "<optgroup label='$value'>";
582
- } elseif (substr($key, 0, 2) == "---") {
583
  $str .= "</optgroup>";
584
  } else {
585
  $sltd = "";
586
  if ($selected == $key)
587
  $sltd = 'selected="selected"';
588
  $str .= "<option $sltd value='$key'>" . $value . "</option>";
589
- }
590
-
591
- }
592
  return $str;
593
  }
594
 
595
- public function googleAttributes()
596
- {
597
  $attributes = array(
598
- "--1" => "Basic Information",
599
- "id" => "Product Id[id]",
600
- "title" => "Product Title[title]",
601
- "description" => "Product Description[description]",
602
- "link" => "Product URL[link]",
603
- "mobile_link" => "Product URL[mobile_link]",
604
- "product_type" => "Product Categories[product_type] ",
605
- "current_category" => "Google Product Category[google_product_category]",
606
- "image" => "Main Image[image_link]",
607
- "images" => "Comma Separated Images [additional_image_link]",
608
- "images_1" => "Additional Image 1 [additional_image_link]",
609
- "images_2" => "Additional Image 2 [additional_image_link]",
610
- "images_3" => "Additional Image 3 [additional_image_link]",
611
- "images_4" => "Additional Image 4 [additional_image_link]",
612
- "images_5" => "Additional Image 5 [additional_image_link]",
613
- "images_6" => "Additional Image 6 [additional_image_link]",
614
- "images_7" => "Additional Image 7 [additional_image_link]",
615
- "images_8" => "Additional Image 8 [additional_image_link]",
616
- "images_9" => "Additional Image 9 [additional_image_link]",
617
- "images_10" => "Additional Image 10 [additional_image_link]",
618
- "condition" => "Condition[condition]",
619
- "---1" => "",
620
 
621
- "--2" => "Availability & Price",
622
- "availability" => "Stock Status[availability]",
623
- "availability_date" => "Availability Date[availability_date]",
624
- "cost_of_goods_sold" => "Cost of Goods Sold[cost_of_goods_sold]",
625
- "expiration_date" => "Expiration Date[expiration_date]",
626
- "inventory" => "Facebook Inventory[inventory]",
627
- "override" => "Facebook Override[override]",
628
- "price" => "Regular Price[price]",
629
- "sale_price" => "Sale Price[sale_price]",
630
  "sale_price_effective_date" => "Sale Price Effective Date[sale_price_effective_date]",
631
- "---2" => "",
632
 
633
- "--3" => "Unique Product Identifiers",
634
- "brand" => "Manufacturer[brand]",
635
- "upc" => "GTIN[gtin]",
636
- "sku" => "MPN[mpn]",
637
- "identifier_exists" => "Identifier Exist[identifier_exists]",
638
- "---3" => "",
639
 
640
- "--4" => "Detailed Product Attributes",
641
- "item_group_id" => "Item Group Id[item_group_id]",
642
- "color" => "Color[color]",
643
- "gender" => "Gender[gender]",
644
- "age_group" => "Age Group[age_group]",
645
- "material" => "Material[material]",
646
- "pattern" => "Pattern[pattern]",
647
- "size" => "Size of the item[size]",
648
- "size_type" => "Size Type[size_type]",
649
- "size_system" => "Size System[size_system]",
650
- "---4" => "",
651
 
652
- "--5" => "Tax & Shipping",
653
- // "tax" => "Tax[tax]",
654
- "tax_country" => "Tax Country[tax_country]",
655
- "tax_region" => "Tax Region[tax_region]",
656
- "tax_rate" => "Tax Rate[tax_rate]",
657
- "tax_ship" => "Tax Ship[tax_ship]",
658
- "tax_category" => "Tax[tax_category]",
659
- "shipping_country" => "Shipping Country",
660
- "shipping_region" => "Shipping Region",
661
- "shipping_service" => "Shipping Service",
662
- "shipping_price" => "Shipping Price",
663
- "weight" => "Shipping Weight[shipping_weight]",
664
- "length" => "Shipping Length[shipping_length]",
665
- "width" => "Shipping Width[shipping_width]",
666
- "height" => "Shipping Height[shipping_height]",
667
- "shipping_label" => "Shipping Label[shipping_label]",
668
- "---5" => "",
669
 
670
- "--6" => "Product Combinations",
671
- "multipack" => "Multipack[multipack]",
672
- "is_bundle" => "Is Bundle[is_bundle]",
673
- "---6" => "",
674
 
675
- "--7" => "Adult Products",
676
- "adult" => "Adult[adult]",
677
- "---7" => "",
678
 
679
- "--8" => "AdWord Attributes",
680
- "adwords_redirect" => "Adwords Redirect[adwords_redirect]",
681
- "---8" => "",
682
 
683
- "--9" => "Custom Label Attributes",
684
- "custom_label_0" => "Custom label 0 [custom_label_0]",
685
- "custom_label_1" => "Custom label 1 [custom_label_1]",
686
- "custom_label_2" => "Custom label 2 [custom_label_2]",
687
- "custom_label_3" => "Custom label 3 [custom_label_3]",
688
- "custom_label_4" => "Custom label 4 [custom_label_4]",
689
- "---9" => "",
690
 
691
- "--10" => "Additional Attributes",
692
- "excluded_destination" => "Excluded Destination[excluded_destination]",
693
- "included_destination" => "Included Destination[included_destination]",
694
- "expiration_date" => "Expiration Date [expiration_date]",
695
- "---10" => "",
696
 
697
- "--11" => "Unit Prices (EU Countries and Switzerland Only)",
698
- "unit_pricing_measure" => "Unit Pricing Measure[unit_pricing_measure]",
699
  "unit_pricing_base_measure" => "Unit Pricing Base Measure[unit_pricing_base_measure]",
700
- "---11" => "",
701
 
702
- "--12" => "Energy Labels",
703
- "energy_efficiency_class" => "Energy Efficiency Class[energy_efficiency_class]",
704
- "---12" => "",
705
 
706
- "--13" => "Loyalty Points (Japan Only)",
707
- "loyalty_points" => "loyalty_points[loyalty_points]",
708
- "---13" => "",
709
 
710
- "--14" => "Multiple Installments (Brazil Only)",
711
- "installment" => "Installment[installment]",
712
- "---14" => "",
713
 
714
- "--15" => "Merchant Promotions Attribute",
715
- "promotion_id" => "Promotion Id[promotion_id]",
716
- "---15" => "",
717
  );
718
 
719
  return $attributes;
720
  }
721
 
722
- public function pricegrabberAttribute()
723
- {
724
  $attributes = array(
725
- "--1" => "Required Attributes",
726
- "Retsku" => "Retsku",
727
- "Product Title" => "Product Title",
728
- "Detailed Description" => "Detailed Description",
729
- "Categorization" => "Categorization",
730
- "Product URL" => "Product URL",
731
- "Primary Image URL" => "Primary Image URL",
732
- "Selling Price" => "Selling Price",
733
- "Regular Price" => "Regular Price",
734
- "Condition" => "Condition",
735
- "Availability" => "Availability",
736
- "Manufacturer Name" => "Manufacturer Name",
737
- "GTIN" => "GTIN (UPC / EAN / ISBN)",
738
- "Mature" => "Mature",
739
- "---1" => "",
740
- "--2" => "Additional Attributes",
741
- "Parent Retsku" => "Parent Retsku",
742
- "Merchant Categorization" => "Merchant Categorization",
743
  "Manufacturer Part Number" => "Manufacturer Part Number",
744
- "Additional Image URL 1" => "Additional Image URL 1",
745
- "Additional Image URL 2" => "Additional Image URL 2",
746
- "Additional Image URL 3" => "Additional Image URL 3",
747
- "Additional Image URL 4" => "Additional Image URL 4",
748
- "Additional Image URL 5" => "Additional Image URL 5",
749
- "Additional Image URL 6" => "Additional Image URL 6",
750
- "Additional Image URL 7" => "Additional Image URL 7",
751
- "Additional Image URL 8" => "Additional Image URL 8",
752
- "Additional Image URL 9" => "Additional Image URL 9",
753
- "Additional Image URL 10" => "Additional Image URL 10",
754
- "Video URL" => "Video URL",
755
- "Color" => "Color",
756
- "Size" => "Size",
757
- "Material" => "Material",
758
- "Pattern" => "Pattern",
759
- "Gender" => "Gender",
760
- "Age" => "Age",
761
- "Parent UPC" => "Parent UPC",
762
- "Multipack" => "Multipack",
763
- "Shipping Cost" => "Shipping Cost",
764
- "Weight" => "Weight",
765
- "---2" => "",
766
  );
767
  return $attributes;
768
  }
769
 
770
- public function nextagAttribute()
771
- {
772
  $attributes = array(
773
- "--1" => "Required Attributes",
774
- "Product Name" => "Product Name",
775
  "Product Description" => "Product Description",
776
- "Image URL" => "Image URL",
777
- "Click-Out URL" => "Click-Out URL",
778
- "Price" => "Price",
779
- "Category" => "Category: Nextag Numeric ID or Other",
780
- "---1" => "",
781
- "--2" => "Additional Attributes",
782
- "Manufacturer" => "Manufacturer",
783
- "Condition" => "Condition",
784
- "Stock Status" => "Stock Status",
785
- "Cost-per-Click " => "Cost-per-Click ",
786
- "Distributor ID " => "Distributor ID ",
787
- "Ground Shipping" => "Ground Shipping",
788
- "Ingram Part #" => "Ingram Part #",
789
- "ISBN" => "ISBN",
790
  "Manufacturer Part #" => "Manufacturer Part #",
791
- "Marketing Message " => "Marketing Message ",
792
- "MUZE ID" => "MUZE ID",
793
- "Seller Part #" => "Seller Part #",
794
- "UPC" => "UPC",
795
- "Weight" => "Weight",
796
- "ListPrice" => "ListPrice",
797
- "---2" => "",
798
  );
799
  return $attributes;
800
  }
801
 
802
- public function kelkooAttribute()
803
- {
804
  $attributes = array(
805
- "--1" => "Required Attributes",
806
- "title" => "title",
807
- "product-url" => "product-url",
808
- "price" => "price",
809
- "merchant-category" => "merchant-category",
810
- "ean" => "ean",
811
- "delivery-cost" => "delivery-cost",
812
- "brand" => "brand",
813
- "description" => "description",
814
- "image-url" => "image-url",
815
- "availability" => "availability",
816
- "mpn" => "mpn",
817
- "sku" => "sku",
818
- "---1" => "",
819
- "--2" => "Additional Attributes",
820
- "delivery-time" => "delivery-time",
821
- "condition" => "condition",
822
- "ecotax" => "ecotax",
823
- "warranty" => "warranty",
824
- "mobile-url" => "mobile-url",
825
- "kelkoo-category-id" => "kelkoo-category-id",
826
- "colour" => "colour",
827
- "unit-price" => "unit-price",
828
- "offer-type" => "offer-type",
829
- "merchant-info" => "merchant-info",
830
- "currency" => "currency",
831
- "image-url-2" => "image-url-2",
832
- "image-url-3" => "image-url-3",
833
- "image-url-4" => "image-url-4",
834
- "green-product" => "green-product",
835
- "green-label" => "green-label",
836
- "sales-rank" => "sales-rank",
837
- "unit-quantity" => "unit-quantity",
838
- "made-in" => "made-in",
839
- "occasion" => "occasion",
840
- "efficiency-class" => "efficiency-class",
841
- "shipping-method" => "shipping-method",
842
- "delivery-cost-2" => "delivery-cost-2",
843
- "shipping-method-2" => "shipping-method-2",
844
- "delivery-cost-3" => "delivery-cost-3",
845
- "shipping-method-3" => "shipping-method-3",
846
- "delivery-cost-4" => "delivery-cost-4 ",
847
- "shipping-method-4" => "shipping-method-4",
848
- "zip-code" => "zip-code",
849
- "stock-quantity" => "stock-quantity",
850
- "shipping-weight" => "shipping-weight",
851
- "payment-methods" => "payment-methods",
852
- "voucher-title" => "voucher-title",
853
  "voucher-description" => "voucher-description",
854
- "voucher-url" => "voucher-url",
855
- "voucher-code" => "voucher-code",
856
- "voucher-start-date" => "voucher-start-date",
857
- "voucher-end-date" => "voucher-end-date",
858
- "price-no-rebate" => "price-no-rebate",
859
- "percentage-promo" => "percentage-promo",
860
- "promo-start-date" => "promo-start-date",
861
- "promo-end-dat" => "promo-end-dat",
862
- "user-rating" => "user-rating",
863
- "nb-reviews" => "nb-reviews",
864
- "user-review-link" => "user-review-link",
865
- "video-link" => "video-link",
866
- "video-title" => "video-title",
867
- "---2" => "",
868
  );
869
  return $attributes;
870
  }
871
 
872
- public function shopzillaAttribute()
873
- {
874
  $attributes = array(
875
- "--1" => "Required Attributes",
876
- "Unique ID" => "Unique ID",
877
- "Title" => "Title",
878
- "Description" => "Description",
879
- "Category" => "Category",
880
- "Product URL" => "Product URL",
881
- "Image URL" => "Image URL",
882
- "Condition" => "Condition",
883
- "Availability" => "Availability",
884
- "Current Price" => "Current Price",
885
- "---1" => "",
886
- "--2" => "Recommended Attributes",
887
- "Brand" => "Brand",
888
- "GTIN" => "GTIN",
889
- "MPN" => "MPN",
890
- "Ship Cost" => "Ship Cost",
891
- "Ship Weight" => "Ship Weight",
892
- "Bid" => "Bid",
893
- "Regular Price" => "Regular Price",
894
- "Promo Text" => "Promo Text",
895
- "Gender" => "Gender",
896
- "Age Group" => "Age Group",
897
- "Color" => "Color",
898
- "Size" => "Size",
899
- "Material" => "Material",
900
- "Pattern" => "Pattern",
901
- "Item Group ID" => "Item Group ID",
902
- "---2" => "",
903
- "--3" => "Optional Attributes",
904
- "Page ID" => "Page ID",
905
- "Page ID Variant" => "Page ID Variant",
906
- "Generic Title" => "Generic Title",
907
- "Unit Price" => "Unit Price",
908
- "Currency" => "Currency",
909
- "PZN" => "PZN",
910
- "Adult" => "Adult",
911
- "Delivery Period" => "Delivery Period",
912
  "Energy Efficiency Class" => "Energy Efficiency Class",
913
- "---3" => "",
914
  );
915
  return $attributes;
916
  }
917
 
918
- public function shoppingAttribute()
919
- {
920
  $attributes = array(
921
- "--1" => "Required Attributes",
922
- "Unique Merchant SKU" => "Unique Merchant SKU",
923
- "Product Name" => "Product Name",
924
- "Product URL" => "Product URL",
925
- "Image URL" => "Image URL",
926
- "Current Price" => "Current Price",
927
- "Stock Availability" => "Stock Availability",
928
- "Condition" => "Condition",
929
- "MPN" => "MPN",
930
- "ISBN" => "ISBN",
931
- "UPC" => "UPC",
932
- "EAN" => "EAN",
933
- "---1" => "",
934
- "--2" => "Additional Attributes",
935
- "Shipping Rate" => "Shipping Rate",
936
- "Original Price" => "Original Price",
937
- "Coupon Code" => "Coupon Code",
938
  "Coupon Code Description" => "Coupon Code Description",
939
- "Manufacturer" => "Brand / Manufacturer",
940
- "Product Description" => "Product Description",
941
- "Product Type" => "Product Type",
942
- "Category" => "Category",
943
- "Category ID" => "Category ID",
944
- "Parent SKU" => "Parent SKU",
945
- "Parent Name" => "Parent Name",
946
- "Top Seller Rank" => "Top Seller Rank",
947
- "Estimated Ship Date" => "Estimated Ship Date",
948
- "Gender" => "Gender",
949
- "Color" => "Color",
950
- "Material" => "Material",
951
- "Size" => "Size",
952
- "Size Unit of Measure" => "Size Unit of Measure",
953
- "Age Range" => "Age Range",
954
- "Stock Description" => "Stock Description",
955
- "Product Launch Date" => "Product Launch Date",
956
- "Product Bullet Point 1" => "Product Bullet Point 1",
957
- "Product Bullet Point 2" => "Product Bullet Point 2",
958
- "Product Bullet Point 3" => "Product Bullet Point 3",
959
- "Product Bullet Point 4" => "Product Bullet Point 4",
960
- "Product Bullet Point 5" => "Product Bullet Point 5",
961
  "Alternative Image URL 1" => "Alternative Image URL 1",
962
  "Alternative Image URL 2" => "Alternative Image URL 2",
963
  "Alternative Image URL 3" => "Alternative Image URL 3",
964
  "Alternative Image URL 4" => "Alternative Image URL 4",
965
  "Alternative Image URL 5" => "Alternative Image URL 5",
966
- "Mobile URL" => "Mobile URL",
967
- "Related Products" => "Related Products",
968
- "Merchandising Type" => "Merchandising Type",
969
- "Zip Code" => "Zip Code",
970
- "Shipping Weight" => "Shipping Weight",
971
- "Format" => "Format",
972
- "Unit Price" => "Unit Price",
973
- "Bundle" => "Bundle",
974
- "Software Platform" => "Software Platform",
975
- "Watch Display Type" => "Watch Display Type",
976
- "Custom" => "Custom",
977
- "---2" => "",
978
  );
979
  return $attributes;
980
  }
981
 
982
- public function shopmaniaAttribute()
983
- {
984
  $attributes = array(
985
- "--1" => "Required Attributes",
986
- "Category" => "Category",
987
  "Manufacturer" => "Manufacturer",
988
- "Model" => "Model",
989
- "MPC" => "Merchant Code",
990
- "Name" => "Product name",
991
- "Description" => "Product description",
992
- "URL" => "Product URL",
993
- "Image" => "Image URL",
994
- "Price" => "Product price",
995
- "Currency" => "Currency",
996
- "Shipping" => "Shipping cost",
997
  "Availability" => "Availability",
998
- "GTIN" => "GTIN",
999
- "---1" => "",
1000
 
1001
  );
1002
  return $attributes;
1003
  }
1004
 
1005
- public function leguideAttribute()
1006
- {
1007
  $attributes = array(
1008
- "--1" => "",
1009
- "category" => "category",
1010
- "unique_id" => "unique_id",
1011
- "category" => "category",
1012
- "title" => "title",
1013
- "description" => "description",
1014
- "price" => "price",
1015
- "product_URL" => "product_URL",
1016
- "image_URL" => "image_URL",
1017
- "EAN" => "EAN",
1018
  "delivery_charge" => "delivery_charge",
1019
- "availability" => "availability",
1020
- "delivery_time" => "delivery_time",
1021
- "guarantee" => "guarantee",
1022
  "model_reference" => "model_reference",
1023
- "marque" => "marque",
1024
- "MPN" => "MPN",
1025
- "full_price" => "full_price",
1026
- "colour" => "colour",
1027
- "size" => "size",
1028
- "material" => "material",
1029
- "currency" => "currency",
1030
- "second-hand" => "second-hand",
1031
- "type_promotion" => "type_promotion",
1032
- "mobile_URL" => "mobile_URL",
1033
- "unit_price" => "unit_price",
1034
- "---1" => "",
1035
  );
1036
  return $attributes;
1037
  }
1038
 
1039
- public function pricespyAttribute()
1040
- {
1041
  $attributes = array(
1042
- "--1" => "",
1043
- "Product-name" => "Product-name",
1044
- "Your-item-number" => "Your-item-number",
1045
- "category" => "category",
1046
  "price-including-gst" => "price-including-gst",
1047
- "Product-URL" => "Product-URL",
1048
- "manufacturer" => "manufacturer",
1049
- "manufacturer-SKU" => "manufacturer-SKU",
1050
- "shipping" => "shipping",
1051
- "image-URL" => "image-URL",
1052
- "stock status" => "stock status",
1053
- "---1" => "",
1054
  );
1055
  return $attributes;
1056
  }
1057
 
1058
- public function prisjaktAttribute()
1059
- {
1060
  $attributes = array(
1061
- "--1" => "",
1062
- "Produktnamn" => "Produktnamn",
1063
- "Art.nr." => "Art.nr.",
1064
- "Kategori" => "Kategori",
1065
  "Pris inkl.moms" => "Pris inkl.moms",
1066
- "Produkt-URL" => "Produkt-URL",
1067
- "Tillverkare" => "Tillverkare",
1068
  "Tillverkar-SKU" => "Tillverkar-SKU",
1069
- "Frakt" => "Frakt",
1070
- "Bild-URL" => "Bild-URL",
1071
- "Lagerstatus" => "Lagerstatus",
1072
- "---1" => "",
1073
  );
1074
  return $attributes;
1075
  }
1076
 
1077
- public function bingAttribute()
1078
- {
1079
  $attributes = array(
1080
- "id" => "ID",
1081
- "title" => "Title",
1082
- "link" => "Product URL",
1083
- "price" => "Price",
1084
- "description" => "Description",
1085
- "image_link" => "ImageURL",
1086
- "shipping" => "Shipping",
1087
- "required" => "",
1088
- "brand" => "Brand",
1089
- "mpn" => "MPN",
1090
- "gtin" => "GTIN",
1091
- "gender" => "Gender",
1092
- "age_group" => "Age Group",
1093
- "color" => "Color",
1094
- "size" => "Size",
1095
- "item_group_id" => "Item Group Id",
1096
- "material" => "Material",
1097
- "pattern" => "Pattern",
1098
- "adult" => "Adult",
1099
- "availability" => "Availability",
1100
- "product_category" => "Product Category",
1101
- "condition" => "Condition",
1102
- "expiration_date" => "Expiration Date",
1103
- "multipack" => "Multipack",
1104
- "product_type" => "Product Type",
1105
- "mobile_link" => "Mobile Link",
1106
- "seller_name" => "Seller Name",
1107
- "bingads_grouping" => "bingads_grouping",
1108
- "bingads_label" => "bingads_label",
1109
- "bingads_redirect" => "bingads_redirect",
1110
- "custom_label_0" => "custom_label_0",
1111
- "custom_label_1" => "custom_label_1",
1112
- "custom_label_2" => "custom_label_2",
1113
- "custom_label_3" => "custom_label_3",
1114
- "custom_label_4" => "custom_label_4",
1115
- "sale_price" => "Sale Price",
1116
  "sale_price_effective_date" => "Sale Price Effective Date",
1117
- "promotion_ID" => "Promotion Id",
1118
  );
1119
  return $attributes;
1120
  }
1121
 
1122
- public function shopbotAttribute()
1123
- {
1124
  $attributes = array(
1125
- "--1" => "Required Attributes",
1126
- "ID" => "ID",
1127
- "Product Name" => "Product Name",
1128
- "URL" => "URL",
1129
- "Category" => "Category",
1130
- "Photo URL" => "Photo URL",
1131
- "Price" => "Price",
1132
- "Original Price" => "Original Price",
1133
- "Description" => "Description",
1134
- "MPN" => "MPN",
1135
- "Brand" => "Brand",
1136
- "Shipment Cost" => "Shipment Cost",
1137
- "---1" => "",
1138
- "--2" => "Recommended Attributes",
1139
- "Stock" => "Stock",
1140
  "Promotional Phrase" => "Promotional Phrase",
1141
- "Model" => "Model",
1142
- "Color" => "Color",
1143
- "Product Type" => "Product Type",
1144
- "---2" => "",
1145
 
1146
  );
1147
  return $attributes;
1148
  }
1149
 
1150
- public function becomeAttribute()
1151
- {
1152
  $attributes = array(
1153
- "--1" => "Required Attributes",
1154
- "Unique ID" => "Unique ID",
1155
- "Title" => "Title",
1156
- "Description" => "Description",
1157
- "Category" => "Category",
1158
- "Product URL" => "Product URL",
1159
- "Image URL" => "Image URL",
1160
- "Condition" => "Condition",
1161
- "Availability" => "Availability",
1162
- "Current Price" => "Current Price",
1163
- "---1" => "",
1164
- "--2" => "Recommended Attributes",
1165
- "Additional Image URL" => "Additional Image URL",
1166
- "Brand" => "Brand",
1167
- "GTIN" => "GTIN",
1168
- "MPN" => "MPN",
1169
- "Ship Cost" => "Ship Cost",
1170
- "Ship Weight" => "Ship Weight",
1171
- "Bid" => "Bid",
1172
- "Regular Price" => "Regular Price",
1173
- "Promo Text" => "Promo Text",
1174
- "Gender" => "Gender",
1175
- "Age Group" => "Age Group",
1176
- "Color" => "Color",
1177
- "Size" => "Size",
1178
- "Material" => "Material",
1179
- "Pattern" => "Pattern",
1180
- "Item Group ID" => "Item Group ID",
1181
- "---2" => "",
1182
- "--3" => "Optional Attributes",
1183
- "Page ID" => "Page ID",
1184
- "Page ID Variant" => "Page ID Variant",
1185
- "Generic Title" => "Generic Title",
1186
- "Unit Price" => "Unit Price",
1187
- "Currency" => "Currency",
1188
- "PZN" => "PZN",
1189
- "Adult" => "Adult",
1190
- "Delivery Period" => "Delivery Period",
1191
  "Energy Efficiency Class" => "Energy Efficiency Class",
1192
 
1193
- "---3" => "",
1194
  );
1195
  return $attributes;
1196
  }
1197
 
1198
- public function connexityAttribute()
1199
- {
1200
  $attributes = array(
1201
- "--1" => "Required Attributes",
1202
- "Unique ID" => "Unique ID",
1203
- "Title" => "Title",
1204
- "Description" => "Description",
1205
- "Category" => "Category",
1206
- "Product URL" => "Product URL",
1207
- "Image URL" => "Image URL",
1208
- "Condition" => "Condition",
1209
- "Availability" => "Availability",
1210
- "Current Price" => "Current Price",
1211
- "---1" => "",
1212
- "--2" => "Recommended Attributes",
1213
- "Brand" => "Brand",
1214
- "GTIN" => "GTIN",
1215
- "MPN" => "MPN",
1216
- "Ship Cost" => "Ship Cost",
1217
- "Ship Weight" => "Ship Weight",
1218
- "Bid" => "Bid",
1219
- "Regular Price" => "Regular Price",
1220
- "Promo Text" => "Promo Text",
1221
- "Gender" => "Gender",
1222
- "Age Group" => "Age Group",
1223
- "Color" => "Color",
1224
- "Size" => "Size",
1225
- "Material" => "Material",
1226
- "Pattern" => "Pattern",
1227
- "Item Group ID" => "Item Group ID",
1228
- "---2" => "",
1229
- "--3" => "Optional Attributes",
1230
- "Page ID" => "Page ID",
1231
- "Page ID Variant" => "Page ID Variant",
1232
- "Generic Title" => "Generic Title",
1233
- "Unit Price" => "Unit Price",
1234
- "Currency" => "Currency",
1235
- "PZN" => "PZN",
1236
- "Adult" => "Adult",
1237
- "Delivery Period" => "Delivery Period",
1238
  "Energy Efficiency Class" => "Energy Efficiency Class",
1239
- "---3" => "",
1240
  );
1241
  return $attributes;
1242
  }
20
  public $wooAttributes = array();
21
 
22
  public $googleXMLAttribute = array(
23
+ "id" => array( "g:id", false ),
24
+ "title" => array( "title", true ),
25
+ "description" => array( "description", true ),
26
+ "link" => array( "link", true ),
27
+ "mobile_link" => array( "mobile_link", true ),
28
+ "product_type" => array( "g:product_type", true ),
29
+ "current_category" => array( "g:google_product_category", true ),
30
+ "image" => array( "g:image_link", true ),
31
+ "images" => array( "g:additional_image_link", false ),
32
+ "images_1" => array( "g:additional_image_link_1", true ),
33
+ "images_2" => array( "g:additional_image_link_2", true ),
34
+ "images_3" => array( "g:additional_image_link_3", true ),
35
+ "images_4" => array( "g:additional_image_link_4", true ),
36
+ "images_5" => array( "g:additional_image_link_5", true ),
37
+ "images_6" => array( "g:additional_image_link_6", true ),
38
+ "images_7" => array( "g:additional_image_link_7", true ),
39
+ "images_8" => array( "g:additional_image_link_8", true ),
40
+ "images_9" => array( "g:additional_image_link_9", true ),
41
+ "images_10" => array( "g:additional_image_link_10", true ),
42
+ "condition" => array( "g:condition", false ),
43
+ "availability" => array( "g:availability", false ),
44
+ "availability_date" => array( "g:availability_date", false ),
45
+ "inventory" => array( "g:inventory", false ),
46
+ "price" => array( "g:price", true ),
47
+ "sale_price" => array( "g:sale_price", true ),
48
+ "sale_price_effective_date" => array( "g:sale_price_effective_date", true ),
49
+ "brand" => array( "g:brand", true ),
50
+ "sku" => array( "g:mpn", true ),
51
+ "upc" => array( "g:gtin", true ),
52
+ "identifier_exists" => array( "g:identifier_exists", true ),
53
+ "item_group_id" => array( "g:item_group_id", false ),
54
+ "color" => array( "g:color", true ),
55
+ "gender" => array( "g:gender", true ),
56
+ "age_group" => array( "g:age_group", true ),
57
+ "material" => array( "g:material", true ),
58
+ "pattern" => array( "g:pattern", true ),
59
+ "size" => array( "g:size", true ),
60
+ "size_type" => array( "g:size_type", true ),
61
+ "size_system" => array( "g:size_system", true ),
62
+ "tax" => array( "tax", true ),
63
+ "tax_country" => array( "g:tax_country", true ),
64
+ "tax_region" => array( "g:tax_region", true ),
65
+ "tax_rate" => array( "g:tax_rate", true ),
66
+ "tax_ship" => array( "g:tax_ship", true ),
67
+ "tax_category" => array( "g:tax_category", true ),
68
+ "weight" => array( "g:shipping_weight", false ),
69
+ "length" => array( "g:shipping_length", false ),
70
+ "width" => array( "g:shipping_width", false ),
71
+ "height" => array( "g:shipping_height", false ),
72
+ "shipping_label" => array( "g:shipping_label", false ),
73
+ "shipping_country" => array( "g:shipping_country", false ),
74
+ "shipping_service" => array( "g:shipping_service", false ),
75
+ "shipping_price" => array( "g:shipping_price", false ),
76
+ "shipping_region" => array( "g:shipping_region", false ),
77
+ "multipack" => array( "g:multipack", true ),
78
+ "is_bundle" => array( "g:is_bundle", true ),
79
+ "adult" => array( "g:adult", true ),
80
+ "adwords_redirect" => array( "g:adwords_redirect", true ),
81
+ "custom_label_0" => array( "g:custom_label_0", true ),
82
+ "custom_label_1" => array( "g:custom_label_1", true ),
83
+ "custom_label_2" => array( "g:custom_label_2", true ),
84
+ "custom_label_3" => array( "g:custom_label_3", true ),
85
+ "custom_label_4" => array( "g:custom_label_4", true ),
86
+ "excluded_destination" => array( "g:excluded_destination", true ),
87
+ "included_destination" => array( "g:included_destination", true ),
88
+ "expiration_date" => array( "g:expiration_date", true ),
89
+ "unit_pricing_measure" => array( "g:unit_pricing_measure", true ),
90
+ "unit_pricing_base_measure" => array( "g:unit_pricing_base_measure", true ),
91
+ "energy_efficiency_class" => array( "g:energy_efficiency_class", true ),
92
+ "loyalty_points" => array( "g:loyalty_points", true ),
93
+ "installment" => array( "g:installment", true ),
94
+ "promotion_id" => array( "g:promotion_id", true ),
95
+ "cost_of_goods_sold" => array( "g:cost_of_goods_sold", true ),
96
  );
97
  public $googleCSVTXTAttribute = array(
98
+ "id" => array( "id", false ),
99
+ "title" => array( "title", true ),
100
+ "description" => array( "description", true ),
101
+ "link" => array( "link", true ),
102
+ "mobile_link" => array( "mobile_link", true ),
103
+ "product_type" => array( "product type", true ),
104
+ "current_category" => array( "google product category", true ),
105
+ "image" => array( "image link", true ),
106
+ "images" => array( "additional image link", true ),
107
+ "images_1" => array( "additional image link 1", true ),
108
+ "images_2" => array( "additional image link 2", true ),
109
+ "images_3" => array( "additional image link 3", true ),
110
+ "images_4" => array( "additional image link 4", true ),
111
+ "images_5" => array( "additional image link 5", true ),
112
+ "images_6" => array( "additional image link 6", true ),
113
+ "images_7" => array( "additional image link 7", true ),
114
+ "images_8" => array( "additional image link 8", true ),
115
+ "images_9" => array( "additional image link 9", true ),
116
+ "images_10" => array( "additional image link 10", true ),
117
+ "condition" => array( "condition", false ),
118
+ "availability" => array( "availability", false ),
119
+ "availability_date" => array( "availability date", false ),
120
+ "inventory" => array( "inventory", false ),
121
+ "price" => array( "price", true ),
122
+ "sale_price" => array( "sale price", true ),
123
+ "sale_price_effective_date" => array( "sale price effective date", true ),
124
+ "brand" => array( "brand", true ),
125
+ "sku" => array( "mpn", true ),
126
+ "upc" => array( "gtin", true ),
127
+ "identifier_exists" => array( "identifier exists", true ),
128
+ "item_group_id" => array( "item group id", false ),
129
+ "color" => array( "color", true ),
130
+ "gender" => array( "gender", true ),
131
+ "age_group" => array( "age group", true ),
132
+ "material" => array( "material", true ),
133
+ "pattern" => array( "pattern", true ),
134
+ "size" => array( "size", true ),
135
+ "size_type" => array( "size type", true ),
136
+ "size_system" => array( "size system", true ),
137
+ "tax" => array( "tax", true ),
138
+ "tax_country" => array( "tax country", true ),
139
+ "tax_region" => array( "tax region", true ),
140
+ "tax_rate" => array( "tax rate", true ),
141
+ "tax_ship" => array( "tax ship", true ),
142
+ "tax_category" => array( "tax category", true ),
143
+ "weight" => array( "shipping weight", false ),
144
+ "length" => array( "shipping length", false ),
145
+ "width" => array( "shipping width", false ),
146
+ "height" => array( "shipping height", false ),
147
+ "shipping_label" => array( "shipping label", false ),
148
+ "shipping_country" => array( "shipping country", false ),
149
+ "shipping_service" => array( "shipping service", false ),
150
+ "shipping_price" => array( "shipping price", false ),
151
+ "shipping_region" => array( "shipping region", false ),
152
+ "multipack" => array( "multipack", true ),
153
+ "is_bundle" => array( "is bundle", true ),
154
+ "adult" => array( "adult", true ),
155
+ "adwords_redirect" => array( "adwords redirect", true ),
156
+ "custom_label_0" => array( "custom label 0", true ),
157
+ "custom_label_1" => array( "custom label 1", true ),
158
+ "custom_label_2" => array( "custom label 2", true ),
159
+ "custom_label_3" => array( "custom label 3", true ),
160
+ "custom_label_4" => array( "custom label 4", true ),
161
+ "excluded_destination" => array( "excluded destination", true ),
162
+ "included_destination" => array( "included destination", true ),
163
+ "expiration_date" => array( "expiration date", true ),
164
+ "unit_pricing_measure" => array( "unit pricing measure", true ),
165
+ "unit_pricing_base_measure" => array( "unit pricing base measure", true ),
166
+ "energy_efficiency_class" => array( "energy efficiency class", true ),
167
+ "loyalty_points" => array( "loyalty points", true ),
168
+ "installment" => array( "installment", true ),
169
+ "promotion_id" => array( "promotion id", true ),
170
+ "cost_of_goods_sold" => array( "cost of goods sold", true ),
171
  );
172
  public $facebookXMLAttribute = array(
173
+ "id" => array( "g:id", false ),
174
+ "title" => array( "g:title", true ),
175
+ "description" => array( "g:description", true ),
176
+ "link" => array( "g:link", true ),
177
+ "mobile_link" => array( "g:mobile_link", true ),
178
+ "product_type" => array( "g:product_type", true ),
179
+ "current_category" => array( "g:google_product_category", true ),
180
+ "image" => array( "g:image_link", true ),
181
+ "images" => array( "g:additional_image_link", false ),
182
+ "images_1" => array( "g:additional_image_link_1", true ),
183
+ "images_2" => array( "g:additional_image_link_2", true ),
184
+ "images_3" => array( "g:additional_image_link_3", true ),
185
+ "images_4" => array( "g:additional_image_link_4", true ),
186
+ "images_5" => array( "g:additional_image_link_5", true ),
187
+ "images_6" => array( "g:additional_image_link_6", true ),
188
+ "images_7" => array( "g:additional_image_link_7", true ),
189
+ "images_8" => array( "g:additional_image_link_8", true ),
190
+ "images_9" => array( "g:additional_image_link_9", true ),
191
+ "images_10" => array( "g:additional_image_link_10", true ),
192
+ "condition" => array( "g:condition", false ),
193
+ "availability" => array( "g:availability", false ),
194
+ "inventory" => array( "g:inventory", false ),
195
+ "override" => array( "g:override", false ),
196
+ "price" => array( "g:price", true ),
197
+ "sale_price" => array( "g:sale_price", true ),
198
+ "sale_price_effective_date" => array( "g:sale_price_effective_date", true ),
199
+ "brand" => array( "g:brand", true ),
200
+ "sku" => array( "g:mpn", true ),
201
+ "upc" => array( "g:gtin", true ),
202
+ "identifier_exists" => array( "g:identifier_exists", true ),
203
+ "item_group_id" => array( "g:item_group_id", false ),
204
+ "color" => array( "g:color", true ),
205
+ "gender" => array( "g:gender", true ),
206
+ "age_group" => array( "g:age_group", true ),
207
+ "material" => array( "g:material", true ),
208
+ "pattern" => array( "g:pattern", true ),
209
+ "size" => array( "g:size", true ),
210
+ "size_type" => array( "g:size_type", true ),
211
+ "size_system" => array( "g:size_system", true ),
212
+ "tax" => array( "tax", true ),
213
+ "weight" => array( "g:shipping_weight", false ),
214
+ "length" => array( "g:shipping_length", false ),
215
+ "width" => array( "g:shipping_width", false ),
216
+ "height" => array( "g:shipping_height", false ),
217
+ "shipping_label" => array( "g:shipping_label", false ),
218
+ "shipping_country" => array( "g:shipping_country", false ),
219
+ "shipping_service" => array( "g:shipping_service", false ),
220
+ "shipping_price" => array( "g:shipping_price", false ),
221
+ "shipping_region" => array( "g:shipping_region", false ),
222
+ "multipack" => array( "g:multipack", true ),
223
+ "is_bundle" => array( "g:is_bundle", true ),
224
+ "adult" => array( "g:adult", true ),
225
+ "adwords_redirect" => array( "g:adwords_redirect", true ),
226
+ "custom_label_0" => array( "g:custom_label_0", true ),
227
+ "custom_label_1" => array( "g:custom_label_1", true ),
228
+ "custom_label_2" => array( "g:custom_label_2", true ),
229
+ "custom_label_3" => array( "g:custom_label_3", true ),
230
+ "custom_label_4" => array( "g:custom_label_4", true ),
231
+ "excluded_destination" => array( "g:excluded_destination", true ),
232
+ "expiration_date" => array( "g:expiration_date", true ),
233
+ "unit_pricing_measure" => array( "g:unit_pricing_measure", true ),
234
+ "unit_pricing_base_measure" => array( "g:unit_pricing_base_measure", true ),
235
+ "energy_efficiency_class" => array( "g:energy_efficiency_class", true ),
236
+ "loyalty_points" => array( "g:loyalty_points", true ),
237
+ "installment" => array( "g:installment", true ),
238
+ "promotion_id" => array( "g:promotion_id", true ),
239
+ "cost_of_goods_sold" => array( "g:cost_of_goods_sold", true ),
240
+ "availability_date" => array( "g:availability_date", true ),
241
+ "tax_category" => array( "g:tax_category", true ),
242
+ "included_destination" => array( "g:included_destination", true ),
243
  );
244
  public $facebookCSVTXTAttribute = array(
245
+ "id" => array( "id", false ),
246
+ "title" => array( "title", true ),
247
+ "description" => array( "description", true ),
248
+ "link" => array( "link", true ),
249
+ "mobile_link" => array( "mobile_link", true ),
250
+ "product_type" => array( "product type", true ),
251
+ "current_category" => array( "google product category", true ),
252
+ "image" => array( "image link", true ),
253
+ "images" => array( "additional image link", true ),
254
+ "images_1" => array( "additional image link 1", true ),
255
+ "images_2" => array( "additional image link 2", true ),
256
+ "images_3" => array( "additional image link 3", true ),
257
+ "images_4" => array( "additional image link 4", true ),
258
+ "images_5" => array( "additional image link 5", true ),
259
+ "images_6" => array( "additional image link 6", true ),
260
+ "images_7" => array( "additional image link 7", true ),
261
+ "images_8" => array( "additional image link 8", true ),
262
+ "images_9" => array( "additional image link 9", true ),
263
+ "images_10" => array( "additional image link 10", true ),
264
+ "condition" => array( "condition", false ),
265
+ "availability" => array( "availability", false ),
266
+ "inventory" => array( "inventory", false ),
267
+ "override" => array( "override", false ),
268
+ "price" => array( "price", true ),
269
+ "sale_price" => array( "sale price", true ),
270
+ "sale_price_effective_date" => array( "sale price effective date", true ),
271
+ "brand" => array( "brand", true ),
272
+ "sku" => array( "mpn", true ),
273
+ "upc" => array( "gtin", true ),
274
+ "identifier_exists" => array( "identifier exists", true ),
275
+ "item_group_id" => array( "item group id", false ),
276
+ "color" => array( "color", true ),
277
+ "gender" => array( "gender", true ),
278
+ "age_group" => array( "age group", true ),
279
+ "material" => array( "material", true ),
280
+ "pattern" => array( "pattern", true ),
281
+ "size" => array( "size", true ),
282
+ "size_type" => array( "size type", true ),
283
+ "size_system" => array( "size system", true ),
284
+ "tax" => array( "tax", true ),
285
+ "weight" => array( "shipping weight", false ),
286
+ "length" => array( "shipping length", false ),
287
+ "width" => array( "shipping width", false ),
288
+ "height" => array( "shipping height", false ),
289
+ "shipping_label" => array( "shipping label", false ),
290
+ "shipping_country" => array( "shipping country", false ),
291
+ "shipping_service" => array( "shipping service", false ),
292
+ "shipping_price" => array( "shipping price", false ),
293
+ "shipping_region" => array( "shipping region", false ),
294
+ "multipack" => array( "multipack", true ),
295
+ "is_bundle" => array( "is bundle", true ),
296
+ "adult" => array( "adult", true ),
297
+ "adwords_redirect" => array( "adwords redirect", true ),
298
+ "custom_label_0" => array( "custom label 0", true ),
299
+ "custom_label_1" => array( "custom label 1", true ),
300
+ "custom_label_2" => array( "custom label 2", true ),
301
+ "custom_label_3" => array( "custom label 3", true ),
302
+ "custom_label_4" => array( "custom label 4", true ),
303
+ "excluded_destination" => array( "excluded destination", true ),
304
+ "expiration_date" => array( "expiration date", true ),
305
+ "unit_pricing_measure" => array( "unit pricing measure", true ),
306
+ "unit_pricing_base_measure" => array( "unit pricing base measure", true ),
307
+ "energy_efficiency_class" => array( "energy efficiency class", true ),
308
+ "loyalty_points" => array( "loyalty points", true ),
309
+ "installment" => array( "installment", true ),
310
+ "promotion_id" => array( "promotion id", true ),
311
+ "cost_of_goods_sold" => array( "cost of goods sold", true ),
312
+ "availability_date" => array( "availability date", true ),
313
+ "tax_category" => array( "tax category", true ),
314
+ "included_destination" => array( "included destination", true ),
315
  );
316
  public $pinterestXMLAttribute = array(
317
+ "id" => array( "g:id", false ),
318
+ "title" => array( "title", true ),
319
+ "description" => array( "description", true ),
320
+ "link" => array( "link", true ),
321
+ "mobile_link" => array( "mobile_link", true ),
322
+ "product_type" => array( "g:product_type", true ),
323
+ "current_category" => array( "g:google_product_category", true ),
324
+ "image" => array( "g:image_link", true ),
325
+ "images" => array( "g:additional_image_link", false ),
326
+ "images_1" => array( "g:additional_image_link_1", true ),
327
+ "images_2" => array( "g:additional_image_link_2", true ),
328
+ "images_3" => array( "g:additional_image_link_3", true ),
329
+ "images_4" => array( "g:additional_image_link_4", true ),
330
+ "images_5" => array( "g:additional_image_link_5", true ),
331
+ "images_6" => array( "g:additional_image_link_6", true ),
332
+ "images_7" => array( "g:additional_image_link_7", true ),
333
+ "images_8" => array( "g:additional_image_link_8", true ),
334
+ "images_9" => array( "g:additional_image_link_9", true ),
335
+ "images_10" => array( "g:additional_image_link_10", true ),
336
+ "condition" => array( "g:condition", false ),
337
+ "availability" => array( "g:availability", false ),
338
+ "availability_date" => array( "g:availability_date", false ),
339
+ "inventory" => array( "g:inventory", false ),
340
+ "price" => array( "g:price", true ),
341
+ "sale_price" => array( "g:sale_price", true ),
342
+ "sale_price_effective_date" => array( "g:sale_price_effective_date", true ),
343
+ "brand" => array( "g:brand", true ),
344
+ "sku" => array( "g:mpn", true ),
345
+ "upc" => array( "g:gtin", true ),
346
+ "identifier_exists" => array( "g:identifier_exists", true ),
347
+ "item_group_id" => array( "g:item_group_id", false ),
348
+ "color" => array( "g:color", true ),
349
+ "gender" => array( "g:gender", true ),
350
+ "age_group" => array( "g:age_group", true ),
351
+ "material" => array( "g:material", true ),
352
+ "pattern" => array( "g:pattern", true ),
353
+ "size" => array( "g:size", true ),
354
+ "size_type" => array( "g:size_type", true ),
355
+ "size_system" => array( "g:size_system", true ),
356
+ "tax" => array( "tax", true ),
357
+ "tax_country" => array( "g:tax_country", true ),
358
+ "tax_region" => array( "g:tax_region", true ),
359
+ "tax_rate" => array( "g:tax_rate", true ),
360
+ "tax_ship" => array( "g:tax_ship", true ),
361
+ "tax_category" => array( "g:tax_category", true ),
362
+ "weight" => array( "g:shipping_weight", false ),
363
+ "length" => array( "g:shipping_length", false ),
364
+ "width" => array( "g:shipping_width", false ),
365
+ "height" => array( "g:shipping_height", false ),
366
+ "shipping_label" => array( "g:shipping_label", false ),
367
+ "shipping_country" => array( "g:shipping_country", false ),
368
+ "shipping_service" => array( "g:shipping_service", false ),
369
+ "shipping_price" => array( "g:shipping_price", false ),
370
+ "shipping_region" => array( "g:shipping_region", false ),
371
+ "multipack" => array( "g:multipack", true ),
372
+ "is_bundle" => array( "g:is_bundle", true ),
373
+ "adult" => array( "g:adult", true ),
374
+ "adwords_redirect" => array( "g:adwords_redirect", true ),
375
+ "custom_label_0" => array( "g:custom_label_0", true ),
376
+ "custom_label_1" => array( "g:custom_label_1", true ),
377
+ "custom_label_2" => array( "g:custom_label_2", true ),
378
+ "custom_label_3" => array( "g:custom_label_3", true ),
379
+ "custom_label_4" => array( "g:custom_label_4", true ),
380
+ "excluded_destination" => array( "g:excluded_destination", true ),
381
+ "included_destination" => array( "g:included_destination", true ),
382
+ "expiration_date" => array( "g:expiration_date", true ),
383
+ "unit_pricing_measure" => array( "g:unit_pricing_measure", true ),
384
+ "unit_pricing_base_measure" => array( "g:unit_pricing_base_measure", true ),
385
+ "energy_efficiency_class" => array( "g:energy_efficiency_class", true ),
386
+ "loyalty_points" => array( "g:loyalty_points", true ),
387
+ "installment" => array( "g:installment", true ),
388
+ "promotion_id" => array( "g:promotion_id", true ),
389
+ "cost_of_goods_sold" => array( "g:cost_of_goods_sold", true ),
390
  );
391
  public $pinterestCSVTXTAttribute = array(
392
+ "id" => array( "id", false ),
393
+ "title" => array( "title", true ),
394
+ "description" => array( "description", true ),
395
+ "link" => array( "link", true ),
396
+ "mobile_link" => array( "mobile_link", true ),
397
+ "product_type" => array( "product_type", true ),
398
+ "current_category" => array( "google_product_category", true ),
399
+ "image" => array( "image_link", true ),
400
+ "images" => array( "additional_image_link", true ),
401
+ "images_1" => array( "additional_image_link_1", true ),
402
+ "images_2" => array( "additional_image_link_2", true ),
403
+ "images_3" => array( "additional_image_link_3", true ),
404
+ "images_4" => array( "additional_image_link_4", true ),
405
+ "images_5" => array( "additional_image_link_5", true ),
406
+ "images_6" => array( "additional_image_link_6", true ),
407
+ "images_7" => array( "additional_image_link_7", true ),
408
+ "images_8" => array( "additional_image_link_8", true ),
409
+ "images_9" => array( "additional_image_link_9", true ),
410
+ "images_10" => array( "additional_image_link_10", true ),
411
+ "condition" => array( "condition", false ),
412
+ "availability" => array( "availability", false ),
413
+ "availability_date" => array( "availability_date", false ),
414
+ "inventory" => array( "inventory", false ),
415
+ "price" => array( "price", true ),
416
+ "sale_price" => array( "sale_price", true ),
417
+ "sale_price_effective_date" => array( "sale_price_effective_date", true ),
418
+ "brand" => array( "brand", true ),
419
+ "sku" => array( "mpn", true ),
420
+ "upc" => array( "gtin", true ),
421
+ "identifier_exists" => array( "identifier exists", true ),
422
+ "item_group_id" => array( "item_group_id", false ),
423
+ "color" => array( "color", true ),
424
+ "gender" => array( "gender", true ),
425
+ "age_group" => array( "age_group", true ),
426
+ "material" => array( "material", true ),
427
+ "pattern" => array( "pattern", true ),
428
+ "size" => array( "size", true ),
429
+ "size_type" => array( "size_type", true ),
430
+ "size_system" => array( "size_system", true ),
431
+ "tax" => array( "tax", true ),
432
+ "tax_country" => array( "tax_country", true ),
433
+ "tax_region" => array( "tax_region", true ),
434
+ "tax_rate" => array( "tax_rate", true ),
435
+ "tax_ship" => array( "tax_ship", true ),
436
+ "tax_category" => array( "tax_category", true ),
437
+ "weight" => array( "shipping_weight", false ),
438
+ "length" => array( "shipping_length", false ),
439
+ "width" => array( "shipping_width", false ),
440
+ "height" => array( "shipping_height", false ),
441
+ "shipping_label" => array( "shipping_label", false ),
442
+ "shipping_country" => array( "shipping_country", false ),
443
+ "shipping_service" => array( "shipping_service", false ),
444
+ "shipping_price" => array( "shipping_price", false ),
445
+ "shipping_region" => array( "shipping_region", false ),
446
+ "multipack" => array( "multipack", true ),
447
+ "is_bundle" => array( "is_bundle", true ),
448
+ "adult" => array( "adult", true ),
449
+ "adwords_redirect" => array( "adwords_redirect", true ),
450
+ "custom_label_0" => array( "custom_label_0", true ),
451
+ "custom_label_1" => array( "custom_label_1", true ),
452
+ "custom_label_2" => array( "custom_label_2", true ),
453
+ "custom_label_3" => array( "custom_label_3", true ),
454
+ "custom_label_4" => array( "custom_label_4", true ),
455
+ "excluded_destination" => array( "excluded_destination", true ),
456
+ "included_destination" => array( "included_destination", true ),
457
+ "expiration_date" => array( "expiration_date", true ),
458
+ "unit_pricing_measure" => array( "unit_pricing_measure", true ),
459
+ "unit_pricing_base_measure" => array( "unit_pricing_base_measure", true ),
460
+ "energy_efficiency_class" => array( "energy_efficiency_class", true ),
461
+ "loyalty_points" => array( "loyalty_points", true ),
462
+ "installment" => array( "installment", true ),
463
+ "promotion_id" => array( "promotion_id", true ),
464
+ "cost_of_goods_sold" => array( "cost_of_goods_sold", true ),
465
  );
466
 
467
+ public function __construct() {
 
468
 
469
  }
470
 
471
+ public function merchants() {
 
472
 
473
  $feed_engine = array(
474
+ "--1" => "Custom Template",
475
  "custom" => "Custom Feed",
476
+ "---1" => "",
477
  );
478
 
479
  $popular_template = array(
480
+ "--2" => "Popular Templates",
481
+ "google" => "Google Shopping",
482
+ "google_local" => "Google Local Product",
483
  "google_local_inventory" => "Google Local Product Inventory",
484
+ "adwords" => "Google Adwords",
485
+ "facebook" => "Facebook",
486
+ "pinterest" => "Pinterest",
487
+ "---2" => "",
488
  );
489
 
490
  $others_temp = array(
491
+ "shopping" => "eBay (Shopping.com)",
492
+ "adroll" => "AdRoll",
493
+ "adform" => "AdForm",
494
+ "nextag" => "Nextag",
495
+ "pricegrabber" => "Price Grabber",
496
+ "polyvore" => "Polyvore",
497
+ "pricerunner" => "PriceRunner",
498
+ "kelkoo" => "Kelkoo",
499
+ "shopzilla" => "Shopzilla",
500
+ "shopmania" => "Shopmania",
501
+ "shopbot" => "Shopbot",
502
+ "bing" => "Bing",
503
+ "become" => "Become",
504
+ "connexity" => "Connexity",
505
 
506
+ "pricespy" => "PriceSpy",
507
+ "prisjakt" => "Prisjakt",
508
+ "twenga" => "Twenga",
509
+ "fruugo" => "Fruugo",
510
+ "fruugo.au" => "Fruugoaustralia.com",
511
+ "bonanza" => "Bonanza",
512
+ "bol" => "Bol.com",
513
+ "leguide" => "LeGuide",
514
+ "real" => "Real",
515
+ "crowdfox" => "Crowdfox",
516
+ "jet" => "Jet.com",
517
+ "wish" => "Wish.com",
518
+ "zap.co.il" => "Zap.co.il",
519
+ "myshopping.com.au" => "Myshopping.com.au",
520
+ "smartly.io" => "Smartly.io",
521
+ "stylight.com" => "Stylight.com",
522
+ "nextad" => "TheNextAd",
523
+ "skinflint.co.uk" => "SkinFlint.co.uk",
524
+ "yahoo_nfa" => "Yahoo NFA",
525
+ "hintaseuranta.fi" => "Hintaseuranta.fi",
526
+ "incurvy" => "Incurvy",
527
+ "kijiji.ca" => "Kijiji.ca",
528
+ "marktplaats.nl" => "Marktplaats.nl",
529
+ "rakuten.de" => "Rakuten",
530
+ "shopalike.fr" => "Shopalike.fr",
531
+ "spartoo.fi" => "Spartoo.fi",
532
+ "webmarchand" => "Webmarchand",
533
+ "fashiola" => "Fashiola",
534
  "vergelijk_comparer" => "Vergelijk.be & Comparer.be",
535
+ "kieskeurig.nl" => "Kieskeurig.nl",
536
+ "beslist.nl" => "Beslist.nl",
537
+ "billiger.de" => "Billiger.de",
538
+ "vertaa.fi" => "Vertaa.fi",
539
+ "cdiscount.fr" => "CDiscount.fr",
540
+ "fnac.fr" => "Fnac.fr",
541
+ "idealo" => "Idealo",
542
+ "miinto.nl" => "Miinto.nl",
543
+ 'fyndiq.se' => "Fyndiq.se",
544
+ "criteo" => "Criteo",
545
+ "avantlink" => "Avantlink",
546
+ 'shareasale' => "ShareASale",
547
+ "walmart" => "Walmart",
548
+ "modina.de" => "Modina.de",
549
+ "yandex_csv" => "Yandex (CSV)",
550
  );
551
 
552
  asort($others_temp);
553
  $newTemplate = array();
554
  $newTemplate['--3'] = "Templates";
555
+ foreach ( $others_temp as $key => $val ) {
556
  // echo "$key = $val <br>";
557
+ $newTemplate[ $key ] = $val;
558
  }
559
  $newTemplate['---3'] = "";
560
 
570
  * @return string
571
  */
572
 
573
+ public function getAttributeDropDown( $merchant, $selected = "" ) {
 
574
  $str = "<option></option>";
575
  $method = $merchant . "Attribute";
576
+ foreach ( $this->$method() as $key => $value ) {
577
+ if ( substr($key, 0, 2) == "--" ) {
578
  $str .= "<optgroup label='$value'>";
579
+ } elseif ( substr($key, 0, 2) == "---" ) {
580
  $str .= "</optgroup>";
581
  } else {
582
  $sltd = "";
583
  if ($selected == $key)
584
  $sltd = 'selected="selected"';
585
  $str .= "<option $sltd value='$key'>" . $value . "</option>";
586
+ }
587
+ }
 
588
  return $str;
589
  }
590
 
591
+ public function googleAttributes() {
 
592
  $attributes = array(
593
+ "--1" => "Basic Information",
594
+ "id" => "Product Id[id]",
595
+ "title" => "Product Title[title]",
596
+ "description" => "Product Description[description]",
597
+ "link" => "Product URL[link]",
598
+ "mobile_link" => "Product URL[mobile_link]",
599
+ "product_type" => "Product Categories[product_type] ",
600
+ "current_category" => "Google Product Category[google_product_category]",
601
+ "image" => "Main Image[image_link]",
602
+ "images" => "Comma Separated Images [additional_image_link]",
603
+ "images_1" => "Additional Image 1 [additional_image_link]",
604
+ "images_2" => "Additional Image 2 [additional_image_link]",
605
+ "images_3" => "Additional Image 3 [additional_image_link]",
606
+ "images_4" => "Additional Image 4 [additional_image_link]",
607
+ "images_5" => "Additional Image 5 [additional_image_link]",
608
+ "images_6" => "Additional Image 6 [additional_image_link]",
609
+ "images_7" => "Additional Image 7 [additional_image_link]",
610
+ "images_8" => "Additional Image 8 [additional_image_link]",
611
+ "images_9" => "Additional Image 9 [additional_image_link]",
612
+ "images_10" => "Additional Image 10 [additional_image_link]",
613
+ "condition" => "Condition[condition]",
614
+ "---1" => "",
615
 
616
+ "--2" => "Availability & Price",
617
+ "availability" => "Stock Status[availability]",
618
+ "availability_date" => "Availability Date[availability_date]",
619
+ "cost_of_goods_sold" => "Cost of Goods Sold[cost_of_goods_sold]",
620
+ "expiration_date" => "Expiration Date[expiration_date]",
621
+ "inventory" => "Facebook Inventory[inventory]",
622
+ "override" => "Facebook Override[override]",
623
+ "price" => "Regular Price[price]",
624
+ "sale_price" => "Sale Price[sale_price]",
625
  "sale_price_effective_date" => "Sale Price Effective Date[sale_price_effective_date]",
626
+ "---2" => "",
627
 
628
+ "--3" => "Unique Product Identifiers",
629
+ "brand" => "Manufacturer[brand]",
630
+ "upc" => "GTIN[gtin]",
631
+ "sku" => "MPN[mpn]",
632
+ "identifier_exists" => "Identifier Exist[identifier_exists]",
633
+ "---3" => "",
634
 
635
+ "--4" => "Detailed Product Attributes",
636
+ "item_group_id" => "Item Group Id[item_group_id]",
637
+ "color" => "Color[color]",
638
+ "gender" => "Gender[gender]",
639
+ "age_group" => "Age Group[age_group]",
640
+ "material" => "Material[material]",
641
+ "pattern" => "Pattern[pattern]",
642
+ "size" => "Size of the item[size]",
643
+ "size_type" => "Size Type[size_type]",
644
+ "size_system" => "Size System[size_system]",
645
+ "---4" => "",
646
 
647
+ "--5" => "Tax & Shipping",
648
+ // "tax" => "Tax[tax]",
649
+ "tax_country" => "Tax Country[tax_country]",
650
+ "tax_region" => "Tax Region[tax_region]",
651
+ "tax_rate" => "Tax Rate[tax_rate]",
652
+ "tax_ship" => "Tax Ship[tax_ship]",
653
+ "tax_category" => "Tax[tax_category]",
654
+ "shipping_country" => "Shipping Country",
655
+ "shipping_region" => "Shipping Region",
656
+ "shipping_service" => "Shipping Service",
657
+ "shipping_price" => "Shipping Price",
658
+ "weight" => "Shipping Weight[shipping_weight]",
659
+ "length" => "Shipping Length[shipping_length]",
660
+ "width" => "Shipping Width[shipping_width]",
661
+ "height" => "Shipping Height[shipping_height]",
662
+ "shipping_label" => "Shipping Label[shipping_label]",
663
+ "---5" => "",
664
 
665
+ "--6" => "Product Combinations",
666
+ "multipack" => "Multipack[multipack]",
667
+ "is_bundle" => "Is Bundle[is_bundle]",
668
+ "---6" => "",
669
 
670
+ "--7" => "Adult Products",
671
+ "adult" => "Adult[adult]",
672
+ "---7" => "",
673
 
674
+ "--8" => "AdWord Attributes",
675
+ "adwords_redirect" => "Adwords Redirect[adwords_redirect]",
676
+ "---8" => "",
677
 
678
+ "--9" => "Custom Label Attributes",
679
+ "custom_label_0" => "Custom label 0 [custom_label_0]",
680
+ "custom_label_1" => "Custom label 1 [custom_label_1]",
681
+ "custom_label_2" => "Custom label 2 [custom_label_2]",
682
+ "custom_label_3" => "Custom label 3 [custom_label_3]",
683
+ "custom_label_4" => "Custom label 4 [custom_label_4]",
684
+ "---9" => "",
685
 
686
+ "--10" => "Additional Attributes",
687
+ "excluded_destination" => "Excluded Destination[excluded_destination]",
688
+ "included_destination" => "Included Destination[included_destination]",
689
+ "expiration_date" => "Expiration Date [expiration_date]",
690
+ "---10" => "",
691
 
692
+ "--11" => "Unit Prices (EU Countries and Switzerland Only)",
693
+ "unit_pricing_measure" => "Unit Pricing Measure[unit_pricing_measure]",
694
  "unit_pricing_base_measure" => "Unit Pricing Base Measure[unit_pricing_base_measure]",
695
+ "---11" => "",
696
 
697
+ "--12" => "Energy Labels",
698
+ "energy_efficiency_class" => "Energy Efficiency Class[energy_efficiency_class]",
699
+ "---12" => "",
700
 
701
+ "--13" => "Loyalty Points (Japan Only)",
702
+ "loyalty_points" => "loyalty_points[loyalty_points]",
703
+ "---13" => "",
704
 
705
+ "--14" => "Multiple Installments (Brazil Only)",
706
+ "installment" => "Installment[installment]",
707
+ "---14" => "",
708
 
709
+ "--15" => "Merchant Promotions Attribute",
710
+ "promotion_id" => "Promotion Id[promotion_id]",
711
+ "---15" => "",
712
  );
713
 
714
  return $attributes;
715
  }
716
 
717
+ public function pricegrabberAttribute() {
 
718
  $attributes = array(
719
+ "--1" => "Required Attributes",
720
+ "Retsku" => "Retsku",
721
+ "Product Title" => "Product Title",
722
+ "Detailed Description" => "Detailed Description",
723
+ "Categorization" => "Categorization",
724
+ "Product URL" => "Product URL",
725
+ "Primary Image URL" => "Primary Image URL",
726
+ "Selling Price" => "Selling Price",
727
+ "Regular Price" => "Regular Price",
728
+ "Condition" => "Condition",
729
+ "Availability" => "Availability",
730
+ "Manufacturer Name" => "Manufacturer Name",
731
+ "GTIN" => "GTIN (UPC / EAN / ISBN)",
732
+ "Mature" => "Mature",
733
+ "---1" => "",
734
+ "--2" => "Additional Attributes",
735
+ "Parent Retsku" => "Parent Retsku",
736
+ "Merchant Categorization" => "Merchant Categorization",
737
  "Manufacturer Part Number" => "Manufacturer Part Number",
738
+ "Additional Image URL 1" => "Additional Image URL 1",
739
+ "Additional Image URL 2" => "Additional Image URL 2",
740
+ "Additional Image URL 3" => "Additional Image URL 3",
741
+ "Additional Image URL 4" => "Additional Image URL 4",
742
+ "Additional Image URL 5" => "Additional Image URL 5",
743
+ "Additional Image URL 6" => "Additional Image URL 6",
744
+ "Additional Image URL 7" => "Additional Image URL 7",
745
+ "Additional Image URL 8" => "Additional Image URL 8",
746
+ "Additional Image URL 9" => "Additional Image URL 9",
747
+ "Additional Image URL 10" => "Additional Image URL 10",
748
+ "Video URL" => "Video URL",
749
+ "Color" => "Color",
750
+ "Size" => "Size",
751
+ "Material" => "Material",
752
+ "Pattern" => "Pattern",
753
+ "Gender" => "Gender",
754
+ "Age" => "Age",
755
+ "Parent UPC" => "Parent UPC",
756
+ "Multipack" => "Multipack",
757
+ "Shipping Cost" => "Shipping Cost",
758
+ "Weight" => "Weight",
759
+ "---2" => "",
760
  );
761
  return $attributes;
762
  }
763
 
764
+ public function nextagAttribute() {
 
765
  $attributes = array(
766
+ "--1" => "Required Attributes",
767
+ "Product Name" => "Product Name",
768
  "Product Description" => "Product Description",
769
+ "Image URL" => "Image URL",
770
+ "Click-Out URL" => "Click-Out URL",
771
+ "Price" => "Price",
772
+ "Category" => "Category: Nextag Numeric ID or Other",
773
+ "---1" => "",
774
+ "--2" => "Additional Attributes",
775
+ "Manufacturer" => "Manufacturer",
776
+ "Condition" => "Condition",
777
+ "Stock Status" => "Stock Status",
778
+ "Cost-per-Click " => "Cost-per-Click ",
779
+ "Distributor ID " => "Distributor ID ",
780
+ "Ground Shipping" => "Ground Shipping",
781
+ "Ingram Part #" => "Ingram Part #",
782
+ "ISBN" => "ISBN",
783
  "Manufacturer Part #" => "Manufacturer Part #",
784
+ "Marketing Message " => "Marketing Message ",
785
+ "MUZE ID" => "MUZE ID",
786
+ "Seller Part #" => "Seller Part #",
787
+ "UPC" => "UPC",
788
+ "Weight" => "Weight",
789
+ "ListPrice" => "ListPrice",
790
+ "---2" => "",
791
  );
792
  return $attributes;
793
  }
794
 
795
+ public function kelkooAttribute() {
 
796
  $attributes = array(
797
+ "--1" => "Required Attributes",
798
+ "title" => "title",
799
+ "product-url" => "product-url",
800
+ "price" => "price",
801
+ "merchant-category" => "merchant-category",
802
+ "ean" => "ean",
803
+ "delivery-cost" => "delivery-cost",
804
+ "brand" => "brand",
805
+ "description" => "description",
806
+ "image-url" => "image-url",
807
+ "availability" => "availability",
808
+ "mpn" => "mpn",
809
+ "sku" => "sku",
810
+ "---1" => "",
811
+ "--2" => "Additional Attributes",
812
+ "delivery-time" => "delivery-time",
813
+ "condition" => "condition",
814
+ "ecotax" => "ecotax",
815
+ "warranty" => "warranty",
816
+ "mobile-url" => "mobile-url",
817
+ "kelkoo-category-id" => "kelkoo-category-id",
818
+ "colour" => "colour",
819
+ "unit-price" => "unit-price",
820
+ "offer-type" => "offer-type",
821
+ "merchant-info" => "merchant-info",
822
+ "currency" => "currency",
823
+ "image-url-2" => "image-url-2",
824
+ "image-url-3" => "image-url-3",
825
+ "image-url-4" => "image-url-4",
826
+ "green-product" => "green-product",
827
+ "green-label" => "green-label",
828
+ "sales-rank" => "sales-rank",
829
+ "unit-quantity" => "unit-quantity",
830
+ "made-in" => "made-in",
831
+ "occasion" => "occasion",
832
+ "efficiency-class" => "efficiency-class",
833
+ "shipping-method" => "shipping-method",
834
+ "delivery-cost-2" => "delivery-cost-2",
835
+ "shipping-method-2" => "shipping-method-2",
836
+ "delivery-cost-3" => "delivery-cost-3",
837
+ "shipping-method-3" => "shipping-method-3",
838
+ "delivery-cost-4" => "delivery-cost-4 ",
839
+ "shipping-method-4" => "shipping-method-4",
840
+ "zip-code" => "zip-code",
841
+ "stock-quantity" => "stock-quantity",
842
+ "shipping-weight" => "shipping-weight",
843
+ "payment-methods" => "payment-methods",
844
+ "voucher-title" => "voucher-title",
845
  "voucher-description" => "voucher-description",
846
+ "voucher-url" => "voucher-url",
847
+ "voucher-code" => "voucher-code",
848
+ "voucher-start-date" => "voucher-start-date",
849
+ "voucher-end-date" => "voucher-end-date",
850
+ "price-no-rebate" => "price-no-rebate",
851
+ "percentage-promo" => "percentage-promo",
852
+ "promo-start-date" => "promo-start-date",
853
+ "promo-end-dat" => "promo-end-dat",
854
+ "user-rating" => "user-rating",
855
+ "nb-reviews" => "nb-reviews",
856
+ "user-review-link" => "user-review-link",
857
+ "video-link" => "video-link",
858
+ "video-title" => "video-title",
859
+ "---2" => "",
860
  );
861
  return $attributes;
862
  }
863
 
864
+ public function shopzillaAttribute() {
 
865
  $attributes = array(
866
+ "--1" => "Required Attributes",
867
+ "Unique ID" => "Unique ID",
868
+ "Title" => "Title",
869
+ "Description" => "Description",
870
+ "Category" => "Category",
871
+ "Product URL" => "Product URL",
872
+ "Image URL" => "Image URL",
873
+ "Condition" => "Condition",
874
+ "Availability" => "Availability",
875
+ "Current Price" => "Current Price",
876
+ "---1" => "",
877
+ "--2" => "Recommended Attributes",
878
+ "Brand" => "Brand",
879
+ "GTIN" => "GTIN",
880
+ "MPN" => "MPN",
881
+ "Ship Cost" => "Ship Cost",
882
+ "Ship Weight" => "Ship Weight",
883
+ "Bid" => "Bid",
884
+ "Regular Price" => "Regular Price",
885
+ "Promo Text" => "Promo Text",
886
+ "Gender" => "Gender",
887
+ "Age Group" => "Age Group",
888
+ "Color" => "Color",
889
+ "Size" => "Size",
890
+ "Material" => "Material",
891
+ "Pattern" => "Pattern",
892
+ "Item Group ID" => "Item Group ID",
893
+ "---2" => "",
894
+ "--3" => "Optional Attributes",
895
+ "Page ID" => "Page ID",
896
+ "Page ID Variant" => "Page ID Variant",
897
+ "Generic Title" => "Generic Title",
898
+ "Unit Price" => "Unit Price",
899
+ "Currency" => "Currency",
900
+ "PZN" => "PZN",
901
+ "Adult" => "Adult",
902
+ "Delivery Period" => "Delivery Period",
903
  "Energy Efficiency Class" => "Energy Efficiency Class",
904
+ "---3" => "",
905
  );
906
  return $attributes;
907
  }
908
 
909
+ public function shoppingAttribute() {
 
910
  $attributes = array(
911
+ "--1" => "Required Attributes",
912
+ "Unique Merchant SKU" => "Unique Merchant SKU",
913
+ "Product Name" => "Product Name",
914
+ "Product URL" => "Product URL",
915
+ "Image URL" => "Image URL",
916
+ "Current Price" => "Current Price",
917
+ "Stock Availability" => "Stock Availability",
918
+ "Condition" => "Condition",
919
+ "MPN" => "MPN",
920
+ "ISBN" => "ISBN",
921
+ "UPC" => "UPC",
922
+ "EAN" => "EAN",
923
+ "---1" => "",
924
+ "--2" => "Additional Attributes",
925
+ "Shipping Rate" => "Shipping Rate",
926
+ "Original Price" => "Original Price",
927
+ "Coupon Code" => "Coupon Code",
928
  "Coupon Code Description" => "Coupon Code Description",
929
+ "Manufacturer" => "Brand / Manufacturer",
930
+ "Product Description" => "Product Description",
931
+ "Product Type" => "Product Type",
932
+ "Category" => "Category",
933
+ "Category ID" => "Category ID",
934
+ "Parent SKU" => "Parent SKU",
935
+ "Parent Name" => "Parent Name",
936
+ "Top Seller Rank" => "Top Seller Rank",
937
+ "Estimated Ship Date" => "Estimated Ship Date",
938
+ "Gender" => "Gender",
939
+ "Color" => "Color",
940
+ "Material" => "Material",
941
+ "Size" => "Size",
942
+ "Size Unit of Measure" => "Size Unit of Measure",
943
+ "Age Range" => "Age Range",
944
+ "Stock Description" => "Stock Description",
945
+ "Product Launch Date" => "Product Launch Date",
946
+ "Product Bullet Point 1" => "Product Bullet Point 1",
947
+ "Product Bullet Point 2" => "Product Bullet Point 2",
948
+ "Product Bullet Point 3" => "Product Bullet Point 3",
949
+ "Product Bullet Point 4" => "Product Bullet Point 4",
950
+ "Product Bullet Point 5" => "Product Bullet Point 5",
951
  "Alternative Image URL 1" => "Alternative Image URL 1",
952
  "Alternative Image URL 2" => "Alternative Image URL 2",
953
  "Alternative Image URL 3" => "Alternative Image URL 3",
954
  "Alternative Image URL 4" => "Alternative Image URL 4",
955
  "Alternative Image URL 5" => "Alternative Image URL 5",
956
+ "Mobile URL" => "Mobile URL",
957
+ "Related Products" => "Related Products",
958
+ "Merchandising Type" => "Merchandising Type",
959
+ "Zip Code" => "Zip Code",
960
+ "Shipping Weight" => "Shipping Weight",
961
+ "Format" => "Format",
962
+ "Unit Price" => "Unit Price",
963
+ "Bundle" => "Bundle",
964
+ "Software Platform" => "Software Platform",
965
+ "Watch Display Type" => "Watch Display Type",
966
+ "Custom" => "Custom",
967
+ "---2" => "",
968
  );
969
  return $attributes;
970
  }
971
 
972
+ public function shopmaniaAttribute() {
 
973
  $attributes = array(
974
+ "--1" => "Required Attributes",
975
+ "Category" => "Category",
976
  "Manufacturer" => "Manufacturer",
977
+ "Model" => "Model",
978
+ "MPC" => "Merchant Code",
979
+ "Name" => "Product name",
980
+ "Description" => "Product description",
981
+ "URL" => "Product URL",
982
+ "Image" => "Image URL",
983
+ "Price" => "Product price",
984
+ "Currency" => "Currency",
985
+ "Shipping" => "Shipping cost",
986
  "Availability" => "Availability",
987
+ "GTIN" => "GTIN",
988
+ "---1" => "",
989
 
990
  );
991
  return $attributes;
992
  }
993
 
994
+ public function leguideAttribute() {
 
995
  $attributes = array(
996
+ "--1" => "",
997
+ "category" => "category",
998
+ "unique_id" => "unique_id",
999
+ "category" => "category",
1000
+ "title" => "title",
1001
+ "description" => "description",
1002
+ "price" => "price",
1003
+ "product_URL" => "product_URL",
1004
+ "image_URL" => "image_URL",
1005
+ "EAN" => "EAN",
1006
  "delivery_charge" => "delivery_charge",
1007
+ "availability" => "availability",
1008
+ "delivery_time" => "delivery_time",
1009
+ "guarantee" => "guarantee",
1010
  "model_reference" => "model_reference",
1011
+ "marque" => "marque",
1012
+ "MPN" => "MPN",
1013
+ "full_price" => "full_price",
1014
+ "colour" => "colour",
1015
+ "size" => "size",
1016
+ "material" => "material",
1017
+ "currency" => "currency",
1018
+ "second-hand" => "second-hand",
1019
+ "type_promotion" => "type_promotion",
1020
+ "mobile_URL" => "mobile_URL",
1021
+ "unit_price" => "unit_price",
1022
+ "---1" => "",
1023
  );
1024
  return $attributes;
1025
  }
1026
 
1027
+ public function pricespyAttribute() {
 
1028
  $attributes = array(
1029
+ "--1" => "",
1030
+ "Product-name" => "Product-name",
1031
+ "Your-item-number" => "Your-item-number",
1032
+ "category" => "category",
1033
  "price-including-gst" => "price-including-gst",
1034
+ "Product-URL" => "Product-URL",
1035
+ "manufacturer" => "manufacturer",
1036
+ "manufacturer-SKU" => "manufacturer-SKU",
1037
+ "shipping" => "shipping",
1038
+ "image-URL" => "image-URL",
1039
+ "stock status" => "stock status",
1040
+ "---1" => "",
1041
  );
1042
  return $attributes;
1043
  }
1044
 
1045
+ public function prisjaktAttribute() {
 
1046
  $attributes = array(
1047
+ "--1" => "",
1048
+ "Produktnamn" => "Produktnamn",
1049
+ "Art.nr." => "Art.nr.",
1050
+ "Kategori" => "Kategori",
1051
  "Pris inkl.moms" => "Pris inkl.moms",
1052
+ "Produkt-URL" => "Produkt-URL",
1053
+ "Tillverkare" => "Tillverkare",
1054
  "Tillverkar-SKU" => "Tillverkar-SKU",
1055
+ "Frakt" => "Frakt",
1056
+ "Bild-URL" => "Bild-URL",
1057
+ "Lagerstatus" => "Lagerstatus",
1058
+ "---1" => "",
1059
  );
1060
  return $attributes;
1061
  }
1062
 
1063
+ public function bingAttribute() {
 
1064
  $attributes = array(
1065
+ "id" => "ID",
1066
+ "title" => "Title",
1067
+ "link" => "Product URL",
1068
+ "price" => "Price",
1069
+ "description" => "Description",
1070
+ "image_link" => "ImageURL",
1071
+ "shipping" => "Shipping",
1072
+ "required" => "",
1073
+ "brand" => "Brand",
1074
+ "mpn" => "MPN",
1075
+ "gtin" => "GTIN",
1076
+ "gender" => "Gender",
1077
+ "age_group" => "Age Group",
1078
+ "color" => "Color",
1079
+ "size" => "Size",
1080
+ "item_group_id" => "Item Group Id",
1081
+ "material" => "Material",
1082
+ "pattern" => "Pattern",
1083
+ "adult" => "Adult",
1084
+ "availability" => "Availability",
1085
+ "product_category" => "Product Category",
1086
+ "condition" => "Condition",
1087
+ "expiration_date" => "Expiration Date",
1088
+ "multipack" => "Multipack",
1089
+ "product_type" => "Product Type",
1090
+ "mobile_link" => "Mobile Link",
1091
+ "seller_name" => "Seller Name",
1092
+ "bingads_grouping" => "bingads_grouping",
1093
+ "bingads_label" => "bingads_label",
1094
+ "bingads_redirect" => "bingads_redirect",
1095
+ "custom_label_0" => "custom_label_0",
1096
+ "custom_label_1" => "custom_label_1",
1097
+ "custom_label_2" => "custom_label_2",
1098
+ "custom_label_3" => "custom_label_3",
1099
+ "custom_label_4" => "custom_label_4",
1100
+ "sale_price" => "Sale Price",
1101
  "sale_price_effective_date" => "Sale Price Effective Date",
1102
+ "promotion_ID" => "Promotion Id",
1103
  );
1104
  return $attributes;
1105
  }
1106
 
1107
+ public function shopbotAttribute() {
 
1108
  $attributes = array(
1109
+ "--1" => "Required Attributes",
1110
+ "ID" => "ID",
1111
+ "Product Name" => "Product Name",
1112
+ "URL" => "URL",
1113
+ "Category" => "Category",
1114
+ "Photo URL" => "Photo URL",
1115
+ "Price" => "Price",
1116
+ "Original Price" => "Original Price",
1117
+ "Description" => "Description",
1118
+ "MPN" => "MPN",
1119
+ "Brand" => "Brand",
1120
+ "Shipment Cost" => "Shipment Cost",
1121
+ "---1" => "",
1122
+ "--2" => "Recommended Attributes",
1123
+ "Stock" => "Stock",
1124
  "Promotional Phrase" => "Promotional Phrase",
1125
+ "Model" => "Model",
1126
+ "Color" => "Color",
1127
+ "Product Type" => "Product Type",
1128
+ "---2" => "",
1129
 
1130
  );
1131
  return $attributes;
1132
  }
1133
 
1134
+ public function becomeAttribute() {
 
1135
  $attributes = array(
1136
+ "--1" => "Required Attributes",
1137
+ "Unique ID" => "Unique ID",
1138
+ "Title" => "Title",
1139
+ "Description" => "Description",
1140
+ "Category" => "Category",
1141
+ "Product URL" => "Product URL",
1142
+ "Image URL" => "Image URL",
1143
+ "Condition" => "Condition",
1144
+ "Availability" => "Availability",
1145
+ "Current Price" => "Current Price",
1146
+ "---1" => "",
1147
+ "--2" => "Recommended Attributes",
1148
+ "Additional Image URL" => "Additional Image URL",
1149
+ "Brand" => "Brand",
1150
+ "GTIN" => "GTIN",
1151
+ "MPN" => "MPN",
1152
+ "Ship Cost" => "Ship Cost",
1153
+ "Ship Weight" => "Ship Weight",
1154
+ "Bid" => "Bid",
1155
+ "Regular Price" => "Regular Price",
1156
+ "Promo Text" => "Promo Text",
1157
+ "Gender" => "Gender",
1158
+ "Age Group" => "Age Group",
1159
+ "Color" => "Color",
1160
+ "Size" => "Size",
1161
+ "Material" => "Material",
1162
+ "Pattern" => "Pattern",
1163
+ "Item Group ID" => "Item Group ID",
1164
+ "---2" => "",
1165
+ "--3" => "Optional Attributes",
1166
+ "Page ID" => "Page ID",
1167
+ "Page ID Variant" => "Page ID Variant",
1168
+ "Generic Title" => "Generic Title",
1169
+ "Unit Price" => "Unit Price",
1170
+ "Currency" => "Currency",
1171
+ "PZN" => "PZN",
1172
+ "Adult" => "Adult",
1173
+ "Delivery Period" => "Delivery Period",
1174
  "Energy Efficiency Class" => "Energy Efficiency Class",
1175
 
1176
+ "---3" => "",
1177
  );
1178
  return $attributes;
1179
  }
1180
 
1181
+ public function connexityAttribute() {
 
1182
  $attributes = array(
1183
+ "--1" => "Required Attributes",
1184
+ "Unique ID" => "Unique ID",
1185
+ "Title" => "Title",
1186
+ "Description" => "Description",
1187
+ "Category" => "Category",
1188
+ "Product URL" => "Product URL",
1189
+ "Image URL" => "Image URL",
1190
+ "Condition" => "Condition",
1191
+ "Availability" => "Availability",
1192
+ "Current Price" => "Current Price",
1193
+ "---1" => "",
1194
+ "--2" => "Recommended Attributes",
1195
+ "Brand" => "Brand",
1196
+ "GTIN" => "GTIN",
1197
+ "MPN" => "MPN",
1198
+ "Ship Cost" => "Ship Cost",
1199
+ "Ship Weight" => "Ship Weight",
1200
+ "Bid" => "Bid",
1201
+ "Regular Price" => "Regular Price",
1202
+ "Promo Text" => "Promo Text",
1203
+ "Gender" => "Gender",
1204
+ "Age Group" => "Age Group",
1205
+ "Color" => "Color",
1206
+ "Size" => "Size",
1207
+ "Material" => "Material",
1208
+ "Pattern" => "Pattern",
1209
+ "Item Group ID" => "Item Group ID",
1210
+ "---2" => "",
1211
+ "--3" => "Optional Attributes",
1212
+ "Page ID" => "Page ID",
1213
+ "Page ID Variant" => "Page ID Variant",
1214
+ "Generic Title" => "Generic Title",
1215
+ "Unit Price" => "Unit Price",
1216
+ "Currency" => "Currency",
1217
+ "PZN" => "PZN",
1218
+ "Adult" => "Adult",
1219
+ "Delivery Period" => "Delivery Period",
1220
  "Energy Efficiency Class" => "Energy Efficiency Class",
1221
+ "---3" => "",
1222
  );
1223
  return $attributes;
1224
  }
includes/classes/class-woo-feed-dropdown.php CHANGED
@@ -22,24 +22,22 @@ class Woo_Feed_Dropdown
22
  * @param string $selected
23
  * @return string
24
  */
25
- public function merchantsDropdown( $selected = "" )
26
- {
27
  $selected = esc_attr( $selected );
28
  $attributes = new Woo_Feed_Default_Attributes();
29
  $str = "<option></option>";
30
- foreach ($attributes->merchants() as $key => $value) {
31
- if (substr($key, 0, 2) == "--") {
32
  $str .= "<optgroup label='$value'>";
33
- } elseif (substr($key, 0, 2) == "---") {
34
  $str .= "</optgroup>";
35
  } else {
36
  $sltd = "";
37
  if ($selected == $key)
38
  $sltd = 'selected="selected"';
39
  $str .= "<option $sltd value='$key'>" . $value . "</option>";
40
- }
41
-
42
- }
43
  return $str;
44
  }
45
 
@@ -53,12 +51,12 @@ class Woo_Feed_Dropdown
53
  $fileName = WOO_FEED_FREE_ADMIN_PATH . "/partials/templates/google_taxonomy.txt";
54
  $customTaxonomyFile = fopen($fileName, "r");
55
  $str = "";
56
- if( ! empty( $selected ) ) {
57
  $selected = trim( $selected );
58
- if( ! is_numeric( $selected ) ) $selected = html_entity_decode( $selected );
59
  else $selected = (int) $selected;
60
  }
61
- if($customTaxonomyFile){
62
  // First line contains metadata, ignore it
63
  @fgets( $customTaxonomyFile );
64
  while ( $line = fgets( $customTaxonomyFile ) ) {
@@ -74,7 +72,7 @@ class Woo_Feed_Dropdown
74
  );
75
  }
76
  }
77
- if( ! empty( $str ) ) {
78
  $str = "<option></option>" . $str;
79
  }
80
  return $str;
@@ -95,490 +93,443 @@ class Woo_Feed_Dropdown
95
  @fgets( $customTaxonomyFile );
96
  while ( $line = fgets( $customTaxonomyFile ) ) {
97
  list( $catId, $cat ) = explode( "-", $line );
98
- $taxonomy[] = [ 'value' => absint( trim( $catId ) ), 'text' => trim( $cat ) ];
 
 
 
99
  }
100
  }
101
  $taxonomy = array_filter( $taxonomy );
102
  return $taxonomy;
103
  }
104
 
105
- public function amazon_clothingAttributesDropdown($selected = "")
106
- {
107
  $attributes = new Woo_Feed_Default_Attributes();
108
  $str = "<option></option>";
109
- foreach ($attributes->amazon_clothingAttributes() as $key => $value) {
110
- if (substr($key, 0, 2) == "--") {
111
  $str .= "<optgroup label='$value'>";
112
- } elseif (substr($key, 0, 2) == "---") {
113
  $str .= "</optgroup>";
114
  } else {
115
  $sltd = "";
116
  if ($selected == $key)
117
  $sltd = 'selected="selected"';
118
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
119
- }
120
-
121
- }
122
  return $str;
123
  }
124
 
125
- public function amazon_jewelryAttributesDropdown($selected = "")
126
- {
127
  $attributes = new Woo_Feed_Default_Attributes();
128
  $str = "<option></option>";
129
- foreach ($attributes->amazon_jewelryAttributes() as $key => $value) {
130
- if (substr($key, 0, 2) == "--") {
131
  $str .= "<optgroup label='$value'>";
132
- } elseif (substr($key, 0, 2) == "---") {
133
  $str .= "</optgroup>";
134
  } else {
135
  $sltd = "";
136
  if ($selected == $key)
137
  $sltd = 'selected="selected"';
138
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
139
- }
140
-
141
- }
142
  return $str;
143
  }
144
 
145
- public function amazon_jewelry_frAttributesDropdown($selected = "")
146
- {
147
  $attributes = new Woo_Feed_Default_Attributes();
148
  $str = "<option></option>";
149
- foreach ($attributes->amazon_jewelry_frAttributes() as $key => $value) {
150
- if (substr($key, 0, 2) == "--") {
151
  $str .= "<optgroup label='$value'>";
152
- } elseif (substr($key, 0, 2) == "---") {
153
  $str .= "</optgroup>";
154
  } else {
155
  $sltd = "";
156
  if ($selected == $key)
157
  $sltd = 'selected="selected"';
158
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
159
- }
160
-
161
- }
162
  return $str;
163
  }
164
 
165
- public function amazon_lightingAttributesDropdown($selected = "")
166
- {
167
  $attributes = new Woo_Feed_Default_Attributes();
168
  $str = "<option></option>";
169
- foreach ($attributes->amazon_lightingAttributes() as $key => $value) {
170
- if (substr($key, 0, 2) == "--") {
171
  $str .= "<optgroup label='$value'>";
172
- } elseif (substr($key, 0, 2) == "---") {
173
  $str .= "</optgroup>";
174
  } else {
175
  $sltd = "";
176
  if ($selected == $key)
177
  $sltd = 'selected="selected"';
178
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
179
- }
180
-
181
- }
182
  return $str;
183
  }
184
- public function amazon_wirelessAttributesDropdown($selected = "")
185
- {
186
  $attributes = new Woo_Feed_Default_Attributes();
187
  $str = "<option></option>";
188
- foreach ($attributes->amazon_wirelessAttributes() as $key => $value) {
189
- if (substr($key, 0, 2) == "--") {
190
  $str .= "<optgroup label='$value'>";
191
- } elseif (substr($key, 0, 2) == "---") {
192
  $str .= "</optgroup>";
193
  } else {
194
  $sltd = "";
195
  if ($selected == $key)
196
  $sltd = 'selected="selected"';
197
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
198
- }
199
-
200
- }
201
  return $str;
202
  }
203
- public function amazon_autoaccessoryAttributesDropdown($selected = "")
204
- {
205
  $attributes = new Woo_Feed_Default_Attributes();
206
  $str = "<option></option>";
207
- foreach ($attributes->amazon_autoaccessoryAttributes() as $key => $value) {
208
- if (substr($key, 0, 2) == "--") {
209
  $str .= "<optgroup label='$value'>";
210
- } elseif (substr($key, 0, 2) == "---") {
211
  $str .= "</optgroup>";
212
  } else {
213
  $sltd = "";
214
  if ($selected == $key)
215
  $sltd = 'selected="selected"';
216
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
217
- }
218
-
219
- }
220
  return $str;
221
  }
222
- public function amazon_tiresandwheelsAttributesDropdown($selected = "")
223
- {
224
  $attributes = new Woo_Feed_Default_Attributes();
225
  $str = "<option></option>";
226
- foreach ($attributes->amazon_tiresandwheelsAttributes() as $key => $value) {
227
- if (substr($key, 0, 2) == "--") {
228
  $str .= "<optgroup label='$value'>";
229
- } elseif (substr($key, 0, 2) == "---") {
230
  $str .= "</optgroup>";
231
  } else {
232
  $sltd = "";
233
  if ($selected == $key)
234
  $sltd = 'selected="selected"';
235
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
236
- }
237
-
238
- }
239
  return $str;
240
  }
241
- public function amazon_homeAttributesDropdown($selected = "")
242
- {
243
  $attributes = new Woo_Feed_Default_Attributes();
244
  $str = "<option></option>";
245
- foreach ($attributes->amazon_homeAttributes() as $key => $value) {
246
- if (substr($key, 0, 2) == "--") {
247
  $str .= "<optgroup label='$value'>";
248
- } elseif (substr($key, 0, 2) == "---") {
249
  $str .= "</optgroup>";
250
  } else {
251
  $sltd = "";
252
  if ($selected == $key)
253
  $sltd = 'selected="selected"';
254
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
255
- }
256
-
257
- }
258
  return $str;
259
  }
260
- public function amazon_healthAttributesDropdown($selected = "")
261
- {
262
  $attributes = new Woo_Feed_Default_Attributes();
263
  $str = "<option></option>";
264
- foreach ($attributes->amazon_healthAttributes() as $key => $value) {
265
- if (substr($key, 0, 2) == "--") {
266
  $str .= "<optgroup label='$value'>";
267
- } elseif (substr($key, 0, 2) == "---") {
268
  $str .= "</optgroup>";
269
  } else {
270
  $sltd = "";
271
  if ($selected == $key)
272
  $sltd = 'selected="selected"';
273
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
274
- }
275
-
276
- }
277
  return $str;
278
  }
279
- public function amazon_babyAttributesDropdown($selected = "")
280
- {
281
  $attributes = new Woo_Feed_Default_Attributes();
282
  $str = "<option></option>";
283
- foreach ($attributes->amazon_babyAttributes() as $key => $value) {
284
- if (substr($key, 0, 2) == "--") {
285
  $str .= "<optgroup label='$value'>";
286
- } elseif (substr($key, 0, 2) == "---") {
287
  $str .= "</optgroup>";
288
  } else {
289
  $sltd = "";
290
  if ($selected == $key)
291
  $sltd = 'selected="selected"';
292
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
293
- }
294
-
295
- }
296
  return $str;
297
  }
298
- public function amazon_BookLoaderAttributesDropdown($selected = "")
299
- {
300
  $attributes = new Woo_Feed_Default_Attributes();
301
  $str = "<option></option>";
302
- foreach ($attributes->amazon_BookLoaderAttributes() as $key => $value) {
303
- if (substr($key, 0, 2) == "--") {
304
  $str .= "<optgroup label='$value'>";
305
- } elseif (substr($key, 0, 2) == "---") {
306
  $str .= "</optgroup>";
307
  } else {
308
  $sltd = "";
309
  if ($selected == $key)
310
  $sltd = 'selected="selected"';
311
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
312
- }
313
-
314
- }
315
  return $str;
316
  }
317
- public function amazon_CameraAndPhotoAttributesDropdown($selected = "")
318
- {
319
  $attributes = new Woo_Feed_Default_Attributes();
320
  $str = "<option></option>";
321
- foreach ($attributes->amazon_CameraAndPhotoAttributes() as $key => $value) {
322
- if (substr($key, 0, 2) == "--") {
323
  $str .= "<optgroup label='$value'>";
324
- } elseif (substr($key, 0, 2) == "---") {
325
  $str .= "</optgroup>";
326
  } else {
327
  $sltd = "";
328
  if ($selected == $key)
329
  $sltd = 'selected="selected"';
330
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
331
- }
332
-
333
- }
334
  return $str;
335
  }
336
- public function amazon_foodandbeveragesAttributesDropdown($selected = "")
337
- {
338
  $attributes = new Woo_Feed_Default_Attributes();
339
  $str = "<option></option>";
340
- foreach ($attributes->amazon_foodandbeveragesAttributes() as $key => $value) {
341
- if (substr($key, 0, 2) == "--") {
342
  $str .= "<optgroup label='$value'>";
343
- } elseif (substr($key, 0, 2) == "---") {
344
  $str .= "</optgroup>";
345
  } else {
346
  $sltd = "";
347
  if ($selected == $key)
348
  $sltd = 'selected="selected"';
349
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
350
- }
351
-
352
- }
353
  return $str;
354
  }
355
- public function amazon_computersAttributesDropdown($selected = "")
356
- {
357
  $attributes = new Woo_Feed_Default_Attributes();
358
  $str = "<option></option>";
359
- foreach ($attributes->amazon_computersAttributes() as $key => $value) {
360
- if (substr($key, 0, 2) == "--") {
361
  $str .= "<optgroup label='$value'>";
362
- } elseif (substr($key, 0, 2) == "---") {
363
  $str .= "</optgroup>";
364
  } else {
365
  $sltd = "";
366
  if ($selected == $key)
367
  $sltd = 'selected="selected"';
368
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
369
- }
370
-
371
- }
372
  return $str;
373
  }
374
- public function amazon_ConsumerElectronicsAttributesDropdown($selected = "")
375
- {
376
  $attributes = new Woo_Feed_Default_Attributes();
377
  $str = "<option></option>";
378
- foreach ($attributes->amazon_ConsumerElectronicsAttributes() as $key => $value) {
379
- if (substr($key, 0, 2) == "--") {
380
  $str .= "<optgroup label='$value'>";
381
- } elseif (substr($key, 0, 2) == "---") {
382
  $str .= "</optgroup>";
383
  } else {
384
  $sltd = "";
385
  if ($selected == $key)
386
  $sltd = 'selected="selected"';
387
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
388
- }
389
-
390
- }
391
  return $str;
392
  }
393
- public function amazon_entertainmentcollectiblesAttributesDropdown($selected = "")
394
- {
395
  $attributes = new Woo_Feed_Default_Attributes();
396
  $str = "<option></option>";
397
- foreach ($attributes->amazon_entertainmentcollectiblesAttributes() as $key => $value) {
398
- if (substr($key, 0, 2) == "--") {
399
  $str .= "<optgroup label='$value'>";
400
- } elseif (substr($key, 0, 2) == "---") {
401
  $str .= "</optgroup>";
402
  } else {
403
  $sltd = "";
404
  if ($selected == $key)
405
  $sltd = 'selected="selected"';
406
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
407
- }
408
-
409
- }
410
  return $str;
411
  }
412
- public function amazon_homeimprovementAttributesDropdown($selected = "")
413
- {
414
  $attributes = new Woo_Feed_Default_Attributes();
415
  $str = "<option></option>";
416
- foreach ($attributes->amazon_homeimprovementAttributes() as $key => $value) {
417
- if (substr($key, 0, 2) == "--") {
418
  $str .= "<optgroup label='$value'>";
419
- } elseif (substr($key, 0, 2) == "---") {
420
  $str .= "</optgroup>";
421
  } else {
422
  $sltd = "";
423
  if ($selected == $key)
424
  $sltd = 'selected="selected"';
425
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
426
- }
427
-
428
- }
429
  return $str;
430
  }
431
- public function amazon_officeAttributesDropdown($selected = "")
432
- {
433
  $attributes = new Woo_Feed_Default_Attributes();
434
  $str = "<option></option>";
435
- foreach ($attributes->amazon_officeAttributes() as $key => $value) {
436
- if (substr($key, 0, 2) == "--") {
437
  $str .= "<optgroup label='$value'>";
438
- } elseif (substr($key, 0, 2) == "---") {
439
  $str .= "</optgroup>";
440
  } else {
441
  $sltd = "";
442
  if ($selected == $key)
443
  $sltd = 'selected="selected"';
444
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
445
- }
446
-
447
- }
448
  return $str;
449
  }
450
- public function amazon_petsuppliesAttributesDropdown($selected = "")
451
- {
452
  $attributes = new Woo_Feed_Default_Attributes();
453
  $str = "<option></option>";
454
- foreach ($attributes->amazon_petsuppliesAttributes() as $key => $value) {
455
- if (substr($key, 0, 2) == "--") {
456
  $str .= "<optgroup label='$value'>";
457
- } elseif (substr($key, 0, 2) == "---") {
458
  $str .= "</optgroup>";
459
  } else {
460
  $sltd = "";
461
  if ($selected == $key)
462
  $sltd = 'selected="selected"';
463
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
464
- }
465
-
466
- }
467
  return $str;
468
  }
469
 
470
- public function amazon_sportsmemorabiliaAttributesDropdown($selected = "")
471
- {
472
  $attributes = new Woo_Feed_Default_Attributes();
473
  $str = "<option></option>";
474
- foreach ($attributes->amazon_sportsmemorabiliaAttributes() as $key => $value) {
475
- if (substr($key, 0, 2) == "--") {
476
  $str .= "<optgroup label='$value'>";
477
- } elseif (substr($key, 0, 2) == "---") {
478
  $str .= "</optgroup>";
479
  } else {
480
  $sltd = "";
481
  if ($selected == $key)
482
  $sltd = 'selected="selected"';
483
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
484
- }
485
-
486
- }
487
  return $str;
488
  }
489
- public function amazon_shoesAttributesDropdown($selected = "")
490
- {
491
  $attributes = new Woo_Feed_Default_Attributes();
492
  $str = "<option></option>";
493
- foreach ($attributes->amazon_shoesAttributes() as $key => $value) {
494
- if (substr($key, 0, 2) == "--") {
495
  $str .= "<optgroup label='$value'>";
496
- } elseif (substr($key, 0, 2) == "---") {
497
  $str .= "</optgroup>";
498
  } else {
499
  $sltd = "";
500
  if ($selected == $key)
501
  $sltd = 'selected="selected"';
502
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
503
- }
504
-
505
- }
506
  return $str;
507
  }
508
- public function amazon_sportsAttributesDropdown($selected = "")
509
- {
510
  $attributes = new Woo_Feed_Default_Attributes();
511
  $str = "<option></option>";
512
- foreach ($attributes->amazon_sportsAttributes() as $key => $value) {
513
- if (substr($key, 0, 2) == "--") {
514
  $str .= "<optgroup label='$value'>";
515
- } elseif (substr($key, 0, 2) == "---") {
516
  $str .= "</optgroup>";
517
  } else {
518
  $sltd = "";
519
  if ($selected == $key)
520
  $sltd = 'selected="selected"';
521
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
522
- }
523
-
524
- }
525
  return $str;
526
  }
527
- public function amazon_toysAttributesDropdown($selected = "")
528
- {
529
  $attributes = new Woo_Feed_Default_Attributes();
530
  $str = "<option></option>";
531
- foreach ($attributes->amazon_toysAttributes() as $key => $value) {
532
- if (substr($key, 0, 2) == "--") {
533
  $str .= "<optgroup label='$value'>";
534
- } elseif (substr($key, 0, 2) == "---") {
535
  $str .= "</optgroup>";
536
  } else {
537
  $sltd = "";
538
  if ($selected == $key)
539
  $sltd = 'selected="selected"';
540
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
541
- }
542
-
543
- }
544
  return $str;
545
  }
546
- public function amazon_TradingCardsAttributesDropdown($selected = "")
547
- {
548
  $attributes = new Woo_Feed_Default_Attributes();
549
  $str = "<option></option>";
550
- foreach ($attributes->amazon_TradingCardsAttributes() as $key => $value) {
551
- if (substr($key, 0, 2) == "--") {
552
  $str .= "<optgroup label='$value'>";
553
- } elseif (substr($key, 0, 2) == "---") {
554
  $str .= "</optgroup>";
555
  } else {
556
  $sltd = "";
557
  if ($selected == $key)
558
  $sltd = 'selected="selected"';
559
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
560
- }
561
-
562
- }
563
  return $str;
564
  }
565
- public function amazon_watchesAttributesDropdown($selected = "")
566
- {
567
  $attributes = new Woo_Feed_Default_Attributes();
568
  $str = "<option></option>";
569
- foreach ($attributes->amazon_watchesAttributes() as $key => $value) {
570
- if (substr($key, 0, 2) == "--") {
571
  $str .= "<optgroup label='$value'>";
572
- } elseif (substr($key, 0, 2) == "---") {
573
  $str .= "</optgroup>";
574
  } else {
575
  $sltd = "";
576
  if ($selected == $key)
577
  $sltd = 'selected="selected"';
578
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
579
- }
580
-
581
- }
582
  return $str;
583
  }
584
 
@@ -588,23 +539,21 @@ class Woo_Feed_Dropdown
588
  * @param string $selected
589
  * @return string
590
  */
591
- public function pricespyAttributesDropdown($selected = "")
592
- {
593
  $attributes = new Woo_Feed_Default_Attributes();
594
  $str = "<option></option>";
595
- foreach ($attributes->pricespyAttribute() as $key => $value) {
596
- if (substr($key, 0, 2) == "--") {
597
  $str .= "<optgroup label='$value'>";
598
- } elseif (substr($key, 0, 2) == "---") {
599
  $str .= "</optgroup>";
600
  } else {
601
  $sltd = "";
602
  if ($selected == $key)
603
  $sltd = 'selected="selected"';
604
  $str .= "<option $sltd value='$key'>" . $value . "</option>";
605
- }
606
-
607
- }
608
  return $str;
609
  }
610
 
@@ -614,23 +563,21 @@ class Woo_Feed_Dropdown
614
  * @param string $selected
615
  * @return string
616
  */
617
- public function prisjaktAttributesDropdown($selected = "")
618
- {
619
  $attributes = new Woo_Feed_Default_Attributes();
620
  $str = "<option></option>";
621
- foreach ($attributes->prisjaktAttribute() as $key => $value) {
622
- if (substr($key, 0, 2) == "--") {
623
  $str .= "<optgroup label='$value'>";
624
- } elseif (substr($key, 0, 2) == "---") {
625
  $str .= "</optgroup>";
626
  } else {
627
  $sltd = "";
628
  if ($selected == $key)
629
  $sltd = 'selected="selected"';
630
  $str .= "<option $sltd value='$key'>" . $value . "</option>";
631
- }
632
-
633
- }
634
  return $str;
635
  }
636
 
@@ -640,23 +587,21 @@ class Woo_Feed_Dropdown
640
  * @param string $selected
641
  * @return string
642
  */
643
- public function googleAttributesDropdown($selected = "")
644
- {
645
  $attributes = new Woo_Feed_Default_Attributes();
646
  $str = "<option></option>";
647
- foreach ($attributes->googleAttributes() as $key => $value) {
648
- if (substr($key, 0, 2) == "--") {
649
  $str .= "<optgroup label='$value'>";
650
- } elseif (substr($key, 0, 2) == "---") {
651
  $str .= "</optgroup>";
652
  } else {
653
  $sltd = "";
654
  if ($selected == $key)
655
  $sltd = 'selected="selected"';
656
  $str .= "<option $sltd value='$key'>" . $value . "</option>";
657
- }
658
-
659
- }
660
  return $str;
661
  }
662
 
@@ -666,23 +611,21 @@ class Woo_Feed_Dropdown
666
  * @param string $selected
667
  * @return string
668
  */
669
- public function pinterestAttributesDropdown($selected = "")
670
- {
671
  $attributes = new Woo_Feed_Default_Attributes();
672
  $str = "<option></option>";
673
- foreach ($attributes->googleAttributes() as $key => $value) {
674
- if (substr($key, 0, 2) == "--") {
675
  $str .= "<optgroup label='$value'>";
676
- } elseif (substr($key, 0, 2) == "---") {
677
  $str .= "</optgroup>";
678
  } else {
679
  $sltd = "";
680
  if ($selected == $key)
681
  $sltd = 'selected="selected"';
682
  $str .= "<option $sltd value='$key'>" . $value . "</option>";
683
- }
684
-
685
- }
686
  return $str;
687
  }
688
 
@@ -692,23 +635,21 @@ class Woo_Feed_Dropdown
692
  * @param string $selected
693
  * @return string
694
  */
695
- public function facebookAttributesDropdown($selected = "")
696
- {
697
  $attributes = new Woo_Feed_Default_Attributes();
698
  $str = "<option></option>";
699
- foreach ($attributes->googleAttributes() as $key => $value) {
700
- if (substr($key, 0, 2) == "--") {
701
  $str .= "<optgroup label='$value'>";
702
- } elseif (substr($key, 0, 2) == "---") {
703
  $str .= "</optgroup>";
704
  } else {
705
  $sltd = "";
706
  if ($selected == $key)
707
  $sltd = 'selected="selected"';
708
  $str .= "<option $sltd value='$key'>" . $value . "</option>";
709
- }
710
-
711
- }
712
  return $str;
713
  }
714
 
@@ -718,23 +659,21 @@ class Woo_Feed_Dropdown
718
  * @param string $selected
719
  * @return string
720
  */
721
- public function shopbotAttributesDropdown($selected = "")
722
- {
723
  $attributes = new Woo_Feed_Default_Attributes();
724
  $str = "<option></option>";
725
- foreach ($attributes->shopbotAttribute() as $key => $value) {
726
- if (substr($key, 0, 2) == "--") {
727
  $str .= "<optgroup label='$value'>";
728
- } elseif (substr($key, 0, 2) == "---") {
729
  $str .= "</optgroup>";
730
  } else {
731
  $sltd = "";
732
  if ($selected == $key)
733
  $sltd = 'selected="selected"';
734
  $str .= "<option $sltd value='$key'>" . $value . "</option>";
735
- }
736
-
737
- }
738
  return $str;
739
  }
740
 
@@ -744,23 +683,21 @@ class Woo_Feed_Dropdown
744
  * @param string $selected
745
  * @return string
746
  */
747
- public function amazonAttributesDropdown($selected = "")
748
- {
749
  $attributes = new Woo_Feed_Default_Attributes();
750
  $str = "<option></option>";
751
- foreach ($attributes->amazonAttributes() as $key => $value) {
752
- if (substr($key, 0, 2) == "--") {
753
  $str .= "<optgroup label='$value'>";
754
- } elseif (substr($key, 0, 2) == "---") {
755
  $str .= "</optgroup>";
756
  } else {
757
  $sltd = "";
758
  if ($selected == $key)
759
  $sltd = 'selected="selected"';
760
  $str .= "<option $sltd value='$key'>" . $value . "</option>";
761
- }
762
-
763
- }
764
  return $str;
765
  }
766
  /**
@@ -769,23 +706,21 @@ class Woo_Feed_Dropdown
769
  * @param string $selected
770
  * @return string
771
  */
772
- public function priceGrabberAttributesDropdown($selected = "")
773
- {
774
  $attributes = new Woo_Feed_Default_Attributes();
775
  $str = "<option></option>";
776
- foreach ($attributes->priceGrabberAttribute() as $key => $value) {
777
- if (substr($key, 0, 2) == "--") {
778
  $str .= "<optgroup label='$value'>";
779
- } elseif (substr($key, 0, 2) == "---") {
780
  $str .= "</optgroup>";
781
  } else {
782
  $sltd = "";
783
  if ($selected == $key)
784
  $sltd = 'selected="selected"';
785
  $str .= "<option $sltd value='$key'>" . $value . "</option>";
786
- }
787
-
788
- }
789
  return $str;
790
  }
791
 
@@ -795,23 +730,21 @@ class Woo_Feed_Dropdown
795
  * @param string $selected
796
  * @return string
797
  */
798
- public function nextagAttributesDropdown($selected = "")
799
- {
800
  $attributes = new Woo_Feed_Default_Attributes();
801
  $str = "<option></option>";
802
- foreach ($attributes->nextagAttribute() as $key => $value) {
803
- if (substr($key, 0, 2) == "--") {
804
  $str .= "<optgroup label='$value'>";
805
- } elseif (substr($key, 0, 2) == "---") {
806
  $str .= "</optgroup>";
807
  } else {
808
  $sltd = "";
809
  if ($selected == $key)
810
  $sltd = 'selected="selected"';
811
  $str .= "<option $sltd value='$key'>" . $value . "</option>";
812
- }
813
-
814
- }
815
  return $str;
816
  }
817
 
@@ -821,23 +754,21 @@ class Woo_Feed_Dropdown
821
  * @param string $selected
822
  * @return string
823
  */
824
- public function kelkooAttributesDropdown($selected = "")
825
- {
826
  $attributes = new Woo_Feed_Default_Attributes();
827
  $str = "<option></option>";
828
- foreach ($attributes->kelkooAttribute() as $key => $value) {
829
- if (substr($key, 0, 2) == "--") {
830
  $str .= "<optgroup label='$value'>";
831
- } elseif (substr($key, 0, 2) == "---") {
832
  $str .= "</optgroup>";
833
  } else {
834
  $sltd = "";
835
  if ($selected == $key)
836
  $sltd = 'selected="selected"';
837
  $str .= "<option $sltd value='$key'>" . $value . "</option>";
838
- }
839
-
840
- }
841
  return $str;
842
  }
843
 
@@ -847,23 +778,21 @@ class Woo_Feed_Dropdown
847
  * @param string $selected
848
  * @return string
849
  */
850
- public function shopzillaAttributesDropdown($selected = "")
851
- {
852
  $attributes = new Woo_Feed_Default_Attributes();
853
  $str = "<option></option>";
854
- foreach ($attributes->shopzillaAttribute() as $key => $value) {
855
- if (substr($key, 0, 2) == "--") {
856
  $str .= "<optgroup label='$value'>";
857
- } elseif (substr($key, 0, 2) == "---") {
858
  $str .= "</optgroup>";
859
  } else {
860
  $sltd = "";
861
  if ($selected == $key)
862
  $sltd = 'selected="selected"';
863
  $str .= "<option $sltd value='$key'>" . $value . "</option>";
864
- }
865
-
866
- }
867
  return $str;
868
  }
869
 
@@ -873,23 +802,21 @@ class Woo_Feed_Dropdown
873
  * @param string $selected
874
  * @return string
875
  */
876
- public function shoppingAttributesDropdown($selected = "")
877
- {
878
  $attributes = new Woo_Feed_Default_Attributes();
879
  $str = "<option></option>";
880
- foreach ($attributes->shoppingAttribute() as $key => $value) {
881
- if (substr($key, 0, 2) == "--") {
882
  $str .= "<optgroup label='$value'>";
883
- } elseif (substr($key, 0, 2) == "---") {
884
  $str .= "</optgroup>";
885
  } else {
886
  $sltd = "";
887
  if ($selected == $key)
888
  $sltd = 'selected="selected"';
889
  $str .= "<option $sltd value='$key'>" . $value . "</option>";
890
- }
891
-
892
- }
893
  return $str;
894
  }
895
 
@@ -899,23 +826,21 @@ class Woo_Feed_Dropdown
899
  * @param string $selected
900
  * @return string
901
  */
902
- public function shopmaniaAttributesDropdown($selected = "")
903
- {
904
  $attributes = new Woo_Feed_Default_Attributes();
905
  $str = "<option></option>";
906
- foreach ($attributes->shopmaniaAttribute() as $key => $value) {
907
- if (substr($key, 0, 2) == "--") {
908
  $str .= "<optgroup label='$value'>";
909
- } elseif (substr($key, 0, 2) == "---") {
910
  $str .= "</optgroup>";
911
  } else {
912
  $sltd = "";
913
  if ($selected == $key)
914
  $sltd = 'selected="selected"';
915
  $str .= "<option $sltd value='$key'>" . $value . "</option>";
916
- }
917
-
918
- }
919
  return $str;
920
  }
921
 
@@ -926,23 +851,21 @@ class Woo_Feed_Dropdown
926
  * @param string $selected
927
  * @return string
928
  */
929
- public function bingAttributesDropdown($selected = "")
930
- {
931
  $attributes = new Woo_Feed_Default_Attributes();
932
  $str = "<option></option>";
933
- foreach ($attributes->bingAttribute() as $key => $value) {
934
- if (substr($key, 0, 2) == "--") {
935
  $str .= "<optgroup label='$value'>";
936
- } elseif (substr($key, 0, 2) == "---") {
937
  $str .= "</optgroup>";
938
  } else {
939
  $sltd = "";
940
  if ($selected == $key)
941
  $sltd = 'selected="selected"';
942
  $str .= "<option $sltd value='$key'>" . $value . "</option>";
943
- }
944
-
945
- }
946
  return $str;
947
  }
948
 
@@ -952,23 +875,21 @@ class Woo_Feed_Dropdown
952
  * @param string $selected
953
  * @return string
954
  */
955
- public function becomeAttributesDropdown($selected = "")
956
- {
957
  $attributes = new Woo_Feed_Default_Attributes();
958
  $str = "<option></option>";
959
- foreach ($attributes->becomeAttribute() as $key => $value) {
960
- if (substr($key, 0, 2) == "--") {
961
  $str .= "<optgroup label='$value'>";
962
- } elseif (substr($key, 0, 2) == "---") {
963
  $str .= "</optgroup>";
964
  } else {
965
  $sltd = "";
966
  if ($selected == $key)
967
  $sltd = 'selected="selected"';
968
  $str .= "<option $sltd value='$key'>" . $value . "</option>";
969
- }
970
-
971
- }
972
  return $str;
973
  }
974
 
@@ -978,23 +899,21 @@ class Woo_Feed_Dropdown
978
  * @param string $selected
979
  * @return string
980
  */
981
- public function connexityAttributesDropdown($selected = "")
982
- {
983
  $attributes = new Woo_Feed_Default_Attributes();
984
  $str = "<option></option>";
985
- foreach ($attributes->becomeAttribute() as $key => $value) {
986
- if (substr($key, 0, 2) == "--") {
987
  $str .= "<optgroup label='$value'>";
988
- } elseif (substr($key, 0, 2) == "---") {
989
  $str .= "</optgroup>";
990
  } else {
991
  $sltd = "";
992
  if ($selected == $key)
993
  $sltd = 'selected="selected"';
994
  $str .= "<option $sltd value='$key'>" . $value . "</option>";
995
- }
996
-
997
- }
998
  return $str;
999
  }
1000
  }
22
  * @param string $selected
23
  * @return string
24
  */
25
+ public function merchantsDropdown( $selected = "" ) {
 
26
  $selected = esc_attr( $selected );
27
  $attributes = new Woo_Feed_Default_Attributes();
28
  $str = "<option></option>";
29
+ foreach ( $attributes->merchants() as $key => $value ) {
30
+ if ( substr($key, 0, 2) == "--" ) {
31
  $str .= "<optgroup label='$value'>";
32
+ } elseif ( substr($key, 0, 2) == "---" ) {
33
  $str .= "</optgroup>";
34
  } else {
35
  $sltd = "";
36
  if ($selected == $key)
37
  $sltd = 'selected="selected"';
38
  $str .= "<option $sltd value='$key'>" . $value . "</option>";
39
+ }
40
+ }
 
41
  return $str;
42
  }
43
 
51
  $fileName = WOO_FEED_FREE_ADMIN_PATH . "/partials/templates/google_taxonomy.txt";
52
  $customTaxonomyFile = fopen($fileName, "r");
53
  $str = "";
54
+ if ( ! empty( $selected ) ) {
55
  $selected = trim( $selected );
56
+ if ( ! is_numeric( $selected ) ) $selected = html_entity_decode( $selected );
57
  else $selected = (int) $selected;
58
  }
59
+ if ( $customTaxonomyFile ) {
60
  // First line contains metadata, ignore it
61
  @fgets( $customTaxonomyFile );
62
  while ( $line = fgets( $customTaxonomyFile ) ) {
72
  );
73
  }
74
  }
75
+ if ( ! empty( $str ) ) {
76
  $str = "<option></option>" . $str;
77
  }
78
  return $str;
93
  @fgets( $customTaxonomyFile );
94
  while ( $line = fgets( $customTaxonomyFile ) ) {
95
  list( $catId, $cat ) = explode( "-", $line );
96
+ $taxonomy[] = [
97
+ 'value' => absint( trim( $catId ) ),
98
+ 'text' => trim( $cat ),
99
+ ];
100
  }
101
  }
102
  $taxonomy = array_filter( $taxonomy );
103
  return $taxonomy;
104
  }
105
 
106
+ public function amazon_clothingAttributesDropdown( $selected = "" ) {
 
107
  $attributes = new Woo_Feed_Default_Attributes();
108
  $str = "<option></option>";
109
+ foreach ( $attributes->amazon_clothingAttributes() as $key => $value ) {
110
+ if ( substr($key, 0, 2) == "--" ) {
111
  $str .= "<optgroup label='$value'>";
112
+ } elseif ( substr($key, 0, 2) == "---" ) {
113
  $str .= "</optgroup>";
114
  } else {
115
  $sltd = "";
116
  if ($selected == $key)
117
  $sltd = 'selected="selected"';
118
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
119
+ }
120
+ }
 
121
  return $str;
122
  }
123
 
124
+ public function amazon_jewelryAttributesDropdown( $selected = "" ) {
 
125
  $attributes = new Woo_Feed_Default_Attributes();
126
  $str = "<option></option>";
127
+ foreach ( $attributes->amazon_jewelryAttributes() as $key => $value ) {
128
+ if ( substr($key, 0, 2) == "--" ) {
129
  $str .= "<optgroup label='$value'>";
130
+ } elseif ( substr($key, 0, 2) == "---" ) {
131
  $str .= "</optgroup>";
132
  } else {
133
  $sltd = "";
134
  if ($selected == $key)
135
  $sltd = 'selected="selected"';
136
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
137
+ }
138
+ }
 
139
  return $str;
140
  }
141
 
142
+ public function amazon_jewelry_frAttributesDropdown( $selected = "" ) {
 
143
  $attributes = new Woo_Feed_Default_Attributes();
144
  $str = "<option></option>";
145
+ foreach ( $attributes->amazon_jewelry_frAttributes() as $key => $value ) {
146
+ if ( substr($key, 0, 2) == "--" ) {
147
  $str .= "<optgroup label='$value'>";
148
+ } elseif ( substr($key, 0, 2) == "---" ) {
149
  $str .= "</optgroup>";
150
  } else {
151
  $sltd = "";
152
  if ($selected == $key)
153
  $sltd = 'selected="selected"';
154
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
155
+ }
156
+ }
 
157
  return $str;
158
  }
159
 
160
+ public function amazon_lightingAttributesDropdown( $selected = "" ) {
 
161
  $attributes = new Woo_Feed_Default_Attributes();
162
  $str = "<option></option>";
163
+ foreach ( $attributes->amazon_lightingAttributes() as $key => $value ) {
164
+ if ( substr($key, 0, 2) == "--" ) {
165
  $str .= "<optgroup label='$value'>";
166
+ } elseif ( substr($key, 0, 2) == "---" ) {
167
  $str .= "</optgroup>";
168
  } else {
169
  $sltd = "";
170
  if ($selected == $key)
171
  $sltd = 'selected="selected"';
172
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
173
+ }
174
+ }
 
175
  return $str;
176
  }
177
+ public function amazon_wirelessAttributesDropdown( $selected = "" ) {
 
178
  $attributes = new Woo_Feed_Default_Attributes();
179
  $str = "<option></option>";
180
+ foreach ( $attributes->amazon_wirelessAttributes() as $key => $value ) {
181
+ if ( substr($key, 0, 2) == "--" ) {
182
  $str .= "<optgroup label='$value'>";
183
+ } elseif ( substr($key, 0, 2) == "---" ) {
184
  $str .= "</optgroup>";
185
  } else {
186
  $sltd = "";
187
  if ($selected == $key)
188
  $sltd = 'selected="selected"';
189
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
190
+ }
191
+ }
 
192
  return $str;
193
  }
194
+ public function amazon_autoaccessoryAttributesDropdown( $selected = "" ) {
 
195
  $attributes = new Woo_Feed_Default_Attributes();
196
  $str = "<option></option>";
197
+ foreach ( $attributes->amazon_autoaccessoryAttributes() as $key => $value ) {
198
+ if ( substr($key, 0, 2) == "--" ) {
199
  $str .= "<optgroup label='$value'>";
200
+ } elseif ( substr($key, 0, 2) == "---" ) {
201
  $str .= "</optgroup>";
202
  } else {
203
  $sltd = "";
204
  if ($selected == $key)
205
  $sltd = 'selected="selected"';
206
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
207
+ }
208
+ }
 
209
  return $str;
210
  }
211
+ public function amazon_tiresandwheelsAttributesDropdown( $selected = "" ) {
 
212
  $attributes = new Woo_Feed_Default_Attributes();
213
  $str = "<option></option>";
214
+ foreach ( $attributes->amazon_tiresandwheelsAttributes() as $key => $value ) {
215
+ if ( substr($key, 0, 2) == "--" ) {
216
  $str .= "<optgroup label='$value'>";
217
+ } elseif ( substr($key, 0, 2) == "---" ) {
218
  $str .= "</optgroup>";
219
  } else {
220
  $sltd = "";
221
  if ($selected == $key)
222
  $sltd = 'selected="selected"';
223
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
224
+ }
225
+ }
 
226
  return $str;
227
  }
228
+ public function amazon_homeAttributesDropdown( $selected = "" ) {
 
229
  $attributes = new Woo_Feed_Default_Attributes();
230
  $str = "<option></option>";
231
+ foreach ( $attributes->amazon_homeAttributes() as $key => $value ) {
232
+ if ( substr($key, 0, 2) == "--" ) {
233
  $str .= "<optgroup label='$value'>";
234
+ } elseif ( substr($key, 0, 2) == "---" ) {
235
  $str .= "</optgroup>";
236
  } else {
237
  $sltd = "";
238
  if ($selected == $key)
239
  $sltd = 'selected="selected"';
240
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
241
+ }
242
+ }
 
243
  return $str;
244
  }
245
+ public function amazon_healthAttributesDropdown( $selected = "" ) {
 
246
  $attributes = new Woo_Feed_Default_Attributes();
247
  $str = "<option></option>";
248
+ foreach ( $attributes->amazon_healthAttributes() as $key => $value ) {
249
+ if ( substr($key, 0, 2) == "--" ) {
250
  $str .= "<optgroup label='$value'>";
251
+ } elseif ( substr($key, 0, 2) == "---" ) {
252
  $str .= "</optgroup>";
253
  } else {
254
  $sltd = "";
255
  if ($selected == $key)
256
  $sltd = 'selected="selected"';
257
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
258
+ }
259
+ }
 
260
  return $str;
261
  }
262
+ public function amazon_babyAttributesDropdown( $selected = "" ) {
 
263
  $attributes = new Woo_Feed_Default_Attributes();
264
  $str = "<option></option>";
265
+ foreach ( $attributes->amazon_babyAttributes() as $key => $value ) {
266
+ if ( substr($key, 0, 2) == "--" ) {
267
  $str .= "<optgroup label='$value'>";
268
+ } elseif ( substr($key, 0, 2) == "---" ) {
269
  $str .= "</optgroup>";
270
  } else {
271
  $sltd = "";
272
  if ($selected == $key)
273
  $sltd = 'selected="selected"';
274
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
275
+ }
276
+ }
 
277
  return $str;
278
  }
279
+ public function amazon_BookLoaderAttributesDropdown( $selected = "" ) {
 
280
  $attributes = new Woo_Feed_Default_Attributes();
281
  $str = "<option></option>";
282
+ foreach ( $attributes->amazon_BookLoaderAttributes() as $key => $value ) {
283
+ if ( substr($key, 0, 2) == "--" ) {
284
  $str .= "<optgroup label='$value'>";
285
+ } elseif ( substr($key, 0, 2) == "---" ) {
286
  $str .= "</optgroup>";
287
  } else {
288
  $sltd = "";
289
  if ($selected == $key)
290
  $sltd = 'selected="selected"';
291
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
292
+ }
293
+ }
 
294
  return $str;
295
  }
296
+ public function amazon_CameraAndPhotoAttributesDropdown( $selected = "" ) {
 
297
  $attributes = new Woo_Feed_Default_Attributes();
298
  $str = "<option></option>";
299
+ foreach ( $attributes->amazon_CameraAndPhotoAttributes() as $key => $value ) {
300
+ if ( substr($key, 0, 2) == "--" ) {
301
  $str .= "<optgroup label='$value'>";
302
+ } elseif ( substr($key, 0, 2) == "---" ) {
303
  $str .= "</optgroup>";
304
  } else {
305
  $sltd = "";
306
  if ($selected == $key)
307
  $sltd = 'selected="selected"';
308
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
309
+ }
310
+ }
 
311
  return $str;
312
  }
313
+ public function amazon_foodandbeveragesAttributesDropdown( $selected = "" ) {
 
314
  $attributes = new Woo_Feed_Default_Attributes();
315
  $str = "<option></option>";
316
+ foreach ( $attributes->amazon_foodandbeveragesAttributes() as $key => $value ) {
317
+ if ( substr($key, 0, 2) == "--" ) {
318
  $str .= "<optgroup label='$value'>";
319
+ } elseif ( substr($key, 0, 2) == "---" ) {
320
  $str .= "</optgroup>";
321
  } else {
322
  $sltd = "";
323
  if ($selected == $key)
324
  $sltd = 'selected="selected"';
325
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
326
+ }
327
+ }
 
328
  return $str;
329
  }
330
+ public function amazon_computersAttributesDropdown( $selected = "" ) {
 
331
  $attributes = new Woo_Feed_Default_Attributes();
332
  $str = "<option></option>";
333
+ foreach ( $attributes->amazon_computersAttributes() as $key => $value ) {
334
+ if ( substr($key, 0, 2) == "--" ) {
335
  $str .= "<optgroup label='$value'>";
336
+ } elseif ( substr($key, 0, 2) == "---" ) {
337
  $str .= "</optgroup>";
338
  } else {
339
  $sltd = "";
340
  if ($selected == $key)
341
  $sltd = 'selected="selected"';
342
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
343
+ }
344
+ }
 
345
  return $str;
346
  }
347
+ public function amazon_ConsumerElectronicsAttributesDropdown( $selected = "" ) {
 
348
  $attributes = new Woo_Feed_Default_Attributes();
349
  $str = "<option></option>";
350
+ foreach ( $attributes->amazon_ConsumerElectronicsAttributes() as $key => $value ) {
351
+ if ( substr($key, 0, 2) == "--" ) {
352
  $str .= "<optgroup label='$value'>";
353
+ } elseif ( substr($key, 0, 2) == "---" ) {
354
  $str .= "</optgroup>";
355
  } else {
356
  $sltd = "";
357
  if ($selected == $key)
358
  $sltd = 'selected="selected"';
359
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
360
+ }
361
+ }
 
362
  return $str;
363
  }
364
+ public function amazon_entertainmentcollectiblesAttributesDropdown( $selected = "" ) {
 
365
  $attributes = new Woo_Feed_Default_Attributes();
366
  $str = "<option></option>";
367
+ foreach ( $attributes->amazon_entertainmentcollectiblesAttributes() as $key => $value ) {
368
+ if ( substr($key, 0, 2) == "--" ) {
369
  $str .= "<optgroup label='$value'>";
370
+ } elseif ( substr($key, 0, 2) == "---" ) {
371
  $str .= "</optgroup>";
372
  } else {
373
  $sltd = "";
374
  if ($selected == $key)
375
  $sltd = 'selected="selected"';
376
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
377
+ }
378
+ }
 
379
  return $str;
380
  }
381
+ public function amazon_homeimprovementAttributesDropdown( $selected = "" ) {
 
382
  $attributes = new Woo_Feed_Default_Attributes();
383
  $str = "<option></option>";
384
+ foreach ( $attributes->amazon_homeimprovementAttributes() as $key => $value ) {
385
+ if ( substr($key, 0, 2) == "--" ) {
386
  $str .= "<optgroup label='$value'>";
387
+ } elseif ( substr($key, 0, 2) == "---" ) {
388
  $str .= "</optgroup>";
389
  } else {
390
  $sltd = "";
391
  if ($selected == $key)
392
  $sltd = 'selected="selected"';
393
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
394
+ }
395
+ }
 
396
  return $str;
397
  }
398
+ public function amazon_officeAttributesDropdown( $selected = "" ) {
 
399
  $attributes = new Woo_Feed_Default_Attributes();
400
  $str = "<option></option>";
401
+ foreach ( $attributes->amazon_officeAttributes() as $key => $value ) {
402
+ if ( substr($key, 0, 2) == "--" ) {
403
  $str .= "<optgroup label='$value'>";
404
+ } elseif ( substr($key, 0, 2) == "---" ) {
405
  $str .= "</optgroup>";
406
  } else {
407
  $sltd = "";
408
  if ($selected == $key)
409
  $sltd = 'selected="selected"';
410
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
411
+ }
412
+ }
 
413
  return $str;
414
  }
415
+ public function amazon_petsuppliesAttributesDropdown( $selected = "" ) {
 
416
  $attributes = new Woo_Feed_Default_Attributes();
417
  $str = "<option></option>";
418
+ foreach ( $attributes->amazon_petsuppliesAttributes() as $key => $value ) {
419
+ if ( substr($key, 0, 2) == "--" ) {
420
  $str .= "<optgroup label='$value'>";
421
+ } elseif ( substr($key, 0, 2) == "---" ) {
422
  $str .= "</optgroup>";
423
  } else {
424
  $sltd = "";
425
  if ($selected == $key)
426
  $sltd = 'selected="selected"';
427
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
428
+ }
429
+ }
 
430
  return $str;
431
  }
432
 
433
+ public function amazon_sportsmemorabiliaAttributesDropdown( $selected = "" ) {
 
434
  $attributes = new Woo_Feed_Default_Attributes();
435
  $str = "<option></option>";
436
+ foreach ( $attributes->amazon_sportsmemorabiliaAttributes() as $key => $value ) {
437
+ if ( substr($key, 0, 2) == "--" ) {
438
  $str .= "<optgroup label='$value'>";
439
+ } elseif ( substr($key, 0, 2) == "---" ) {
440
  $str .= "</optgroup>";
441
  } else {
442
  $sltd = "";
443
  if ($selected == $key)
444
  $sltd = 'selected="selected"';
445
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
446
+ }
447
+ }
 
448
  return $str;
449
  }
450
+ public function amazon_shoesAttributesDropdown( $selected = "" ) {
 
451
  $attributes = new Woo_Feed_Default_Attributes();
452
  $str = "<option></option>";
453
+ foreach ( $attributes->amazon_shoesAttributes() as $key => $value ) {
454
+ if ( substr($key, 0, 2) == "--" ) {
455
  $str .= "<optgroup label='$value'>";
456
+ } elseif ( substr($key, 0, 2) == "---" ) {
457
  $str .= "</optgroup>";
458
  } else {
459
  $sltd = "";
460
  if ($selected == $key)
461
  $sltd = 'selected="selected"';
462
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
463
+ }
464
+ }
 
465
  return $str;
466
  }
467
+ public function amazon_sportsAttributesDropdown( $selected = "" ) {
 
468
  $attributes = new Woo_Feed_Default_Attributes();
469
  $str = "<option></option>";
470
+ foreach ( $attributes->amazon_sportsAttributes() as $key => $value ) {
471
+ if ( substr($key, 0, 2) == "--" ) {
472
  $str .= "<optgroup label='$value'>";
473
+ } elseif ( substr($key, 0, 2) == "---" ) {
474
  $str .= "</optgroup>";
475
  } else {
476
  $sltd = "";
477
  if ($selected == $key)
478
  $sltd = 'selected="selected"';
479
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
480
+ }
481
+ }
 
482
  return $str;
483
  }
484
+ public function amazon_toysAttributesDropdown( $selected = "" ) {
 
485
  $attributes = new Woo_Feed_Default_Attributes();
486
  $str = "<option></option>";
487
+ foreach ( $attributes->amazon_toysAttributes() as $key => $value ) {
488
+ if ( substr($key, 0, 2) == "--" ) {
489
  $str .= "<optgroup label='$value'>";
490
+ } elseif ( substr($key, 0, 2) == "---" ) {
491
  $str .= "</optgroup>";
492
  } else {
493
  $sltd = "";
494
  if ($selected == $key)
495
  $sltd = 'selected="selected"';
496
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
497
+ }
498
+ }
 
499
  return $str;
500
  }
501
+ public function amazon_TradingCardsAttributesDropdown( $selected = "" ) {
 
502
  $attributes = new Woo_Feed_Default_Attributes();
503
  $str = "<option></option>";
504
+ foreach ( $attributes->amazon_TradingCardsAttributes() as $key => $value ) {
505
+ if ( substr($key, 0, 2) == "--" ) {
506
  $str .= "<optgroup label='$value'>";
507
+ } elseif ( substr($key, 0, 2) == "---" ) {
508
  $str .= "</optgroup>";
509
  } else {
510
  $sltd = "";
511
  if ($selected == $key)
512
  $sltd = 'selected="selected"';
513
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
514
+ }
515
+ }
 
516
  return $str;
517
  }
518
+ public function amazon_watchesAttributesDropdown( $selected = "" ) {
 
519
  $attributes = new Woo_Feed_Default_Attributes();
520
  $str = "<option></option>";
521
+ foreach ( $attributes->amazon_watchesAttributes() as $key => $value ) {
522
+ if ( substr($key, 0, 2) == "--" ) {
523
  $str .= "<optgroup label='$value'>";
524
+ } elseif ( substr($key, 0, 2) == "---" ) {
525
  $str .= "</optgroup>";
526
  } else {
527
  $sltd = "";
528
  if ($selected == $key)
529
  $sltd = 'selected="selected"';
530
  $str .= "<option $sltd value='$key'>" . $value ." [".$key."]". "</option>";
531
+ }
532
+ }
 
533
  return $str;
534
  }
535
 
539
  * @param string $selected
540
  * @return string
541
  */
542
+ public function pricespyAttributesDropdown( $selected = "" ) {
 
543
  $attributes = new Woo_Feed_Default_Attributes();
544
  $str = "<option></option>";
545
+ foreach ( $attributes->pricespyAttribute() as $key => $value ) {
546
+ if ( substr($key, 0, 2) == "--" ) {
547
  $str .= "<optgroup label='$value'>";
548
+ } elseif ( substr($key, 0, 2) == "---" ) {
549
  $str .= "</optgroup>";
550
  } else {
551
  $sltd = "";
552
  if ($selected == $key)
553
  $sltd = 'selected="selected"';
554
  $str .= "<option $sltd value='$key'>" . $value . "</option>";
555
+ }
556
+ }
 
557
  return $str;
558
  }
559
 
563
  * @param string $selected
564
  * @return string
565
  */
566
+ public function prisjaktAttributesDropdown( $selected = "" ) {
 
567
  $attributes = new Woo_Feed_Default_Attributes();
568
  $str = "<option></option>";
569
+ foreach ( $attributes->prisjaktAttribute() as $key => $value ) {
570
+ if ( substr($key, 0, 2) == "--" ) {
571
  $str .= "<optgroup label='$value'>";
572
+ } elseif ( substr($key, 0, 2) == "---" ) {
573
  $str .= "</optgroup>";
574
  } else {
575
  $sltd = "";
576
  if ($selected == $key)
577
  $sltd = 'selected="selected"';
578
  $str .= "<option $sltd value='$key'>" . $value . "</option>";
579
+ }
580
+ }
 
581
  return $str;
582
  }
583
 
587
  * @param string $selected
588
  * @return string
589
  */
590
+ public function googleAttributesDropdown( $selected = "" ) {
 
591
  $attributes = new Woo_Feed_Default_Attributes();
592
  $str = "<option></option>";
593
+ foreach ( $attributes->googleAttributes() as $key => $value ) {
594
+ if ( substr($key, 0, 2) == "--" ) {
595
  $str .= "<optgroup label='$value'>";
596
+ } elseif ( substr($key, 0, 2) == "---" ) {
597
  $str .= "</optgroup>";
598
  } else {
599
  $sltd = "";
600
  if ($selected == $key)
601
  $sltd = 'selected="selected"';
602
  $str .= "<option $sltd value='$key'>" . $value . "</option>";
603
+ }
604
+ }
 
605
  return $str;
606
  }
607
 
611
  * @param string $selected
612
  * @return string
613
  */
614
+ public function pinterestAttributesDropdown( $selected = "" ) {
 
615
  $attributes = new Woo_Feed_Default_Attributes();
616
  $str = "<option></option>";
617
+ foreach ( $attributes->googleAttributes() as $key => $value ) {
618
+ if ( substr($key, 0, 2) == "--" ) {
619
  $str .= "<optgroup label='$value'>";
620
+ } elseif ( substr($key, 0, 2) == "---" ) {
621
  $str .= "</optgroup>";
622
  } else {
623
  $sltd = "";
624
  if ($selected == $key)
625
  $sltd = 'selected="selected"';
626
  $str .= "<option $sltd value='$key'>" . $value . "</option>";
627
+ }
628
+ }
 
629
  return $str;
630
  }
631
 
635
  * @param string $selected
636
  * @return string
637
  */
638
+ public function facebookAttributesDropdown( $selected = "" ) {
 
639
  $attributes = new Woo_Feed_Default_Attributes();
640
  $str = "<option></option>";
641
+ foreach ( $attributes->googleAttributes() as $key => $value ) {
642
+ if ( substr($key, 0, 2) == "--" ) {
643
  $str .= "<optgroup label='$value'>";
644
+ } elseif ( substr($key, 0, 2) == "---" ) {
645
  $str .= "</optgroup>";
646
  } else {
647
  $sltd = "";
648
  if ($selected == $key)
649
  $sltd = 'selected="selected"';
650
  $str .= "<option $sltd value='$key'>" . $value . "</option>";
651
+ }
652
+ }
 
653
  return $str;
654
  }
655
 
659
  * @param string $selected
660
  * @return string
661
  */
662
+ public function shopbotAttributesDropdown( $selected = "" ) {
 
663
  $attributes = new Woo_Feed_Default_Attributes();
664
  $str = "<option></option>";
665
+ foreach ( $attributes->shopbotAttribute() as $key => $value ) {
666
+ if ( substr($key, 0, 2) == "--" ) {
667
  $str .= "<optgroup label='$value'>";
668
+ } elseif ( substr($key, 0, 2) == "---" ) {
669
  $str .= "</optgroup>";
670
  } else {
671
  $sltd = "";
672
  if ($selected == $key)
673
  $sltd = 'selected="selected"';
674
  $str .= "<option $sltd value='$key'>" . $value . "</option>";
675
+ }
676
+ }
 
677
  return $str;
678
  }
679
 
683
  * @param string $selected
684
  * @return string
685
  */
686
+ public function amazonAttributesDropdown( $selected = "" ) {
 
687
  $attributes = new Woo_Feed_Default_Attributes();
688
  $str = "<option></option>";
689
+ foreach ( $attributes->amazonAttributes() as $key => $value ) {
690
+ if ( substr($key, 0, 2) == "--" ) {
691
  $str .= "<optgroup label='$value'>";
692
+ } elseif ( substr($key, 0, 2) == "---" ) {
693
  $str .= "</optgroup>";
694
  } else {
695
  $sltd = "";
696
  if ($selected == $key)
697
  $sltd = 'selected="selected"';
698
  $str .= "<option $sltd value='$key'>" . $value . "</option>";
699
+ }
700
+ }
 
701
  return $str;
702
  }
703
  /**
706
  * @param string $selected
707
  * @return string
708
  */
709
+ public function priceGrabberAttributesDropdown( $selected = "" ) {
 
710
  $attributes = new Woo_Feed_Default_Attributes();
711
  $str = "<option></option>";
712
+ foreach ( $attributes->priceGrabberAttribute() as $key => $value ) {
713
+ if ( substr($key, 0, 2) == "--" ) {
714
  $str .= "<optgroup label='$value'>";
715
+ } elseif ( substr($key, 0, 2) == "---" ) {
716
  $str .= "</optgroup>";
717
  } else {
718
  $sltd = "";
719
  if ($selected == $key)
720
  $sltd = 'selected="selected"';
721
  $str .= "<option $sltd value='$key'>" . $value . "</option>";
722
+ }
723
+ }
 
724
  return $str;
725
  }
726
 
730
  * @param string $selected
731
  * @return string
732
  */
733
+ public function nextagAttributesDropdown( $selected = "" ) {
 
734
  $attributes = new Woo_Feed_Default_Attributes();
735
  $str = "<option></option>";
736
+ foreach ( $attributes->nextagAttribute() as $key => $value ) {
737
+ if ( substr($key, 0, 2) == "--" ) {
738
  $str .= "<optgroup label='$value'>";
739
+ } elseif ( substr($key, 0, 2) == "---" ) {
740
  $str .= "</optgroup>";
741
  } else {
742
  $sltd = "";
743
  if ($selected == $key)
744
  $sltd = 'selected="selected"';
745
  $str .= "<option $sltd value='$key'>" . $value . "</option>";
746
+ }
747
+ }
 
748
  return $str;
749
  }
750
 
754
  * @param string $selected
755
  * @return string
756
  */
757
+ public function kelkooAttributesDropdown( $selected = "" ) {
 
758
  $attributes = new Woo_Feed_Default_Attributes();
759
  $str = "<option></option>";
760
+ foreach ( $attributes->kelkooAttribute() as $key => $value ) {
761
+ if ( substr($key, 0, 2) == "--" ) {
762
  $str .= "<optgroup label='$value'>";
763
+ } elseif ( substr($key, 0, 2) == "---" ) {
764
  $str .= "</optgroup>";
765
  } else {
766
  $sltd = "";
767
  if ($selected == $key)
768
  $sltd = 'selected="selected"';
769
  $str .= "<option $sltd value='$key'>" . $value . "</option>";
770
+ }
771
+ }
 
772
  return $str;
773
  }
774
 
778
  * @param string $selected
779
  * @return string
780
  */
781
+ public function shopzillaAttributesDropdown( $selected = "" ) {
 
782
  $attributes = new Woo_Feed_Default_Attributes();
783
  $str = "<option></option>";
784
+ foreach ( $attributes->shopzillaAttribute() as $key => $value ) {
785
+ if ( substr($key, 0, 2) == "--" ) {
786
  $str .= "<optgroup label='$value'>";
787
+ } elseif ( substr($key, 0, 2) == "---" ) {
788
  $str .= "</optgroup>";
789
  } else {
790
  $sltd = "";
791
  if ($selected == $key)
792
  $sltd = 'selected="selected"';
793
  $str .= "<option $sltd value='$key'>" . $value . "</option>";
794
+ }
795
+ }
 
796
  return $str;
797
  }
798
 
802
  * @param string $selected
803
  * @return string
804
  */
805
+ public function shoppingAttributesDropdown( $selected = "" ) {
 
806
  $attributes = new Woo_Feed_Default_Attributes();
807
  $str = "<option></option>";
808
+ foreach ( $attributes->shoppingAttribute() as $key => $value ) {
809
+ if ( substr($key, 0, 2) == "--" ) {
810
  $str .= "<optgroup label='$value'>";
811
+ } elseif ( substr($key, 0, 2) == "---" ) {
812
  $str .= "</optgroup>";
813
  } else {
814
  $sltd = "";
815
  if ($selected == $key)
816
  $sltd = 'selected="selected"';
817
  $str .= "<option $sltd value='$key'>" . $value . "</option>";
818
+ }
819
+ }
 
820
  return $str;
821
  }
822
 
826
  * @param string $selected
827
  * @return string
828
  */
829
+ public function shopmaniaAttributesDropdown( $selected = "" ) {
 
830
  $attributes = new Woo_Feed_Default_Attributes();
831
  $str = "<option></option>";
832
+ foreach ( $attributes->shopmaniaAttribute() as $key => $value ) {
833
+ if ( substr($key, 0, 2) == "--" ) {
834
  $str .= "<optgroup label='$value'>";
835
+ } elseif ( substr($key, 0, 2) == "---" ) {
836
  $str .= "</optgroup>";
837
  } else {
838
  $sltd = "";
839
  if ($selected == $key)
840
  $sltd = 'selected="selected"';
841
  $str .= "<option $sltd value='$key'>" . $value . "</option>";
842
+ }
843
+ }
 
844
  return $str;
845
  }
846
 
851
  * @param string $selected
852
  * @return string
853
  */
854
+ public function bingAttributesDropdown( $selected = "" ) {
 
855
  $attributes = new Woo_Feed_Default_Attributes();
856
  $str = "<option></option>";
857
+ foreach ( $attributes->bingAttribute() as $key => $value ) {
858
+ if ( substr($key, 0, 2) == "--" ) {
859
  $str .= "<optgroup label='$value'>";
860
+ } elseif ( substr($key, 0, 2) == "---" ) {
861
  $str .= "</optgroup>";
862
  } else {
863
  $sltd = "";
864
  if ($selected == $key)
865
  $sltd = 'selected="selected"';
866
  $str .= "<option $sltd value='$key'>" . $value . "</option>";
867
+ }
868
+ }
 
869
  return $str;
870
  }
871
 
875
  * @param string $selected
876
  * @return string
877
  */
878
+ public function becomeAttributesDropdown( $selected = "" ) {
 
879
  $attributes = new Woo_Feed_Default_Attributes();
880
  $str = "<option></option>";
881
+ foreach ( $attributes->becomeAttribute() as $key => $value ) {
882
+ if ( substr($key, 0, 2) == "--" ) {
883
  $str .= "<optgroup label='$value'>";
884
+ } elseif ( substr($key, 0, 2) == "---" ) {
885
  $str .= "</optgroup>";
886
  } else {
887
  $sltd = "";
888
  if ($selected == $key)
889
  $sltd = 'selected="selected"';
890
  $str .= "<option $sltd value='$key'>" . $value . "</option>";
891
+ }
892
+ }
 
893
  return $str;
894
  }
895
 
899
  * @param string $selected
900
  * @return string
901
  */
902
+ public function connexityAttributesDropdown( $selected = "" ) {
 
903
  $attributes = new Woo_Feed_Default_Attributes();
904
  $str = "<option></option>";
905
+ foreach ( $attributes->becomeAttribute() as $key => $value ) {
906
+ if ( substr($key, 0, 2) == "--" ) {
907
  $str .= "<optgroup label='$value'>";
908
+ } elseif ( substr($key, 0, 2) == "---" ) {
909
  $str .= "</optgroup>";
910
  } else {
911
  $sltd = "";
912
  if ($selected == $key)
913
  $sltd = 'selected="selected"';
914
  $str .= "<option $sltd value='$key'>" . $value . "</option>";
915
+ }
916
+ }
 
917
  return $str;
918
  }
919
  }
includes/classes/class-woo-feed-list-table.php CHANGED
@@ -285,8 +285,8 @@ class Woo_Feed_List_Table {
285
 
286
  // Redirect if page number is invalid and headers are not already sent.
287
  if ( ! headers_sent() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) {
288
- wp_redirect( add_query_arg( 'paged', $args['total_pages'] ) );
289
- exit;
290
  }
291
 
292
  $this->_pagination_args = $args;
285
 
286
  // Redirect if page number is invalid and headers are not already sent.
287
  if ( ! headers_sent() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) {
288
+ wp_safe_redirect( add_query_arg( 'paged', $args['total_pages'] ) );
289
+ die();
290
  }
291
 
292
  $this->_pagination_args = $args;
includes/classes/class-woo-feed-log-handler-file.php CHANGED
@@ -9,7 +9,7 @@
9
  * @author KD <mhaudul.hk@gmail.com>
10
  *
11
  */
12
- if( ! defined( 'ABSPATH' ) ) die(); // Silence...
13
 
14
  class Woo_Feed_Log_Handler_File extends WC_Log_Handler {
15
 
@@ -358,7 +358,7 @@ class Woo_Feed_Log_Handler_File extends WC_Log_Handler {
358
  */
359
  public static function get_log_file_name( $handle ) {
360
  if ( function_exists( 'wp_hash' ) ) {
361
- $date_suffix = date( 'Y-m-d', current_time( 'timestamp', true ) );
362
  $hash_suffix = wp_hash( $handle );
363
  return sanitize_file_name( implode( '-', array( $handle, $date_suffix, $hash_suffix ) ) . '.log' );
364
  } else {
9
  * @author KD <mhaudul.hk@gmail.com>
10
  *
11
  */
12
+ if ( ! defined( 'ABSPATH' ) ) die(); // Silence...
13
 
14
  class Woo_Feed_Log_Handler_File extends WC_Log_Handler {
15
 
358
  */
359
  public static function get_log_file_name( $handle ) {
360
  if ( function_exists( 'wp_hash' ) ) {
361
+ $date_suffix = gmdate( 'Y-m-d', time() );
362
  $hash_suffix = wp_hash( $handle );
363
  return sanitize_file_name( implode( '-', array( $handle, $date_suffix, $hash_suffix ) ) . '.log' );
364
  } else {
includes/classes/class-woo-feed-merchant.php CHANGED
@@ -21,7 +21,7 @@ class Woo_Feed_Merchant {
21
  'categories',
22
  'brand',
23
  ),
24
- 'prefix' => array( '', '', '', '', '', '', '', '', ),
25
  'type' => array(
26
  'attribute',
27
  'attribute',
@@ -32,11 +32,11 @@ class Woo_Feed_Merchant {
32
  'attribute',
33
  'attribute',
34
  ),
35
- 'attributes' => array( 'id', 'title', 'description', 'link', 'image', 'price', 'product_type', '', ),
36
- 'default' => array( '', '', '', '', '', '', '', '', ),
37
- 'suffix' => array( '', '', '', '', '', '', '', '', ),
38
- 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', ),
39
- 'limit' => array( '', '', '', '', '', '', '', '', ),
40
  ),
41
  "bol" => array(
42
  'mattributes' => array(
@@ -48,7 +48,7 @@ class Woo_Feed_Merchant {
48
  'Cover Image URL',
49
  'Brand',
50
  ),
51
- 'prefix' => array( '', '', '', '', '', '', '', ),
52
  'type' => array(
53
  'attribute',
54
  'attribute',
@@ -58,11 +58,11 @@ class Woo_Feed_Merchant {
58
  'attribute',
59
  'pattern',
60
  ),
61
- 'attributes' => array( 'sku', 'id', 'title', 'product_type', 'description', 'image', '', ),
62
- 'default' => array( '', '', '', '', '', '', '', ),
63
- 'suffix' => array( '', '', '', '', '', '', '', ),
64
- 'output_type' => array( '1', '1', '1', '1', '2', '1', '', ),
65
- 'limit' => array( '', '', '', '', '', '500', '5000', ),
66
  ),
67
  'adform' => array(
68
  'mattributes' => array(
@@ -73,13 +73,13 @@ class Woo_Feed_Merchant {
73
  'product_image',
74
  'product_price',
75
  ),
76
- 'prefix' => array( '', '', '', '', '', '', ),
77
- 'type' => array( 'attribute', 'attribute', 'attribute', 'attribute', 'attribute', 'attribute', ),
78
- 'attributes' => array( 'id', 'title', 'product_type', 'link', 'image', 'price', ),
79
- 'default' => array( '', '', '', '', '', '', ),
80
- 'suffix' => array( '', '', '', '', '', '', ),
81
- 'output_type' => array( '1', '1', '1', '1', '1', '1', ),
82
- 'limit' => array( '', '', '', '', '', '', ),
83
  ),
84
  'avantlink' => array(
85
  'mattributes' => array(
@@ -95,7 +95,7 @@ class Woo_Feed_Merchant {
95
  'Sale Price',
96
  'UPC',
97
  ),
98
- 'prefix' => array( '', '', '', '', '', '', '', '', '', '', '', ),
99
  'type' => array(
100
  'attribute',
101
  'attribute',
@@ -122,10 +122,10 @@ class Woo_Feed_Merchant {
122
  'sale_price',
123
  '',
124
  ),
125
- 'default' => array( '', '', '', '', '', '', '', '', '', '', '', ),
126
- 'suffix' => array( '', '', '', '', '', '', '', '', '', '', '', ),
127
- 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', ),
128
- 'limit' => array( '', '', '', '', '', '', '', '', '', '', '', ),
129
  ),
130
  'become' => array(
131
  'mattributes' => array(
@@ -139,7 +139,7 @@ class Woo_Feed_Merchant {
139
  'Availability',
140
  'Current Price',
141
  ),
142
- 'prefix' => array( '', '', '', '', '', '', '', '', '', ),
143
  'type' => array(
144
  'attribute',
145
  'attribute',
@@ -162,10 +162,10 @@ class Woo_Feed_Merchant {
162
  'availability',
163
  'price',
164
  ),
165
- 'default' => array( '', '', '', '', '', '', '', '', '', ),
166
- 'suffix' => array( '', '', '', '', '', '', '', '', '', ),
167
- 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', ),
168
- 'limit' => array( '', '', '', '', '', '', '', '', '', ),
169
  ),
170
  'bonanza' => array(
171
  'mattributes' => array(
@@ -365,7 +365,7 @@ class Woo_Feed_Merchant {
365
  'Availability',
366
  'Current Price',
367
  ),
368
- 'prefix' => array( '', '', '', '', '', '', '', '', '', ),
369
  'type' => array(
370
  'attribute',
371
  'attribute',
@@ -388,10 +388,10 @@ class Woo_Feed_Merchant {
388
  'availability',
389
  'price',
390
  ),
391
- 'default' => array( '', '', '', '', '', '', '', '', '', ),
392
- 'suffix' => array( '', '', '', '', '', '', '', '', '', ),
393
- 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', ),
394
- 'limit' => array( '', '', '', '', '', '', '', '', '', ),
395
  ),
396
  'criteo' => array(
397
  'mattributes' => array(
@@ -415,7 +415,7 @@ class Woo_Feed_Merchant {
415
  'filters',
416
  'adult',
417
  ),
418
- 'prefix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ),
419
  'type' => array(
420
  'attribute',
421
  'attribute',
@@ -458,8 +458,8 @@ class Woo_Feed_Merchant {
458
  '',
459
  '',
460
  ),
461
- 'default' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ),
462
- 'suffix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ),
463
  'output_type' => array(
464
  '1',
465
  '1',
@@ -520,7 +520,7 @@ class Woo_Feed_Merchant {
520
  'sell_max',
521
  'shop_cat',
522
  ),
523
- 'prefix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', ),
524
  'type' => array(
525
  'attribute',
526
  'attribute',
@@ -553,10 +553,10 @@ class Woo_Feed_Merchant {
553
  'quantity',
554
  'product_type',
555
  ),
556
- 'default' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', ),
557
- 'suffix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', ),
558
- 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', ),
559
- 'limit' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', ),
560
  ),
561
  'fruugo' => array(
562
  'mattributes' => array(
@@ -576,7 +576,7 @@ class Woo_Feed_Merchant {
576
  'Currency',
577
  'Country',
578
  ),
579
- 'prefix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ),
580
  'type' => array(
581
  'attribute',
582
  'attribute',
@@ -611,10 +611,10 @@ class Woo_Feed_Merchant {
611
  '',
612
  '',
613
  ),
614
- 'default' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', 'USD', '', ),
615
- 'suffix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ),
616
- 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', ),
617
- 'limit' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ),
618
  ),
619
  'fruugo.au' => array(
620
  'mattributes' => array(
@@ -634,7 +634,7 @@ class Woo_Feed_Merchant {
634
  'Currency',
635
  'Country',
636
  ),
637
- 'prefix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ),
638
  'type' => array(
639
  'attribute',
640
  'attribute',
@@ -669,10 +669,10 @@ class Woo_Feed_Merchant {
669
  '',
670
  '',
671
  ),
672
- 'default' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', 'USD', '', ),
673
- 'suffix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ),
674
- 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', ),
675
- 'limit' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ),
676
  ),
677
  'jet' => array(
678
  'mattributes' => array(
@@ -686,7 +686,7 @@ class Woo_Feed_Merchant {
686
  'Jet Category',
687
  'Brand',
688
  ),
689
- 'prefix' => array( '', '', '', '', '', '', '', '', '', ),
690
  'type' => array(
691
  'attribute',
692
  'attribute',
@@ -698,11 +698,11 @@ class Woo_Feed_Merchant {
698
  'pattern',
699
  'pattern',
700
  ),
701
- 'attributes' => array( 'sku', 'id', '', 'title', 'description', 'image', 'price', '', '', ),
702
- 'default' => array( '', '', '', '', '', '', '', '', '', ),
703
- 'suffix' => array( '', '', '', '', '', '', '', '', '', ),
704
- 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', ),
705
- 'limit' => array( '', '', '', '', '', '', '', '', '', ),
706
  ),
707
  'kelkoo' => array(
708
  'mattributes' => array(
@@ -718,7 +718,7 @@ class Woo_Feed_Merchant {
718
  'availability',
719
  'mpn',
720
  ),
721
- 'prefix' => array( '', '', '', '', '', '', '', '', '', '', '', ),
722
  'type' => array(
723
  'attribute',
724
  'attribute',
@@ -745,10 +745,10 @@ class Woo_Feed_Merchant {
745
  'availability',
746
  '',
747
  ),
748
- 'default' => array( '', '', '', '', '', '', '', '', '', '', '', ),
749
- 'suffix' => array( '', '', '', '', '', '', '', '', '', '', '', ),
750
- 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', ),
751
- 'limit' => array( '', '', '', '', '', '', '', '', '', '', '', ),
752
  ),
753
  'kieskeurig.nl' => array(
754
  'mattributes' => array(
@@ -768,7 +768,7 @@ class Woo_Feed_Merchant {
768
  'imagelink',
769
  'voorraad',
770
  ),
771
- 'prefix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ),
772
  'type' => array(
773
  'attribute',
774
  'attribute',
@@ -803,10 +803,10 @@ class Woo_Feed_Merchant {
803
  'image',
804
  'quantity',
805
  ),
806
- 'default' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ),
807
- 'suffix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ),
808
- 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', ),
809
- 'limit' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ),
810
  ),
811
  'kijiji.ca' => array(
812
  'mattributes' => array(
@@ -819,7 +819,7 @@ class Woo_Feed_Merchant {
819
  'categories',
820
  'brand',
821
  ),
822
- 'prefix' => array( '', '', '', '', '', '', '', '', ),
823
  'type' => array(
824
  'attribute',
825
  'attribute',
@@ -830,11 +830,11 @@ class Woo_Feed_Merchant {
830
  'attribute',
831
  'attribute',
832
  ),
833
- 'attributes' => array( 'id', 'title', 'description', 'link', 'image', 'price', 'product_type', '', ),
834
- 'default' => array( '', '', '', '', '', '', '', '', ),
835
- 'suffix' => array( '', '', '', '', '', '', '', '', ),
836
- 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', ),
837
- 'limit' => array( '', '', '', '', '', '', '', '', ),
838
  ),
839
  'leguide' => array(
840
  'mattributes' => array(
@@ -852,7 +852,7 @@ class Woo_Feed_Merchant {
852
  'availability',
853
  'guarantee',
854
  ),
855
- 'prefix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', ),
856
  'type' => array(
857
  'attribute',
858
  'attribute',
@@ -883,10 +883,10 @@ class Woo_Feed_Merchant {
883
  '',
884
  '',
885
  ),
886
- 'default' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', ),
887
- 'suffix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', ),
888
- 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', ),
889
- 'limit' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', ),
890
  ),
891
  'modina.de' => array(
892
  'mattributes' => array(
@@ -1088,7 +1088,7 @@ class Woo_Feed_Merchant {
1088
  'InStock',
1089
  'MPN',
1090
  ),
1091
- 'prefix' => array( '', '', '', '', '', '', '', '', '', '', '', ),
1092
  'type' => array(
1093
  'pattern',
1094
  'attribute',
@@ -1115,10 +1115,10 @@ class Woo_Feed_Merchant {
1115
  '',
1116
  'sku',
1117
  ),
1118
- 'default' => array( '', '', '', '', '', '', '', '', '', 'Y', '', ),
1119
- 'suffix' => array( '', '', '', '', '', '', '', '', '', '', '', ),
1120
- 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', ),
1121
- 'limit' => array( '', '', '', '', '', '', '', '', '', '', '', ),
1122
  ),
1123
  'nextag' => array(
1124
  'mattributes' => array(
@@ -1132,7 +1132,7 @@ class Woo_Feed_Merchant {
1132
  'Stock Status',
1133
  'Condition',
1134
  ),
1135
- 'prefix' => array( '', '', '', '$', '', '', '', '', '', ),
1136
  'type' => array(
1137
  'pattern',
1138
  'attribute',
@@ -1155,14 +1155,14 @@ class Woo_Feed_Merchant {
1155
  'availability',
1156
  'condition',
1157
  ),
1158
- 'default' => array( '', '', '', '', '', '', '', '', '', ),
1159
- 'suffix' => array( '', '', '', '', '', '', '', '', '', ),
1160
- 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', ),
1161
- 'limit' => array( '', '', '', '', '', '', '', '', '', ),
1162
  ),
1163
  'polyvore' => array(
1164
- 'mattributes' => array( 'title', 'brand', 'url', 'imgurl', 'price', 'currency', 'description', 'subject', ),
1165
- 'prefix' => array( '', '', '', '', '', '', '', '', ),
1166
  'type' => array(
1167
  'attribute',
1168
  'pattern',
@@ -1173,11 +1173,11 @@ class Woo_Feed_Merchant {
1173
  'attribute',
1174
  'pattern',
1175
  ),
1176
- 'attributes' => array( 'title', '', 'link', 'image', 'price', '', 'description', '', ),
1177
- 'default' => array( '', '', '', '', '', 'USD', '', '', ),
1178
- 'suffix' => array( '', '', '', '', '', '', '', '', ),
1179
- 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', ),
1180
- 'limit' => array( '', '', '', '', '', '', '', '', ),
1181
  ),
1182
  'pricegrabber' => array(
1183
  'mattributes' => array(
@@ -1194,7 +1194,7 @@ class Woo_Feed_Merchant {
1194
  'Manufacturer Name',
1195
  'GTIN',
1196
  ),
1197
- 'prefix' => array( '', '', '', '', '', '', '', '', '', '', '', '', ),
1198
  'type' => array(
1199
  'attribute',
1200
  'attribute',
@@ -1223,10 +1223,10 @@ class Woo_Feed_Merchant {
1223
  '',
1224
  '',
1225
  ),
1226
- 'default' => array( '', '', '', '', '', '', '', '', '', '', '', '', ),
1227
- 'suffix' => array( '', '', '', '', '', '', '', '', '', '', '', '', ),
1228
- 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', ),
1229
- 'limit' => array( '', '', '', '', '', '', '', '', '', '', '', '', ),
1230
  ),
1231
  'pricerunner' => array(
1232
  'mattributes' => array(
@@ -1245,7 +1245,7 @@ class Woo_Feed_Merchant {
1245
  'Shipping Cost',
1246
  'Delivery time',
1247
  ),
1248
- 'prefix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', ),
1249
  'type' => array(
1250
  'attribute',
1251
  'attribute',
@@ -1278,10 +1278,10 @@ class Woo_Feed_Merchant {
1278
  '',
1279
  '',
1280
  ),
1281
- 'default' => array( '', '', '', '', '', '', '', '', '', '', 'Yes', '', '10.00', '5-7 days', ),
1282
- 'suffix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', ),
1283
- 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', ),
1284
- 'limit' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', ),
1285
  ),
1286
  'prisjakt' => array(
1287
  'mattributes' => array(
@@ -1296,7 +1296,7 @@ class Woo_Feed_Merchant {
1296
  'Bild-URL',
1297
  'Lagerstatus',
1298
  ),
1299
- 'prefix' => array( '', '', '', '', '', '', '', '', '', '', ),
1300
  'type' => array(
1301
  'attribute',
1302
  'attribute',
@@ -1321,20 +1321,20 @@ class Woo_Feed_Merchant {
1321
  'image',
1322
  'condition',
1323
  ),
1324
- 'default' => array( '', '', '', '', '', '', '', '', 'mens, womens', '', ),
1325
- 'suffix' => array( '', '', '', '', '', '', '', '', '', '', ),
1326
- 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', ),
1327
- 'limit' => array( '', '', '', '', '', '', '', '', '', '', ),
1328
  ),
1329
  'real' => array(
1330
- 'mattributes' => array( 'ean', 'category', 'title', 'description', 'picture', 'manufacturer', ),
1331
- 'prefix' => array( '', '', '', '', '', '', ),
1332
- 'type' => array( 'attribute', 'attribute', 'attribute', 'attribute', 'attribute', 'pattern', ),
1333
- 'attributes' => array( 'sku', 'product_type', 'title', 'description', 'image', '', ),
1334
- 'default' => array( '', '', '', '', '', '', ),
1335
- 'suffix' => array( '', '', '', '', '', '', ),
1336
- 'output_type' => array( '1', '1', '1', '1', '1', '1', ),
1337
- 'limit' => array( '', '', '', '', '', '', ),
1338
  ),
1339
  'shareasale' => array(
1340
  'mattributes' => array(
@@ -1351,7 +1351,7 @@ class Woo_Feed_Merchant {
1351
  'Subcategory',
1352
  'Description',
1353
  ),
1354
- 'prefix' => array( '', '', '', '', '', '', '', '', '', '', '', '', ),
1355
  'type' => array(
1356
  'attribute',
1357
  'attribute',
@@ -1380,10 +1380,10 @@ class Woo_Feed_Merchant {
1380
  '',
1381
  'description',
1382
  ),
1383
- 'default' => array( '', '', '', '', '', '', '', '', '', '', '', '', ),
1384
- 'suffix' => array( '', '', '', '', '', '', '', '', '', '', '', '', ),
1385
- 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', ),
1386
- 'limit' => array( '8', '255', '8', '255', '255', '255', '255', '', '', '50', '50', '', ),
1387
  ),
1388
  'shopalike.fr' => array(
1389
  'mattributes' => array(
@@ -1396,7 +1396,7 @@ class Woo_Feed_Merchant {
1396
  'categories',
1397
  'brand',
1398
  ),
1399
- 'prefix' => array( '', '', '', '', '', '', '', '', ),
1400
  'type' => array(
1401
  'attribute',
1402
  'attribute',
@@ -1407,11 +1407,11 @@ class Woo_Feed_Merchant {
1407
  'attribute',
1408
  'attribute',
1409
  ),
1410
- 'attributes' => array( 'id', 'title', 'description', 'link', 'image', 'price', 'product_type', '', ),
1411
- 'default' => array( '', '', '', '', '', '', '', '', ),
1412
- 'suffix' => array( '', '', '', '', '', '', '', '', ),
1413
- 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', ),
1414
- 'limit' => array( '', '', '', '', '', '', '', '', ),
1415
  ),
1416
  'shopbot' => array(
1417
  'mattributes' => array(
@@ -1432,7 +1432,7 @@ class Woo_Feed_Merchant {
1432
  'Color',
1433
  'Product Type',
1434
  ),
1435
- 'prefix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ),
1436
  'type' => array(
1437
  'attribute',
1438
  'attribute',
@@ -1469,10 +1469,10 @@ class Woo_Feed_Merchant {
1469
  '',
1470
  '',
1471
  ),
1472
- 'default' => array( '', '', '', '', '', '', '', '', 'mens, womens', '', '', '', '', '', '', '', ),
1473
- 'suffix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ),
1474
- 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', ),
1475
- 'limit' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ),
1476
  ),
1477
  'shopmania' => array(
1478
  'mattributes' => array(
@@ -1490,7 +1490,7 @@ class Woo_Feed_Merchant {
1490
  'Availability',
1491
  'GTIN',
1492
  ),
1493
- 'prefix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', ),
1494
  'type' => array(
1495
  'attribute',
1496
  'attribute',
@@ -1521,10 +1521,10 @@ class Woo_Feed_Merchant {
1521
  'availability',
1522
  '',
1523
  ),
1524
- 'default' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', ),
1525
- 'suffix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', ),
1526
- 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', ),
1527
- 'limit' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', ),
1528
  ),
1529
  'shopping' => array(
1530
  'mattributes' => array(
@@ -1538,7 +1538,7 @@ class Woo_Feed_Merchant {
1538
  'MPN',
1539
  'UPC',
1540
  ),
1541
- 'prefix' => array( '', '', '', '', '', '', '', '', '', ),
1542
  'type' => array(
1543
  'attribute',
1544
  'attribute',
@@ -1550,11 +1550,11 @@ class Woo_Feed_Merchant {
1550
  'attribute',
1551
  'attribute',
1552
  ),
1553
- 'attributes' => array( 'sku', 'title', 'link', 'image', 'price', 'availability', 'condition', '', '', ),
1554
- 'default' => array( '', '', '', '', '', '', '', '', '', ),
1555
- 'suffix' => array( '', '', '', '', '', '', '', '', '', ),
1556
- 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', ),
1557
- 'limit' => array( '', '', '', '', '', '', '', '', '', ),
1558
  ),
1559
  'shopzilla' => array(
1560
  'mattributes' => array(
@@ -1568,7 +1568,7 @@ class Woo_Feed_Merchant {
1568
  'Availability',
1569
  'Current Price',
1570
  ),
1571
- 'prefix' => array( '', '', '', '', '', '', '', '', '', ),
1572
  'type' => array(
1573
  'attribute',
1574
  'attribute',
@@ -1591,10 +1591,10 @@ class Woo_Feed_Merchant {
1591
  'availability',
1592
  'price',
1593
  ),
1594
- 'default' => array( '', '', '', '', '', '', '', '', '', ),
1595
- 'suffix' => array( '', '', '', '', '', '', '', '', '', ),
1596
- 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', ),
1597
- 'limit' => array( '', '', '', '', '', '', '', '', '', ),
1598
  ),
1599
  'spartoo.fi' => array(
1600
  'mattributes' => array(
@@ -2012,7 +2012,7 @@ class Woo_Feed_Merchant {
2012
  'Delivery price',
2013
  'Service country code',
2014
  ),
2015
- 'prefix' => array( '', '', '', '', '', '', '', '', '', ),
2016
  'type' => array(
2017
  'attribute',
2018
  'attribute',
@@ -2024,11 +2024,11 @@ class Woo_Feed_Merchant {
2024
  'attribute',
2025
  'attribute',
2026
  ),
2027
- 'attributes' => array( 'product_type', 'title', '', 'price', 'link', '', '', '', '', ),
2028
- 'default' => array( '', '', '', '', '', '', '', '', '', ),
2029
- 'suffix' => array( '', '', '', '', '', '', '', '', '', ),
2030
- 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', ),
2031
- 'limit' => array( '', '', '', '', '', '', '', '', '', ),
2032
  ),
2033
  'walmart' => array(
2034
  'mattributes' => array(
@@ -2043,7 +2043,7 @@ class Woo_Feed_Merchant {
2043
  'Price',
2044
  'Shipping Weight',
2045
  ),
2046
- 'prefix' => array( '', '', '', '', '', '', '', '', '', '', ),
2047
  'type' => array(
2048
  'attribute',
2049
  'attribute',
@@ -2056,11 +2056,11 @@ class Woo_Feed_Merchant {
2056
  'attribute',
2057
  'attribute',
2058
  ),
2059
- 'attributes' => array( 'title', 'sku', '', '', 'id', '', 'description', '', 'price', '', ),
2060
- 'default' => array( '', '', '', '', '', '', '', '', '', '', ),
2061
- 'suffix' => array( '', '', '', '', '', '', '', '', '', '', ),
2062
- 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', ),
2063
- 'limit' => array( '', '', '', '', '', '', '', '', '', '', ),
2064
  ),
2065
  'wish' => array(
2066
  'mattributes' => array(
@@ -2074,7 +2074,7 @@ class Woo_Feed_Merchant {
2074
  'Unique ID/SKU',
2075
  'Description',
2076
  ),
2077
- 'prefix' => array( '', '', '', '', '', '', '', '', '', ),
2078
  'type' => array(
2079
  'attribute',
2080
  'attribute',
@@ -2097,10 +2097,10 @@ class Woo_Feed_Merchant {
2097
  'id',
2098
  'description',
2099
  ),
2100
- 'default' => array( '', '', '', '', '', '', '', '', '', ),
2101
- 'suffix' => array( '', '', '', '', '', '', '', '', '', ),
2102
- 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', ),
2103
- 'limit' => array( '', '', '', '', '', '', '', '', '', ),
2104
  ),
2105
  'yahoo_nfa' => array(
2106
  'mattributes' => array(
@@ -2114,7 +2114,7 @@ class Woo_Feed_Merchant {
2114
  'price',
2115
  'gtin',
2116
  ),
2117
- 'prefix' => array( '', '', '', '', '', '', '', '', '', ),
2118
  'type' => array(
2119
  'attribute',
2120
  'attribute',
@@ -2137,10 +2137,10 @@ class Woo_Feed_Merchant {
2137
  'price',
2138
  '',
2139
  ),
2140
- 'default' => array( '', '', '', '', '', '', '', '', '', ),
2141
- 'suffix' => array( '', '', '', '', '', '', '', '', '', ),
2142
- 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', ),
2143
- 'limit' => array( '', '', '', '', '', '', '', '', '', ),
2144
  ),
2145
  'zap.co.il' => array(
2146
  'mattributes' => array(
@@ -2154,7 +2154,7 @@ class Woo_Feed_Merchant {
2154
  'DELIVERY_TIME',
2155
  'IMAGE',
2156
  ),
2157
- 'prefix' => array( '', '', '', '', '', '', '', '', '', ),
2158
  'type' => array(
2159
  'attribute',
2160
  'attribute',
@@ -2166,11 +2166,11 @@ class Woo_Feed_Merchant {
2166
  'attribute',
2167
  'attribute',
2168
  ),
2169
- 'attributes' => array( 'link', 'title', 'description', 'id', '', 'price', '', '', 'image', ),
2170
- 'default' => array( '', '', '', '', '', '', '', '', '', ),
2171
- 'suffix' => array( '', '', '', '', '', '', '', '', '', ),
2172
- 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', ),
2173
- 'limit' => array( '', '', '', '', '', '', '', '', '', ),
2174
  ),
2175
  'adwords' => array(
2176
  'mattributes' => array(
@@ -2187,7 +2187,7 @@ class Woo_Feed_Merchant {
2187
  'Contextual keywords',
2188
  'Item address',
2189
  ),
2190
- 'prefix' => array( '', '', '', '', '', '', '', '', '', '', '', '', ),
2191
  'type' => array(
2192
  'attribute',
2193
  'attribute',
@@ -2216,14 +2216,14 @@ class Woo_Feed_Merchant {
2216
  '',
2217
  '',
2218
  ),
2219
- 'default' => array( '', '', '', '', '', '', '', '', '', '', '', '', ),
2220
- 'suffix' => array( '', '', '', '', '', '', '', '', '', '', '', '', ),
2221
- 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', ),
2222
- 'limit' => array( '', '', '', '', '', '', '', '', '', '', '', '', ),
2223
  ),
2224
  'bing' => array(
2225
- 'mattributes' => array( 'id', 'title', 'link', 'price', 'description', 'image_link', 'shipping', ),
2226
- 'prefix' => array( '', '', '', '', '', '', '', ),
2227
  'type' => array(
2228
  'attribute',
2229
  'attribute',
@@ -2233,11 +2233,11 @@ class Woo_Feed_Merchant {
2233
  'attribute',
2234
  'attribute',
2235
  ),
2236
- 'attributes' => array( 'id', 'title', 'link', 'price', 'description', 'image', '', ),
2237
- 'default' => array( '', '', '', '', '', '', '', ),
2238
- 'suffix' => array( '', '', '', '', '', '', '', ),
2239
- 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', ),
2240
- 'limit' => array( '', '', '', '', '', '', '', ),
2241
  ),
2242
  'google_local_inventory' => array(
2243
  'mattributes' => array(
@@ -2251,7 +2251,7 @@ class Woo_Feed_Merchant {
2251
  'pickup method',
2252
  'pickup sla',
2253
  ),
2254
- 'prefix' => array( '', '', '', '', '', '', '', '', '', ),
2255
  'type' => array(
2256
  'pattern',
2257
  'attribute',
@@ -2274,10 +2274,10 @@ class Woo_Feed_Merchant {
2274
  '',
2275
  '',
2276
  ),
2277
- 'default' => array( ' ', '', '', '', '', '', '', '', '', ),
2278
- 'suffix' => array( '', '', '', '', '', '', '', '', '', ),
2279
- 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', ),
2280
- 'limit' => array( '', '', '', '', '', '', '', '', '', ),
2281
  ),
2282
  'google_local' => array(
2283
  'mattributes' => array(
@@ -2525,7 +2525,7 @@ class Woo_Feed_Merchant {
2525
  'Unit price',
2526
  'Energy efficiency rating',
2527
  ),
2528
- 'prefix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ),
2529
  'type' => array(
2530
  'attribute',
2531
  'attribute',
@@ -2564,8 +2564,8 @@ class Woo_Feed_Merchant {
2564
  '',
2565
  '',
2566
  ),
2567
- 'default' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ),
2568
- 'suffix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ),
2569
  'output_type' => array(
2570
  '1',
2571
  '1',
@@ -2585,7 +2585,7 @@ class Woo_Feed_Merchant {
2585
  '1',
2586
  '1',
2587
  ),
2588
- 'limit' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ),
2589
  ),
2590
  'pricespy' => array(
2591
  'mattributes' => array(
@@ -2600,7 +2600,7 @@ class Woo_Feed_Merchant {
2600
  'image-URL',
2601
  'stock status',
2602
  ),
2603
- 'prefix' => array( '', '', '', '', '', '', '', '', '', '', ),
2604
  'type' => array(
2605
  'attribute',
2606
  'attribute',
@@ -2625,10 +2625,10 @@ class Woo_Feed_Merchant {
2625
  'image',
2626
  'condition',
2627
  ),
2628
- 'default' => array( '', '', '', '', '', '', '', '', 'mens, womens', '', ),
2629
- 'suffix' => array( '', '', '', '', '', '', '', '', '', '', ),
2630
- 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', ),
2631
- 'limit' => array( '', '', '', '', '', '', '', '', '', '', ),
2632
  ),
2633
  'yandex_csv' => array(
2634
  'mattributes' => array(
@@ -2641,7 +2641,7 @@ class Woo_Feed_Merchant {
2641
  'name',
2642
  'description',
2643
  ),
2644
- 'prefix' => array( '', '', '', '', '', '', '', '', ),
2645
  'type' => array(
2646
  'attribute',
2647
  'attribute',
@@ -2662,10 +2662,10 @@ class Woo_Feed_Merchant {
2662
  'title',
2663
  'description',
2664
  ),
2665
- 'default' => array( '', '', '', 'RUR', '', '', '', '', ),
2666
- 'suffix' => array( '', '', '', '', '', '', '', '', ),
2667
- 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', ),
2668
- 'limit' => array( '', '', '', '', '', '', '', '', ),
2669
  ),
2670
  'fyndiq.se' => array(
2671
  'mattributes' => array(
@@ -2683,7 +2683,7 @@ class Woo_Feed_Merchant {
2683
  'article-quantity',
2684
  'article-name',
2685
  ),
2686
- 'prefix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', ),
2687
  'type' => array(
2688
  'attribute',
2689
  'attribute',
@@ -2714,10 +2714,10 @@ class Woo_Feed_Merchant {
2714
  'quantity',
2715
  '',
2716
  ),
2717
- 'default' => array( '', '', '', '', 'USD', '', '', '', '', '', '', '', '', ),
2718
- 'suffix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', ),
2719
- 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', ),
2720
- 'limit' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', ),
2721
  ),
2722
  'miinto.nl' => array(
2723
  'mattributes' => array(
@@ -2737,7 +2737,7 @@ class Woo_Feed_Merchant {
2737
  'washing',
2738
  'retail_price_currencyCode',
2739
  ),
2740
- 'prefix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ),
2741
  'type' => array(
2742
  'attribute',
2743
  'attribute',
@@ -2772,10 +2772,10 @@ class Woo_Feed_Merchant {
2772
  '',
2773
  '',
2774
  ),
2775
- 'default' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ),
2776
- 'suffix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ),
2777
- 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', ),
2778
- 'limit' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ),
2779
  ),
2780
  );
2781
 
@@ -2821,10 +2821,10 @@ class Woo_Feed_Merchant {
2821
  "video" => "https://youtu.be/PTUYgF7DwEo",
2822
  "feed_file_type" => array( "XML", "CSV", "TXT" ),
2823
  "doc" => array(
2824
- "How to make google merchant feed?" => "http://bit.ly/355q0jY",
2825
- "How to configure shipping info?" => "http://bit.ly/2Rzr0sI",
2826
- "How to set price with tax?" => "http://bit.ly/2PuzWga",
2827
- "How to solve micro data error?" => "http://bit.ly/345nIQz",
2828
  "How to configure google product categories?" => "http://bit.ly/2RFWRrP",
2829
  ),
2830
  ),
@@ -2985,7 +2985,7 @@ class Woo_Feed_Merchant {
2985
  */
2986
  public function getInfo( $merchant = '' ) {
2987
  $infos = $this->merchantInfo();
2988
- $info = ( isset( $infos[$merchant] ) && ! empty( $infos[$merchant] ) ) ? $infos[$merchant] : [];
2989
  /**
2990
  * Filter single merchant data before retrieve
2991
  * @param array $info
21
  'categories',
22
  'brand',
23
  ),
24
+ 'prefix' => array( '', '', '', '', '', '', '', '' ),
25
  'type' => array(
26
  'attribute',
27
  'attribute',
32
  'attribute',
33
  'attribute',
34
  ),
35
+ 'attributes' => array( 'id', 'title', 'description', 'link', 'image', 'price', 'product_type', '' ),
36
+ 'default' => array( '', '', '', '', '', '', '', '' ),
37
+ 'suffix' => array( '', '', '', '', '', '', '', '' ),
38
+ 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1' ),
39
+ 'limit' => array( '', '', '', '', '', '', '', '' ),
40
  ),
41
  "bol" => array(
42
  'mattributes' => array(
48
  'Cover Image URL',
49
  'Brand',
50
  ),
51
+ 'prefix' => array( '', '', '', '', '', '', '' ),
52
  'type' => array(
53
  'attribute',
54
  'attribute',
58
  'attribute',
59
  'pattern',
60
  ),
61
+ 'attributes' => array( 'sku', 'id', 'title', 'product_type', 'description', 'image', '' ),
62
+ 'default' => array( '', '', '', '', '', '', '' ),
63
+ 'suffix' => array( '', '', '', '', '', '', '' ),
64
+ 'output_type' => array( '1', '1', '1', '1', '2', '1', '' ),
65
+ 'limit' => array( '', '', '', '', '', '500', '5000' ),
66
  ),
67
  'adform' => array(
68
  'mattributes' => array(
73
  'product_image',
74
  'product_price',
75
  ),
76
+ 'prefix' => array( '', '', '', '', '', '' ),
77
+ 'type' => array( 'attribute', 'attribute', 'attribute', 'attribute', 'attribute', 'attribute' ),
78
+ 'attributes' => array( 'id', 'title', 'product_type', 'link', 'image', 'price' ),
79
+ 'default' => array( '', '', '', '', '', '' ),
80
+ 'suffix' => array( '', '', '', '', '', '' ),
81
+ 'output_type' => array( '1', '1', '1', '1', '1', '1' ),
82
+ 'limit' => array( '', '', '', '', '', '' ),
83
  ),
84
  'avantlink' => array(
85
  'mattributes' => array(
95
  'Sale Price',
96
  'UPC',
97
  ),
98
+ 'prefix' => array( '', '', '', '', '', '', '', '', '', '', '' ),
99
  'type' => array(
100
  'attribute',
101
  'attribute',
122
  'sale_price',
123
  '',
124
  ),
125
+ 'default' => array( '', '', '', '', '', '', '', '', '', '', '' ),
126
+ 'suffix' => array( '', '', '', '', '', '', '', '', '', '', '' ),
127
+ 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1' ),
128
+ 'limit' => array( '', '', '', '', '', '', '', '', '', '', '' ),
129
  ),
130
  'become' => array(
131
  'mattributes' => array(
139
  'Availability',
140
  'Current Price',
141
  ),
142
+ 'prefix' => array( '', '', '', '', '', '', '', '', '' ),
143
  'type' => array(
144
  'attribute',
145
  'attribute',
162
  'availability',
163
  'price',
164
  ),
165
+ 'default' => array( '', '', '', '', '', '', '', '', '' ),
166
+ 'suffix' => array( '', '', '', '', '', '', '', '', '' ),
167
+ 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1' ),
168
+ 'limit' => array( '', '', '', '', '', '', '', '', '' ),
169
  ),
170
  'bonanza' => array(
171
  'mattributes' => array(
365
  'Availability',
366
  'Current Price',
367
  ),
368
+ 'prefix' => array( '', '', '', '', '', '', '', '', '' ),
369
  'type' => array(
370
  'attribute',
371
  'attribute',
388
  'availability',
389
  'price',
390
  ),
391
+ 'default' => array( '', '', '', '', '', '', '', '', '' ),
392
+ 'suffix' => array( '', '', '', '', '', '', '', '', '' ),
393
+ 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1' ),
394
+ 'limit' => array( '', '', '', '', '', '', '', '', '' ),
395
  ),
396
  'criteo' => array(
397
  'mattributes' => array(
415
  'filters',
416
  'adult',
417
  ),
418
+ 'prefix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' ),
419
  'type' => array(
420
  'attribute',
421
  'attribute',
458
  '',
459
  '',
460
  ),
461
+ 'default' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' ),
462
+ 'suffix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' ),
463
  'output_type' => array(
464
  '1',
465
  '1',
520
  'sell_max',
521
  'shop_cat',
522
  ),
523
+ 'prefix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '' ),
524
  'type' => array(
525
  'attribute',
526
  'attribute',
553
  'quantity',
554
  'product_type',
555
  ),
556
+ 'default' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '' ),
557
+ 'suffix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '' ),
558
+ 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1' ),
559
+ 'limit' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '' ),
560
  ),
561
  'fruugo' => array(
562
  'mattributes' => array(
576
  'Currency',
577
  'Country',
578
  ),
579
+ 'prefix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' ),
580
  'type' => array(
581
  'attribute',
582
  'attribute',
611
  '',
612
  '',
613
  ),
614
+ 'default' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', 'USD', '' ),
615
+ 'suffix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' ),
616
+ 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1' ),
617
+ 'limit' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' ),
618
  ),
619
  'fruugo.au' => array(
620
  'mattributes' => array(
634
  'Currency',
635
  'Country',
636
  ),
637
+ 'prefix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' ),
638
  'type' => array(
639
  'attribute',
640
  'attribute',
669
  '',
670
  '',
671
  ),
672
+ 'default' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', 'USD', '' ),
673
+ 'suffix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' ),
674
+ 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1' ),
675
+ 'limit' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' ),
676
  ),
677
  'jet' => array(
678
  'mattributes' => array(
686
  'Jet Category',
687
  'Brand',
688
  ),
689
+ 'prefix' => array( '', '', '', '', '', '', '', '', '' ),
690
  'type' => array(
691
  'attribute',
692
  'attribute',
698
  'pattern',
699
  'pattern',
700
  ),
701
+ 'attributes' => array( 'sku', 'id', '', 'title', 'description', 'image', 'price', '', '' ),
702
+ 'default' => array( '', '', '', '', '', '', '', '', '' ),
703
+ 'suffix' => array( '', '', '', '', '', '', '', '', '' ),
704
+ 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1' ),
705
+ 'limit' => array( '', '', '', '', '', '', '', '', '' ),
706
  ),
707
  'kelkoo' => array(
708
  'mattributes' => array(
718
  'availability',
719
  'mpn',
720
  ),
721
+ 'prefix' => array( '', '', '', '', '', '', '', '', '', '', '' ),
722
  'type' => array(
723
  'attribute',
724
  'attribute',
745
  'availability',
746
  '',
747
  ),
748
+ 'default' => array( '', '', '', '', '', '', '', '', '', '', '' ),
749
+ 'suffix' => array( '', '', '', '', '', '', '', '', '', '', '' ),
750
+ 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1' ),
751
+ 'limit' => array( '', '', '', '', '', '', '', '', '', '', '' ),
752
  ),
753
  'kieskeurig.nl' => array(
754
  'mattributes' => array(
768
  'imagelink',
769
  'voorraad',
770
  ),
771
+ 'prefix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' ),
772
  'type' => array(
773
  'attribute',
774
  'attribute',
803
  'image',
804
  'quantity',
805
  ),
806
+ 'default' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' ),
807
+ 'suffix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' ),
808
+ 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1' ),
809
+ 'limit' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' ),
810
  ),
811
  'kijiji.ca' => array(
812
  'mattributes' => array(
819
  'categories',
820
  'brand',
821
  ),
822
+ 'prefix' => array( '', '', '', '', '', '', '', '' ),
823
  'type' => array(
824
  'attribute',
825
  'attribute',
830
  'attribute',
831
  'attribute',
832
  ),
833
+ 'attributes' => array( 'id', 'title', 'description', 'link', 'image', 'price', 'product_type', '' ),
834
+ 'default' => array( '', '', '', '', '', '', '', '' ),
835
+ 'suffix' => array( '', '', '', '', '', '', '', '' ),
836
+ 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1' ),
837
+ 'limit' => array( '', '', '', '', '', '', '', '' ),
838
  ),
839
  'leguide' => array(
840
  'mattributes' => array(
852
  'availability',
853
  'guarantee',
854
  ),
855
+ 'prefix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '' ),
856
  'type' => array(
857
  'attribute',
858
  'attribute',
883
  '',
884
  '',
885
  ),
886
+ 'default' => array( '', '', '', '', '', '', '', '', '', '', '', '', '' ),
887
+ 'suffix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '' ),
888
+ 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1' ),
889
+ 'limit' => array( '', '', '', '', '', '', '', '', '', '', '', '', '' ),
890
  ),
891
  'modina.de' => array(
892
  'mattributes' => array(
1088
  'InStock',
1089
  'MPN',
1090
  ),
1091
+ 'prefix' => array( '', '', '', '', '', '', '', '', '', '', '' ),
1092
  'type' => array(
1093
  'pattern',
1094
  'attribute',
1115
  '',
1116
  'sku',
1117
  ),
1118
+ 'default' => array( '', '', '', '', '', '', '', '', '', 'Y', '' ),
1119
+ 'suffix' => array( '', '', '', '', '', '', '', '', '', '', '' ),
1120
+ 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1' ),
1121
+ 'limit' => array( '', '', '', '', '', '', '', '', '', '', '' ),
1122
  ),
1123
  'nextag' => array(
1124
  'mattributes' => array(
1132
  'Stock Status',
1133
  'Condition',
1134
  ),
1135
+ 'prefix' => array( '', '', '', '$', '', '', '', '', '' ),
1136
  'type' => array(
1137
  'pattern',
1138
  'attribute',
1155
  'availability',
1156
  'condition',
1157
  ),
1158
+ 'default' => array( '', '', '', '', '', '', '', '', '' ),
1159
+ 'suffix' => array( '', '', '', '', '', '', '', '', '' ),
1160
+ 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1' ),
1161
+ 'limit' => array( '', '', '', '', '', '', '', '', '' ),
1162
  ),
1163
  'polyvore' => array(
1164
+ 'mattributes' => array( 'title', 'brand', 'url', 'imgurl', 'price', 'currency', 'description', 'subject' ),
1165
+ 'prefix' => array( '', '', '', '', '', '', '', '' ),
1166
  'type' => array(
1167
  'attribute',
1168
  'pattern',
1173
  'attribute',
1174
  'pattern',
1175
  ),
1176
+ 'attributes' => array( 'title', '', 'link', 'image', 'price', '', 'description', '' ),
1177
+ 'default' => array( '', '', '', '', '', 'USD', '', '' ),
1178
+ 'suffix' => array( '', '', '', '', '', '', '', '' ),
1179
+ 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1' ),
1180
+ 'limit' => array( '', '', '', '', '', '', '', '' ),
1181
  ),
1182
  'pricegrabber' => array(
1183
  'mattributes' => array(
1194
  'Manufacturer Name',
1195
  'GTIN',
1196
  ),
1197
+ 'prefix' => array( '', '', '', '', '', '', '', '', '', '', '', '' ),
1198
  'type' => array(
1199
  'attribute',
1200
  'attribute',
1223
  '',
1224
  '',
1225
  ),
1226
+ 'default' => array( '', '', '', '', '', '', '', '', '', '', '', '' ),
1227
+ 'suffix' => array( '', '', '', '', '', '', '', '', '', '', '', '' ),
1228
+ 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1' ),
1229
+ 'limit' => array( '', '', '', '', '', '', '', '', '', '', '', '' ),
1230
  ),
1231
  'pricerunner' => array(
1232
  'mattributes' => array(
1245
  'Shipping Cost',
1246
  'Delivery time',
1247
  ),
1248
+ 'prefix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '' ),
1249
  'type' => array(
1250
  'attribute',
1251
  'attribute',
1278
  '',
1279
  '',
1280
  ),
1281
+ 'default' => array( '', '', '', '', '', '', '', '', '', '', 'Yes', '', '10.00', '5-7 days' ),
1282
+ 'suffix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '' ),
1283
+ 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1' ),
1284
+ 'limit' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '' ),
1285
  ),
1286
  'prisjakt' => array(
1287
  'mattributes' => array(
1296
  'Bild-URL',
1297
  'Lagerstatus',
1298
  ),
1299
+ 'prefix' => array( '', '', '', '', '', '', '', '', '', '' ),
1300
  'type' => array(
1301
  'attribute',
1302
  'attribute',
1321
  'image',
1322
  'condition',
1323
  ),
1324
+ 'default' => array( '', '', '', '', '', '', '', '', 'mens, womens', '' ),
1325
+ 'suffix' => array( '', '', '', '', '', '', '', '', '', '' ),
1326
+ 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', '1' ),
1327
+ 'limit' => array( '', '', '', '', '', '', '', '', '', '' ),
1328
  ),
1329
  'real' => array(
1330
+ 'mattributes' => array( 'ean', 'category', 'title', 'description', 'picture', 'manufacturer' ),
1331
+ 'prefix' => array( '', '', '', '', '', '' ),
1332
+ 'type' => array( 'attribute', 'attribute', 'attribute', 'attribute', 'attribute', 'pattern' ),
1333
+ 'attributes' => array( 'sku', 'product_type', 'title', 'description', 'image', '' ),
1334
+ 'default' => array( '', '', '', '', '', '' ),
1335
+ 'suffix' => array( '', '', '', '', '', '' ),
1336
+ 'output_type' => array( '1', '1', '1', '1', '1', '1' ),
1337
+ 'limit' => array( '', '', '', '', '', '' ),
1338
  ),
1339
  'shareasale' => array(
1340
  'mattributes' => array(
1351
  'Subcategory',
1352
  'Description',
1353
  ),
1354
+ 'prefix' => array( '', '', '', '', '', '', '', '', '', '', '', '' ),
1355
  'type' => array(
1356
  'attribute',
1357
  'attribute',
1380
  '',
1381
  'description',
1382
  ),
1383
+ 'default' => array( '', '', '', '', '', '', '', '', '', '', '', '' ),
1384
+ 'suffix' => array( '', '', '', '', '', '', '', '', '', '', '', '' ),
1385
+ 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1' ),
1386
+ 'limit' => array( '8', '255', '8', '255', '255', '255', '255', '', '', '50', '50', '' ),
1387
  ),
1388
  'shopalike.fr' => array(
1389
  'mattributes' => array(
1396
  'categories',
1397
  'brand',
1398
  ),
1399
+ 'prefix' => array( '', '', '', '', '', '', '', '' ),
1400
  'type' => array(
1401
  'attribute',
1402
  'attribute',
1407
  'attribute',
1408
  'attribute',
1409
  ),
1410
+ 'attributes' => array( 'id', 'title', 'description', 'link', 'image', 'price', 'product_type', '' ),
1411
+ 'default' => array( '', '', '', '', '', '', '', '' ),
1412
+ 'suffix' => array( '', '', '', '', '', '', '', '' ),
1413
+ 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1' ),
1414
+ 'limit' => array( '', '', '', '', '', '', '', '' ),
1415
  ),
1416
  'shopbot' => array(
1417
  'mattributes' => array(
1432
  'Color',
1433
  'Product Type',
1434
  ),
1435
+ 'prefix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' ),
1436
  'type' => array(
1437
  'attribute',
1438
  'attribute',
1469
  '',
1470
  '',
1471
  ),
1472
+ 'default' => array( '', '', '', '', '', '', '', '', 'mens, womens', '', '', '', '', '', '', '' ),
1473
+ 'suffix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' ),
1474
+ 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1' ),
1475
+ 'limit' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' ),
1476
  ),
1477
  'shopmania' => array(
1478
  'mattributes' => array(
1490
  'Availability',
1491
  'GTIN',
1492
  ),
1493
+ 'prefix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '' ),
1494
  'type' => array(
1495
  'attribute',
1496
  'attribute',
1521
  'availability',
1522
  '',
1523
  ),
1524
+ 'default' => array( '', '', '', '', '', '', '', '', '', '', '', '', '' ),
1525
+ 'suffix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '' ),
1526
+ 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1' ),
1527
+ 'limit' => array( '', '', '', '', '', '', '', '', '', '', '', '', '' ),
1528
  ),
1529
  'shopping' => array(
1530
  'mattributes' => array(
1538
  'MPN',
1539
  'UPC',
1540
  ),
1541
+ 'prefix' => array( '', '', '', '', '', '', '', '', '' ),
1542
  'type' => array(
1543
  'attribute',
1544
  'attribute',
1550
  'attribute',
1551
  'attribute',
1552
  ),
1553
+ 'attributes' => array( 'sku', 'title', 'link', 'image', 'price', 'availability', 'condition', '', '' ),
1554
+ 'default' => array( '', '', '', '', '', '', '', '', '' ),
1555
+ 'suffix' => array( '', '', '', '', '', '', '', '', '' ),
1556
+ 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1' ),
1557
+ 'limit' => array( '', '', '', '', '', '', '', '', '' ),
1558
  ),
1559
  'shopzilla' => array(
1560
  'mattributes' => array(
1568
  'Availability',
1569
  'Current Price',
1570
  ),
1571
+ 'prefix' => array( '', '', '', '', '', '', '', '', '' ),
1572
  'type' => array(
1573
  'attribute',
1574
  'attribute',
1591
  'availability',
1592
  'price',
1593
  ),
1594
+ 'default' => array( '', '', '', '', '', '', '', '', '' ),
1595
+ 'suffix' => array( '', '', '', '', '', '', '', '', '' ),
1596
+ 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1' ),
1597
+ 'limit' => array( '', '', '', '', '', '', '', '', '' ),
1598
  ),
1599
  'spartoo.fi' => array(
1600
  'mattributes' => array(
2012
  'Delivery price',
2013
  'Service country code',
2014
  ),
2015
+ 'prefix' => array( '', '', '', '', '', '', '', '', '' ),
2016
  'type' => array(
2017
  'attribute',
2018
  'attribute',
2024
  'attribute',
2025
  'attribute',
2026
  ),
2027
+ 'attributes' => array( 'product_type', 'title', '', 'price', 'link', '', '', '', '' ),
2028
+ 'default' => array( '', '', '', '', '', '', '', '', '' ),
2029
+ 'suffix' => array( '', '', '', '', '', '', '', '', '' ),
2030
+ 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1' ),
2031
+ 'limit' => array( '', '', '', '', '', '', '', '', '' ),
2032
  ),
2033
  'walmart' => array(
2034
  'mattributes' => array(
2043
  'Price',
2044
  'Shipping Weight',
2045
  ),
2046
+ 'prefix' => array( '', '', '', '', '', '', '', '', '', '' ),
2047
  'type' => array(
2048
  'attribute',
2049
  'attribute',
2056
  'attribute',
2057
  'attribute',
2058
  ),
2059
+ 'attributes' => array( 'title', 'sku', '', '', 'id', '', 'description', '', 'price', '' ),
2060
+ 'default' => array( '', '', '', '', '', '', '', '', '', '' ),
2061
+ 'suffix' => array( '', '', '', '', '', '', '', '', '', '' ),
2062
+ 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', '1' ),
2063
+ 'limit' => array( '', '', '', '', '', '', '', '', '', '' ),
2064
  ),
2065
  'wish' => array(
2066
  'mattributes' => array(
2074
  'Unique ID/SKU',
2075
  'Description',
2076
  ),
2077
+ 'prefix' => array( '', '', '', '', '', '', '', '', '' ),
2078
  'type' => array(
2079
  'attribute',
2080
  'attribute',
2097
  'id',
2098
  'description',
2099
  ),
2100
+ 'default' => array( '', '', '', '', '', '', '', '', '' ),
2101
+ 'suffix' => array( '', '', '', '', '', '', '', '', '' ),
2102
+ 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1' ),
2103
+ 'limit' => array( '', '', '', '', '', '', '', '', '' ),
2104
  ),
2105
  'yahoo_nfa' => array(
2106
  'mattributes' => array(
2114
  'price',
2115
  'gtin',
2116
  ),
2117
+ 'prefix' => array( '', '', '', '', '', '', '', '', '' ),
2118
  'type' => array(
2119
  'attribute',
2120
  'attribute',
2137
  'price',
2138
  '',
2139
  ),
2140
+ 'default' => array( '', '', '', '', '', '', '', '', '' ),
2141
+ 'suffix' => array( '', '', '', '', '', '', '', '', '' ),
2142
+ 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1' ),
2143
+ 'limit' => array( '', '', '', '', '', '', '', '', '' ),
2144
  ),
2145
  'zap.co.il' => array(
2146
  'mattributes' => array(
2154
  'DELIVERY_TIME',
2155
  'IMAGE',
2156
  ),
2157
+ 'prefix' => array( '', '', '', '', '', '', '', '', '' ),
2158
  'type' => array(
2159
  'attribute',
2160
  'attribute',
2166
  'attribute',
2167
  'attribute',
2168
  ),
2169
+ 'attributes' => array( 'link', 'title', 'description', 'id', '', 'price', '', '', 'image' ),
2170
+ 'default' => array( '', '', '', '', '', '', '', '', '' ),
2171
+ 'suffix' => array( '', '', '', '', '', '', '', '', '' ),
2172
+ 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1' ),
2173
+ 'limit' => array( '', '', '', '', '', '', '', '', '' ),
2174
  ),
2175
  'adwords' => array(
2176
  'mattributes' => array(
2187
  'Contextual keywords',
2188
  'Item address',
2189
  ),
2190
+ 'prefix' => array( '', '', '', '', '', '', '', '', '', '', '', '' ),
2191
  'type' => array(
2192
  'attribute',
2193
  'attribute',
2216
  '',
2217
  '',
2218
  ),
2219
+ 'default' => array( '', '', '', '', '', '', '', '', '', '', '', '' ),
2220
+ 'suffix' => array( '', '', '', '', '', '', '', '', '', '', '', '' ),
2221
+ 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1' ),
2222
+ 'limit' => array( '', '', '', '', '', '', '', '', '', '', '', '' ),
2223
  ),
2224
  'bing' => array(
2225
+ 'mattributes' => array( 'id', 'title', 'link', 'price', 'description', 'image_link', 'shipping' ),
2226
+ 'prefix' => array( '', '', '', '', '', '', '' ),
2227
  'type' => array(
2228
  'attribute',
2229
  'attribute',
2233
  'attribute',
2234
  'attribute',
2235
  ),
2236
+ 'attributes' => array( 'id', 'title', 'link', 'price', 'description', 'image', '' ),
2237
+ 'default' => array( '', '', '', '', '', '', '' ),
2238
+ 'suffix' => array( '', '', '', '', '', '', '' ),
2239
+ 'output_type' => array( '1', '1', '1', '1', '1', '1', '1' ),
2240
+ 'limit' => array( '', '', '', '', '', '', '' ),
2241
  ),
2242
  'google_local_inventory' => array(
2243
  'mattributes' => array(
2251
  'pickup method',
2252
  'pickup sla',
2253
  ),
2254
+ 'prefix' => array( '', '', '', '', '', '', '', '', '' ),
2255
  'type' => array(
2256
  'pattern',
2257
  'attribute',
2274
  '',
2275
  '',
2276
  ),
2277
+ 'default' => array( ' ', '', '', '', '', '', '', '', '' ),
2278
+ 'suffix' => array( '', '', '', '', '', '', '', '', '' ),
2279
+ 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1' ),
2280
+ 'limit' => array( '', '', '', '', '', '', '', '', '' ),
2281
  ),
2282
  'google_local' => array(
2283
  'mattributes' => array(
2525
  'Unit price',
2526
  'Energy efficiency rating',
2527
  ),
2528
+ 'prefix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' ),
2529
  'type' => array(
2530
  'attribute',
2531
  'attribute',
2564
  '',
2565
  '',
2566
  ),
2567
+ 'default' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' ),
2568
+ 'suffix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' ),
2569
  'output_type' => array(
2570
  '1',
2571
  '1',
2585
  '1',
2586
  '1',
2587
  ),
2588
+ 'limit' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' ),
2589
  ),
2590
  'pricespy' => array(
2591
  'mattributes' => array(
2600
  'image-URL',
2601
  'stock status',
2602
  ),
2603
+ 'prefix' => array( '', '', '', '', '', '', '', '', '', '' ),
2604
  'type' => array(
2605
  'attribute',
2606
  'attribute',
2625
  'image',
2626
  'condition',
2627
  ),
2628
+ 'default' => array( '', '', '', '', '', '', '', '', 'mens, womens', '' ),
2629
+ 'suffix' => array( '', '', '', '', '', '', '', '', '', '' ),
2630
+ 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', '1' ),
2631
+ 'limit' => array( '', '', '', '', '', '', '', '', '', '' ),
2632
  ),
2633
  'yandex_csv' => array(
2634
  'mattributes' => array(
2641
  'name',
2642
  'description',
2643
  ),
2644
+ 'prefix' => array( '', '', '', '', '', '', '', '' ),
2645
  'type' => array(
2646
  'attribute',
2647
  'attribute',
2662
  'title',
2663
  'description',
2664
  ),
2665
+ 'default' => array( '', '', '', 'RUR', '', '', '', '' ),
2666
+ 'suffix' => array( '', '', '', '', '', '', '', '' ),
2667
+ 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1' ),
2668
+ 'limit' => array( '', '', '', '', '', '', '', '' ),
2669
  ),
2670
  'fyndiq.se' => array(
2671
  'mattributes' => array(
2683
  'article-quantity',
2684
  'article-name',
2685
  ),
2686
+ 'prefix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '' ),
2687
  'type' => array(
2688
  'attribute',
2689
  'attribute',
2714
  'quantity',
2715
  '',
2716
  ),
2717
+ 'default' => array( '', '', '', '', 'USD', '', '', '', '', '', '', '', '' ),
2718
+ 'suffix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '' ),
2719
+ 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1' ),
2720
+ 'limit' => array( '', '', '', '', '', '', '', '', '', '', '', '', '' ),
2721
  ),
2722
  'miinto.nl' => array(
2723
  'mattributes' => array(
2737
  'washing',
2738
  'retail_price_currencyCode',
2739
  ),
2740
+ 'prefix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' ),
2741
  'type' => array(
2742
  'attribute',
2743
  'attribute',
2772
  '',
2773
  '',
2774
  ),
2775
+ 'default' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' ),
2776
+ 'suffix' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' ),
2777
+ 'output_type' => array( '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1' ),
2778
+ 'limit' => array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' ),
2779
  ),
2780
  );
2781
 
2821
  "video" => "https://youtu.be/PTUYgF7DwEo",
2822
  "feed_file_type" => array( "XML", "CSV", "TXT" ),
2823
  "doc" => array(
2824
+ "How to make google merchant feed?" => "http://bit.ly/355q0jY",
2825
+ "How to configure shipping info?" => "http://bit.ly/2Rzr0sI",
2826
+ "How to set price with tax?" => "http://bit.ly/2PuzWga",
2827
+ "How to solve micro data error?" => "http://bit.ly/345nIQz",
2828
  "How to configure google product categories?" => "http://bit.ly/2RFWRrP",
2829
  ),
2830
  ),
2985
  */
2986
  public function getInfo( $merchant = '' ) {
2987
  $infos = $this->merchantInfo();
2988
+ $info = ( isset( $infos[ $merchant ] ) && ! empty( $infos[ $merchant ] ) ) ? $infos[ $merchant ] : [];
2989
  /**
2990
  * Filter single merchant data before retrieve
2991
  * @param array $info
includes/classes/class-woo-feed-products-v3.php CHANGED
@@ -24,7 +24,7 @@ class Woo_Feed_Products_v3 {
24
  'tax_country',
25
  'tax_region',
26
  'tax_rate',
27
- 'tax_ship'
28
  );
29
  private $product_types = array(
30
  'simple',
@@ -55,9 +55,9 @@ class Woo_Feed_Products_v3 {
55
 
56
  public function __construct( $config ) {
57
  $this->config = $config;
58
- $this->queryType=get_option('woo_feed_product_query_type');
59
- if(empty($this->queryType)){
60
- $this->queryType='wc';
61
  }
62
  }
63
 
@@ -123,13 +123,13 @@ class Woo_Feed_Products_v3 {
123
  */
124
  public function query_products() {
125
  $products = [];
126
- if($this->queryType=='wc'){
127
  $products = $this->get_wc_query_products();
128
- }elseif ($this->queryType=='wp'){
129
  $products = $this->get_wp_query_products();
130
- }elseif ($this->queryType=='both'){
131
- $wc=$this->get_wc_query_products();
132
- $wp=$this->get_wp_query_products();
133
  $products = array_unique(array_merge($wc,$wp));
134
  }
135
  return $products;
@@ -197,40 +197,40 @@ class Woo_Feed_Products_v3 {
197
  }
198
 
199
  # Unique Merchant Attributes
200
- $mAttributes=array();
201
  # Get Product Attribute values by type and assign to product array
202
  foreach ( $this->config['attributes'] as $attr_key => $attribute ) {
203
 
204
  # Continue for Google Shipping and Tax attributes
205
  $skipFor = array( 'google', 'facebook' );
206
  if ( $this->config['feedType'] == 'xml'
207
- && in_array( $this->config['mattributes'][$attr_key], $this->google_shipping_tax )
208
  && in_array( $this->config['provider'], $skipFor ) ) {
209
  continue;
210
  }
211
 
212
- if( in_array( $this->config['mattributes'][ $attr_key ],$mAttributes ) ){
213
  continue;
214
  }
215
 
216
- if ( $this->config['type'][$attr_key] == "pattern" ) {
217
- $attributeValue = $this->config['default'][$attr_key];
218
  } else { # Get Pattern value
219
  $attributeValue = $this->getAttributeValueByType($product, $attribute);
220
  }
221
 
222
  # Format Output according to Output Type config
223
- $outputType = $this->config['output_type'][$attr_key];
224
- if ($outputType != "default" && !empty($attributeValue)) {
225
  $attributeValue = $this->format_output($attributeValue, $outputType);
226
  }
227
 
228
 
229
  # Limit Output
230
- $limit = $this->config['limit'][$attr_key];
231
- if (!empty($limit) && is_numeric($limit)) {
232
- if (strpos($attributeValue, "<![CDATA[") !== false) {
233
- $attributeValue = str_replace(array("<![CDATA[", "]]>"), array("", ""), $attributeValue);
234
  $attributeValue = substr($attributeValue, 0, $limit);
235
  $attributeValue = '<![CDATA[' . $attributeValue . ']]>';
236
  } else {
@@ -258,8 +258,8 @@ class Woo_Feed_Products_v3 {
258
  # XML does not support space in node. So replace Space with Underscore
259
  $getReplacedAttribute = str_replace( " ", "_", $getReplacedAttribute );
260
 
261
- if(!empty($attributeValue)){
262
- $attributeValue=trim($attributeValue);
263
  }
264
 
265
  # Add closing XML node if value is empty
@@ -269,7 +269,7 @@ class Woo_Feed_Products_v3 {
269
 
270
  #TODO Move to proper place
271
  # Replace Google Color attribute value according to requirements
272
- if ($getReplacedAttribute == 'g:color') {
273
  $attributeValue = str_replace( ", ", "/", $attributeValue );
274
  }
275
 
@@ -282,27 +282,26 @@ class Woo_Feed_Products_v3 {
282
  } else {
283
  $this->feedBody .= "<" . $getReplacedAttribute . "/>";
284
  $this->feedBody .= "\n";
285
- }
286
-
287
- } else if ( $this->config['feedType'] == 'csv' ) {
288
  $pluginAttribute = woo_feed_replace_to_merchant_attribute( $pluginAttribute, $merchant, $feedType );
289
  $pluginAttribute = $this->processStringForCSV( $pluginAttribute );
290
  $attributeValue = $this->processStringForCSV( $attributeValue );
291
- } else if ( $this->config['feedType'] == 'txt' ) {
292
  $pluginAttribute = woo_feed_replace_to_merchant_attribute( $pluginAttribute, $merchant, $feedType );
293
  $pluginAttribute = $this->processStringForTXT( $pluginAttribute );
294
  $attributeValue = $this->processStringForTXT( $attributeValue );
295
  }
296
 
297
- $mAttributes[$attr_key]=$this->config['mattributes'][ $attr_key ];
298
  $this->products[ $this->pi ][ $pluginAttribute ] = $attributeValue;
299
  }
300
 
301
  # Process feed data for uncommon merchant feed like Google,Facebook,Pinterest
302
  $this->process_for_merchant($product, $this->pi);
303
 
304
- if ($this->config['feedType'] == 'xml') {
305
- if (empty($this->feedHeader)) {
306
  $this->feedHeader = $this->process_xml_feed_header();
307
  $this->feedFooter = $this->process_xml_feed_footer();
308
 
@@ -311,13 +310,13 @@ class Woo_Feed_Products_v3 {
311
  $this->feedBody .= "</" . $this->config['itemWrapper'] . ">";
312
 
313
 
314
- } else if ($this->config['feedType'] == 'txt') {
315
- if (empty($this->feedHeader)) {
316
  $this->process_txt_feed_header();
317
  }
318
  $this->process_txt_feed_body();
319
  } else {
320
- if (empty($this->feedHeader)) {
321
  $this->process_csv_feed_header();
322
  }
323
  $this->process_csv_feed_body();
@@ -348,18 +347,17 @@ class Woo_Feed_Products_v3 {
348
  * @param $index | Product Index
349
  */
350
 
351
- private function process_for_merchant($productObj, $index)
352
- {
353
- $product = $this->products[$index];
354
  $merchantAttributes = $this->config['mattributes'];
355
 
356
  # Debug Here
357
  # echo "<pre>";print_r($product);print_r($merchantAttributes);die();
358
 
359
  # Format Shipping and Tax data for CSV and TXT feed only for google and facebook
360
- if ($this->config['provider'] == 'google'
361
  || $this->config['provider'] == 'facebook'
362
- && $this->config['feedType'] != 'xml') {
363
 
364
  $shipping = array();
365
  $tax = array();
@@ -375,76 +373,76 @@ class Woo_Feed_Products_v3 {
375
  'tax_rate',
376
  'tax_ship',
377
  );
378
- foreach ($this->products[$this->pi] as $attribute => $value) {
379
- if (in_array($attribute, $shippingAttr)) {
380
 
381
- if ($attribute == "tax_country") {
382
  $t++;
383
- $tax[$t] .= $value . ":";
384
- } else if ($attribute == "tax_region") {
385
- $tax[$t] .= $value . ":";
386
- } else if ($attribute == "tax_rate") {
387
- $tax[$t] .= $value . ":";
388
- } else if ($attribute == "tax_ship") {
389
- $tax[$t] .= $value . ":";
390
  }
391
 
392
- if ($attribute == "shipping_country") {
393
  $s++;
394
- $shipping[$s] .= $value . ":";
395
- } else if ($attribute == "shipping_service") {
396
- $shipping[$s] .= $value . ":";
397
- } else if ($attribute == "shipping_price") {
398
- $shipping[$s] .= $value . ":";
399
- } else if ($attribute == "shipping_region") {
400
- $shipping[$s] .= $value . ":";
401
  }
402
 
403
- unset($this->products[$this->pi][$attribute]);
404
  }
405
  }
406
 
407
- foreach ($shipping as $key => $val) {
408
- $this->products[$this->pi]['shipping(country:region:service:price)'] = $val;
409
  }
410
 
411
- foreach ($tax as $key => $val) {
412
- $this->products[$this->pi]['tax(country:region:rate:tax_ship)'] = $val;
413
  }
414
  }
415
 
416
- if ($this->config['provider'] == 'google') {
417
 
418
  # Reformat Shipping attributes for google, facebook
419
  $s = 0;
420
  $t = 0;
421
  $tax = "";
422
  $shipping = "";
423
- if ($this->config['feedType'] == 'xml') {
424
- foreach ($merchantAttributes as $key => $value) {
425
 
426
- if (!in_array($value, $this->google_shipping_tax)) {
427
  continue;
428
  }
429
 
430
- $prefix = $this->config['prefix'][$key];
431
- $suffix = $this->config['suffix'][$key];
432
 
433
- if ($this->config['type'][$key] == "pattern") {
434
- $output = $this->config['default'][$key];
435
  } else { # Get Pattern value
436
- $attribute = $this->config['attributes'][$key];
437
  $output = $this->getAttributeValueByType($productObj, $attribute);
438
  }
439
 
440
- if (strpos($value, "price") !== false || strpos($value, "rate") !== false) {
441
  $suffix = " " . $suffix;
442
  }
443
 
444
 
445
  $output = $prefix . $output . $suffix;
446
 
447
- if ( $value == "shipping_country") {
448
  if ( $s == 0 ) {
449
  $shipping .= "<g:shipping>";
450
  $s = 1;
@@ -452,7 +450,7 @@ class Woo_Feed_Products_v3 {
452
  $shipping .= "</g:shipping>" . "\n";
453
  $shipping .= "<g:shipping>";
454
  }
455
- }elseif (!in_array("shipping_country",$merchantAttributes) && $value == "shipping_price"){
456
  if ( $s == 0 ) {
457
  $shipping .= "<g:shipping>";
458
  $s = 1;
@@ -462,16 +460,16 @@ class Woo_Feed_Products_v3 {
462
  }
463
  }
464
 
465
- if ($value == "shipping_country") {
466
  $shipping .= "<g:country>" . $output . "</g:country>" . "\n";
467
- } else if ($value == "shipping_region") {
468
  $shipping .= "<g:region>" . $output . "</g:region>" . "\n";
469
- } else if ($value == "shipping_service") {
470
  $shipping .= "<g:service>" . $output . "</g:service>" . "\n";
471
- } else if ($value == "shipping_price") {
472
  $shipping .= "<g:price>" . $output . "</g:price>" . "\n";
473
- } else if ($value == "tax_country") {
474
- if ($t == 0) {
475
  $tax .= "<g:tax>";
476
  $t = 1;
477
  } else {
@@ -479,19 +477,19 @@ class Woo_Feed_Products_v3 {
479
  $tax .= "<g:tax>";
480
  }
481
  $tax .= "<g:country>" . $output . "</g:country>" . "\n";
482
- } else if ($value == "tax_region") {
483
  $tax .= "<g:region>" . $output . "</g:region>" . "\n";
484
- } else if ($value == "tax_rate") {
485
  $tax .= "<g:rate>" . $output . "</g:rate>" . "\n";
486
- } else if ($value == "tax_ship") {
487
  $tax .= "<g:tax_ship>" . $output . "</g:tax_ship>" . "\n";
488
  }
489
  }
490
 
491
- if ($s == 1) {
492
  $shipping .= "</g:shipping>";
493
  }
494
- if ($t == 1) {
495
  $tax .= "</g:tax>";
496
  }
497
 
@@ -501,42 +499,41 @@ class Woo_Feed_Products_v3 {
501
  }
502
 
503
  # ADD g:identifier_exists
504
- if ($this->config['provider'] == 'google') {
505
- $identifier = array('brand', 'upc', 'sku', 'mpn', 'gtin');
506
  $countIdentifier = 0;
507
- if (!in_array('identifier_exists', $merchantAttributes)) {
508
- if (count(array_intersect_key(array_flip($identifier), $product)) >= 2) {
509
  # Any 2 required keys exist!
510
  //@TODO Refactor with OR
511
- if (array_key_exists('brand', $product) && !empty($product['brand'])) {
512
  $countIdentifier++;
513
  }
514
- if (array_key_exists('upc', $product) && !empty($product['upc'])) {
515
  $countIdentifier++;
516
  }
517
- if (array_key_exists('sku', $product) && !empty($product['sku'])) {
518
  $countIdentifier++;
519
  }
520
- if (array_key_exists('mpn', $product) && !empty($product['mpn'])) {
521
  $countIdentifier++;
522
  }
523
- if (array_key_exists('gtin', $product) && !empty($product['gtin'])) {
524
  $countIdentifier++;
525
- }
526
-
527
- }
528
 
529
- if ($this->config['feedType'] == 'xml') {
530
- if ($countIdentifier >= 2) {
531
  $this->feedBody .= "<g:identifier_exists>yes</g:identifier_exists>";
532
  } else {
533
  $this->feedBody .= "<g:identifier_exists>no</g:identifier_exists>";
534
  }
535
  } else {
536
- if ($countIdentifier >= 2) {
537
- $this->products[$this->pi]['identifier exists'] = "yes";
538
  } else {
539
- $this->products[$this->pi]['identifier exists'] = "no";
540
  }
541
  }
542
  }
@@ -550,21 +547,20 @@ class Woo_Feed_Products_v3 {
550
  *
551
  * @return string
552
  */
553
- private function process_txt_feed_header()
554
- {
555
  # Set Delimiter
556
- if ($this->config['delimiter'] == 'tab') {
557
  $this->delimiter = "\t";
558
  } else {
559
  $this->delimiter = $this->config['delimiter'];
560
  }
561
 
562
  # Set Enclosure
563
- if (!empty($this->config['enclosure'])) {
564
  $this->enclosure = $this->config['enclosure'];
565
- if ($this->enclosure == 'double') {
566
  $this->enclosure = '"';
567
- } elseif ($this->enclosure == 'single') {
568
  $this->enclosure = "'";
569
  } else {
570
  $this->enclosure = "";
@@ -573,7 +569,7 @@ class Woo_Feed_Products_v3 {
573
  $this->enclosure = "";
574
  }
575
 
576
- $product = $this->products[$this->pi];
577
  $headers = array_keys($product);
578
  $this->feedHeader .= $this->enclosure . implode("$this->enclosure$this->delimiter$this->enclosure", $headers) . $this->enclosure . "\n";
579
 
@@ -587,9 +583,8 @@ class Woo_Feed_Products_v3 {
587
  *
588
  * @return string
589
  */
590
- private function process_txt_feed_body()
591
- {
592
- $product = $this->products[$this->pi];
593
  $productInfo = array_values($product);
594
  $this->feedBody .= $this->enclosure . implode("$this->enclosure$this->delimiter$this->enclosure", $productInfo) . $this->enclosure . "\n";
595
 
@@ -603,21 +598,20 @@ class Woo_Feed_Products_v3 {
603
  *
604
  * @return array
605
  */
606
- private function process_csv_feed_header()
607
- {
608
  # Set Delimiter
609
- if ($this->config['delimiter'] == 'tab') {
610
  $this->delimiter = "\t";
611
  } else {
612
  $this->delimiter = $this->config['delimiter'];
613
  }
614
 
615
  # Set Enclosure
616
- if (!empty($this->config['enclosure'])) {
617
  $this->enclosure = $this->config['enclosure'];
618
- if ($this->enclosure == 'double') {
619
  $this->enclosure = '"';
620
- } elseif ($this->enclosure == 'single') {
621
  $this->enclosure = "'";
622
  } else {
623
  $this->enclosure = "";
@@ -626,7 +620,7 @@ class Woo_Feed_Products_v3 {
626
  $this->enclosure = "";
627
  }
628
 
629
- $product = $this->products[$this->pi];
630
  $this->feedHeader = array_keys($product);
631
 
632
  return $this->feedHeader;
@@ -637,9 +631,8 @@ class Woo_Feed_Products_v3 {
637
  * @since 3.2.0
638
  * @return array
639
  */
640
- private function process_csv_feed_body()
641
- {
642
- $product = $this->products[$this->pi];
643
  $this->feedBody[] = array_values($product);
644
 
645
  return $this->feedBody;
@@ -650,10 +643,9 @@ class Woo_Feed_Products_v3 {
650
  * @since 3.2.0
651
  * @return string
652
  */
653
- private function process_xml_feed_header()
654
- {
655
  $datetime_now = date("Y-m-d H:i:s");
656
- if ($this->config["provider"] == 'fruugo.au') {
657
  $fruugo_au = "<products version=\"1.0\" standalone=\"yes\">
658
  <datetime>$datetime_now</datetime>
659
  <title>" . get_bloginfo('name') . "</title>
@@ -661,7 +653,7 @@ class Woo_Feed_Products_v3 {
661
  <description>" . get_bloginfo('description') . "</description>";
662
 
663
  return $fruugo_au;
664
- } else if ($this->config['provider'] == 'zap.co.il') {
665
  $zap = "<STORE>
666
  <datetime>$datetime_now</datetime>
667
  <title>" . get_bloginfo('name') . "</title>
@@ -671,81 +663,81 @@ class Woo_Feed_Products_v3 {
671
  <email>" . get_bloginfo('admin_email') . "</email>";
672
 
673
  return $zap;
674
- } else if ($this->config['provider'] == 'myshopping.com.au') {
675
  return "<productset>";
676
- } else if ($this->config['provider'] == 'stylight.com') {
677
  return "<products version=\"1.0\" standalone=\"yes\">
678
  <datetime>$datetime_now</datetime>
679
  <title>" . get_bloginfo('name') . "</title>
680
  <link>" . get_bloginfo('url') . "</link>
681
  <description>" . get_bloginfo('description') . "</description>";
682
- } else if ($this->config['provider'] == 'nextad') {
683
  return "<products version=\"1.0\" standalone=\"yes\">
684
  <datetime>$datetime_now</datetime>
685
  <title>" . get_bloginfo('name') . "</title>
686
  <link>" . get_bloginfo('url') . "</link>
687
  <description>" . get_bloginfo('description') . "</description>";
688
- } else if ($this->config['provider'] == 'skinflint.co.uk') {
689
  return "<products version=\"1.0\" standalone=\"yes\">
690
  <datetime>$datetime_now</datetime>
691
  <title>" . get_bloginfo('name') . "</title>
692
  <link>" . get_bloginfo('url') . "</link>
693
  <description>" . get_bloginfo('description') . "</description>";
694
- } else if ($this->config['provider'] == 'comparer.be') {
695
  return "<products version=\"1.0\" standalone=\"yes\">
696
  <datetime>$datetime_now</datetime>
697
  <title>" . get_bloginfo('name') . "</title>
698
  <link>" . get_bloginfo('url') . "</link>
699
  <description>" . get_bloginfo('description') . "</description>";
700
- } else if ($this->config['provider'] == 'dooyoo') {
701
  return "<products version=\"1.0\" standalone=\"yes\">
702
  <datetime>$datetime_now</datetime>
703
  <title>" . get_bloginfo('name') . "</title>
704
  <link>" . get_bloginfo('url') . "</link>
705
  <description>" . get_bloginfo('description') . "</description>";
706
- } else if ($this->config['provider'] == 'hintaseuranta.fi') {
707
  return "<products version=\"1.0\" standalone=\"yes\">
708
  <datetime>$datetime_now</datetime>
709
  <title>" . get_bloginfo('name') . "</title>
710
  <link>" . get_bloginfo('url') . "</link>
711
  <description>" . get_bloginfo('description') . "</description>";
712
- } else if ($this->config['provider'] == 'incurvy') {
713
  return "<products version=\"1.0\" standalone=\"yes\">
714
  <datetime>$datetime_now</datetime>
715
  <title>" . get_bloginfo('name') . "</title>
716
  <link>" . get_bloginfo('url') . "</link>
717
  <description>" . get_bloginfo('description') . "</description>";
718
- } else if ($this->config['provider'] == 'kijiji.ca') {
719
  return "<products version=\"1.0\" standalone=\"yes\">
720
  <datetime>$datetime_now</datetime>
721
  <title>" . get_bloginfo('name') . "</title>
722
  <link>" . get_bloginfo('url') . "</link>
723
  <description>" . get_bloginfo('description') . "</description>";
724
- } else if ($this->config['provider'] == 'marktplaats.nl') {
725
  return "<products version=\"1.0\" standalone=\"yes\">
726
  <datetime>$datetime_now</datetime>
727
  <title>" . get_bloginfo('name') . "</title>
728
  <link>" . get_bloginfo('url') . "</link>
729
  <description>" . get_bloginfo('description') . "</description>";
730
- } else if ($this->config['provider'] == 'rakuten.de') {
731
  return "<products version=\"1.0\" standalone=\"yes\">
732
  <datetime>$datetime_now</datetime>
733
  <title>" . get_bloginfo('name') . "</title>
734
  <link>" . get_bloginfo('url') . "</link>
735
  <description>" . get_bloginfo('description') . "</description>";
736
- } else if ($this->config['provider'] == 'shopalike.fr') {
737
  return "<products version=\"1.0\" standalone=\"yes\">
738
  <datetime>$datetime_now</datetime>
739
  <title>" . get_bloginfo('name') . "</title>
740
  <link>" . get_bloginfo('url') . "</link>
741
  <description>" . get_bloginfo('description') . "</description>";
742
- } else if ($this->config['provider'] == 'spartoo.fi') {
743
  return "<products version=\"1.0\" standalone=\"yes\">
744
  <datetime>$datetime_now</datetime>
745
  <title>" . get_bloginfo('name') . "</title>
746
  <link>" . get_bloginfo('url') . "</link>
747
  <description>" . get_bloginfo('description') . "</description>";
748
- } else if ($this->config['provider'] == 'webmarchand') {
749
  return "<products version=\"1.0\" standalone=\"yes\">
750
  <datetime>$datetime_now</datetime>
751
  <title>" . get_bloginfo('name') . "</title>
@@ -753,14 +745,14 @@ class Woo_Feed_Products_v3 {
753
  <description>" . get_bloginfo('description') . "</description>";
754
  } else {
755
  $wrapper = $this->config['itemsWrapper'];
756
- $extraHeader = $this->config['extraHeader'];
757
 
758
  $output = '<?xml version="1.0" encoding="UTF-8" ?>';
759
  $output .= "\n";
760
  $output .= '<' . $wrapper . '>';
761
 
762
  // $output .= "\n";
763
- if (!empty($extraHeader)) {
764
  //$output .= $extraHeader;
765
  //$output .= "\n";
766
  }
@@ -774,9 +766,8 @@ class Woo_Feed_Products_v3 {
774
  * @since 3.2.0
775
  * @return string
776
  */
777
- private function process_xml_feed_footer()
778
- {
779
- if (in_array($this->config['provider'], [
780
  'fruugo.au',
781
  'stylight.com',
782
  'nextad',
@@ -790,12 +781,12 @@ class Woo_Feed_Products_v3 {
790
  'rakuten.de',
791
  'shopalike.fr',
792
  'spartoo.fi',
793
- 'webmarchand'
794
- ])) {
795
  return "</products>";
796
- } else if ($this->config['provider'] == 'zap.co.il') {
797
  return "</STORE>";
798
- } else if ($this->config['provider'] == 'myshopping.com.au') {
799
  return "</productset>";
800
  } else {
801
  $wrapper = $this->config['itemsWrapper'];
@@ -814,12 +805,11 @@ class Woo_Feed_Products_v3 {
814
  *
815
  * @return mixed|string
816
  */
817
- private function processStringForTXT($string)
818
- {
819
- if (!empty($string)) {
820
  $string = html_entity_decode($string, ENT_HTML401 | ENT_QUOTES); // Convert any HTML entities
821
 
822
- if (stristr($string, '"')) {
823
  $string = str_replace('"', '""', $string);
824
  }
825
  $string = str_replace("\n", ' ', $string);
@@ -829,7 +819,7 @@ class Woo_Feed_Products_v3 {
829
  $string = stripslashes($string);
830
 
831
  return $string;
832
- } else if ($string == "0") {
833
  return "0";
834
  } else {
835
  return "";
@@ -844,16 +834,15 @@ class Woo_Feed_Products_v3 {
844
  *
845
  * @return mixed|string
846
  */
847
- private function processStringForCSV($string)
848
- {
849
- if (!empty($string)) {
850
  $string = str_replace("\n", ' ', $string);
851
  $string = str_replace("\r", ' ', $string);
852
  $string = trim($string);
853
  $string = stripslashes($string);
854
 
855
  return $string;
856
- } else if ($string == "0") {
857
  return "0";
858
  } else {
859
  return "";
@@ -869,35 +858,34 @@ class Woo_Feed_Products_v3 {
869
  *
870
  * @return mixed|string
871
  */
872
- public function getAttributeValueByType($product, $attribute)
873
- {
874
  # Set call_user_func_array parameters
875
- $params = array($product);
876
- $method = array($this, $attribute);
877
 
878
- if (method_exists($this, $attribute)) {
879
 
880
  return call_user_func_array($method, $params);
881
 
882
- } else if (strpos($attribute, self::PRODUCT_ATTRIBUTE_PREFIX) !== false) {
883
 
884
  return $this->getProductAttribute($product, $attribute);
885
 
886
- } else if (strpos($attribute, self::POST_META_PREFIX) !== false) {
887
 
888
  return $this->getProductMeta($product, $attribute);
889
 
890
- } else if (strpos($attribute, self::PRODUCT_TAXONOMY_PREFIX) !== false) {
891
 
892
  return $this->getProductTaxonomy($product, $attribute);
893
 
894
- } else if (substr($attribute, 0, 6) == "image_") {
895
 
896
  # For additional image method images() will be used with extra parameter - image number
897
  $imageKey = explode("_", $attribute);
898
  $params[] = $imageKey[1];
899
  $attribute = "images";
900
- $method = array($this, $attribute);
901
 
902
  return call_user_func_array($method, $params);
903
  } else {
@@ -914,8 +902,7 @@ class Woo_Feed_Products_v3 {
914
  * @since 3.2.0
915
  * @return mixed
916
  */
917
- private function id($product)
918
- {
919
  return $product->get_id();
920
  }
921
 
@@ -927,8 +914,7 @@ class Woo_Feed_Products_v3 {
927
  *
928
  * @return mixed
929
  */
930
- private function title($product)
931
- {
932
  return $product->get_name();
933
  }
934
 
@@ -940,12 +926,12 @@ class Woo_Feed_Products_v3 {
940
  *
941
  * @return mixed
942
  */
943
- private function yoast_wpseo_title($product) {
944
  $title = "";
945
- if (class_exists('WPSEO_Frontend')) {
946
  $title = WPSEO_Frontend::get_instance()->get_seo_title(get_post($product->get_id()));
947
  }
948
- if (!empty($title)) {
949
  return $title;
950
  }
951
 
@@ -965,7 +951,7 @@ class Woo_Feed_Products_v3 {
965
  if ( class_exists( 'All_in_One_SEO_Pack' ) ) {
966
  global $aioseop_options, $aiosp;
967
  $selfLoadAIOSP = false;
968
- if( ! is_array( $aioseop_options ) ) $aioseop_options = get_option( 'aioseop_options' );
969
  if ( ! ( $aiosp instanceof All_in_One_SEO_Pack ) ) {
970
  $aiosp = new All_in_One_SEO_Pack();
971
  $selfLoadAIOSP = true;
@@ -994,21 +980,21 @@ class Woo_Feed_Products_v3 {
994
  *
995
  * @return mixed|string
996
  */
997
- private function description($product) {
998
 
999
  $description = $product->get_description();
1000
 
1001
  # Get Variation Description
1002
- if ($product->is_type('variation') && empty($description)) {
1003
  $parent = wc_get_product($product->get_parent_id());
1004
  $description = $parent->get_description();
1005
  }
1006
  $description = $this->remove_short_codes($description);
1007
 
1008
  # Add variations attributes after description to prevent Facebook error
1009
- if ($this->config['provider'] == 'facebook') {
1010
  $variationInfo = explode("-", $product->get_name());
1011
- if (isset($variationInfo[1])) {
1012
  $extension = $variationInfo[1];
1013
  } else {
1014
  $extension = $product->get_id();
@@ -1027,12 +1013,12 @@ class Woo_Feed_Products_v3 {
1027
  *
1028
  * @return mixed
1029
  */
1030
- private function yoast_wpseo_metadesc($product) {
1031
  $description = "";
1032
- if (class_exists('WPSEO_Frontend')) {
1033
  $description = wpseo_replace_vars(WPSEO_Meta::get_value('metadesc', $product->get_id()), get_post($product->get_id()));
1034
  }
1035
- if (!empty($description)) {
1036
  return $description;
1037
  }
1038
 
@@ -1052,7 +1038,7 @@ class Woo_Feed_Products_v3 {
1052
  if ( class_exists( 'All_in_One_SEO_Pack' ) ) {
1053
  global $aioseop_options, $aiosp;
1054
  $selfLoadAIOSP = false;
1055
- if( ! is_array( $aioseop_options ) ) $aioseop_options = get_option( 'aioseop_options' );
1056
  if ( ! ( $aiosp instanceof All_in_One_SEO_Pack ) ) {
1057
  $aiosp = new All_in_One_SEO_Pack();
1058
  $selfLoadAIOSP = true;
@@ -1078,13 +1064,12 @@ class Woo_Feed_Products_v3 {
1078
  *
1079
  * @return mixed|string
1080
  */
1081
- private function short_description($product)
1082
- {
1083
 
1084
  $short_description = $product->get_short_description();
1085
 
1086
  # Get Variation Short Description
1087
- if ($product->is_type('variation') && empty($short_description)) {
1088
  $parent = wc_get_product($product->get_parent_id());
1089
  $short_description = $parent->get_short_description();
1090
  }
@@ -1104,14 +1089,13 @@ class Woo_Feed_Products_v3 {
1104
  *
1105
  * @return mixed|string
1106
  */
1107
- private function remove_short_codes($content)
1108
- {
1109
- if (empty($content)) {
1110
  return "";
1111
  }
1112
 
1113
  # Remove DIVI Builder Short Codes
1114
- if (class_exists('ET_Builder_Module') || defined('ET_BUILDER_PLUGIN_VERSION')) {
1115
  $content = preg_replace('/\[\/?et_pb.*?\]/', '', $content);
1116
  }
1117
 
@@ -1130,14 +1114,13 @@ class Woo_Feed_Products_v3 {
1130
  *
1131
  * @return mixed
1132
  */
1133
- private function product_type($product)
1134
- {
1135
  $id = $product->get_id();
1136
- if ($product->is_type('variation')) {
1137
  $id = $product->get_parent_id();
1138
  }
1139
 
1140
- return strip_tags(wc_get_product_category_list($id, ">", ""));;
1141
  }
1142
 
1143
  /**
@@ -1148,8 +1131,7 @@ class Woo_Feed_Products_v3 {
1148
  *
1149
  * @return mixed
1150
  */
1151
- private function link($product)
1152
- {
1153
  return $product->get_permalink();
1154
  }
1155
 
@@ -1161,9 +1143,8 @@ class Woo_Feed_Products_v3 {
1161
  *
1162
  * @return mixed
1163
  */
1164
- private function ex_link($product)
1165
- {
1166
- if ($product->is_type('external')) {
1167
  return $product->get_product_url();
1168
  }
1169
 
@@ -1178,23 +1159,22 @@ class Woo_Feed_Products_v3 {
1178
  *
1179
  * @return mixed
1180
  */
1181
- private function image($product)
1182
- {
1183
  $id = $product->get_id();
1184
  $image = "";
1185
- if ($product->is_type('variation')) {
1186
  $getImage = wp_get_attachment_image_src(get_post_thumbnail_id($id), 'single-post-thumbnail');
1187
- if (has_post_thumbnail($id) && !empty($getImage[0])):
1188
  $image = woo_feed_get_formatted_url($getImage[0]);
1189
- else:
1190
  $getImage = wp_get_attachment_image_src(get_post_thumbnail_id($product->get_parent_id()), 'single-post-thumbnail');
1191
  $image = woo_feed_get_formatted_url($getImage[0]);
1192
  endif;
1193
  } else {
1194
- if (has_post_thumbnail($id)):
1195
  $getImage = wp_get_attachment_image_src(get_post_thumbnail_id($id), 'single-post-thumbnail');
1196
  $image = woo_feed_get_formatted_url($getImage[0]);
1197
- else:
1198
  $image = woo_feed_get_formatted_url(wp_get_attachment_url($id));
1199
  endif;
1200
  }
@@ -1210,23 +1190,22 @@ class Woo_Feed_Products_v3 {
1210
  *
1211
  * @return mixed
1212
  */
1213
- private function feature_image($product)
1214
- {
1215
  $id = $product->get_id();
1216
  $feature_image = "";
1217
- if ($product->is_type('variation')) {
1218
  $getImage = wp_get_attachment_image_src(get_post_thumbnail_id($id), 'single-post-thumbnail');
1219
- if (has_post_thumbnail($id) && !empty($getImage[0])):
1220
  $feature_image = woo_feed_get_formatted_url($getImage[0]);
1221
- else:
1222
  $getImage = wp_get_attachment_image_src(get_post_thumbnail_id($product->get_parent_id()), 'single-post-thumbnail');
1223
  $feature_image = woo_feed_get_formatted_url($getImage[0]);
1224
  endif;
1225
  } else {
1226
- if (has_post_thumbnail($id)):
1227
  $getImage = wp_get_attachment_image_src(get_post_thumbnail_id($id), 'single-post-thumbnail');
1228
  $feature_image = woo_feed_get_formatted_url($getImage[0]);
1229
- else:
1230
  $feature_image = woo_feed_get_formatted_url(wp_get_attachment_url($id));
1231
  endif;
1232
  }
@@ -1302,8 +1281,7 @@ class Woo_Feed_Products_v3 {
1302
  *
1303
  * @return mixed
1304
  */
1305
- private function type($product)
1306
- {
1307
  return $product->get_type();
1308
  }
1309
 
@@ -1315,8 +1293,7 @@ class Woo_Feed_Products_v3 {
1315
  *
1316
  * @return mixed
1317
  */
1318
- private function is_bundle($product)
1319
- {
1320
  return "no";
1321
  }
1322
 
@@ -1328,11 +1305,10 @@ class Woo_Feed_Products_v3 {
1328
  *
1329
  * @return mixed
1330
  */
1331
- private function multipack($product)
1332
- {
1333
  $multi_pack = "";
1334
- if ($product->is_type('grouped')) {
1335
- $multi_pack = (!empty($product->get_children())) ? count($product->get_children()) : "";
1336
  }
1337
 
1338
  return $multi_pack;
@@ -1346,8 +1322,7 @@ class Woo_Feed_Products_v3 {
1346
  *
1347
  * @return mixed
1348
  */
1349
- private function visibility($product)
1350
- {
1351
  return $product->get_catalog_visibility();
1352
  }
1353
 
@@ -1359,8 +1334,7 @@ class Woo_Feed_Products_v3 {
1359
  *
1360
  * @return mixed
1361
  */
1362
- private function rating_total($product)
1363
- {
1364
  return $product->get_rating_count();
1365
  }
1366
 
@@ -1372,8 +1346,7 @@ class Woo_Feed_Products_v3 {
1372
  *
1373
  * @return mixed
1374
  */
1375
- private function rating_average($product)
1376
- {
1377
  return $product->get_average_rating();
1378
  }
1379
 
@@ -1385,16 +1358,15 @@ class Woo_Feed_Products_v3 {
1385
  *
1386
  * @return mixed
1387
  */
1388
- private function tags($product)
1389
- {
1390
  $id = $product->get_id();
1391
- if ($product->is_type('variation')) {
1392
  $id = $product->get_parent_id();
1393
  }
1394
 
1395
  $tags = get_the_term_list($id, "product_tag", "", ",", "");
1396
 
1397
- if (!empty($tags)) {
1398
  return strip_tags($tags);
1399
  }
1400
 
@@ -1409,10 +1381,9 @@ class Woo_Feed_Products_v3 {
1409
  *
1410
  * @return mixed
1411
  */
1412
- private function item_group_id($product)
1413
- {
1414
  $id = $product->get_id();
1415
- if ($product->is_type('variation')) {
1416
  $id = $product->get_parent_id();
1417
  }
1418
 
@@ -1427,8 +1398,7 @@ class Woo_Feed_Products_v3 {
1427
  *
1428
  * @return mixed
1429
  */
1430
- private function sku($product)
1431
- {
1432
  return $product->get_sku();
1433
  }
1434
 
@@ -1440,9 +1410,8 @@ class Woo_Feed_Products_v3 {
1440
  *
1441
  * @return mixed
1442
  */
1443
- private function parent_sku($product)
1444
- {
1445
- if ($product->is_type('variation')) {
1446
  $id = $product->get_parent_id();
1447
  $parent = wc_get_product($id);
1448
 
@@ -1460,16 +1429,15 @@ class Woo_Feed_Products_v3 {
1460
  *
1461
  * @return mixed
1462
  */
1463
- private function availability($product)
1464
- {
1465
  $id = $product->get_id();
1466
  $status = get_post_meta($id, '_stock_status', true);
1467
- if ($status) {
1468
- if ($status == 'instock') {
1469
  return "in stock";
1470
- } elseif ($status == 'outofstock') {
1471
  return "out of stock";
1472
- } elseif ($status == 'onbackorder') {
1473
  return "on backorder";
1474
  } else {
1475
  return "in stock";
@@ -1487,26 +1455,25 @@ class Woo_Feed_Products_v3 {
1487
  *
1488
  * @return mixed
1489
  */
1490
- private function quantity($product)
1491
- {
1492
- if ($product->is_type('variable') && $product->has_child()) {
1493
  $visible_children = $product->get_visible_children();
1494
  $qty = array();
1495
- foreach ($visible_children as $key => $child) {
1496
  $childQty = get_post_meta($child, '_stock', true);
1497
  $qty[] = (int)$childQty + 0;
1498
  }
1499
 
1500
- if (isset($this->config['variable_quantity'])) {
1501
  $vaQty = $this->config['variable_quantity'];
1502
- if ($vaQty == "max") {
1503
  return max($qty);
1504
- } elseif ($vaQty == "min") {
1505
  return min($qty);
1506
- } elseif ($vaQty == "sum") {
1507
  return array_sum($qty);
1508
- } elseif ($vaQty == "first") {
1509
- return ((int)$qty[0]);
1510
  }
1511
 
1512
  return array_sum($qty);
@@ -1524,10 +1491,9 @@ class Woo_Feed_Products_v3 {
1524
  *
1525
  * @return mixed
1526
  */
1527
- private function sale_price_sdate($product)
1528
- {
1529
  $startDate = $product->get_date_on_sale_from();
1530
- if (is_object($startDate)) {
1531
  return $startDate->date_i18n();
1532
  }
1533
 
@@ -1542,10 +1508,9 @@ class Woo_Feed_Products_v3 {
1542
  *
1543
  * @return mixed
1544
  */
1545
- private function sale_price_edate($product)
1546
- {
1547
  $endDate = $product->get_date_on_sale_to();
1548
- if (is_object($endDate)) {
1549
  return $endDate->date_i18n();
1550
  }
1551
 
@@ -1560,13 +1525,12 @@ class Woo_Feed_Products_v3 {
1560
  *
1561
  * @return mixed
1562
  */
1563
- private function price($product)
1564
- {
1565
  $price = $product->get_regular_price();
1566
  # Set variable product regular price according to setting
1567
- if ($product->is_type('variable')) {
1568
  $price = $this->getVariableProductPrice($product, 'regular_price');
1569
- } else if ($product->is_type('grouped')) {
1570
  return $this->getGroupProductPrice($product, 'regular');
1571
  }
1572
 
@@ -1581,13 +1545,12 @@ class Woo_Feed_Products_v3 {
1581
  *
1582
  * @return mixed
1583
  */
1584
- private function current_price($product)
1585
- {
1586
  $price = $product->get_price();
1587
  # Set variable product current price according to setting
1588
- if ($product->is_type('variable')) {
1589
  $price = $this->getVariableProductPrice($product, 'price');
1590
- } else if ($product->is_type('grouped')) {
1591
  return $this->getGroupProductPrice($product, 'current');
1592
  }
1593
 
@@ -1602,13 +1565,12 @@ class Woo_Feed_Products_v3 {
1602
  *
1603
  * @return mixed
1604
  */
1605
- private function sale_price($product)
1606
- {
1607
  $price = $product->get_sale_price();
1608
  # Set variable product sale price according to setting
1609
- if ($product->is_type('variable')) {
1610
  $price = $this->getVariableProductPrice($product, 'sale_price');
1611
- } else if ($product->is_type('grouped')) {
1612
  return $this->getGroupProductPrice($product, 'sale');
1613
  }
1614
 
@@ -1708,22 +1670,22 @@ class Woo_Feed_Products_v3 {
1708
  *
1709
  * @return int|string
1710
  */
1711
- private function getGroupProductPrice($grouped, $type, $tax = false) {
1712
  $groupProductIds = $grouped->get_children();
1713
  $sum = 0;
1714
- if (!empty($groupProductIds)) {
1715
- foreach ($groupProductIds as $id) {
1716
  $product = wc_get_product($id);
1717
 
1718
- if (!is_object($product)) {
1719
  continue; // make sure that the product exists..
1720
  }
1721
 
1722
- if ($tax) {
1723
- if ($type == "regular") {
1724
  $regularPrice = $this->price_with_tax($product);
1725
  $sum += (float)$regularPrice;
1726
- } else if ($type == "current") {
1727
  $currentPrice = $this->current_price_with_tax($product);
1728
  $sum += (float)$currentPrice;
1729
  } else {
@@ -1731,10 +1693,10 @@ class Woo_Feed_Products_v3 {
1731
  $sum += (float)$salePrice;
1732
  }
1733
  } else {
1734
- if ($type == "regular") {
1735
  $regularPrice = $this->price($product);
1736
  $sum += (float)$regularPrice;
1737
- } else if ($type == "current") {
1738
  $currentPrice = $this->current_price($product);
1739
  $sum += (float)$currentPrice;
1740
  } else {
@@ -1761,7 +1723,7 @@ class Woo_Feed_Products_v3 {
1761
  private function getVariableProductPrice( $variable, $type ) {
1762
  if ( $type == "regular_price" ) {
1763
  return $variable->get_variation_regular_price();
1764
- } else if ( $type == "sale_price" ) {
1765
  return $variable->get_variation_sale_price();
1766
  } else {
1767
  return $variable->get_variation_price();
@@ -1793,8 +1755,7 @@ class Woo_Feed_Products_v3 {
1793
  *
1794
  * @return mixed
1795
  */
1796
- private function weight($product)
1797
- {
1798
  // echo "Product Id: ".$product->get_name();
1799
  // echo " Product Name: ".$product->get_id(); echo "<br>";
1800
  // echo " Weight: ".$product->get_weight(); echo "<br>";
@@ -1810,8 +1771,7 @@ class Woo_Feed_Products_v3 {
1810
  *
1811
  * @return mixed
1812
  */
1813
- private function width($product)
1814
- {
1815
  return $product->get_width();
1816
  }
1817
 
@@ -1823,8 +1783,7 @@ class Woo_Feed_Products_v3 {
1823
  *
1824
  * @return mixed
1825
  */
1826
- private function height($product)
1827
- {
1828
  return $product->get_height();
1829
  }
1830
 
@@ -1836,8 +1795,7 @@ class Woo_Feed_Products_v3 {
1836
  *
1837
  * @return mixed
1838
  */
1839
- private function length($product)
1840
- {
1841
  return $product->get_length();
1842
  }
1843
 
@@ -1849,8 +1807,7 @@ class Woo_Feed_Products_v3 {
1849
  *
1850
  * @return mixed
1851
  */
1852
- private function shipping_class($product)
1853
- {
1854
  return $product->get_shipping_class();
1855
  }
1856
 
@@ -1862,8 +1819,7 @@ class Woo_Feed_Products_v3 {
1862
  *
1863
  * @return mixed
1864
  */
1865
- private function author_name($product)
1866
- {
1867
  $post = get_post($product->get_id());
1868
  $authorId = $post->post_author;
1869
 
@@ -1878,8 +1834,7 @@ class Woo_Feed_Products_v3 {
1878
  *
1879
  * @return mixed
1880
  */
1881
- private function author_email($product)
1882
- {
1883
  $post = get_post($product->get_id());
1884
  $authorId = $post->post_author;
1885
 
@@ -1894,8 +1849,7 @@ class Woo_Feed_Products_v3 {
1894
  *
1895
  * @return mixed
1896
  */
1897
- private function date_created($product)
1898
- {
1899
  $dateCreated = $product->get_date_created();
1900
 
1901
  return date("Y-m-d", strtotime($dateCreated));
@@ -1909,8 +1863,7 @@ class Woo_Feed_Products_v3 {
1909
  *
1910
  * @return mixed
1911
  */
1912
- private function date_updated($product)
1913
- {
1914
  $dateModified = $product->get_date_modified();
1915
 
1916
  return date("Y-m-d", strtotime($dateModified));
@@ -1924,12 +1877,11 @@ class Woo_Feed_Products_v3 {
1924
  *
1925
  * @return mixed
1926
  */
1927
- private function sale_price_effective_date($product)
1928
- {
1929
  $sale_price_effective_date = "";
1930
  $from = $this->sale_price_sdate($product);
1931
  $to = $this->sale_price_edate($product);
1932
- if (!empty($from) && !empty($to)) {
1933
  $from = date("c", strtotime($from));
1934
  $to = date("c", strtotime($to));
1935
  $sale_price_effective_date = "$from" . "/" . "$to";
@@ -1948,20 +1900,19 @@ class Woo_Feed_Products_v3 {
1948
  *
1949
  * @return string
1950
  */
1951
- public function getProductAttribute($product, $attr)
1952
- {
1953
  $id = $product->get_id();
1954
  $attr = str_replace(self::PRODUCT_ATTRIBUTE_PREFIX, "", $attr);
1955
 
1956
- if (woo_feed_wc_version_check(3.2)) {
1957
- if (woo_feed_wc_version_check(3.6)) {
1958
  $attr = str_replace("pa_", "", $attr);
1959
  }
1960
  $value = $product->get_attribute($attr);
1961
 
1962
  return $value;
1963
  } else {
1964
- return implode(',', wc_get_product_terms($id, $attr, array('fields' => 'names')));
1965
  }
1966
  }
1967
 
@@ -1975,12 +1926,11 @@ class Woo_Feed_Products_v3 {
1975
  *
1976
  * @return mixed|string
1977
  */
1978
- public function getProductMeta($product, $meta)
1979
- {
1980
  $id = $product->get_id();
1981
  $meta = str_replace(self::POST_META_PREFIX, "", $meta);
1982
 
1983
- if (strpos($meta, 'attribute_pa') !== false) {
1984
  $productMeta = $this->getProductAttribute($product, str_replace("attribute_", "", $meta));
1985
  } else {
1986
  $productMeta = get_post_meta($id, $meta, true);
@@ -1988,9 +1938,9 @@ class Woo_Feed_Products_v3 {
1988
 
1989
  //@TODO check pro version
1990
 
1991
- if ($productMeta == "") {
1992
  $postParent = wp_get_post_parent_id($id);
1993
- if ($postParent > 0) {
1994
  $productMeta = get_post_meta($postParent, $meta, true);
1995
  }
1996
  }
@@ -2007,13 +1957,12 @@ class Woo_Feed_Products_v3 {
2007
  *
2008
  * @return string
2009
  */
2010
- public function getProductTaxonomy($product, $taxonomy)
2011
- {
2012
  $id = $product->get_id();
2013
  $taxonomy = str_replace(self::PRODUCT_TAXONOMY_PREFIX, "", $taxonomy);
2014
  $taxonomy_list = get_the_term_list($id, $taxonomy, "", ",", "");
2015
 
2016
- if (!empty($taxonomy_list)) {
2017
  return strip_tags($taxonomy_list);
2018
  }
2019
 
@@ -2030,33 +1979,32 @@ class Woo_Feed_Products_v3 {
2030
  *
2031
  * @return mixed
2032
  */
2033
- private function price_format($name, $conditionName, $result)
2034
- {
2035
  $plus = "+";
2036
  $minus = "-";
2037
  $percent = "%";
2038
 
2039
- if (strpos($name, 'price') !== false) {
2040
- if (strpos($result, $plus) !== false && strpos($result, $percent) !== false) {
2041
  $result = str_replace("+", "", $result);
2042
  $result = str_replace("%", "", $result);
2043
- if (is_numeric($result)) {
2044
  $result = $conditionName + (($conditionName * $result) / 100);
2045
  }
2046
- } elseif (strpos($result, $minus) !== false && strpos($result, $percent) !== false) {
2047
  $result = str_replace("-", "", $result);
2048
  $result = str_replace("%", "", $result);
2049
- if (is_numeric($result)) {
2050
  $result = $conditionName - (($conditionName * $result) / 100);
2051
  }
2052
- } elseif (strpos($result, $plus) !== false) {
2053
  $result = str_replace("+", "", $result);
2054
- if (is_numeric($result)) {
2055
  $result = ($conditionName + $result);
2056
  }
2057
- } elseif (strpos($result, $minus) !== false) {
2058
  $result = str_replace("-", "", $result);
2059
- if (is_numeric($result)) {
2060
  $result = $conditionName - $result;
2061
  }
2062
  }
@@ -2074,46 +2022,45 @@ class Woo_Feed_Products_v3 {
2074
  *
2075
  * @return float|int|string
2076
  */
2077
- public function format_output($output, $outputTypes)
2078
- {
2079
- if (!empty($outputTypes) && is_array($outputTypes)) {
2080
 
2081
  # Format Output According to output type
2082
- if (in_array(2, $outputTypes)) { # Strip Tags
2083
  $output = strip_tags(html_entity_decode($output));
2084
  }
2085
 
2086
- if (in_array(3, $outputTypes)) { # UTF-8 Encode
2087
  $output = utf8_encode($output);
2088
  }
2089
 
2090
- if (in_array(4, $outputTypes)) { # htmlentities
2091
  $output = htmlentities($output, ENT_QUOTES, 'UTF-8');
2092
  }
2093
 
2094
- if (in_array(5, $outputTypes)) { # Integer
2095
  $output = absint($output);
2096
  }
2097
 
2098
- if (in_array(6, $outputTypes)) { # Format Price
2099
  $output = (float)$output;
2100
  $output = number_format($output, 2, '.', '');
2101
  }
2102
 
2103
- if (in_array(7, $outputTypes)) { # Delete Space
2104
  $output = trim($output);
2105
  $output = preg_replace('!\s+!', ' ', $output);
2106
  }
2107
 
2108
- if (in_array(9, $outputTypes)) { # Remove Invalid Character
2109
  $output = woo_feed_stripInvalidXml($output);
2110
  }
2111
 
2112
- if (in_array(10, $outputTypes)) { # Remove ShortCodes
2113
  $output = $this->remove_short_codes($output);
2114
  }
2115
 
2116
- if (in_array(8, $outputTypes)) { # Add CDATA
2117
  $output = '<![CDATA[' . $output . ']]>';
2118
  }
2119
  }
@@ -2138,12 +2085,12 @@ class Woo_Feed_Products_v3 {
2138
  }
2139
 
2140
  # Add Prefix before Output
2141
- if ( $prefix!="") {
2142
  $output = "$prefix" . $output;
2143
  }
2144
 
2145
  # Add Suffix after Output
2146
- if ( $suffix!="") {
2147
  if ( $attribute == 'price'
2148
  || $attribute == 'sale_price'
2149
  || $attribute == 'current_price'
@@ -2155,7 +2102,7 @@ class Woo_Feed_Products_v3 {
2155
 
2156
  $output = $output . " " . $suffix;
2157
 
2158
- } else if ( substr( $output, 0, 4 ) === "http" ) {
2159
 
2160
  # Parse URL Parameters if available into suffix field
2161
  $output = woo_feed_make_url_with_parameter( $output, $suffix );
24
  'tax_country',
25
  'tax_region',
26
  'tax_rate',
27
+ 'tax_ship',
28
  );
29
  private $product_types = array(
30
  'simple',
55
 
56
  public function __construct( $config ) {
57
  $this->config = $config;
58
+ $this->queryType = get_option('woo_feed_product_query_type');
59
+ if ( empty($this->queryType) ) {
60
+ $this->queryType = 'wc';
61
  }
62
  }
63
 
123
  */
124
  public function query_products() {
125
  $products = [];
126
+ if ( $this->queryType == 'wc' ) {
127
  $products = $this->get_wc_query_products();
128
+ }elseif ( $this->queryType == 'wp' ) {
129
  $products = $this->get_wp_query_products();
130
+ }elseif ( $this->queryType == 'both' ) {
131
+ $wc = $this->get_wc_query_products();
132
+ $wp = $this->get_wp_query_products();
133
  $products = array_unique(array_merge($wc,$wp));
134
  }
135
  return $products;
197
  }
198
 
199
  # Unique Merchant Attributes
200
+ $mAttributes = array();
201
  # Get Product Attribute values by type and assign to product array
202
  foreach ( $this->config['attributes'] as $attr_key => $attribute ) {
203
 
204
  # Continue for Google Shipping and Tax attributes
205
  $skipFor = array( 'google', 'facebook' );
206
  if ( $this->config['feedType'] == 'xml'
207
+ && in_array( $this->config['mattributes'][ $attr_key ], $this->google_shipping_tax )
208
  && in_array( $this->config['provider'], $skipFor ) ) {
209
  continue;
210
  }
211
 
212
+ if ( in_array( $this->config['mattributes'][ $attr_key ],$mAttributes ) ) {
213
  continue;
214
  }
215
 
216
+ if ( $this->config['type'][ $attr_key ] == "pattern" ) {
217
+ $attributeValue = $this->config['default'][ $attr_key ];
218
  } else { # Get Pattern value
219
  $attributeValue = $this->getAttributeValueByType($product, $attribute);
220
  }
221
 
222
  # Format Output according to Output Type config
223
+ $outputType = $this->config['output_type'][ $attr_key ];
224
+ if ( $outputType != "default" && ! empty($attributeValue) ) {
225
  $attributeValue = $this->format_output($attributeValue, $outputType);
226
  }
227
 
228
 
229
  # Limit Output
230
+ $limit = $this->config['limit'][ $attr_key ];
231
+ if ( ! empty($limit) && is_numeric($limit) ) {
232
+ if ( strpos($attributeValue, "<![CDATA[") !== false ) {
233
+ $attributeValue = str_replace(array( "<![CDATA[", "]]>" ), array( "", "" ), $attributeValue);
234
  $attributeValue = substr($attributeValue, 0, $limit);
235
  $attributeValue = '<![CDATA[' . $attributeValue . ']]>';
236
  } else {
258
  # XML does not support space in node. So replace Space with Underscore
259
  $getReplacedAttribute = str_replace( " ", "_", $getReplacedAttribute );
260
 
261
+ if ( ! empty($attributeValue) ) {
262
+ $attributeValue = trim($attributeValue);
263
  }
264
 
265
  # Add closing XML node if value is empty
269
 
270
  #TODO Move to proper place
271
  # Replace Google Color attribute value according to requirements
272
+ if ( $getReplacedAttribute == 'g:color' ) {
273
  $attributeValue = str_replace( ", ", "/", $attributeValue );
274
  }
275
 
282
  } else {
283
  $this->feedBody .= "<" . $getReplacedAttribute . "/>";
284
  $this->feedBody .= "\n";
285
+ }
286
+ } elseif ( $this->config['feedType'] == 'csv' ) {
 
287
  $pluginAttribute = woo_feed_replace_to_merchant_attribute( $pluginAttribute, $merchant, $feedType );
288
  $pluginAttribute = $this->processStringForCSV( $pluginAttribute );
289
  $attributeValue = $this->processStringForCSV( $attributeValue );
290
+ } elseif ( $this->config['feedType'] == 'txt' ) {
291
  $pluginAttribute = woo_feed_replace_to_merchant_attribute( $pluginAttribute, $merchant, $feedType );
292
  $pluginAttribute = $this->processStringForTXT( $pluginAttribute );
293
  $attributeValue = $this->processStringForTXT( $attributeValue );
294
  }
295
 
296
+ $mAttributes[ $attr_key ] = $this->config['mattributes'][ $attr_key ];
297
  $this->products[ $this->pi ][ $pluginAttribute ] = $attributeValue;
298
  }
299
 
300
  # Process feed data for uncommon merchant feed like Google,Facebook,Pinterest
301
  $this->process_for_merchant($product, $this->pi);
302
 
303
+ if ( $this->config['feedType'] == 'xml' ) {
304
+ if ( empty($this->feedHeader) ) {
305
  $this->feedHeader = $this->process_xml_feed_header();
306
  $this->feedFooter = $this->process_xml_feed_footer();
307
 
310
  $this->feedBody .= "</" . $this->config['itemWrapper'] . ">";
311
 
312
 
313
+ } elseif ( $this->config['feedType'] == 'txt' ) {
314
+ if ( empty($this->feedHeader) ) {
315
  $this->process_txt_feed_header();
316
  }
317
  $this->process_txt_feed_body();
318
  } else {
319
+ if ( empty($this->feedHeader) ) {
320
  $this->process_csv_feed_header();
321
  }
322
  $this->process_csv_feed_body();
347
  * @param $index | Product Index
348
  */
349
 
350
+ private function process_for_merchant( $productObj, $index ) {
351
+ $product = $this->products[ $index ];
 
352
  $merchantAttributes = $this->config['mattributes'];
353
 
354
  # Debug Here
355
  # echo "<pre>";print_r($product);print_r($merchantAttributes);die();
356
 
357
  # Format Shipping and Tax data for CSV and TXT feed only for google and facebook
358
+ if ( $this->config['provider'] == 'google'
359
  || $this->config['provider'] == 'facebook'
360
+ && $this->config['feedType'] != 'xml' ) {
361
 
362
  $shipping = array();
363
  $tax = array();
373
  'tax_rate',
374
  'tax_ship',
375
  );
376
+ foreach ( $this->products[ $this->pi ] as $attribute => $value ) {
377
+ if ( in_array($attribute, $shippingAttr) ) {
378
 
379
+ if ( $attribute == "tax_country" ) {
380
  $t++;
381
+ $tax[ $t ] .= $value . ":";
382
+ } elseif ( $attribute == "tax_region" ) {
383
+ $tax[ $t ] .= $value . ":";
384
+ } elseif ( $attribute == "tax_rate" ) {
385
+ $tax[ $t ] .= $value . ":";
386
+ } elseif ( $attribute == "tax_ship" ) {
387
+ $tax[ $t ] .= $value . ":";
388
  }
389
 
390
+ if ( $attribute == "shipping_country" ) {
391
  $s++;
392
+ $shipping[ $s ] .= $value . ":";
393
+ } elseif ( $attribute == "shipping_service" ) {
394
+ $shipping[ $s ] .= $value . ":";
395
+ } elseif ( $attribute == "shipping_price" ) {
396
+ $shipping[ $s ] .= $value . ":";
397
+ } elseif ( $attribute == "shipping_region" ) {
398
+ $shipping[ $s ] .= $value . ":";
399
  }
400
 
401
+ unset($this->products[ $this->pi ][ $attribute ]);
402
  }
403
  }
404
 
405
+ foreach ( $shipping as $key => $val ) {
406
+ $this->products[ $this->pi ]['shipping(country:region:service:price)'] = $val;
407
  }
408
 
409
+ foreach ( $tax as $key => $val ) {
410
+ $this->products[ $this->pi ]['tax(country:region:rate:tax_ship)'] = $val;
411
  }
412
  }
413
 
414
+ if ( $this->config['provider'] == 'google' ) {
415
 
416
  # Reformat Shipping attributes for google, facebook
417
  $s = 0;
418
  $t = 0;
419
  $tax = "";
420
  $shipping = "";
421
+ if ( $this->config['feedType'] == 'xml' ) {
422
+ foreach ( $merchantAttributes as $key => $value ) {
423
 
424
+ if ( ! in_array($value, $this->google_shipping_tax) ) {
425
  continue;
426
  }
427
 
428
+ $prefix = $this->config['prefix'][ $key ];
429
+ $suffix = $this->config['suffix'][ $key ];
430
 
431
+ if ( $this->config['type'][ $key ] == "pattern" ) {
432
+ $output = $this->config['default'][ $key ];
433
  } else { # Get Pattern value
434
+ $attribute = $this->config['attributes'][ $key ];
435
  $output = $this->getAttributeValueByType($productObj, $attribute);
436
  }
437
 
438
+ if ( strpos($value, "price") !== false || strpos($value, "rate") !== false ) {
439
  $suffix = " " . $suffix;
440
  }
441
 
442
 
443
  $output = $prefix . $output . $suffix;
444
 
445
+ if ( $value == "shipping_country" ) {
446
  if ( $s == 0 ) {
447
  $shipping .= "<g:shipping>";
448
  $s = 1;
450
  $shipping .= "</g:shipping>" . "\n";
451
  $shipping .= "<g:shipping>";
452
  }
453
+ }elseif ( ! in_array("shipping_country",$merchantAttributes) && $value == "shipping_price" ) {
454
  if ( $s == 0 ) {
455
  $shipping .= "<g:shipping>";
456
  $s = 1;
460
  }
461
  }
462
 
463
+ if ( $value == "shipping_country" ) {
464
  $shipping .= "<g:country>" . $output . "</g:country>" . "\n";
465
+ } elseif ( $value == "shipping_region" ) {
466
  $shipping .= "<g:region>" . $output . "</g:region>" . "\n";
467
+ } elseif ( $value == "shipping_service" ) {
468
  $shipping .= "<g:service>" . $output . "</g:service>" . "\n";
469
+ } elseif ( $value == "shipping_price" ) {
470
  $shipping .= "<g:price>" . $output . "</g:price>" . "\n";
471
+ } elseif ( $value == "tax_country" ) {
472
+ if ( $t == 0 ) {
473
  $tax .= "<g:tax>";
474
  $t = 1;
475
  } else {
477
  $tax .= "<g:tax>";
478
  }
479
  $tax .= "<g:country>" . $output . "</g:country>" . "\n";
480
+ } elseif ( $value == "tax_region" ) {
481
  $tax .= "<g:region>" . $output . "</g:region>" . "\n";
482
+ } elseif ( $value == "tax_rate" ) {
483
  $tax .= "<g:rate>" . $output . "</g:rate>" . "\n";
484
+ } elseif ( $value == "tax_ship" ) {
485
  $tax .= "<g:tax_ship>" . $output . "</g:tax_ship>" . "\n";
486
  }
487
  }
488
 
489
+ if ( $s == 1 ) {
490
  $shipping .= "</g:shipping>";
491
  }
492
+ if ( $t == 1 ) {
493
  $tax .= "</g:tax>";
494
  }
495
 
499
  }
500
 
501
  # ADD g:identifier_exists
502
+ if ( $this->config['provider'] == 'google' ) {
503
+ $identifier = array( 'brand', 'upc', 'sku', 'mpn', 'gtin' );
504
  $countIdentifier = 0;
505
+ if ( ! in_array('identifier_exists', $merchantAttributes) ) {
506
+ if ( count(array_intersect_key(array_flip($identifier), $product)) >= 2 ) {
507
  # Any 2 required keys exist!
508
  //@TODO Refactor with OR
509
+ if ( array_key_exists('brand', $product) && ! empty($product['brand']) ) {
510
  $countIdentifier++;
511
  }
512
+ if ( array_key_exists('upc', $product) && ! empty($product['upc']) ) {
513
  $countIdentifier++;
514
  }
515
+ if ( array_key_exists('sku', $product) && ! empty($product['sku']) ) {
516
  $countIdentifier++;
517
  }
518
+ if ( array_key_exists('mpn', $product) && ! empty($product['mpn']) ) {
519
  $countIdentifier++;
520
  }
521
+ if ( array_key_exists('gtin', $product) && ! empty($product['gtin']) ) {
522
  $countIdentifier++;
523
+ }
524
+ }
 
525
 
526
+ if ( $this->config['feedType'] == 'xml' ) {
527
+ if ( $countIdentifier >= 2 ) {
528
  $this->feedBody .= "<g:identifier_exists>yes</g:identifier_exists>";
529
  } else {
530
  $this->feedBody .= "<g:identifier_exists>no</g:identifier_exists>";
531
  }
532
  } else {
533
+ if ( $countIdentifier >= 2 ) {
534
+ $this->products[ $this->pi ]['identifier exists'] = "yes";
535
  } else {
536
+ $this->products[ $this->pi ]['identifier exists'] = "no";
537
  }
538
  }
539
  }
547
  *
548
  * @return string
549
  */
550
+ private function process_txt_feed_header() {
 
551
  # Set Delimiter
552
+ if ( $this->config['delimiter'] == 'tab' ) {
553
  $this->delimiter = "\t";
554
  } else {
555
  $this->delimiter = $this->config['delimiter'];
556
  }
557
 
558
  # Set Enclosure
559
+ if ( ! empty($this->config['enclosure']) ) {
560
  $this->enclosure = $this->config['enclosure'];
561
+ if ( $this->enclosure == 'double' ) {
562
  $this->enclosure = '"';
563
+ } elseif ( $this->enclosure == 'single' ) {
564
  $this->enclosure = "'";
565
  } else {
566
  $this->enclosure = "";
569
  $this->enclosure = "";
570
  }
571
 
572
+ $product = $this->products[ $this->pi ];
573
  $headers = array_keys($product);
574
  $this->feedHeader .= $this->enclosure . implode("$this->enclosure$this->delimiter$this->enclosure", $headers) . $this->enclosure . "\n";
575
 
583
  *
584
  * @return string
585
  */
586
+ private function process_txt_feed_body() {
587
+ $product = $this->products[ $this->pi ];
 
588
  $productInfo = array_values($product);
589
  $this->feedBody .= $this->enclosure . implode("$this->enclosure$this->delimiter$this->enclosure", $productInfo) . $this->enclosure . "\n";
590
 
598
  *
599
  * @return array
600
  */
601
+ private function process_csv_feed_header() {
 
602
  # Set Delimiter
603
+ if ( $this->config['delimiter'] == 'tab' ) {
604
  $this->delimiter = "\t";
605
  } else {
606
  $this->delimiter = $this->config['delimiter'];
607
  }
608
 
609
  # Set Enclosure
610
+ if ( ! empty($this->config['enclosure']) ) {
611
  $this->enclosure = $this->config['enclosure'];
612
+ if ( $this->enclosure == 'double' ) {
613
  $this->enclosure = '"';
614
+ } elseif ( $this->enclosure == 'single' ) {
615
  $this->enclosure = "'";
616
  } else {
617
  $this->enclosure = "";
620
  $this->enclosure = "";
621
  }
622
 
623
+ $product = $this->products[ $this->pi ];
624
  $this->feedHeader = array_keys($product);
625
 
626
  return $this->feedHeader;
631
  * @since 3.2.0
632
  * @return array
633
  */
634
+ private function process_csv_feed_body() {
635
+ $product = $this->products[ $this->pi ];
 
636
  $this->feedBody[] = array_values($product);
637
 
638
  return $this->feedBody;
643
  * @since 3.2.0
644
  * @return string
645
  */
646
+ private function process_xml_feed_header() {
 
647
  $datetime_now = date("Y-m-d H:i:s");
648
+ if ( $this->config["provider"] == 'fruugo.au' ) {
649
  $fruugo_au = "<products version=\"1.0\" standalone=\"yes\">
650
  <datetime>$datetime_now</datetime>
651
  <title>" . get_bloginfo('name') . "</title>
653
  <description>" . get_bloginfo('description') . "</description>";
654
 
655
  return $fruugo_au;
656
+ } elseif ( $this->config['provider'] == 'zap.co.il' ) {
657
  $zap = "<STORE>
658
  <datetime>$datetime_now</datetime>
659
  <title>" . get_bloginfo('name') . "</title>
663
  <email>" . get_bloginfo('admin_email') . "</email>";
664
 
665
  return $zap;
666
+ } elseif ( $this->config['provider'] == 'myshopping.com.au' ) {
667
  return "<productset>";
668
+ } elseif ( $this->config['provider'] == 'stylight.com' ) {
669
  return "<products version=\"1.0\" standalone=\"yes\">
670
  <datetime>$datetime_now</datetime>
671
  <title>" . get_bloginfo('name') . "</title>
672
  <link>" . get_bloginfo('url') . "</link>
673
  <description>" . get_bloginfo('description') . "</description>";
674
+ } elseif ( $this->config['provider'] == 'nextad' ) {
675
  return "<products version=\"1.0\" standalone=\"yes\">
676
  <datetime>$datetime_now</datetime>
677
  <title>" . get_bloginfo('name') . "</title>
678
  <link>" . get_bloginfo('url') . "</link>
679
  <description>" . get_bloginfo('description') . "</description>";
680
+ } elseif ( $this->config['provider'] == 'skinflint.co.uk' ) {
681
  return "<products version=\"1.0\" standalone=\"yes\">
682
  <datetime>$datetime_now</datetime>
683
  <title>" . get_bloginfo('name') . "</title>
684
  <link>" . get_bloginfo('url') . "</link>
685
  <description>" . get_bloginfo('description') . "</description>";
686
+ } elseif ( $this->config['provider'] == 'comparer.be' ) {
687
  return "<products version=\"1.0\" standalone=\"yes\">
688
  <datetime>$datetime_now</datetime>
689
  <title>" . get_bloginfo('name') . "</title>
690
  <link>" . get_bloginfo('url') . "</link>
691
  <description>" . get_bloginfo('description') . "</description>";
692
+ } elseif ( $this->config['provider'] == 'dooyoo' ) {
693
  return "<products version=\"1.0\" standalone=\"yes\">
694
  <datetime>$datetime_now</datetime>
695
  <title>" . get_bloginfo('name') . "</title>
696
  <link>" . get_bloginfo('url') . "</link>
697
  <description>" . get_bloginfo('description') . "</description>";
698
+ } elseif ( $this->config['provider'] == 'hintaseuranta.fi' ) {
699
  return "<products version=\"1.0\" standalone=\"yes\">
700
  <datetime>$datetime_now</datetime>
701
  <title>" . get_bloginfo('name') . "</title>
702
  <link>" . get_bloginfo('url') . "</link>
703
  <description>" . get_bloginfo('description') . "</description>";
704
+ } elseif ( $this->config['provider'] == 'incurvy' ) {
705
  return "<products version=\"1.0\" standalone=\"yes\">
706
  <datetime>$datetime_now</datetime>
707
  <title>" . get_bloginfo('name') . "</title>
708
  <link>" . get_bloginfo('url') . "</link>
709
  <description>" . get_bloginfo('description') . "</description>";
710
+ } elseif ( $this->config['provider'] == 'kijiji.ca' ) {
711
  return "<products version=\"1.0\" standalone=\"yes\">
712
  <datetime>$datetime_now</datetime>
713
  <title>" . get_bloginfo('name') . "</title>
714
  <link>" . get_bloginfo('url') . "</link>
715
  <description>" . get_bloginfo('description') . "</description>";
716
+ } elseif ( $this->config['provider'] == 'marktplaats.nl' ) {
717
  return "<products version=\"1.0\" standalone=\"yes\">
718
  <datetime>$datetime_now</datetime>
719
  <title>" . get_bloginfo('name') . "</title>
720
  <link>" . get_bloginfo('url') . "</link>
721
  <description>" . get_bloginfo('description') . "</description>";
722
+ } elseif ( $this->config['provider'] == 'rakuten.de' ) {
723
  return "<products version=\"1.0\" standalone=\"yes\">
724
  <datetime>$datetime_now</datetime>
725
  <title>" . get_bloginfo('name') . "</title>
726
  <link>" . get_bloginfo('url') . "</link>
727
  <description>" . get_bloginfo('description') . "</description>";
728
+ } elseif ( $this->config['provider'] == 'shopalike.fr' ) {
729
  return "<products version=\"1.0\" standalone=\"yes\">
730
  <datetime>$datetime_now</datetime>
731
  <title>" . get_bloginfo('name') . "</title>
732
  <link>" . get_bloginfo('url') . "</link>
733
  <description>" . get_bloginfo('description') . "</description>";
734
+ } elseif ( $this->config['provider'] == 'spartoo.fi' ) {
735
  return "<products version=\"1.0\" standalone=\"yes\">
736
  <datetime>$datetime_now</datetime>
737
  <title>" . get_bloginfo('name') . "</title>
738
  <link>" . get_bloginfo('url') . "</link>
739
  <description>" . get_bloginfo('description') . "</description>";
740
+ } elseif ( $this->config['provider'] == 'webmarchand' ) {
741
  return "<products version=\"1.0\" standalone=\"yes\">
742
  <datetime>$datetime_now</datetime>
743
  <title>" . get_bloginfo('name') . "</title>
745
  <description>" . get_bloginfo('description') . "</description>";
746
  } else {
747
  $wrapper = $this->config['itemsWrapper'];
748
+ $extraHeader = isset( $this->config['extraHeader'] ) ? $this->config['extraHeader'] : '';
749
 
750
  $output = '<?xml version="1.0" encoding="UTF-8" ?>';
751
  $output .= "\n";
752
  $output .= '<' . $wrapper . '>';
753
 
754
  // $output .= "\n";
755
+ if ( ! empty($extraHeader) ) {
756
  //$output .= $extraHeader;
757
  //$output .= "\n";
758
  }
766
  * @since 3.2.0
767
  * @return string
768
  */
769
+ private function process_xml_feed_footer() {
770
+ if ( in_array($this->config['provider'], [
 
771
  'fruugo.au',
772
  'stylight.com',
773
  'nextad',
781
  'rakuten.de',
782
  'shopalike.fr',
783
  'spartoo.fi',
784
+ 'webmarchand',
785
+ ]) ) {
786
  return "</products>";
787
+ } elseif ( $this->config['provider'] == 'zap.co.il' ) {
788
  return "</STORE>";
789
+ } elseif ( $this->config['provider'] == 'myshopping.com.au' ) {
790
  return "</productset>";
791
  } else {
792
  $wrapper = $this->config['itemsWrapper'];
805
  *
806
  * @return mixed|string
807
  */
808
+ private function processStringForTXT( $string ) {
809
+ if ( ! empty($string) ) {
 
810
  $string = html_entity_decode($string, ENT_HTML401 | ENT_QUOTES); // Convert any HTML entities
811
 
812
+ if ( stristr($string, '"') ) {
813
  $string = str_replace('"', '""', $string);
814
  }
815
  $string = str_replace("\n", ' ', $string);
819
  $string = stripslashes($string);
820
 
821
  return $string;
822
+ } elseif ( $string == "0" ) {
823
  return "0";
824
  } else {
825
  return "";
834
  *
835
  * @return mixed|string
836
  */
837
+ private function processStringForCSV( $string ) {
838
+ if ( ! empty($string) ) {
 
839
  $string = str_replace("\n", ' ', $string);
840
  $string = str_replace("\r", ' ', $string);
841
  $string = trim($string);
842
  $string = stripslashes($string);
843
 
844
  return $string;
845
+ } elseif ( $string == "0" ) {
846
  return "0";
847
  } else {
848
  return "";
858
  *
859
  * @return mixed|string
860
  */
861
+ public function getAttributeValueByType( $product, $attribute ) {
 
862
  # Set call_user_func_array parameters
863
+ $params = array( $product );
864
+ $method = array( $this, $attribute );
865
 
866
+ if ( method_exists($this, $attribute) ) {
867
 
868
  return call_user_func_array($method, $params);
869
 
870
+ } elseif ( strpos($attribute, self::PRODUCT_ATTRIBUTE_PREFIX) !== false ) {
871
 
872
  return $this->getProductAttribute($product, $attribute);
873
 
874
+ } elseif ( strpos($attribute, self::POST_META_PREFIX) !== false ) {
875
 
876
  return $this->getProductMeta($product, $attribute);
877
 
878
+ } elseif ( strpos($attribute, self::PRODUCT_TAXONOMY_PREFIX) !== false ) {
879
 
880
  return $this->getProductTaxonomy($product, $attribute);
881
 
882
+ } elseif ( substr($attribute, 0, 6) == "image_" ) {
883
 
884
  # For additional image method images() will be used with extra parameter - image number
885
  $imageKey = explode("_", $attribute);
886
  $params[] = $imageKey[1];
887
  $attribute = "images";
888
+ $method = array( $this, $attribute );
889
 
890
  return call_user_func_array($method, $params);
891
  } else {
902
  * @since 3.2.0
903
  * @return mixed
904
  */
905
+ private function id( $product ) {
 
906
  return $product->get_id();
907
  }
908
 
914
  *
915
  * @return mixed
916
  */
917
+ private function title( $product ) {
 
918
  return $product->get_name();
919
  }
920
 
926
  *
927
  * @return mixed
928
  */
929
+ private function yoast_wpseo_title( $product ) {
930
  $title = "";
931
+ if ( class_exists('WPSEO_Frontend') ) {
932
  $title = WPSEO_Frontend::get_instance()->get_seo_title(get_post($product->get_id()));
933
  }
934
+ if ( ! empty($title) ) {
935
  return $title;
936
  }
937
 
951
  if ( class_exists( 'All_in_One_SEO_Pack' ) ) {
952
  global $aioseop_options, $aiosp;
953
  $selfLoadAIOSP = false;
954
+ if ( ! is_array( $aioseop_options ) ) $aioseop_options = get_option( 'aioseop_options' );
955
  if ( ! ( $aiosp instanceof All_in_One_SEO_Pack ) ) {
956
  $aiosp = new All_in_One_SEO_Pack();
957
  $selfLoadAIOSP = true;
980
  *
981
  * @return mixed|string
982
  */
983
+ private function description( $product ) {
984
 
985
  $description = $product->get_description();
986
 
987
  # Get Variation Description
988
+ if ( $product->is_type('variation') && empty($description) ) {
989
  $parent = wc_get_product($product->get_parent_id());
990
  $description = $parent->get_description();
991
  }
992
  $description = $this->remove_short_codes($description);
993
 
994
  # Add variations attributes after description to prevent Facebook error
995
+ if ( $this->config['provider'] == 'facebook' ) {
996
  $variationInfo = explode("-", $product->get_name());
997
+ if ( isset($variationInfo[1]) ) {
998
  $extension = $variationInfo[1];
999
  } else {
1000
  $extension = $product->get_id();
1013
  *
1014
  * @return mixed
1015
  */
1016
+ private function yoast_wpseo_metadesc( $product ) {
1017
  $description = "";
1018
+ if ( class_exists('WPSEO_Frontend') ) {
1019
  $description = wpseo_replace_vars(WPSEO_Meta::get_value('metadesc', $product->get_id()), get_post($product->get_id()));
1020
  }
1021
+ if ( ! empty($description) ) {
1022
  return $description;
1023
  }
1024
 
1038
  if ( class_exists( 'All_in_One_SEO_Pack' ) ) {
1039
  global $aioseop_options, $aiosp;
1040
  $selfLoadAIOSP = false;
1041
+ if ( ! is_array( $aioseop_options ) ) $aioseop_options = get_option( 'aioseop_options' );
1042
  if ( ! ( $aiosp instanceof All_in_One_SEO_Pack ) ) {
1043
  $aiosp = new All_in_One_SEO_Pack();
1044
  $selfLoadAIOSP = true;
1064
  *
1065
  * @return mixed|string
1066
  */
1067
+ private function short_description( $product ) {
 
1068
 
1069
  $short_description = $product->get_short_description();
1070
 
1071
  # Get Variation Short Description
1072
+ if ( $product->is_type('variation') && empty($short_description) ) {
1073
  $parent = wc_get_product($product->get_parent_id());
1074
  $short_description = $parent->get_short_description();
1075
  }
1089
  *
1090
  * @return mixed|string
1091
  */
1092
+ private function remove_short_codes( $content ) {
1093
+ if ( empty($content) ) {
 
1094
  return "";
1095
  }
1096
 
1097
  # Remove DIVI Builder Short Codes
1098
+ if ( class_exists('ET_Builder_Module') || defined('ET_BUILDER_PLUGIN_VERSION') ) {
1099
  $content = preg_replace('/\[\/?et_pb.*?\]/', '', $content);
1100
  }
1101
 
1114
  *
1115
  * @return mixed
1116
  */
1117
+ private function product_type( $product ) {
 
1118
  $id = $product->get_id();
1119
+ if ( $product->is_type('variation') ) {
1120
  $id = $product->get_parent_id();
1121
  }
1122
 
1123
+ return strip_tags(wc_get_product_category_list($id, ">", ""));
1124
  }
1125
 
1126
  /**
1131
  *
1132
  * @return mixed
1133
  */
1134
+ private function link( $product ) {
 
1135
  return $product->get_permalink();
1136
  }
1137
 
1143
  *
1144
  * @return mixed
1145
  */
1146
+ private function ex_link( $product ) {
1147
+ if ( $product->is_type('external') ) {
 
1148
  return $product->get_product_url();
1149
  }
1150
 
1159
  *
1160
  * @return mixed
1161
  */
1162
+ private function image( $product ) {
 
1163
  $id = $product->get_id();
1164
  $image = "";
1165
+ if ( $product->is_type('variation') ) {
1166
  $getImage = wp_get_attachment_image_src(get_post_thumbnail_id($id), 'single-post-thumbnail');
1167
+ if ( has_post_thumbnail($id) && ! empty($getImage[0]) ) :
1168
  $image = woo_feed_get_formatted_url($getImage[0]);
1169
+ else :
1170
  $getImage = wp_get_attachment_image_src(get_post_thumbnail_id($product->get_parent_id()), 'single-post-thumbnail');
1171
  $image = woo_feed_get_formatted_url($getImage[0]);
1172
  endif;
1173
  } else {
1174
+ if ( has_post_thumbnail($id) ) :
1175
  $getImage = wp_get_attachment_image_src(get_post_thumbnail_id($id), 'single-post-thumbnail');
1176
  $image = woo_feed_get_formatted_url($getImage[0]);
1177
+ else :
1178
  $image = woo_feed_get_formatted_url(wp_get_attachment_url($id));
1179
  endif;
1180
  }
1190
  *
1191
  * @return mixed
1192
  */
1193
+ private function feature_image( $product ) {
 
1194
  $id = $product->get_id();
1195
  $feature_image = "";
1196
+ if ( $product->is_type('variation') ) {
1197
  $getImage = wp_get_attachment_image_src(get_post_thumbnail_id($id), 'single-post-thumbnail');
1198
+ if ( has_post_thumbnail($id) && ! empty($getImage[0]) ) :
1199
  $feature_image = woo_feed_get_formatted_url($getImage[0]);
1200
+ else :
1201
  $getImage = wp_get_attachment_image_src(get_post_thumbnail_id($product->get_parent_id()), 'single-post-thumbnail');
1202
  $feature_image = woo_feed_get_formatted_url($getImage[0]);
1203
  endif;
1204
  } else {
1205
+ if ( has_post_thumbnail($id) ) :
1206
  $getImage = wp_get_attachment_image_src(get_post_thumbnail_id($id), 'single-post-thumbnail');
1207
  $feature_image = woo_feed_get_formatted_url($getImage[0]);
1208
+ else :
1209
  $feature_image = woo_feed_get_formatted_url(wp_get_attachment_url($id));
1210
  endif;
1211
  }
1281
  *
1282
  * @return mixed
1283
  */
1284
+ private function type( $product ) {
 
1285
  return $product->get_type();
1286
  }
1287
 
1293
  *
1294
  * @return mixed
1295
  */
1296
+ private function is_bundle( $product ) {
 
1297
  return "no";
1298
  }
1299
 
1305
  *
1306
  * @return mixed
1307
  */
1308
+ private function multipack( $product ) {
 
1309
  $multi_pack = "";
1310
+ if ( $product->is_type('grouped') ) {
1311
+ $multi_pack = ( ! empty($product->get_children())) ? count($product->get_children()) : "";
1312
  }
1313
 
1314
  return $multi_pack;
1322
  *
1323
  * @return mixed
1324
  */
1325
+ private function visibility( $product ) {
 
1326
  return $product->get_catalog_visibility();
1327
  }
1328
 
1334
  *
1335
  * @return mixed
1336
  */
1337
+ private function rating_total( $product ) {
 
1338
  return $product->get_rating_count();
1339
  }
1340
 
1346
  *
1347
  * @return mixed
1348
  */
1349
+ private function rating_average( $product ) {
 
1350
  return $product->get_average_rating();
1351
  }
1352
 
1358
  *
1359
  * @return mixed
1360
  */
1361
+ private function tags( $product ) {
 
1362
  $id = $product->get_id();
1363
+ if ( $product->is_type('variation') ) {
1364
  $id = $product->get_parent_id();
1365
  }
1366
 
1367
  $tags = get_the_term_list($id, "product_tag", "", ",", "");
1368
 
1369
+ if ( ! empty($tags) ) {
1370
  return strip_tags($tags);
1371
  }
1372
 
1381
  *
1382
  * @return mixed
1383
  */
1384
+ private function item_group_id( $product ) {
 
1385
  $id = $product->get_id();
1386
+ if ( $product->is_type('variation') ) {
1387
  $id = $product->get_parent_id();
1388
  }
1389
 
1398
  *
1399
  * @return mixed
1400
  */
1401
+ private function sku( $product ) {
 
1402
  return $product->get_sku();
1403
  }
1404
 
1410
  *
1411
  * @return mixed
1412
  */
1413
+ private function parent_sku( $product ) {
1414
+ if ( $product->is_type('variation') ) {
 
1415
  $id = $product->get_parent_id();
1416
  $parent = wc_get_product($id);
1417
 
1429
  *
1430
  * @return mixed
1431
  */
1432
+ private function availability( $product ) {
 
1433
  $id = $product->get_id();
1434
  $status = get_post_meta($id, '_stock_status', true);
1435
+ if ( $status ) {
1436
+ if ( $status == 'instock' ) {
1437
  return "in stock";
1438
+ } elseif ( $status == 'outofstock' ) {
1439
  return "out of stock";
1440
+ } elseif ( $status == 'onbackorder' ) {
1441
  return "on backorder";
1442
  } else {
1443
  return "in stock";
1455
  *
1456
  * @return mixed
1457
  */
1458
+ private function quantity( $product ) {
1459
+ if ( $product->is_type('variable') && $product->has_child() ) {
 
1460
  $visible_children = $product->get_visible_children();
1461
  $qty = array();
1462
+ foreach ( $visible_children as $key => $child ) {
1463
  $childQty = get_post_meta($child, '_stock', true);
1464
  $qty[] = (int)$childQty + 0;
1465
  }
1466
 
1467
+ if ( isset($this->config['variable_quantity']) ) {
1468
  $vaQty = $this->config['variable_quantity'];
1469
+ if ( $vaQty == "max" ) {
1470
  return max($qty);
1471
+ } elseif ( $vaQty == "min" ) {
1472
  return min($qty);
1473
+ } elseif ( $vaQty == "sum" ) {
1474
  return array_sum($qty);
1475
+ } elseif ( $vaQty == "first" ) {
1476
+ return ( (int)$qty[0]);
1477
  }
1478
 
1479
  return array_sum($qty);
1491
  *
1492
  * @return mixed
1493
  */
1494
+ private function sale_price_sdate( $product ) {
 
1495
  $startDate = $product->get_date_on_sale_from();
1496
+ if ( is_object($startDate) ) {
1497
  return $startDate->date_i18n();
1498
  }
1499
 
1508
  *
1509
  * @return mixed
1510
  */
1511
+ private function sale_price_edate( $product ) {
 
1512
  $endDate = $product->get_date_on_sale_to();
1513
+ if ( is_object($endDate) ) {
1514
  return $endDate->date_i18n();
1515
  }
1516
 
1525
  *
1526
  * @return mixed
1527
  */
1528
+ private function price( $product ) {
 
1529
  $price = $product->get_regular_price();
1530
  # Set variable product regular price according to setting
1531
+ if ( $product->is_type('variable') ) {
1532
  $price = $this->getVariableProductPrice($product, 'regular_price');
1533
+ } elseif ( $product->is_type('grouped') ) {
1534
  return $this->getGroupProductPrice($product, 'regular');
1535
  }
1536
 
1545
  *
1546
  * @return mixed
1547
  */
1548
+ private function current_price( $product ) {
 
1549
  $price = $product->get_price();
1550
  # Set variable product current price according to setting
1551
+ if ( $product->is_type('variable') ) {
1552
  $price = $this->getVariableProductPrice($product, 'price');
1553
+ } elseif ( $product->is_type('grouped') ) {
1554
  return $this->getGroupProductPrice($product, 'current');
1555
  }
1556
 
1565
  *
1566
  * @return mixed
1567
  */
1568
+ private function sale_price( $product ) {
 
1569
  $price = $product->get_sale_price();
1570
  # Set variable product sale price according to setting
1571
+ if ( $product->is_type('variable') ) {
1572
  $price = $this->getVariableProductPrice($product, 'sale_price');
1573
+ } elseif ( $product->is_type('grouped') ) {
1574
  return $this->getGroupProductPrice($product, 'sale');
1575
  }
1576
 
1670
  *
1671
  * @return int|string
1672
  */
1673
+ private function getGroupProductPrice( $grouped, $type, $tax = false ) {
1674
  $groupProductIds = $grouped->get_children();
1675
  $sum = 0;
1676
+ if ( ! empty($groupProductIds) ) {
1677
+ foreach ( $groupProductIds as $id ) {
1678
  $product = wc_get_product($id);
1679
 
1680
+ if ( ! is_object($product) ) {
1681
  continue; // make sure that the product exists..
1682
  }
1683
 
1684
+ if ( $tax ) {
1685
+ if ( $type == "regular" ) {
1686
  $regularPrice = $this->price_with_tax($product);
1687
  $sum += (float)$regularPrice;
1688
+ } elseif ( $type == "current" ) {
1689
  $currentPrice = $this->current_price_with_tax($product);
1690
  $sum += (float)$currentPrice;
1691
  } else {
1693
  $sum += (float)$salePrice;
1694
  }
1695
  } else {
1696
+ if ( $type == "regular" ) {
1697
  $regularPrice = $this->price($product);
1698
  $sum += (float)$regularPrice;
1699
+ } elseif ( $type == "current" ) {
1700
  $currentPrice = $this->current_price($product);
1701
  $sum += (float)$currentPrice;
1702
  } else {
1723
  private function getVariableProductPrice( $variable, $type ) {
1724
  if ( $type == "regular_price" ) {
1725
  return $variable->get_variation_regular_price();
1726
+ } elseif ( $type == "sale_price" ) {
1727
  return $variable->get_variation_sale_price();
1728
  } else {
1729
  return $variable->get_variation_price();
1755
  *
1756
  * @return mixed
1757
  */
1758
+ private function weight( $product ) {
 
1759
  // echo "Product Id: ".$product->get_name();
1760
  // echo " Product Name: ".$product->get_id(); echo "<br>";
1761
  // echo " Weight: ".$product->get_weight(); echo "<br>";
1771
  *
1772
  * @return mixed
1773
  */
1774
+ private function width( $product ) {
 
1775
  return $product->get_width();
1776
  }
1777
 
1783
  *
1784
  * @return mixed
1785
  */
1786
+ private function height( $product ) {
 
1787
  return $product->get_height();
1788
  }
1789
 
1795
  *
1796
  * @return mixed
1797
  */
1798
+ private function length( $product ) {
 
1799
  return $product->get_length();
1800
  }
1801
 
1807
  *
1808
  * @return mixed
1809
  */
1810
+ private function shipping_class( $product ) {
 
1811
  return $product->get_shipping_class();
1812
  }
1813
 
1819
  *
1820
  * @return mixed
1821
  */
1822
+ private function author_name( $product ) {
 
1823
  $post = get_post($product->get_id());
1824
  $authorId = $post->post_author;
1825
 
1834
  *
1835
  * @return mixed
1836
  */
1837
+ private function author_email( $product ) {
 
1838
  $post = get_post($product->get_id());
1839
  $authorId = $post->post_author;
1840
 
1849
  *
1850
  * @return mixed
1851
  */
1852
+ private function date_created( $product ) {
 
1853
  $dateCreated = $product->get_date_created();
1854
 
1855
  return date("Y-m-d", strtotime($dateCreated));
1863
  *
1864
  * @return mixed
1865
  */
1866
+ private function date_updated( $product ) {
 
1867
  $dateModified = $product->get_date_modified();
1868
 
1869
  return date("Y-m-d", strtotime($dateModified));
1877
  *
1878
  * @return mixed
1879
  */
1880
+ private function sale_price_effective_date( $product ) {
 
1881
  $sale_price_effective_date = "";
1882
  $from = $this->sale_price_sdate($product);
1883
  $to = $this->sale_price_edate($product);
1884
+ if ( ! empty($from) && ! empty($to) ) {
1885
  $from = date("c", strtotime($from));
1886
  $to = date("c", strtotime($to));
1887
  $sale_price_effective_date = "$from" . "/" . "$to";
1900
  *
1901
  * @return string
1902
  */
1903
+ public function getProductAttribute( $product, $attr ) {
 
1904
  $id = $product->get_id();
1905
  $attr = str_replace(self::PRODUCT_ATTRIBUTE_PREFIX, "", $attr);
1906
 
1907
+ if ( woo_feed_wc_version_check(3.2) ) {
1908
+ if ( woo_feed_wc_version_check(3.6) ) {
1909
  $attr = str_replace("pa_", "", $attr);
1910
  }
1911
  $value = $product->get_attribute($attr);
1912
 
1913
  return $value;
1914
  } else {
1915
+ return implode(',', wc_get_product_terms($id, $attr, array( 'fields' => 'names' )));
1916
  }
1917
  }
1918
 
1926
  *
1927
  * @return mixed|string
1928
  */
1929
+ public function getProductMeta( $product, $meta ) {
 
1930
  $id = $product->get_id();
1931
  $meta = str_replace(self::POST_META_PREFIX, "", $meta);
1932
 
1933
+ if ( strpos($meta, 'attribute_pa') !== false ) {
1934
  $productMeta = $this->getProductAttribute($product, str_replace("attribute_", "", $meta));
1935
  } else {
1936
  $productMeta = get_post_meta($id, $meta, true);
1938
 
1939
  //@TODO check pro version
1940
 
1941
+ if ( $productMeta == "" ) {
1942
  $postParent = wp_get_post_parent_id($id);
1943
+ if ( $postParent > 0 ) {
1944
  $productMeta = get_post_meta($postParent, $meta, true);
1945
  }
1946
  }
1957
  *
1958
  * @return string
1959
  */
1960
+ public function getProductTaxonomy( $product, $taxonomy ) {
 
1961
  $id = $product->get_id();
1962
  $taxonomy = str_replace(self::PRODUCT_TAXONOMY_PREFIX, "", $taxonomy);
1963
  $taxonomy_list = get_the_term_list($id, $taxonomy, "", ",", "");
1964
 
1965
+ if ( ! empty($taxonomy_list) ) {
1966
  return strip_tags($taxonomy_list);
1967
  }
1968
 
1979
  *
1980
  * @return mixed
1981
  */
1982
+ private function price_format( $name, $conditionName, $result ) {
 
1983
  $plus = "+";
1984
  $minus = "-";
1985
  $percent = "%";
1986
 
1987
+ if ( strpos($name, 'price') !== false ) {
1988
+ if ( strpos($result, $plus) !== false && strpos($result, $percent) !== false ) {
1989
  $result = str_replace("+", "", $result);
1990
  $result = str_replace("%", "", $result);
1991
+ if ( is_numeric($result) ) {
1992
  $result = $conditionName + (($conditionName * $result) / 100);
1993
  }
1994
+ } elseif ( strpos($result, $minus) !== false && strpos($result, $percent) !== false ) {
1995
  $result = str_replace("-", "", $result);
1996
  $result = str_replace("%", "", $result);
1997
+ if ( is_numeric($result) ) {
1998
  $result = $conditionName - (($conditionName * $result) / 100);
1999
  }
2000
+ } elseif ( strpos($result, $plus) !== false ) {
2001
  $result = str_replace("+", "", $result);
2002
+ if ( is_numeric($result) ) {
2003
  $result = ($conditionName + $result);
2004
  }
2005
+ } elseif ( strpos($result, $minus) !== false ) {
2006
  $result = str_replace("-", "", $result);
2007
+ if ( is_numeric($result) ) {
2008
  $result = $conditionName - $result;
2009
  }
2010
  }
2022
  *
2023
  * @return float|int|string
2024
  */
2025
+ public function format_output( $output, $outputTypes ) {
2026
+ if ( ! empty($outputTypes) && is_array($outputTypes) ) {
 
2027
 
2028
  # Format Output According to output type
2029
+ if ( in_array(2, $outputTypes) ) { # Strip Tags
2030
  $output = strip_tags(html_entity_decode($output));
2031
  }
2032
 
2033
+ if ( in_array(3, $outputTypes) ) { # UTF-8 Encode
2034
  $output = utf8_encode($output);
2035
  }
2036
 
2037
+ if ( in_array(4, $outputTypes) ) { # htmlentities
2038
  $output = htmlentities($output, ENT_QUOTES, 'UTF-8');
2039
  }
2040
 
2041
+ if ( in_array(5, $outputTypes) ) { # Integer
2042
  $output = absint($output);
2043
  }
2044
 
2045
+ if ( in_array(6, $outputTypes) ) { # Format Price
2046
  $output = (float)$output;
2047
  $output = number_format($output, 2, '.', '');
2048
  }
2049
 
2050
+ if ( in_array(7, $outputTypes) ) { # Delete Space
2051
  $output = trim($output);
2052
  $output = preg_replace('!\s+!', ' ', $output);
2053
  }
2054
 
2055
+ if ( in_array(9, $outputTypes) ) { # Remove Invalid Character
2056
  $output = woo_feed_stripInvalidXml($output);
2057
  }
2058
 
2059
+ if ( in_array(10, $outputTypes) ) { # Remove ShortCodes
2060
  $output = $this->remove_short_codes($output);
2061
  }
2062
 
2063
+ if ( in_array(8, $outputTypes) ) { # Add CDATA
2064
  $output = '<![CDATA[' . $output . ']]>';
2065
  }
2066
  }
2085
  }
2086
 
2087
  # Add Prefix before Output
2088
+ if ( $prefix != "" ) {
2089
  $output = "$prefix" . $output;
2090
  }
2091
 
2092
  # Add Suffix after Output
2093
+ if ( $suffix != "" ) {
2094
  if ( $attribute == 'price'
2095
  || $attribute == 'sale_price'
2096
  || $attribute == 'current_price'
2102
 
2103
  $output = $output . " " . $suffix;
2104
 
2105
+ } elseif ( substr( $output, 0, 4 ) === "http" ) {
2106
 
2107
  # Parse URL Parameters if available into suffix field
2108
  $output = woo_feed_make_url_with_parameter( $output, $suffix );
includes/classes/class-woo-feed-products.php CHANGED
@@ -64,26 +64,26 @@ class Woo_Feed_Products {
64
  public $attributeList;
65
 
66
  public $feedRule;
67
- public $idExist=array();
68
  public $pi;
69
 
70
 
71
 
72
- public function wooProductQuery($arg) {
73
 
74
  global $wpdb;
75
 
76
 
77
- $limit="";
78
- $offset="";
79
- if($arg['limit']!="" && $arg['limit']!="-1" && $arg['limit']>0){
80
- $limit= absint( $arg['limit'] );
81
- $limit="LIMIT $limit";
82
 
83
 
84
- if($arg['offset']!="" && $arg['offset']!="-1"){
85
- $offset= absint( $arg['offset'] );
86
- $offset="OFFSET $offset";
87
  }
88
  }
89
 
@@ -128,8 +128,8 @@ class Woo_Feed_Products {
128
  'status' => 'publish',
129
  'orderby' => 'date',
130
  'order' => 'DESC',
131
- 'type' => array('variable','variation','simple','grouped','external'),
132
- 'return' => 'ids',
133
  );
134
 
135
 
@@ -143,22 +143,21 @@ class Woo_Feed_Products {
143
 
144
  $this->pi = 1; # Product Index
145
  foreach ( $products as $key => $productId ) {
146
- $prod=wc_get_product($productId);
147
 
148
  $id = $prod->get_id();
149
 
150
- if($getIDs){
151
- if(in_array($id,$getIDs)){
152
  continue;
153
- }else{
154
  array_push($this->idExist,$id);
155
  }
156
- }else{
157
  array_push($this->idExist,$id);
158
  }
159
 
160
- if ( $prod->is_type( 'simple' ) )
161
- {
162
 
163
  $simple = new WC_Product_Simple( $id );
164
 
@@ -174,11 +173,11 @@ class Woo_Feed_Products {
174
 
175
 
176
  # Featured Image
177
- if ( has_post_thumbnail( $id ) ):
178
  $image = wp_get_attachment_image_src( get_post_thumbnail_id( $id ), 'single-post-thumbnail' );
179
  $this->productsList[ $this->pi ]['image'] = $this->get_formatted_url( $image[0] );
180
  $this->productsList[ $this->pi ]['feature_image'] = $this->get_formatted_url( $image[0] );
181
- else:
182
  $this->productsList[ $this->pi ]['image'] = $this->get_formatted_url( wp_get_attachment_url( $id ) );
183
  $this->productsList[ $this->pi ]['feature_image'] = $this->get_formatted_url( wp_get_attachment_url( $id ) );
184
  endif;
@@ -190,11 +189,10 @@ class Woo_Feed_Products {
190
  $mKey = 1;
191
  foreach ( $attachmentIds as $attachmentId ) {
192
  $imgUrls[ $mKey ] = $this->get_formatted_url( wp_get_attachment_url( $attachmentId ) );
193
- $this->productsList[ $this->pi ]["image_$mKey"] = $imgUrls[ $mKey ];
194
  $mKey ++;
195
- }
196
-
197
- }
198
 
199
  $this->productsList[ $this->pi ]['images'] = implode( ",", $imgUrls );
200
  $this->productsList[ $this->pi ]['condition'] = "new";
@@ -229,8 +227,8 @@ class Woo_Feed_Products {
229
  $from = $this->sale_price_effective_date( $id, '_sale_price_dates_from' );
230
  $to = $this->sale_price_effective_date( $id, '_sale_price_dates_to' );
231
  if ( ! empty( $from ) && ! empty( $to ) ) {
232
- $from = date( "c", strtotime( $from ) );
233
- $to = date( "c", strtotime( $to ) );
234
  $this->productsList[ $this->pi ]['sale_price_effective_date'] = "$from" . "/" . "$to";
235
  } else {
236
  $this->productsList[ $this->pi ]['sale_price_effective_date'] = "";
@@ -245,7 +243,7 @@ class Woo_Feed_Products {
245
  // }
246
  // }
247
  }
248
- else if ( $prod->is_type( 'external' ) ) {
249
 
250
  $external = new WC_Product_External( $id );
251
 
@@ -260,11 +258,11 @@ class Woo_Feed_Products {
260
 
261
 
262
  # Featured Image
263
- if ( has_post_thumbnail( $id ) ):
264
  $image = wp_get_attachment_image_src( get_post_thumbnail_id( $id ), 'single-post-thumbnail' );
265
  $this->productsList[ $this->pi ]['image'] = $this->get_formatted_url( $image[0] );
266
  $this->productsList[ $this->pi ]['feature_image'] = $this->get_formatted_url( $image[0] );
267
- else:
268
  $this->productsList[ $this->pi ]['image'] = $this->get_formatted_url( wp_get_attachment_url( $id ) );
269
  $this->productsList[ $this->pi ]['feature_image'] = $this->get_formatted_url( wp_get_attachment_url( $id ) );
270
  endif;
@@ -276,11 +274,10 @@ class Woo_Feed_Products {
276
  $mKey = 1;
277
  foreach ( $attachmentIds as $attachmentId ) {
278
  $imgUrls[ $mKey ] = $this->get_formatted_url( wp_get_attachment_url( $attachmentId ) );
279
- $this->productsList[ $this->pi ]["image_$mKey"] = $imgUrls[ $mKey ];
280
  $mKey ++;
281
- }
282
-
283
- }
284
 
285
  $this->productsList[ $this->pi ]['images'] = implode( ",", $imgUrls );
286
  $this->productsList[ $this->pi ]['condition'] = "new";
@@ -315,8 +312,8 @@ class Woo_Feed_Products {
315
  $from = $this->sale_price_effective_date( $id, '_sale_price_dates_from' );
316
  $to = $this->sale_price_effective_date( $id, '_sale_price_dates_to' );
317
  if ( ! empty( $from ) && ! empty( $to ) ) {
318
- $from = date( "c", strtotime( $from ) );
319
- $to = date( "c", strtotime( $to ) );
320
  $this->productsList[ $this->pi ]['sale_price_effective_date'] = "$from" . "/" . "$to";
321
  } else {
322
  $this->productsList[ $this->pi ]['sale_price_effective_date'] = "";
@@ -331,7 +328,7 @@ class Woo_Feed_Products {
331
  // }
332
  // }
333
  }
334
- else if ( $prod->is_type( 'grouped' ) ) {
335
 
336
  $grouped = new WC_Product_Grouped( $id );
337
 
@@ -346,11 +343,11 @@ class Woo_Feed_Products {
346
  $this->productsList[ $this->pi ]['ex_link'] = $grouped->get_permalink();
347
 
348
  # Featured Image
349
- if ( has_post_thumbnail( $id ) ):
350
  $image = wp_get_attachment_image_src( get_post_thumbnail_id( $id ), 'single-post-thumbnail' );
351
  $this->productsList[ $this->pi ]['image'] = $this->get_formatted_url( $image[0] );
352
  $this->productsList[ $this->pi ]['feature_image'] = $this->get_formatted_url( $image[0] );
353
- else:
354
  $this->productsList[ $this->pi ]['image'] = $this->get_formatted_url( wp_get_attachment_url( $id ) );
355
  $this->productsList[ $this->pi ]['feature_image'] = $this->get_formatted_url( wp_get_attachment_url( $id ) );
356
  endif;
@@ -362,11 +359,10 @@ class Woo_Feed_Products {
362
  $mKey = 1;
363
  foreach ( $attachmentIds as $attachmentId ) {
364
  $imgUrls[ $mKey ] = $this->get_formatted_url( wp_get_attachment_url( $attachmentId ) );
365
- $this->productsList[ $this->pi ]["image_$mKey"] = $imgUrls[ $mKey ];
366
  $mKey ++;
367
- }
368
-
369
- }
370
 
371
  $this->productsList[ $this->pi ]['images'] = implode( ",", $imgUrls );
372
  $this->productsList[ $this->pi ]['condition'] = "new";
@@ -400,8 +396,8 @@ class Woo_Feed_Products {
400
  $from = $this->sale_price_effective_date( $id, '_sale_price_dates_from' );
401
  $to = $this->sale_price_effective_date( $id, '_sale_price_dates_to' );
402
  if ( ! empty( $from ) && ! empty( $to ) ) {
403
- $from = date( "c", strtotime( $from ) );
404
- $to = date( "c", strtotime( $to ) );
405
  $this->productsList[ $this->pi ]['sale_price_effective_date'] = "$from" . "/" . "$to";
406
  } else {
407
  $this->productsList[ $this->pi ]['sale_price_effective_date'] = "";
@@ -416,7 +412,7 @@ class Woo_Feed_Products {
416
  // }
417
  // }
418
  }
419
- else if ( $prod->is_type( 'variable' ) ) {
420
 
421
  $variable = new WC_Product_Variable( $id );
422
 
@@ -432,11 +428,11 @@ class Woo_Feed_Products {
432
 
433
 
434
  # Featured Image
435
- if ( has_post_thumbnail( $id ) ):
436
  $image = wp_get_attachment_image_src( get_post_thumbnail_id( $id ), 'single-post-thumbnail' );
437
  $this->productsList[ $this->pi ]['image'] = $this->get_formatted_url( $image[0] );
438
  $this->productsList[ $this->pi ]['feature_image'] = $this->get_formatted_url( $image[0] );
439
- else:
440
  $this->productsList[ $this->pi ]['image'] = $this->get_formatted_url( wp_get_attachment_url( $id ) );
441
  $this->productsList[ $this->pi ]['feature_image'] = $this->get_formatted_url( wp_get_attachment_url( $id ) );
442
  endif;
@@ -448,11 +444,10 @@ class Woo_Feed_Products {
448
  $mKey = 1;
449
  foreach ( $attachmentIds as $attachmentId ) {
450
  $imgUrls[ $mKey ] = $this->get_formatted_url( wp_get_attachment_url( $attachmentId ) );
451
- $this->productsList[ $this->pi ]["image_$mKey"] = $imgUrls[ $mKey ];
452
  $mKey ++;
453
- }
454
-
455
- }
456
 
457
  $this->productsList[ $this->pi ]['images'] = implode( ",", $imgUrls );
458
  $this->productsList[ $this->pi ]['condition'] = "new";
@@ -489,8 +484,8 @@ class Woo_Feed_Products {
489
  $from = $this->sale_price_effective_date( $id, '_sale_price_dates_from' );
490
  $to = $this->sale_price_effective_date( $id, '_sale_price_dates_to' );
491
  if ( ! empty( $from ) && ! empty( $to ) ) {
492
- $from = date( "c", strtotime( $from ) );
493
- $to = date( "c", strtotime( $to ) );
494
  $this->productsList[ $this->pi ]['sale_price_effective_date'] = "$from" . "/" . "$to";
495
  } else {
496
  $this->productsList[ $this->pi ]['sale_price_effective_date'] = "";
@@ -505,48 +500,48 @@ class Woo_Feed_Products {
505
  // }
506
  // }
507
  }
508
- else if ( $prod->is_type( 'variation' )) {
509
 
510
- $variation=new WC_Product_Variation($id);
511
 
512
  # Parent Info
513
- $parentId=$variation->get_parent_id();
514
- $parent=new WC_Product_Variable($parentId);
515
 
516
  # Skip if not a valid product
517
- if(!$variation->variation_is_visible()){
518
  continue;
519
  }
520
 
521
- if(!$parent->is_purchasable()){
522
  continue;
523
  }
524
 
525
  # Set Variation Description
526
- $description=$variation->get_description();
527
- if(empty($description)){
528
- $description=$parent->get_description();
529
  }
530
- $description=$this->remove_short_codes($description);
531
 
532
  # Set Variation Short Description
533
- $short_description=$variation->get_short_description();
534
- if(empty($short_description)){
535
- $short_description=$parent->get_short_description();
536
  }
537
- $short_description=$this->remove_short_codes($short_description);
538
 
539
  $this->productsList[ $this->pi ]["id"] = $variation->get_id();
540
  $this->productsList[ $this->pi ]["title"] = $variation->get_name();
541
 
542
- if($this->feedRule['provider'] == 'facebook'){
543
- $variationInfo=explode("-",$variation->get_name());
544
- if(isset($variationInfo[1])){
545
- $extension=$variationInfo[1];
546
- }else{
547
- $extension=$variation->get_id();
548
  }
549
- $description.=" ".$extension;
550
  }
551
 
552
  $this->productsList[ $this->pi ]["description"] = $description;
@@ -559,11 +554,11 @@ class Woo_Feed_Products {
559
 
560
  # Featured Image
561
  $image = wp_get_attachment_image_src( get_post_thumbnail_id( $id ), 'single-post-thumbnail' );
562
- if ( has_post_thumbnail( $id ) && !empty($image[0])):
563
 
564
  $this->productsList[ $this->pi ]['image'] = $this->get_formatted_url( $image[0] );
565
  $this->productsList[ $this->pi ]['feature_image'] = $this->get_formatted_url( $image[0] );
566
- else:
567
  $image = wp_get_attachment_image_src( get_post_thumbnail_id( $variation->get_parent_id() ), 'single-post-thumbnail' );
568
  $this->productsList[ $this->pi ]['image'] = $this->get_formatted_url( $image[0] );
569
  $this->productsList[ $this->pi ]['feature_image'] = $this->get_formatted_url( $image[0] );
@@ -575,12 +570,11 @@ class Woo_Feed_Products {
575
  if ( $attachmentIds && is_array( $attachmentIds ) ) {
576
  $mKey = 1;
577
  foreach ( $attachmentIds as $attachmentId ) {
578
- $imgUrls[$mKey] =$this->get_formatted_url( wp_get_attachment_url( $attachmentId ));
579
- $this->productsList[ $this->pi ]["image_$mKey"] = $imgUrls[$mKey];
580
  $mKey ++;
581
- }
582
-
583
- }
584
 
585
  $this->productsList[ $this->pi ]['images'] = implode( ",", $imgUrls );
586
  $this->productsList[ $this->pi ]['condition'] = "new";
@@ -615,8 +609,8 @@ class Woo_Feed_Products {
615
  $from = $this->sale_price_effective_date( $id, '_sale_price_dates_from' );
616
  $to = $this->sale_price_effective_date( $id, '_sale_price_dates_to' );
617
  if ( ! empty( $from ) && ! empty( $to ) ) {
618
- $from = date( "c", strtotime( $from ) );
619
- $to = date( "c", strtotime( $to ) );
620
  $this->productsList[ $this->pi ]['sale_price_effective_date'] = "$from" . "/" . "$to";
621
  } else {
622
  $this->productsList[ $this->pi ]['sale_price_effective_date'] = "";
@@ -635,10 +629,10 @@ class Woo_Feed_Products {
635
  $this->pi ++;
636
  }
637
 
638
- if($getIDs){
639
- $mergedIds=array_merge($getIDs,$this->idExist);
640
  update_option("wf_check_duplicate",$mergedIds);
641
- }else{
642
  update_option("wf_check_duplicate",$this->idExist);
643
  }
644
 
@@ -657,24 +651,24 @@ class Woo_Feed_Products {
657
  public function getGroupProductPrice( $grouped, $type, $taxable = false ) {
658
  $groupProductIds = $grouped->get_children();
659
  $sum = 0;
660
- if( ! empty( $groupProductIds ) ) {
661
- foreach( $groupProductIds as $id ) {
662
  $product = wc_get_product( $id );
663
- if( ! $product ) {
664
  continue; // make sure that the product exists..
665
  }
666
  $regularPrice = $product->get_regular_price();
667
- if( empty( $regularPrice ) ) $regularPrice = 0;
668
  $currentPrice = $product->get_price();
669
- if( empty( $currentPrice ) ) $currentPrice = 0;
670
- if( $type == "regular" ) {
671
- if( $taxable ) {
672
- $regularPrice=$this->getPriceWithTax($product);
673
  }
674
  $sum += $regularPrice;
675
- }else{
676
- if( $taxable ) {
677
- $currentPrice=$this->getPriceWithTax($product);
678
  }
679
  $sum += $currentPrice;
680
  }
@@ -691,37 +685,37 @@ class Woo_Feed_Products {
691
  * @param $variations
692
  * @param $parent
693
  */
694
- public function getWC3Variations($variations, $parent ) {
695
- try{
696
- if(is_array($variations) && (sizeof($variations) > 0 )){
697
- foreach ($variations as $vKey=>$variationProd){
698
 
699
- $id=$variationProd['variation_id'];
700
 
701
- $variation=new WC_Product_Variation($id);
702
 
703
- if(!is_object($variation)){
704
  continue;
705
  }
706
- $parentId=$variation->get_parent_id();
707
- $parent=new WC_Product_Variable($parentId);
708
  # Parent Info
709
- $parentInfo=$variation->get_parent_data();
710
- $variationTitle= $parentInfo['title'];
711
 
712
  # Set Variation Description
713
- $description=$variation->get_description();
714
- if(empty($description)){
715
- $description=$parent->get_description();
716
  }
717
- $description=$this->remove_short_codes($description);
718
 
719
  # Set Variation Short Description
720
- $short_description=$variation->get_short_description();
721
- if(empty($short_description)){
722
- $short_description=$parent->get_short_description();
723
  }
724
- $short_description=$this->remove_short_codes($short_description);
725
 
726
  $this->productsList[ $this->pi ]["id"] = $variation->get_id();
727
  $this->productsList[ $this->pi ]["title"] = $variationTitle;
@@ -736,11 +730,11 @@ class Woo_Feed_Products {
736
 
737
  # Featured Image
738
  $image = wp_get_attachment_image_src( get_post_thumbnail_id( $id ), 'single-post-thumbnail' );
739
- if ( has_post_thumbnail( $id ) && !empty($image[0])):
740
 
741
  $this->productsList[ $this->pi ]['image'] = $this->get_formatted_url( $image[0] );
742
  $this->productsList[ $this->pi ]['feature_image'] = $this->get_formatted_url( $image[0] );
743
- else:
744
  $image = wp_get_attachment_image_src( get_post_thumbnail_id( $variation->get_parent_id() ), 'single-post-thumbnail' );
745
  $this->productsList[ $this->pi ]['image'] = $this->get_formatted_url( $image[0] );
746
  $this->productsList[ $this->pi ]['feature_image'] = $this->get_formatted_url( $image[0] );
@@ -752,12 +746,11 @@ class Woo_Feed_Products {
752
  if ( $attachmentIds && is_array( $attachmentIds ) ) {
753
  $mKey = 1;
754
  foreach ( $attachmentIds as $attachmentId ) {
755
- $imgUrls[$mKey] =$this->get_formatted_url( wp_get_attachment_url( $attachmentId ));
756
- $this->productsList[ $this->pi ]["image_$mKey"] = $imgUrls[$mKey];
757
  $mKey ++;
758
- }
759
-
760
- }
761
 
762
  $this->productsList[ $this->pi ]['images'] = implode( ",", $imgUrls );
763
  $this->productsList[ $this->pi ]['condition'] = "new";
@@ -790,19 +783,19 @@ class Woo_Feed_Products {
790
  $from = $this->sale_price_effective_date( $id, '_sale_price_dates_from' );
791
  $to = $this->sale_price_effective_date( $id, '_sale_price_dates_to' );
792
  if ( ! empty( $from ) && ! empty( $to ) ) {
793
- $from = date( "c", strtotime( $from ) );
794
- $to = date( "c", strtotime( $to ) );
795
  $this->productsList[ $this->pi ]['sale_price_effective_date'] = "$from" . "/" . "$to";
796
  } else {
797
  $this->productsList[ $this->pi ]['sale_price_effective_date'] = "";
798
  }
799
 
800
  # Get all Attributes and their values
801
- $data=$variation->get_data();
802
- $attributes=$data['attributes'];
803
- if(!empty($attributes)){
804
- foreach ($attributes as $aKey=>$attr){
805
- $this->productsList[ $this->pi ][$aKey] = $variation->get_attribute($aKey);
806
  }
807
  }
808
 
@@ -828,7 +821,7 @@ class Woo_Feed_Products {
828
  $this->pi++;
829
  }
830
  }
831
- }catch (Exception $e){
832
 
833
  }
834
 
@@ -982,10 +975,10 @@ class Woo_Feed_Products {
982
  $this->productsList[ $i ]['image'] = $this->get_formatted_url( $mainImage );
983
 
984
  # Featured Image
985
- if ( has_post_thumbnail( $post->ID ) ):
986
  $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );
987
  $this->productsList[ $i ]['feature_image'] = $this->get_formatted_url( $image[0] );
988
- else:
989
  $this->productsList[ $i ]['feature_image'] = $this->get_formatted_url( $mainImage );
990
  endif;
991
 
@@ -997,7 +990,7 @@ class Woo_Feed_Products {
997
  foreach ( $images as $key => $value ) {
998
  if ( $value != $this->productsList[ $i ]['image'] ) {
999
  $imgLink = $this->get_formatted_url( $value );
1000
- $this->productsList[ $i ]["image_$mKey"] = $imgLink;
1001
  if ( ! empty( $imgLink ) ) {
1002
  array_push( $imageLinks, $imgLink );
1003
  }
@@ -1029,14 +1022,13 @@ class Woo_Feed_Products {
1029
  $from = $this->sale_price_effective_date( $this->childID, '_sale_price_dates_from' );
1030
  $to = $this->sale_price_effective_date( $this->childID, '_sale_price_dates_to' );
1031
  if ( ! empty( $from ) && ! empty( $to ) ) {
1032
- $from = date( "c", strtotime( $from ) );
1033
- $to = date( "c", strtotime( $to ) );
1034
  $this->productsList[ $i ]['sale_price_effective_date'] = "$from" . "/" . "$to";
1035
  } else {
1036
  $this->productsList[ $i ]['sale_price_effective_date'] = "";
1037
- }
1038
-
1039
- }
1040
  } elseif ( get_post_type() == 'product' ) {
1041
  if ( $type1 == 'simple' ) {
1042
 
@@ -1071,10 +1063,10 @@ class Woo_Feed_Products {
1071
  $this->productsList[ $i ]['image'] = $this->get_formatted_url( $mainImage );
1072
 
1073
  # Featured Image
1074
- if ( has_post_thumbnail( $post->ID ) ):
1075
  $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );
1076
  $this->productsList[ $i ]['feature_image'] = $this->get_formatted_url( $image[0] );
1077
- else:
1078
  $this->productsList[ $i ]['feature_image'] = $this->get_formatted_url( $mainImage );
1079
  endif;
1080
 
@@ -1086,7 +1078,7 @@ class Woo_Feed_Products {
1086
  foreach ( $images as $key => $value ) {
1087
  if ( $value != $this->productsList[ $i ]['image'] ) {
1088
  $imgLink = $this->get_formatted_url( $value );
1089
- $this->productsList[ $i ]["image_$mKey"] = $imgLink;
1090
  if ( ! empty( $imgLink ) ) {
1091
  array_push( $imageLinks, $imgLink );
1092
  }
@@ -1121,15 +1113,14 @@ class Woo_Feed_Products {
1121
  $from = $this->sale_price_effective_date( $post->ID, '_sale_price_dates_from' );
1122
  $to = $this->sale_price_effective_date( $post->ID, '_sale_price_dates_to' );
1123
  if ( ! empty( $from ) && ! empty( $to ) ) {
1124
- $from = date( "c", strtotime( $from ) );
1125
- $to = date( "c", strtotime( $to ) );
1126
  $this->productsList[ $i ]['sale_price_effective_date'] = "$from" . "/" . "$to";
1127
  } else {
1128
  $this->productsList[ $i ]['sale_price_effective_date'] = "";
1129
- }
1130
-
1131
- }
1132
- else if ( $type1 == 'external' ) {
1133
 
1134
  $mainImage = wp_get_attachment_url( $product->get_image_id() );
1135
 
@@ -1144,7 +1135,7 @@ class Woo_Feed_Products {
1144
 
1145
  $this->productsList[ $i ]['id'] = $post->ID;
1146
  $this->productsList[ $i ]['variation_type'] = "external";
1147
- $this->productsList[ $i ]['title'] =$post->post_title;
1148
  $this->productsList[ $i ]['description'] = do_shortcode( $post->post_content );
1149
 
1150
  $this->productsList[ $i ]['short_description'] = $post->post_excerpt;
@@ -1154,10 +1145,10 @@ class Woo_Feed_Products {
1154
  $this->productsList[ $i ]['image'] = $this->get_formatted_url( $mainImage );
1155
 
1156
  # Featured Image
1157
- if ( has_post_thumbnail( $post->ID ) ):
1158
  $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );
1159
  $this->productsList[ $i ]['feature_image'] = $this->get_formatted_url( $image[0] );
1160
- else:
1161
  $this->productsList[ $i ]['feature_image'] = $this->get_formatted_url( $mainImage );
1162
  endif;
1163
 
@@ -1169,7 +1160,7 @@ class Woo_Feed_Products {
1169
  foreach ( $images as $key => $value ) {
1170
  if ( $value != $this->productsList[ $i ]['image'] ) {
1171
  $imgLink = $this->get_formatted_url( $value );
1172
- $this->productsList[ $i ]["image_$mKey"] = $imgLink;
1173
  if ( ! empty( $imgLink ) ) {
1174
  array_push( $imageLinks, $imgLink );
1175
  }
@@ -1205,14 +1196,13 @@ class Woo_Feed_Products {
1205
  $from = $this->sale_price_effective_date( $post->ID, '_sale_price_dates_from' );
1206
  $to = $this->sale_price_effective_date( $post->ID, '_sale_price_dates_to' );
1207
  if ( ! empty( $from ) && ! empty( $to ) ) {
1208
- $from = date( "c", strtotime( $from ) );
1209
- $to = date( "c", strtotime( $to ) );
1210
  $this->productsList[ $i ]['sale_price_effective_date'] = "$from" . "/" . "$to";
1211
  } else {
1212
  $this->productsList[ $i ]['sale_price_effective_date'] = "";
1213
- }
1214
-
1215
- }
1216
  elseif ( $type1 == 'grouped' ) {
1217
 
1218
  $grouped = new WC_Product_Grouped( $post->ID );
@@ -1263,10 +1253,10 @@ class Woo_Feed_Products {
1263
  $this->productsList[ $i ]['image'] = $this->get_formatted_url( $mainImage );
1264
 
1265
  # Featured Image
1266
- if ( has_post_thumbnail( $post->ID ) ):
1267
  $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );
1268
  $this->productsList[ $i ]['feature_image'] = $this->get_formatted_url( $image[0] );
1269
- else:
1270
  $this->productsList[ $i ]['feature_image'] = $this->get_formatted_url( $mainImage );
1271
  endif;
1272
 
@@ -1278,7 +1268,7 @@ class Woo_Feed_Products {
1278
  foreach ( $images as $key => $value ) {
1279
  if ( $value != $this->productsList[ $i ]['image'] ) {
1280
  $imgLink = $this->get_formatted_url( $value );
1281
- $this->productsList[ $i ]["image_$mKey"] = $imgLink;
1282
  if ( ! empty( $imgLink ) ) {
1283
  array_push( $imageLinks, $imgLink );
1284
  }
@@ -1313,8 +1303,8 @@ class Woo_Feed_Products {
1313
  $from = $this->sale_price_effective_date( $post->ID, '_sale_price_dates_from' );
1314
  $to = $this->sale_price_effective_date( $post->ID, '_sale_price_dates_to' );
1315
  if ( ! empty( $from ) && ! empty( $to ) ) {
1316
- $from = date( "c", strtotime( $from ) );
1317
- $to = date( "c", strtotime( $to ) );
1318
  $this->productsList[ $i ]['sale_price_effective_date'] = "$from" . "/" . "$to";
1319
  } else {
1320
  $this->productsList[ $i ]['sale_price_effective_date'] = "";
@@ -1322,7 +1312,7 @@ class Woo_Feed_Products {
1322
  }
1323
  }
1324
  }
1325
- else if ( $type1 == 'variable' && $product->has_child() ) {
1326
 
1327
  # Check Valid URL
1328
  $mainImage = wp_get_attachment_url( $product->get_image_id() );
@@ -1347,10 +1337,10 @@ class Woo_Feed_Products {
1347
  $this->productsList[ $i ]['image'] = $this->get_formatted_url( $mainImage );
1348
 
1349
  # Featured Image
1350
- if ( has_post_thumbnail( $post->ID ) ):
1351
  $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );
1352
  $this->productsList[ $i ]['feature_image'] = $this->get_formatted_url( $image[0] );
1353
- else:
1354
  $this->productsList[ $i ]['feature_image'] = $this->get_formatted_url( $mainImage );
1355
  endif;
1356
 
@@ -1362,7 +1352,7 @@ class Woo_Feed_Products {
1362
  foreach ( $images as $key => $value ) {
1363
  if ( $value != $this->productsList[ $i ]['image'] ) {
1364
  $imgLink = $this->get_formatted_url( $value );
1365
- $this->productsList[ $i ]["image_$mKey"] = $imgLink;
1366
  if ( ! empty( $imgLink ) ) {
1367
  array_push( $imageLinks, $imgLink );
1368
  }
@@ -1400,8 +1390,8 @@ class Woo_Feed_Products {
1400
  $from = $this->sale_price_effective_date( $post->ID, '_sale_price_dates_from' );
1401
  $to = $this->sale_price_effective_date( $post->ID, '_sale_price_dates_to' );
1402
  if ( ! empty( $from ) && ! empty( $to ) ) {
1403
- $from = date( "c", strtotime( $from ) );
1404
- $to = date( "c", strtotime( $to ) );
1405
  $this->productsList[ $i ]['sale_price_effective_date'] = "$from" . "/" . "$to";
1406
  } else {
1407
  $this->productsList[ $i ]['sale_price_effective_date'] = "";
@@ -1432,15 +1422,14 @@ class Woo_Feed_Products {
1432
  *
1433
  * @return mixed|string
1434
  */
1435
- public function remove_short_codes($content)
1436
- {
1437
- if( empty( $content ) ) {
1438
  return "";
1439
  }
1440
  $content = do_shortcode( $content );
1441
  $content = $this->stripInvalidXml( $content );
1442
  # Remove DIVI Builder Short Codes
1443
- if( class_exists('ET_Builder_Module') || defined('ET_BUILDER_PLUGIN_VERSION')){
1444
  $content = preg_replace('/\[\/?et_pb.*?\]/', '', $content);
1445
  }
1446
  return strip_shortcodes($content);
@@ -1454,16 +1443,16 @@ class Woo_Feed_Products {
1454
  *
1455
  * @return string
1456
  */
1457
- public function stripInvalidXml($value) {
1458
  $ret = "";
1459
- $current="";
1460
- if (empty($value)) {
1461
  return $ret;
1462
  }
1463
  $length = strlen($value);
1464
- for ($i=0; $i < $length; $i++) {
1465
- $current = ord($value{$i});
1466
- if (($current == 0x9) || ($current == 0xA) || ($current == 0xD) || (($current >= 0x20) && ($current <= 0xD7FF)) || (($current >= 0xE000) && ($current <= 0xFFFD)) || (($current >= 0x10000) && ($current <= 0x10FFFF))) {
1467
  $ret .= chr($current);
1468
  }
1469
  else {
@@ -1479,10 +1468,9 @@ class Woo_Feed_Products {
1479
  * @param $url
1480
  * @return bool|string
1481
  */
1482
- public function get_formatted_url($url = "")
1483
- {
1484
- if (!empty($url)) {
1485
- if (substr(trim($url), 0, 4) === "http" || substr(trim($url), 0, 3) === "ftp" || substr(trim($url), 0, 4) === "sftp") {
1486
  return rtrim($url, "/");
1487
  } else {
1488
  $base = get_site_url();
@@ -1501,11 +1489,10 @@ class Woo_Feed_Products {
1501
  * @param $name
1502
  * @return bool|string
1503
  */
1504
- public function get_date($id, $name)
1505
- {
1506
  $date = $this->getAttributeValue($id, $name);
1507
- if ($date) {
1508
- return date("Y-m-d", $date);
1509
  }
1510
  return false;
1511
  }
@@ -1517,10 +1504,9 @@ class Woo_Feed_Products {
1517
  * @param $name
1518
  * @return bool|mixed
1519
  */
1520
- public function get_quantity($id, $name)
1521
- {
1522
  $qty = $this->getAttributeValue($id, $name);
1523
- if ($qty) {
1524
  return $qty + 0;
1525
  }
1526
  return "0";
@@ -1539,21 +1525,20 @@ class Woo_Feed_Products {
1539
  *
1540
  * @return string|false|WP_Error A list of terms on success, false if there are no terms, WP_Error on failure.
1541
  */
1542
- function get_product_term_list($id, $taxonomy, $before = '', $sep = ',', $after = '')
1543
- {
1544
  $terms = get_the_terms($id, $taxonomy);
1545
 
1546
- if (is_wp_error($terms)) {
1547
  return $terms;
1548
  }
1549
 
1550
- if (empty($terms)) {
1551
  return false;
1552
  }
1553
 
1554
  $links = array();
1555
 
1556
- foreach ($terms as $term) {
1557
  $links[] = $term->name;
1558
  }
1559
  ksort($links);
@@ -1567,16 +1552,15 @@ class Woo_Feed_Products {
1567
  * @return bool|array
1568
  */
1569
 
1570
- public function additionalImages($Id)
1571
- {
1572
- $ids=$this->getAttributeValue($Id,"_product_image_gallery");
1573
- $imgIds=!empty($ids)?explode(",",$ids):"";
1574
 
1575
  $images = array();
1576
- if (!empty($imgIds)) {
1577
- foreach ($imgIds as $key => $value) {
1578
- if ($key < 10) {
1579
- $images[$key] = wp_get_attachment_url($value);
1580
  }
1581
  }
1582
  return $images;
@@ -1591,13 +1575,12 @@ class Woo_Feed_Products {
1591
  *
1592
  * @return string
1593
  */
1594
- public function availability($id)
1595
- {
1596
- $status=$this->getProductMeta($id,"_stock_status");
1597
- if ($status) {
1598
- if ($status == 'instock') {
1599
  return "in stock";
1600
- } elseif ($status == 'outofstock') {
1601
  return "out of stock";
1602
  }
1603
  }
@@ -1613,31 +1596,31 @@ class Woo_Feed_Products {
1613
  *
1614
  * @return string
1615
  */
1616
- public function getProductAttribute($id,$attr) {
1617
 
1618
- $attr=str_replace("wf_attr_", "",$attr);
1619
 
1620
- if(woo_feed_wc_version_check(3.1)){
1621
  # Get Product
1622
- $product=wc_get_product($id);
1623
 
1624
- if(!is_object($product)){
1625
  return "";
1626
  }
1627
 
1628
- if(woo_feed_wc_version_check(3.6)){
1629
- $attr=str_replace("pa_", "",$attr);
1630
  }
1631
 
1632
- $value=$product->get_attribute($attr);
1633
 
1634
- if(!empty($value)){
1635
  $value = trim($value);
1636
  }
1637
 
1638
  return $value;
1639
- }else{
1640
- return implode(',', wc_get_product_terms($id,$attr, array('fields' => 'names')));
1641
  }
1642
  }
1643
 
@@ -1652,13 +1635,13 @@ class Woo_Feed_Products {
1652
  * @return mixed|string
1653
  */
1654
 
1655
- public function getProductMeta($id,$meta) {
1656
 
1657
- $meta=str_replace("wf_cattr_", "",$meta);
1658
 
1659
- if (strpos($meta, 'attribute_pa') !== false) {
1660
  return $this->getProductAttribute($id,str_replace("attribute_","",$meta));
1661
- }else{
1662
  return get_post_meta($id, $meta, true);
1663
  }
1664
  }
@@ -1672,8 +1655,7 @@ class Woo_Feed_Products {
1672
  *
1673
  * @return mixed
1674
  */
1675
- public function getAttributeValue($id, $name)
1676
- {
1677
 
1678
  return $this->getProductMeta($id,$name);
1679
  // if (strpos($name, 'attribute_pa') !== false) {
@@ -1694,8 +1676,7 @@ class Woo_Feed_Products {
1694
  * @param $name
1695
  * @return string
1696
  */
1697
- public function sale_price_effective_date($id, $name)
1698
- {
1699
  return ($date = $this->getAttributeValue($id, $name)) ? date_i18n('Y-m-d', $date) : "";
1700
  }
1701
 
@@ -1711,7 +1692,7 @@ class Woo_Feed_Products {
1711
  $globalAttributes = wc_get_attribute_taxonomy_labels();
1712
  if ( count( $globalAttributes ) ) {
1713
  foreach ( $globalAttributes as $key => $value ) {
1714
- $info["wf_attr_pa_" . $key] = $value;
1715
  }
1716
  }
1717
 
@@ -1737,9 +1718,9 @@ class Woo_Feed_Products {
1737
  )";
1738
  $data = $wpdb->get_results($sql);
1739
  if ( count( $data ) ) {
1740
- foreach ($data as $key => $value ) {
1741
  /** @noinspection SpellCheckingInspection */
1742
- $info["wf_cattr_" . $value->meta_key] = $value->meta_key;
1743
  }
1744
  return $info;
1745
  }
@@ -1751,16 +1732,15 @@ class Woo_Feed_Products {
1751
  * Get Category Mappings
1752
  * @return bool|array
1753
  */
1754
- public function getCustomCategoryMappedAttributes()
1755
- {
1756
  global $wpdb;
1757
 
1758
  //Load Custom Category Mapped Attributes
1759
  $sql = $wpdb->prepare("SELECT * FROM $wpdb->options WHERE option_name LIKE %s;", "wf_cmapping_%");
1760
  $data = $wpdb->get_results($sql);
1761
- if (count($data)) {
1762
- foreach ($data as $key => $value) {
1763
- $info[$key] = $value->option_name;
1764
  }
1765
 
1766
  return $info;
@@ -1781,66 +1761,66 @@ class Woo_Feed_Products {
1781
 
1782
  $attributeDropdown = wp_cache_get( 'woo-feed-products-attributes' );
1783
 
1784
- if( ! $attributeDropdown ) {
1785
  $attributes = array(
1786
- "id" => esc_attr__( "Product Id", 'woo-feed' ),
1787
- "title" => esc_attr__( "Product Title", 'woo-feed' ),
1788
- "description" => esc_attr__( "Product Description", 'woo-feed' ),
1789
- "short_description" => esc_attr__( "Product Short Description", 'woo-feed' ),
1790
- "product_type" => esc_attr__( "Product Local Category", 'woo-feed' ),
1791
- "link" => esc_attr__( "Product URL", 'woo-feed' ),
1792
- "ex_link" => esc_attr__( "External Product URL", 'woo-feed' ),
1793
- "condition" => esc_attr__( "Condition", 'woo-feed' ),
1794
- "item_group_id" => esc_attr__( "Parent Id [Group Id]", 'woo-feed' ),
1795
- "sku" => esc_attr__( "SKU", 'woo-feed' ),
1796
- "parent_sku" => esc_attr__( "Parent SKU", 'woo-feed' ),
1797
- "availability" => esc_attr__( "Availability", 'woo-feed' ),
1798
- "quantity" => esc_attr__( "Quantity", 'woo-feed' ),
1799
- "price" => esc_attr__( "Regular Price", 'woo-feed' ),
1800
- "current_price" => esc_attr__( "Current Price", 'woo-feed' ),
1801
- "sale_price" => esc_attr__( "Sale Price", 'woo-feed' ),
1802
- "price_with_tax" => esc_attr__( "Regular Price With Tax", 'woo-feed' ),
1803
- "current_price_with_tax" => esc_attr__( "Current Price With Tax", 'woo-feed' ),
1804
- "sale_price_with_tax" => esc_attr__( "Sale Price With Tax", 'woo-feed' ),
1805
- "sale_price_sdate" => esc_attr__( "Sale Start Date", 'woo-feed' ),
1806
- "sale_price_edate" => esc_attr__( "Sale End Date", 'woo-feed' ),
1807
- "weight" => esc_attr__( "Weight", 'woo-feed' ),
1808
- "width" => esc_attr__( "Width", 'woo-feed' ),
1809
- "height" => esc_attr__( "Height", 'woo-feed' ),
1810
- "length" => esc_attr__( "Length", 'woo-feed' ),
1811
- "shipping_class" => esc_attr__( "Shipping Class", 'woo-feed' ),
1812
- "type" => esc_attr__( "Product Type", 'woo-feed' ),
1813
- "variation_type" => esc_attr__( "Variation Type", 'woo-feed' ),
1814
- "visibility" => esc_attr__( "Visibility", 'woo-feed' ),
1815
- "rating_total" => esc_attr__( "Total Rating", 'woo-feed' ),
1816
- "rating_average" => esc_attr__( "Average Rating", 'woo-feed' ),
1817
- "tags" => esc_attr__( "Tags", 'woo-feed' ),
1818
- "sale_price_effective_date" => esc_attr__( "Sale Price Effective Date", 'woo-feed' ),
1819
- "is_bundle" => esc_attr__( "Is Bundle", 'woo-feed' ),
1820
- "date_created" => esc_attr__( "Date Created", 'woo-feed' ),
1821
- "date_updated" => esc_attr__( "Date Updated", 'woo-feed' ),
1822
  );
1823
  $images = array(
1824
- "image" => esc_attr__( "Main Image", 'woo-feed' ),
1825
- "feature_image" => esc_attr__( "Featured Image", 'woo-feed' ),
1826
- "images" => esc_attr__( "Images [Comma Separated]", 'woo-feed' ),
1827
- "image_1" => esc_attr__( "Additional Image 1", 'woo-feed' ),
1828
- "image_2" => esc_attr__( "Additional Image 2", 'woo-feed' ),
1829
- "image_3" => esc_attr__( "Additional Image 3", 'woo-feed' ),
1830
- "image_4" => esc_attr__( "Additional Image 4", 'woo-feed' ),
1831
- "image_5" => esc_attr__( "Additional Image 5", 'woo-feed' ),
1832
- "image_6" => esc_attr__( "Additional Image 6", 'woo-feed' ),
1833
- "image_7" => esc_attr__( "Additional Image 7", 'woo-feed' ),
1834
- "image_8" => esc_attr__( "Additional Image 8", 'woo-feed' ),
1835
- "image_9" => esc_attr__( "Additional Image 9", 'woo-feed' ),
1836
- "image_10" => esc_attr__( "Additional Image 10", 'woo-feed' ),
1837
  );
1838
 
1839
  # Primary Attributes
1840
  $attributeDropdown = "<option></option>";
1841
- if( ! empty( $attributes ) ) {
1842
  $attributeDropdown .= sprintf( "<optgroup label=\"%s\">", esc_attr__( 'Primary Attributes', 'woo-feed' ) );
1843
- foreach ($attributes as $key => $value) {
1844
  $attributeDropdown .= sprintf( '<option value="%s">%s</option>', $key, $value );
1845
  }
1846
  $attributeDropdown .= "</optgroup>";
@@ -1849,7 +1829,7 @@ class Woo_Feed_Products {
1849
  # Additional Images
1850
  if ( ! empty( $images ) ) {
1851
  $attributeDropdown .= sprintf( "<optgroup label=\"%s\">", esc_attr__( 'Image Attributes', 'woo-feed' ) );
1852
- foreach ($images as $key => $value) {
1853
  $attributeDropdown .= sprintf( '<option value="%s">%s</option>', $key, $value );
1854
  }
1855
  $attributeDropdown .= "</optgroup>";
@@ -1859,14 +1839,14 @@ class Woo_Feed_Products {
1859
  $vAttributes = $this->getAllAttributes();
1860
  if ( $vAttributes && ! empty( $vAttributes ) ) {
1861
  $attributeDropdown .= sprintf( "<optgroup label=\"%s\">", esc_attr__( 'Product Attributes', 'woo-feed' ) );
1862
- foreach ($vAttributes as $key => $value) {
1863
  $attributeDropdown .= sprintf( '<option value="%s">%s</option>', $key, $value );
1864
  }
1865
  $attributeDropdown .= "</optgroup>";
1866
  }
1867
  }
1868
 
1869
- if( $selected && strpos( $attributeDropdown, 'value="'.$selected.'"' ) !== false ) {
1870
  $attributeDropdown = str_replace( 'value="'.$selected.'"', 'value="'.$selected.'"'.' selected', $attributeDropdown );
1871
  }
1872
  return $attributeDropdown;
@@ -1875,8 +1855,7 @@ class Woo_Feed_Products {
1875
  /**
1876
  * Load all WooCommerce attributes into an option
1877
  */
1878
- public function load_attributes()
1879
- {
1880
  # Get All WooCommerce Attributes
1881
  $vAttributes = $this->getAllAttributes();
1882
  update_option("wpfw_vAttributes", $vAttributes);
@@ -1901,11 +1880,10 @@ class Woo_Feed_Products {
1901
  * @param $product
1902
  * @return float|string
1903
  */
1904
- public function getPriceWithTax($product)
1905
- {
1906
- if(woo_feed_wc_version_check(3.0)){
1907
- return wc_get_price_including_tax($product,array('price'=>$product->get_price()));
1908
- }else{
1909
  return $product->get_price_including_tax();
1910
  }
1911
  }
@@ -1914,9 +1892,8 @@ class Woo_Feed_Products {
1914
  * @param $date
1915
  * @return false|string
1916
  */
1917
- public function format_product_date($date)
1918
- {
1919
- return date("Y-m-d",strtotime($date));
1920
  }
1921
 
1922
  /**
@@ -1928,10 +1905,10 @@ class Woo_Feed_Products {
1928
  * @return string
1929
  */
1930
  public function getProductTaxonomy( $id, $taxonomy ) {
1931
- $taxonomy=str_replace("wf_taxo_", "",$taxonomy);
1932
- $Taxo=get_the_term_list($id,$taxonomy,"",",","");
1933
 
1934
- if(!empty($Taxo)){
1935
  return strip_tags($Taxo);
1936
  }
1937
 
64
  public $attributeList;
65
 
66
  public $feedRule;
67
+ public $idExist = array();
68
  public $pi;
69
 
70
 
71
 
72
+ public function wooProductQuery( $arg ) {
73
 
74
  global $wpdb;
75
 
76
 
77
+ $limit = "";
78
+ $offset = "";
79
+ if ( $arg['limit'] != "" && $arg['limit'] != "-1" && $arg['limit'] > 0 ) {
80
+ $limit = absint( $arg['limit'] );
81
+ $limit = "LIMIT $limit";
82
 
83
 
84
+ if ( $arg['offset'] != "" && $arg['offset'] != "-1" ) {
85
+ $offset = absint( $arg['offset'] );
86
+ $offset = "OFFSET $offset";
87
  }
88
  }
89
 
128
  'status' => 'publish',
129
  'orderby' => 'date',
130
  'order' => 'DESC',
131
+ 'type' => array( 'variable', 'variation', 'simple', 'grouped', 'external' ),
132
+ 'return' => 'ids',
133
  );
134
 
135
 
143
 
144
  $this->pi = 1; # Product Index
145
  foreach ( $products as $key => $productId ) {
146
+ $prod = wc_get_product($productId);
147
 
148
  $id = $prod->get_id();
149
 
150
+ if ( $getIDs ) {
151
+ if ( in_array($id,$getIDs) ) {
152
  continue;
153
+ }else {
154
  array_push($this->idExist,$id);
155
  }
156
+ }else {
157
  array_push($this->idExist,$id);
158
  }
159
 
160
+ if ( $prod->is_type( 'simple' ) ) {
 
161
 
162
  $simple = new WC_Product_Simple( $id );
163
 
173
 
174
 
175
  # Featured Image
176
+ if ( has_post_thumbnail( $id ) ) :
177
  $image = wp_get_attachment_image_src( get_post_thumbnail_id( $id ), 'single-post-thumbnail' );
178
  $this->productsList[ $this->pi ]['image'] = $this->get_formatted_url( $image[0] );
179
  $this->productsList[ $this->pi ]['feature_image'] = $this->get_formatted_url( $image[0] );
180
+ else :
181
  $this->productsList[ $this->pi ]['image'] = $this->get_formatted_url( wp_get_attachment_url( $id ) );
182
  $this->productsList[ $this->pi ]['feature_image'] = $this->get_formatted_url( wp_get_attachment_url( $id ) );
183
  endif;
189
  $mKey = 1;
190
  foreach ( $attachmentIds as $attachmentId ) {
191
  $imgUrls[ $mKey ] = $this->get_formatted_url( wp_get_attachment_url( $attachmentId ) );
192
+ $this->productsList[ $this->pi ][ "image_$mKey" ] = $imgUrls[ $mKey ];
193
  $mKey ++;
194
+ }
195
+ }
 
196
 
197
  $this->productsList[ $this->pi ]['images'] = implode( ",", $imgUrls );
198
  $this->productsList[ $this->pi ]['condition'] = "new";
227
  $from = $this->sale_price_effective_date( $id, '_sale_price_dates_from' );
228
  $to = $this->sale_price_effective_date( $id, '_sale_price_dates_to' );
229
  if ( ! empty( $from ) && ! empty( $to ) ) {
230
+ $from = gmdate( "c", strtotime( $from ) );
231
+ $to = gmdate( "c", strtotime( $to ) );
232
  $this->productsList[ $this->pi ]['sale_price_effective_date'] = "$from" . "/" . "$to";
233
  } else {
234
  $this->productsList[ $this->pi ]['sale_price_effective_date'] = "";
243
  // }
244
  // }
245
  }
246
+ elseif ( $prod->is_type( 'external' ) ) {
247
 
248
  $external = new WC_Product_External( $id );
249
 
258
 
259
 
260
  # Featured Image
261
+ if ( has_post_thumbnail( $id ) ) :
262
  $image = wp_get_attachment_image_src( get_post_thumbnail_id( $id ), 'single-post-thumbnail' );
263
  $this->productsList[ $this->pi ]['image'] = $this->get_formatted_url( $image[0] );
264
  $this->productsList[ $this->pi ]['feature_image'] = $this->get_formatted_url( $image[0] );
265
+ else :
266
  $this->productsList[ $this->pi ]['image'] = $this->get_formatted_url( wp_get_attachment_url( $id ) );
267
  $this->productsList[ $this->pi ]['feature_image'] = $this->get_formatted_url( wp_get_attachment_url( $id ) );
268
  endif;
274
  $mKey = 1;
275
  foreach ( $attachmentIds as $attachmentId ) {
276
  $imgUrls[ $mKey ] = $this->get_formatted_url( wp_get_attachment_url( $attachmentId ) );
277
+ $this->productsList[ $this->pi ][ "image_$mKey" ] = $imgUrls[ $mKey ];
278
  $mKey ++;
279
+ }
280
+ }
 
281
 
282
  $this->productsList[ $this->pi ]['images'] = implode( ",", $imgUrls );
283
  $this->productsList[ $this->pi ]['condition'] = "new";
312
  $from = $this->sale_price_effective_date( $id, '_sale_price_dates_from' );
313
  $to = $this->sale_price_effective_date( $id, '_sale_price_dates_to' );
314
  if ( ! empty( $from ) && ! empty( $to ) ) {
315
+ $from = gmdate( "c", strtotime( $from ) );
316
+ $to = gmdate( "c", strtotime( $to ) );
317
  $this->productsList[ $this->pi ]['sale_price_effective_date'] = "$from" . "/" . "$to";
318
  } else {
319
  $this->productsList[ $this->pi ]['sale_price_effective_date'] = "";
328
  // }
329
  // }
330
  }
331
+ elseif ( $prod->is_type( 'grouped' ) ) {
332
 
333
  $grouped = new WC_Product_Grouped( $id );
334
 
343
  $this->productsList[ $this->pi ]['ex_link'] = $grouped->get_permalink();
344
 
345
  # Featured Image
346
+ if ( has_post_thumbnail( $id ) ) :
347
  $image = wp_get_attachment_image_src( get_post_thumbnail_id( $id ), 'single-post-thumbnail' );
348
  $this->productsList[ $this->pi ]['image'] = $this->get_formatted_url( $image[0] );
349
  $this->productsList[ $this->pi ]['feature_image'] = $this->get_formatted_url( $image[0] );
350
+ else :
351
  $this->productsList[ $this->pi ]['image'] = $this->get_formatted_url( wp_get_attachment_url( $id ) );
352
  $this->productsList[ $this->pi ]['feature_image'] = $this->get_formatted_url( wp_get_attachment_url( $id ) );
353
  endif;
359
  $mKey = 1;
360
  foreach ( $attachmentIds as $attachmentId ) {
361
  $imgUrls[ $mKey ] = $this->get_formatted_url( wp_get_attachment_url( $attachmentId ) );
362
+ $this->productsList[ $this->pi ][ "image_$mKey" ] = $imgUrls[ $mKey ];
363
  $mKey ++;
364
+ }
365
+ }
 
366
 
367
  $this->productsList[ $this->pi ]['images'] = implode( ",", $imgUrls );
368
  $this->productsList[ $this->pi ]['condition'] = "new";
396
  $from = $this->sale_price_effective_date( $id, '_sale_price_dates_from' );
397
  $to = $this->sale_price_effective_date( $id, '_sale_price_dates_to' );
398
  if ( ! empty( $from ) && ! empty( $to ) ) {
399
+ $from = gmdate( "c", strtotime( $from ) );
400
+ $to = gmdate( "c", strtotime( $to ) );
401
  $this->productsList[ $this->pi ]['sale_price_effective_date'] = "$from" . "/" . "$to";
402
  } else {
403
  $this->productsList[ $this->pi ]['sale_price_effective_date'] = "";
412
  // }
413
  // }
414
  }
415
+ elseif ( $prod->is_type( 'variable' ) ) {
416
 
417
  $variable = new WC_Product_Variable( $id );
418
 
428
 
429
 
430
  # Featured Image
431
+ if ( has_post_thumbnail( $id ) ) :
432
  $image = wp_get_attachment_image_src( get_post_thumbnail_id( $id ), 'single-post-thumbnail' );
433
  $this->productsList[ $this->pi ]['image'] = $this->get_formatted_url( $image[0] );
434
  $this->productsList[ $this->pi ]['feature_image'] = $this->get_formatted_url( $image[0] );
435
+ else :
436
  $this->productsList[ $this->pi ]['image'] = $this->get_formatted_url( wp_get_attachment_url( $id ) );
437
  $this->productsList[ $this->pi ]['feature_image'] = $this->get_formatted_url( wp_get_attachment_url( $id ) );
438
  endif;
444
  $mKey = 1;
445
  foreach ( $attachmentIds as $attachmentId ) {
446
  $imgUrls[ $mKey ] = $this->get_formatted_url( wp_get_attachment_url( $attachmentId ) );
447
+ $this->productsList[ $this->pi ][ "image_$mKey" ] = $imgUrls[ $mKey ];
448
  $mKey ++;
449
+ }
450
+ }
 
451
 
452
  $this->productsList[ $this->pi ]['images'] = implode( ",", $imgUrls );
453
  $this->productsList[ $this->pi ]['condition'] = "new";
484
  $from = $this->sale_price_effective_date( $id, '_sale_price_dates_from' );
485
  $to = $this->sale_price_effective_date( $id, '_sale_price_dates_to' );
486
  if ( ! empty( $from ) && ! empty( $to ) ) {
487
+ $from = gmdate( "c", strtotime( $from ) );
488
+ $to = gmdate( "c", strtotime( $to ) );
489
  $this->productsList[ $this->pi ]['sale_price_effective_date'] = "$from" . "/" . "$to";
490
  } else {
491
  $this->productsList[ $this->pi ]['sale_price_effective_date'] = "";
500
  // }
501
  // }
502
  }
503
+ elseif ( $prod->is_type( 'variation' ) ) {
504
 
505
+ $variation = new WC_Product_Variation($id);
506
 
507
  # Parent Info
508
+ $parentId = $variation->get_parent_id();
509
+ $parent = new WC_Product_Variable($parentId);
510
 
511
  # Skip if not a valid product
512
+ if ( ! $variation->variation_is_visible() ) {
513
  continue;
514
  }
515
 
516
+ if ( ! $parent->is_purchasable() ) {
517
  continue;
518
  }
519
 
520
  # Set Variation Description
521
+ $description = $variation->get_description();
522
+ if ( empty($description) ) {
523
+ $description = $parent->get_description();
524
  }
525
+ $description = $this->remove_short_codes($description);
526
 
527
  # Set Variation Short Description
528
+ $short_description = $variation->get_short_description();
529
+ if ( empty($short_description) ) {
530
+ $short_description = $parent->get_short_description();
531
  }
532
+ $short_description = $this->remove_short_codes($short_description);
533
 
534
  $this->productsList[ $this->pi ]["id"] = $variation->get_id();
535
  $this->productsList[ $this->pi ]["title"] = $variation->get_name();
536
 
537
+ if ( $this->feedRule['provider'] == 'facebook' ) {
538
+ $variationInfo = explode("-",$variation->get_name());
539
+ if ( isset($variationInfo[1]) ) {
540
+ $extension = $variationInfo[1];
541
+ }else {
542
+ $extension = $variation->get_id();
543
  }
544
+ $description .= " ".$extension;
545
  }
546
 
547
  $this->productsList[ $this->pi ]["description"] = $description;
554
 
555
  # Featured Image
556
  $image = wp_get_attachment_image_src( get_post_thumbnail_id( $id ), 'single-post-thumbnail' );
557
+ if ( has_post_thumbnail( $id ) && ! empty($image[0]) ) :
558
 
559
  $this->productsList[ $this->pi ]['image'] = $this->get_formatted_url( $image[0] );
560
  $this->productsList[ $this->pi ]['feature_image'] = $this->get_formatted_url( $image[0] );
561
+ else :
562
  $image = wp_get_attachment_image_src( get_post_thumbnail_id( $variation->get_parent_id() ), 'single-post-thumbnail' );
563
  $this->productsList[ $this->pi ]['image'] = $this->get_formatted_url( $image[0] );
564
  $this->productsList[ $this->pi ]['feature_image'] = $this->get_formatted_url( $image[0] );
570
  if ( $attachmentIds && is_array( $attachmentIds ) ) {
571
  $mKey = 1;
572
  foreach ( $attachmentIds as $attachmentId ) {
573
+ $imgUrls[ $mKey ] = $this->get_formatted_url( wp_get_attachment_url( $attachmentId ));
574
+ $this->productsList[ $this->pi ][ "image_$mKey" ] = $imgUrls[ $mKey ];
575
  $mKey ++;
576
+ }
577
+ }
 
578
 
579
  $this->productsList[ $this->pi ]['images'] = implode( ",", $imgUrls );
580
  $this->productsList[ $this->pi ]['condition'] = "new";
609
  $from = $this->sale_price_effective_date( $id, '_sale_price_dates_from' );
610
  $to = $this->sale_price_effective_date( $id, '_sale_price_dates_to' );
611
  if ( ! empty( $from ) && ! empty( $to ) ) {
612
+ $from = gmdate( "c", strtotime( $from ) );
613
+ $to = gmdate( "c", strtotime( $to ) );
614
  $this->productsList[ $this->pi ]['sale_price_effective_date'] = "$from" . "/" . "$to";
615
  } else {
616
  $this->productsList[ $this->pi ]['sale_price_effective_date'] = "";
629
  $this->pi ++;
630
  }
631
 
632
+ if ( $getIDs ) {
633
+ $mergedIds = array_merge($getIDs,$this->idExist);
634
  update_option("wf_check_duplicate",$mergedIds);
635
+ }else {
636
  update_option("wf_check_duplicate",$this->idExist);
637
  }
638
 
651
  public function getGroupProductPrice( $grouped, $type, $taxable = false ) {
652
  $groupProductIds = $grouped->get_children();
653
  $sum = 0;
654
+ if ( ! empty( $groupProductIds ) ) {
655
+ foreach ( $groupProductIds as $id ) {
656
  $product = wc_get_product( $id );
657
+ if ( ! $product ) {
658
  continue; // make sure that the product exists..
659
  }
660
  $regularPrice = $product->get_regular_price();
661
+ if ( empty( $regularPrice ) ) $regularPrice = 0;
662
  $currentPrice = $product->get_price();
663
+ if ( empty( $currentPrice ) ) $currentPrice = 0;
664
+ if ( $type == "regular" ) {
665
+ if ( $taxable ) {
666
+ $regularPrice = $this->getPriceWithTax($product);
667
  }
668
  $sum += $regularPrice;
669
+ }else {
670
+ if ( $taxable ) {
671
+ $currentPrice = $this->getPriceWithTax($product);
672
  }
673
  $sum += $currentPrice;
674
  }
685
  * @param $variations
686
  * @param $parent
687
  */
688
+ public function getWC3Variations( $variations, $parent ) {
689
+ try {
690
+ if ( is_array($variations) && (sizeof($variations) > 0 ) ) {
691
+ foreach ( $variations as $vKey => $variationProd ) {
692
 
693
+ $id = $variationProd['variation_id'];
694
 
695
+ $variation = new WC_Product_Variation($id);
696
 
697
+ if ( ! is_object($variation) ) {
698
  continue;
699
  }
700
+ $parentId = $variation->get_parent_id();
701
+ $parent = new WC_Product_Variable($parentId);
702
  # Parent Info
703
+ $parentInfo = $variation->get_parent_data();
704
+ $variationTitle = $parentInfo['title'];
705
 
706
  # Set Variation Description
707
+ $description = $variation->get_description();
708
+ if ( empty($description) ) {
709
+ $description = $parent->get_description();
710
  }
711
+ $description = $this->remove_short_codes($description);
712
 
713
  # Set Variation Short Description
714
+ $short_description = $variation->get_short_description();
715
+ if ( empty($short_description) ) {
716
+ $short_description = $parent->get_short_description();
717
  }
718
+ $short_description = $this->remove_short_codes($short_description);
719
 
720
  $this->productsList[ $this->pi ]["id"] = $variation->get_id();
721
  $this->productsList[ $this->pi ]["title"] = $variationTitle;
730
 
731
  # Featured Image
732
  $image = wp_get_attachment_image_src( get_post_thumbnail_id( $id ), 'single-post-thumbnail' );
733
+ if ( has_post_thumbnail( $id ) && ! empty($image[0]) ) :
734
 
735
  $this->productsList[ $this->pi ]['image'] = $this->get_formatted_url( $image[0] );
736
  $this->productsList[ $this->pi ]['feature_image'] = $this->get_formatted_url( $image[0] );
737
+ else :
738
  $image = wp_get_attachment_image_src( get_post_thumbnail_id( $variation->get_parent_id() ), 'single-post-thumbnail' );
739
  $this->productsList[ $this->pi ]['image'] = $this->get_formatted_url( $image[0] );
740
  $this->productsList[ $this->pi ]['feature_image'] = $this->get_formatted_url( $image[0] );
746
  if ( $attachmentIds && is_array( $attachmentIds ) ) {
747
  $mKey = 1;
748
  foreach ( $attachmentIds as $attachmentId ) {
749
+ $imgUrls[ $mKey ] = $this->get_formatted_url( wp_get_attachment_url( $attachmentId ));
750
+ $this->productsList[ $this->pi ][ "image_$mKey" ] = $imgUrls[ $mKey ];
751
  $mKey ++;
752
+ }
753
+ }
 
754
 
755
  $this->productsList[ $this->pi ]['images'] = implode( ",", $imgUrls );
756
  $this->productsList[ $this->pi ]['condition'] = "new";
783
  $from = $this->sale_price_effective_date( $id, '_sale_price_dates_from' );
784
  $to = $this->sale_price_effective_date( $id, '_sale_price_dates_to' );
785
  if ( ! empty( $from ) && ! empty( $to ) ) {
786
+ $from = gmdate( "c", strtotime( $from ) );
787
+ $to = gmdate( "c", strtotime( $to ) );
788
  $this->productsList[ $this->pi ]['sale_price_effective_date'] = "$from" . "/" . "$to";
789
  } else {
790
  $this->productsList[ $this->pi ]['sale_price_effective_date'] = "";
791
  }
792
 
793
  # Get all Attributes and their values
794
+ $data = $variation->get_data();
795
+ $attributes = $data['attributes'];
796
+ if ( ! empty($attributes) ) {
797
+ foreach ( $attributes as $aKey => $attr ) {
798
+ $this->productsList[ $this->pi ][ $aKey ] = $variation->get_attribute($aKey);
799
  }
800
  }
801
 
821
  $this->pi++;
822
  }
823
  }
824
+ }catch ( Exception $e ) {
825
 
826
  }
827
 
975
  $this->productsList[ $i ]['image'] = $this->get_formatted_url( $mainImage );
976
 
977
  # Featured Image
978
+ if ( has_post_thumbnail( $post->ID ) ) :
979
  $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );
980
  $this->productsList[ $i ]['feature_image'] = $this->get_formatted_url( $image[0] );
981
+ else :
982
  $this->productsList[ $i ]['feature_image'] = $this->get_formatted_url( $mainImage );
983
  endif;
984
 
990
  foreach ( $images as $key => $value ) {
991
  if ( $value != $this->productsList[ $i ]['image'] ) {
992
  $imgLink = $this->get_formatted_url( $value );
993
+ $this->productsList[ $i ][ "image_$mKey" ] = $imgLink;
994
  if ( ! empty( $imgLink ) ) {
995
  array_push( $imageLinks, $imgLink );
996
  }
1022
  $from = $this->sale_price_effective_date( $this->childID, '_sale_price_dates_from' );
1023
  $to = $this->sale_price_effective_date( $this->childID, '_sale_price_dates_to' );
1024
  if ( ! empty( $from ) && ! empty( $to ) ) {
1025
+ $from = gmdate( "c", strtotime( $from ) );
1026
+ $to = gmdate( "c", strtotime( $to ) );
1027
  $this->productsList[ $i ]['sale_price_effective_date'] = "$from" . "/" . "$to";
1028
  } else {
1029
  $this->productsList[ $i ]['sale_price_effective_date'] = "";
1030
+ }
1031
+ }
 
1032
  } elseif ( get_post_type() == 'product' ) {
1033
  if ( $type1 == 'simple' ) {
1034
 
1063
  $this->productsList[ $i ]['image'] = $this->get_formatted_url( $mainImage );
1064
 
1065
  # Featured Image
1066
+ if ( has_post_thumbnail( $post->ID ) ) :
1067
  $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );
1068
  $this->productsList[ $i ]['feature_image'] = $this->get_formatted_url( $image[0] );
1069
+ else :
1070
  $this->productsList[ $i ]['feature_image'] = $this->get_formatted_url( $mainImage );
1071
  endif;
1072
 
1078
  foreach ( $images as $key => $value ) {
1079
  if ( $value != $this->productsList[ $i ]['image'] ) {
1080
  $imgLink = $this->get_formatted_url( $value );
1081
+ $this->productsList[ $i ][ "image_$mKey" ] = $imgLink;
1082
  if ( ! empty( $imgLink ) ) {
1083
  array_push( $imageLinks, $imgLink );
1084
  }
1113
  $from = $this->sale_price_effective_date( $post->ID, '_sale_price_dates_from' );
1114
  $to = $this->sale_price_effective_date( $post->ID, '_sale_price_dates_to' );
1115
  if ( ! empty( $from ) && ! empty( $to ) ) {
1116
+ $from = gmdate( "c", strtotime( $from ) );
1117
+ $to = gmdate( "c", strtotime( $to ) );
1118
  $this->productsList[ $i ]['sale_price_effective_date'] = "$from" . "/" . "$to";
1119
  } else {
1120
  $this->productsList[ $i ]['sale_price_effective_date'] = "";
1121
+ }
1122
+ }
1123
+ elseif ( $type1 == 'external' ) {
 
1124
 
1125
  $mainImage = wp_get_attachment_url( $product->get_image_id() );
1126
 
1135
 
1136
  $this->productsList[ $i ]['id'] = $post->ID;
1137
  $this->productsList[ $i ]['variation_type'] = "external";
1138
+ $this->productsList[ $i ]['title'] = $post->post_title;
1139
  $this->productsList[ $i ]['description'] = do_shortcode( $post->post_content );
1140
 
1141
  $this->productsList[ $i ]['short_description'] = $post->post_excerpt;
1145
  $this->productsList[ $i ]['image'] = $this->get_formatted_url( $mainImage );
1146
 
1147
  # Featured Image
1148
+ if ( has_post_thumbnail( $post->ID ) ) :
1149
  $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );
1150
  $this->productsList[ $i ]['feature_image'] = $this->get_formatted_url( $image[0] );
1151
+ else :
1152
  $this->productsList[ $i ]['feature_image'] = $this->get_formatted_url( $mainImage );
1153
  endif;
1154
 
1160
  foreach ( $images as $key => $value ) {
1161
  if ( $value != $this->productsList[ $i ]['image'] ) {
1162
  $imgLink = $this->get_formatted_url( $value );
1163
+ $this->productsList[ $i ][ "image_$mKey" ] = $imgLink;
1164
  if ( ! empty( $imgLink ) ) {
1165
  array_push( $imageLinks, $imgLink );
1166
  }
1196
  $from = $this->sale_price_effective_date( $post->ID, '_sale_price_dates_from' );
1197
  $to = $this->sale_price_effective_date( $post->ID, '_sale_price_dates_to' );
1198
  if ( ! empty( $from ) && ! empty( $to ) ) {
1199
+ $from = gmdate( "c", strtotime( $from ) );
1200
+ $to = gmdate( "c", strtotime( $to ) );
1201
  $this->productsList[ $i ]['sale_price_effective_date'] = "$from" . "/" . "$to";
1202
  } else {
1203
  $this->productsList[ $i ]['sale_price_effective_date'] = "";
1204
+ }
1205
+ }
 
1206
  elseif ( $type1 == 'grouped' ) {
1207
 
1208
  $grouped = new WC_Product_Grouped( $post->ID );
1253
  $this->productsList[ $i ]['image'] = $this->get_formatted_url( $mainImage );
1254
 
1255
  # Featured Image
1256
+ if ( has_post_thumbnail( $post->ID ) ) :
1257
  $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );
1258
  $this->productsList[ $i ]['feature_image'] = $this->get_formatted_url( $image[0] );
1259
+ else :
1260
  $this->productsList[ $i ]['feature_image'] = $this->get_formatted_url( $mainImage );
1261
  endif;
1262
 
1268
  foreach ( $images as $key => $value ) {
1269
  if ( $value != $this->productsList[ $i ]['image'] ) {
1270
  $imgLink = $this->get_formatted_url( $value );
1271
+ $this->productsList[ $i ][ "image_$mKey" ] = $imgLink;
1272
  if ( ! empty( $imgLink ) ) {
1273
  array_push( $imageLinks, $imgLink );
1274
  }
1303
  $from = $this->sale_price_effective_date( $post->ID, '_sale_price_dates_from' );
1304
  $to = $this->sale_price_effective_date( $post->ID, '_sale_price_dates_to' );
1305
  if ( ! empty( $from ) && ! empty( $to ) ) {
1306
+ $from = gmdate( "c", strtotime( $from ) );
1307
+ $to = gmdate( "c", strtotime( $to ) );
1308
  $this->productsList[ $i ]['sale_price_effective_date'] = "$from" . "/" . "$to";
1309
  } else {
1310
  $this->productsList[ $i ]['sale_price_effective_date'] = "";
1312
  }
1313
  }
1314
  }
1315
+ elseif ( $type1 == 'variable' && $product->has_child() ) {
1316
 
1317
  # Check Valid URL
1318
  $mainImage = wp_get_attachment_url( $product->get_image_id() );
1337
  $this->productsList[ $i ]['image'] = $this->get_formatted_url( $mainImage );
1338
 
1339
  # Featured Image
1340
+ if ( has_post_thumbnail( $post->ID ) ) :
1341
  $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );
1342
  $this->productsList[ $i ]['feature_image'] = $this->get_formatted_url( $image[0] );
1343
+ else :
1344
  $this->productsList[ $i ]['feature_image'] = $this->get_formatted_url( $mainImage );
1345
  endif;
1346
 
1352
  foreach ( $images as $key => $value ) {
1353
  if ( $value != $this->productsList[ $i ]['image'] ) {
1354
  $imgLink = $this->get_formatted_url( $value );
1355
+ $this->productsList[ $i ][ "image_$mKey" ] = $imgLink;
1356
  if ( ! empty( $imgLink ) ) {
1357
  array_push( $imageLinks, $imgLink );
1358
  }
1390
  $from = $this->sale_price_effective_date( $post->ID, '_sale_price_dates_from' );
1391
  $to = $this->sale_price_effective_date( $post->ID, '_sale_price_dates_to' );
1392
  if ( ! empty( $from ) && ! empty( $to ) ) {
1393
+ $from = gmdate( "c", strtotime( $from ) );
1394
+ $to = gmdate( "c", strtotime( $to ) );
1395
  $this->productsList[ $i ]['sale_price_effective_date'] = "$from" . "/" . "$to";
1396
  } else {
1397
  $this->productsList[ $i ]['sale_price_effective_date'] = "";
1422
  *
1423
  * @return mixed|string
1424
  */
1425
+ public function remove_short_codes( $content ) {
1426
+ if ( empty( $content ) ) {
 
1427
  return "";
1428
  }
1429
  $content = do_shortcode( $content );
1430
  $content = $this->stripInvalidXml( $content );
1431
  # Remove DIVI Builder Short Codes
1432
+ if ( class_exists('ET_Builder_Module') || defined('ET_BUILDER_PLUGIN_VERSION') ) {
1433
  $content = preg_replace('/\[\/?et_pb.*?\]/', '', $content);
1434
  }
1435
  return strip_shortcodes($content);
1443
  *
1444
  * @return string
1445
  */
1446
+ public function stripInvalidXml( $value ) {
1447
  $ret = "";
1448
+ $current = "";
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 ( ($current == 0x9) || ($current == 0xA) || ($current == 0xD) || (($current >= 0x20) && ($current <= 0xD7FF)) || (($current >= 0xE000) && ($current <= 0xFFFD)) || (($current >= 0x10000) && ($current <= 0x10FFFF)) ) {
1456
  $ret .= chr($current);
1457
  }
1458
  else {
1468
  * @param $url
1469
  * @return bool|string
1470
  */
1471
+ public function get_formatted_url( $url = "" ) {
1472
+ if ( ! empty($url) ) {
1473
+ if ( substr(trim($url), 0, 4) === "http" || substr(trim($url), 0, 3) === "ftp" || substr(trim($url), 0, 4) === "sftp" ) {
 
1474
  return rtrim($url, "/");
1475
  } else {
1476
  $base = get_site_url();
1489
  * @param $name
1490
  * @return bool|string
1491
  */
1492
+ public function get_date( $id, $name ) {
 
1493
  $date = $this->getAttributeValue($id, $name);
1494
+ if ( $date ) {
1495
+ return gmdate("Y-m-d", $date);
1496
  }
1497
  return false;
1498
  }
1504
  * @param $name
1505
  * @return bool|mixed
1506
  */
1507
+ public function get_quantity( $id, $name ) {
 
1508
  $qty = $this->getAttributeValue($id, $name);
1509
+ if ( $qty ) {
1510
  return $qty + 0;
1511
  }
1512
  return "0";
1525
  *
1526
  * @return string|false|WP_Error A list of terms on success, false if there are no terms, WP_Error on failure.
1527
  */
1528
+ function get_product_term_list( $id, $taxonomy, $before = '', $sep = ',', $after = '' ) {
 
1529
  $terms = get_the_terms($id, $taxonomy);
1530
 
1531
+ if ( is_wp_error($terms) ) {
1532
  return $terms;
1533
  }
1534
 
1535
+ if ( empty($terms) ) {
1536
  return false;
1537
  }
1538
 
1539
  $links = array();
1540
 
1541
+ foreach ( $terms as $term ) {
1542
  $links[] = $term->name;
1543
  }
1544
  ksort($links);
1552
  * @return bool|array
1553
  */
1554
 
1555
+ public function additionalImages( $Id ) {
1556
+ $ids = $this->getAttributeValue($Id,"_product_image_gallery");
1557
+ $imgIds = ! empty($ids) ? explode(",",$ids) : "";
 
1558
 
1559
  $images = array();
1560
+ if ( ! empty($imgIds) ) {
1561
+ foreach ( $imgIds as $key => $value ) {
1562
+ if ( $key < 10 ) {
1563
+ $images[ $key ] = wp_get_attachment_url($value);
1564
  }
1565
  }
1566
  return $images;
1575
  *
1576
  * @return string
1577
  */
1578
+ public function availability( $id ) {
1579
+ $status = $this->getProductMeta($id,"_stock_status");
1580
+ if ( $status ) {
1581
+ if ( $status == 'instock' ) {
 
1582
  return "in stock";
1583
+ } elseif ( $status == 'outofstock' ) {
1584
  return "out of stock";
1585
  }
1586
  }
1596
  *
1597
  * @return string
1598
  */
1599
+ public function getProductAttribute( $id,$attr ) {
1600
 
1601
+ $attr = str_replace("wf_attr_", "",$attr);
1602
 
1603
+ if ( woo_feed_wc_version_check(3.1) ) {
1604
  # Get Product
1605
+ $product = wc_get_product($id);
1606
 
1607
+ if ( ! is_object($product) ) {
1608
  return "";
1609
  }
1610
 
1611
+ if ( woo_feed_wc_version_check(3.6) ) {
1612
+ $attr = str_replace("pa_", "",$attr);
1613
  }
1614
 
1615
+ $value = $product->get_attribute($attr);
1616
 
1617
+ if ( ! empty($value) ) {
1618
  $value = trim($value);
1619
  }
1620
 
1621
  return $value;
1622
+ }else {
1623
+ return implode(',', wc_get_product_terms($id,$attr, array( 'fields' => 'names' )));
1624
  }
1625
  }
1626
 
1635
  * @return mixed|string
1636
  */
1637
 
1638
+ public function getProductMeta( $id,$meta ) {
1639
 
1640
+ $meta = str_replace("wf_cattr_", "",$meta);
1641
 
1642
+ if ( strpos($meta, 'attribute_pa') !== false ) {
1643
  return $this->getProductAttribute($id,str_replace("attribute_","",$meta));
1644
+ }else {
1645
  return get_post_meta($id, $meta, true);
1646
  }
1647
  }
1655
  *
1656
  * @return mixed
1657
  */
1658
+ public function getAttributeValue( $id, $name ) {
 
1659
 
1660
  return $this->getProductMeta($id,$name);
1661
  // if (strpos($name, 'attribute_pa') !== false) {
1676
  * @param $name
1677
  * @return string
1678
  */
1679
+ public function sale_price_effective_date( $id, $name ) {
 
1680
  return ($date = $this->getAttributeValue($id, $name)) ? date_i18n('Y-m-d', $date) : "";
1681
  }
1682
 
1692
  $globalAttributes = wc_get_attribute_taxonomy_labels();
1693
  if ( count( $globalAttributes ) ) {
1694
  foreach ( $globalAttributes as $key => $value ) {
1695
+ $info[ "wf_attr_pa_" . $key ] = $value;
1696
  }
1697
  }
1698
 
1718
  )";
1719
  $data = $wpdb->get_results($sql);
1720
  if ( count( $data ) ) {
1721
+ foreach ( $data as $key => $value ) {
1722
  /** @noinspection SpellCheckingInspection */
1723
+ $info[ "wf_cattr_" . $value->meta_key ] = $value->meta_key;
1724
  }
1725
  return $info;
1726
  }
1732
  * Get Category Mappings
1733
  * @return bool|array
1734
  */
1735
+ public function getCustomCategoryMappedAttributes() {
 
1736
  global $wpdb;
1737
 
1738
  //Load Custom Category Mapped Attributes
1739
  $sql = $wpdb->prepare("SELECT * FROM $wpdb->options WHERE option_name LIKE %s;", "wf_cmapping_%");
1740
  $data = $wpdb->get_results($sql);
1741
+ if ( count($data) ) {
1742
+ foreach ( $data as $key => $value ) {
1743
+ $info[ $key ] = $value->option_name;
1744
  }
1745
 
1746
  return $info;
1761
 
1762
  $attributeDropdown = wp_cache_get( 'woo-feed-products-attributes' );
1763
 
1764
+ if ( ! $attributeDropdown ) {
1765
  $attributes = array(
1766
+ "id" => esc_attr__( "Product Id", 'woo-feed' ),
1767
+ "title" => esc_attr__( "Product Title", 'woo-feed' ),
1768
+ "description" => esc_attr__( "Product Description", 'woo-feed' ),
1769
+ "short_description" => esc_attr__( "Product Short Description", 'woo-feed' ),
1770
+ "product_type" => esc_attr__( "Product Local Category", 'woo-feed' ),
1771
+ "link" => esc_attr__( "Product URL", 'woo-feed' ),
1772
+ "ex_link" => esc_attr__( "External Product URL", 'woo-feed' ),
1773
+ "condition" => esc_attr__( "Condition", 'woo-feed' ),
1774
+ "item_group_id" => esc_attr__( "Parent Id [Group Id]", 'woo-feed' ),
1775
+ "sku" => esc_attr__( "SKU", 'woo-feed' ),
1776
+ "parent_sku" => esc_attr__( "Parent SKU", 'woo-feed' ),
1777
+ "availability" => esc_attr__( "Availability", 'woo-feed' ),
1778
+ "quantity" => esc_attr__( "Quantity", 'woo-feed' ),
1779
+ "price" => esc_attr__( "Regular Price", 'woo-feed' ),
1780
+ "current_price" => esc_attr__( "Current Price", 'woo-feed' ),
1781
+ "sale_price" => esc_attr__( "Sale Price", 'woo-feed' ),
1782
+ "price_with_tax" => esc_attr__( "Regular Price With Tax", 'woo-feed' ),
1783
+ "current_price_with_tax" => esc_attr__( "Current Price With Tax", 'woo-feed' ),
1784
+ "sale_price_with_tax" => esc_attr__( "Sale Price With Tax", 'woo-feed' ),
1785
+ "sale_price_sdate" => esc_attr__( "Sale Start Date", 'woo-feed' ),
1786
+ "sale_price_edate" => esc_attr__( "Sale End Date", 'woo-feed' ),
1787
+ "weight" => esc_attr__( "Weight", 'woo-feed' ),
1788
+ "width" => esc_attr__( "Width", 'woo-feed' ),
1789
+ "height" => esc_attr__( "Height", 'woo-feed' ),
1790
+ "length" => esc_attr__( "Length", 'woo-feed' ),
1791
+ "shipping_class" => esc_attr__( "Shipping Class", 'woo-feed' ),
1792
+ "type" => esc_attr__( "Product Type", 'woo-feed' ),
1793
+ "variation_type" => esc_attr__( "Variation Type", 'woo-feed' ),
1794
+ "visibility" => esc_attr__( "Visibility", 'woo-feed' ),
1795
+ "rating_total" => esc_attr__( "Total Rating", 'woo-feed' ),
1796
+ "rating_average" => esc_attr__( "Average Rating", 'woo-feed' ),
1797
+ "tags" => esc_attr__( "Tags", 'woo-feed' ),
1798
+ "sale_price_effective_date" => esc_attr__( "Sale Price Effective Date", 'woo-feed' ),
1799
+ "is_bundle" => esc_attr__( "Is Bundle", 'woo-feed' ),
1800
+ "date_created" => esc_attr__( "Date Created", 'woo-feed' ),
1801
+ "date_updated" => esc_attr__( "Date Updated", 'woo-feed' ),
1802
  );
1803
  $images = array(
1804
+ "image" => esc_attr__( "Main Image", 'woo-feed' ),
1805
+ "feature_image" => esc_attr__( "Featured Image", 'woo-feed' ),
1806
+ "images" => esc_attr__( "Images [Comma Separated]", 'woo-feed' ),
1807
+ "image_1" => esc_attr__( "Additional Image 1", 'woo-feed' ),
1808
+ "image_2" => esc_attr__( "Additional Image 2", 'woo-feed' ),
1809
+ "image_3" => esc_attr__( "Additional Image 3", 'woo-feed' ),
1810
+ "image_4" => esc_attr__( "Additional Image 4", 'woo-feed' ),
1811
+ "image_5" => esc_attr__( "Additional Image 5", 'woo-feed' ),
1812
+ "image_6" => esc_attr__( "Additional Image 6", 'woo-feed' ),
1813
+ "image_7" => esc_attr__( "Additional Image 7", 'woo-feed' ),
1814
+ "image_8" => esc_attr__( "Additional Image 8", 'woo-feed' ),
1815
+ "image_9" => esc_attr__( "Additional Image 9", 'woo-feed' ),
1816
+ "image_10" => esc_attr__( "Additional Image 10", 'woo-feed' ),
1817
  );
1818
 
1819
  # Primary Attributes
1820
  $attributeDropdown = "<option></option>";
1821
+ if ( ! empty( $attributes ) ) {
1822
  $attributeDropdown .= sprintf( "<optgroup label=\"%s\">", esc_attr__( 'Primary Attributes', 'woo-feed' ) );
1823
+ foreach ( $attributes as $key => $value ) {
1824
  $attributeDropdown .= sprintf( '<option value="%s">%s</option>', $key, $value );
1825
  }
1826
  $attributeDropdown .= "</optgroup>";
1829
  # Additional Images
1830
  if ( ! empty( $images ) ) {
1831
  $attributeDropdown .= sprintf( "<optgroup label=\"%s\">", esc_attr__( 'Image Attributes', 'woo-feed' ) );
1832
+ foreach ( $images as $key => $value ) {
1833
  $attributeDropdown .= sprintf( '<option value="%s">%s</option>', $key, $value );
1834
  }
1835
  $attributeDropdown .= "</optgroup>";
1839
  $vAttributes = $this->getAllAttributes();
1840
  if ( $vAttributes && ! empty( $vAttributes ) ) {
1841
  $attributeDropdown .= sprintf( "<optgroup label=\"%s\">", esc_attr__( 'Product Attributes', 'woo-feed' ) );
1842
+ foreach ( $vAttributes as $key => $value ) {
1843
  $attributeDropdown .= sprintf( '<option value="%s">%s</option>', $key, $value );
1844
  }
1845
  $attributeDropdown .= "</optgroup>";
1846
  }
1847
  }
1848
 
1849
+ if ( $selected && strpos( $attributeDropdown, 'value="'.$selected.'"' ) !== false ) {
1850
  $attributeDropdown = str_replace( 'value="'.$selected.'"', 'value="'.$selected.'"'.' selected', $attributeDropdown );
1851
  }
1852
  return $attributeDropdown;
1855
  /**
1856
  * Load all WooCommerce attributes into an option
1857
  */
1858
+ public function load_attributes() {
 
1859
  # Get All WooCommerce Attributes
1860
  $vAttributes = $this->getAllAttributes();
1861
  update_option("wpfw_vAttributes", $vAttributes);
1880
  * @param $product
1881
  * @return float|string
1882
  */
1883
+ public function getPriceWithTax( $product ) {
1884
+ if ( woo_feed_wc_version_check(3.0) ) {
1885
+ return wc_get_price_including_tax($product,array( 'price' => $product->get_price() ));
1886
+ }else {
 
1887
  return $product->get_price_including_tax();
1888
  }
1889
  }
1892
  * @param $date
1893
  * @return false|string
1894
  */
1895
+ public function format_product_date( $date ) {
1896
+ return gmdate("Y-m-d",strtotime($date));
 
1897
  }
1898
 
1899
  /**
1905
  * @return string
1906
  */
1907
  public function getProductTaxonomy( $id, $taxonomy ) {
1908
+ $taxonomy = str_replace("wf_taxo_", "",$taxonomy);
1909
+ $Taxo = get_the_term_list($id,$taxonomy,"",",","");
1910
 
1911
+ if ( ! empty($Taxo) ) {
1912
  return strip_tags($Taxo);
1913
  }
1914
 
includes/classes/class-woo-feed-savefile.php CHANGED
@@ -17,7 +17,7 @@ class Woo_Feed_Savefile
17
  * @param $path
18
  * @return bool
19
  */
20
- public function checkDir($path) {
21
  if ( ! file_exists( $path ) ) {
22
  return wp_mkdir_p( $path );
23
  }
@@ -36,7 +36,7 @@ class Woo_Feed_Savefile
36
  * @param $info
37
  * @return bool
38
  */
39
- public function saveCSVFile($path, $file, $content, $info) {
40
  if ( $this->checkDir( $path ) ) {
41
  /**
42
  * @TODO see below
@@ -46,26 +46,26 @@ class Woo_Feed_Savefile
46
 
47
  $fp = fopen($file, "wb");
48
 
49
- if ($info['delimiter'] == 'tab') {
50
  $delimiter = "\t";
51
  } else {
52
- $delimiter = !empty($info['delimiter'])?trim($info['delimiter']):$info['delimiter'];
53
  }
54
 
55
- if (!empty($info['enclosure'])) {
56
  $enclosure = $info['enclosure'];
57
  } else {
58
  $enclosure = "";
59
  }
60
 
61
  $enclosure = $info['enclosure'];
62
- if (count($content)) {
63
- foreach ($content as $fields) {
64
  if ($enclosure == "double")
65
  fputcsv($fp,$fields,$delimiter,chr(34));
66
- else if ($enclosure == "single")
67
  fputcsv($fp,$fields,$delimiter,chr(39));
68
- else{
69
  fputs($fp,implode($fields,$delimiter)."\n");
70
  }
71
  }
@@ -91,7 +91,7 @@ class Woo_Feed_Savefile
91
  * @param $content
92
  * @return bool
93
  */
94
- public function saveFile($path, $file, $content) {
95
  if ( $this->checkDir( $path ) ) {
96
  if ( file_exists( $file ) ) @unlink( $file );
97
  $fp = fopen( $file, "w+" );
17
  * @param $path
18
  * @return bool
19
  */
20
+ public function checkDir( $path ) {
21
  if ( ! file_exists( $path ) ) {
22
  return wp_mkdir_p( $path );
23
  }
36
  * @param $info
37
  * @return bool
38
  */
39
+ public function saveCSVFile( $path, $file, $content, $info ) {
40
  if ( $this->checkDir( $path ) ) {
41
  /**
42
  * @TODO see below
46
 
47
  $fp = fopen($file, "wb");
48
 
49
+ if ( $info['delimiter'] == 'tab' ) {
50
  $delimiter = "\t";
51
  } else {
52
+ $delimiter = ! empty($info['delimiter']) ? trim($info['delimiter']) : $info['delimiter'];
53
  }
54
 
55
+ if ( ! empty($info['enclosure']) ) {
56
  $enclosure = $info['enclosure'];
57
  } else {
58
  $enclosure = "";
59
  }
60
 
61
  $enclosure = $info['enclosure'];
62
+ if ( count($content) ) {
63
+ foreach ( $content as $fields ) {
64
  if ($enclosure == "double")
65
  fputcsv($fp,$fields,$delimiter,chr(34));
66
+ elseif ($enclosure == "single")
67
  fputcsv($fp,$fields,$delimiter,chr(39));
68
+ else {
69
  fputs($fp,implode($fields,$delimiter)."\n");
70
  }
71
  }
91
  * @param $content
92
  * @return bool
93
  */
94
+ public function saveFile( $path, $file, $content ) {
95
  if ( $this->checkDir( $path ) ) {
96
  if ( file_exists( $file ) ) @unlink( $file );
97
  $fp = fopen( $file, "w+" );
includes/classes/class-woo-feed-sftp.php CHANGED
@@ -5,30 +5,27 @@ class SFTPConnection
5
  private $connection;
6
  private $sftp;
7
 
8
- public function __construct($host, $port=22)
9
- {
10
  $this->connection = @ssh2_connect($host, $port);
11
- if (! $this->connection)
12
  throw new Exception("Could not connect to $host on port $port.");
13
  }
14
 
15
- public function login($username, $password)
16
- {
17
- if (! @ssh2_auth_password($this->connection, $username, $password))
18
  throw new Exception("Could not authenticate with username $username " .
19
  "and password $password.");
20
 
21
  $this->sftp = @ssh2_sftp($this->connection);
22
- if (! $this->sftp)
23
  throw new Exception("Could not initialize SFTP subsystem.");
24
  }
25
 
26
- public function uploadFile($local_file, $remote_file)
27
- {
28
  $sftp = $this->sftp;
29
  $stream = @fopen("ssh2.sftp://$sftp$remote_file", 'w');
30
 
31
- if (! $stream)
32
  throw new Exception("Could not open file: $remote_file");
33
 
34
  $data_to_send = @file_get_contents($local_file);
@@ -40,8 +37,7 @@ class SFTPConnection
40
 
41
  @fclose($stream);
42
  }
43
- public function deleteFile($remote_file)
44
- {
45
  $sftp = $this->sftp;
46
  unlink("ssh2.sftp://$sftp$remote_file");
47
  }
5
  private $connection;
6
  private $sftp;
7
 
8
+ public function __construct( $host, $port=22 ) {
 
9
  $this->connection = @ssh2_connect($host, $port);
10
+ if ( ! $this->connection)
11
  throw new Exception("Could not connect to $host on port $port.");
12
  }
13
 
14
+ public function login( $username, $password ) {
15
+ if ( ! @ssh2_auth_password($this->connection, $username, $password))
 
16
  throw new Exception("Could not authenticate with username $username " .
17
  "and password $password.");
18
 
19
  $this->sftp = @ssh2_sftp($this->connection);
20
+ if ( ! $this->sftp)
21
  throw new Exception("Could not initialize SFTP subsystem.");
22
  }
23
 
24
+ public function uploadFile( $local_file, $remote_file ) {
 
25
  $sftp = $this->sftp;
26
  $stream = @fopen("ssh2.sftp://$sftp$remote_file", 'w');
27
 
28
+ if ( ! $stream)
29
  throw new Exception("Could not open file: $remote_file");
30
 
31
  $data_to_send = @file_get_contents($local_file);
37
 
38
  @fclose($stream);
39
  }
40
+ public function deleteFile( $remote_file ) {
 
41
  $sftp = $this->sftp;
42
  unlink("ssh2.sftp://$sftp$remote_file");
43
  }
includes/classes/class-woo-feed-webappick-api.php CHANGED
@@ -5,9 +5,9 @@
5
  * @since 3.1.41
6
  * @version 1.0.2
7
  */
8
- if( ! defined( 'ABSPATH' ) ) die();
9
 
10
- if( ! class_exists( 'WooFeedWebAppickAPI' ) ) {
11
  /**
12
  * Class WooFeedWebAppickAPI
13
  */
@@ -52,7 +52,7 @@ if( ! class_exists( 'WooFeedWebAppickAPI' ) ) {
52
  * @return WooFeedWebAppickAPI
53
  */
54
  public static function getInstance() {
55
- if( is_null( self::$instance ) ) self::$instance = new self();
56
  return self::$instance;
57
  }
58
 
@@ -80,6 +80,12 @@ if( ! class_exists( 'WooFeedWebAppickAPI' ) ) {
80
  // Initialize
81
  $this->insightInit();
82
  $this->promotion->init();
 
 
 
 
 
 
83
  }
84
 
85
  /**
@@ -87,7 +93,7 @@ if( ! class_exists( 'WooFeedWebAppickAPI' ) ) {
87
  * @since 1.0.2
88
  */
89
  public function __clone() {
90
- _doing_it_wrong( __FUNCTION__, __( 'Cloning is forbidden.', 'woo-feed' ), '1.0.2' );
91
  }
92
 
93
  /**
@@ -96,22 +102,34 @@ if( ! class_exists( 'WooFeedWebAppickAPI' ) ) {
96
  */
97
  private function insightInit() {
98
  global $wpdb;
99
- $result = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->options WHERE option_name LIKE %s;", "wf_feed_%"), 'ARRAY_A' );
100
- if( ! is_array( $result ) ) $result = [];
101
- $catCount = wp_count_terms( 'product_cat', ['hide_empty'=> false, 'parent' => 0] );
102
- if( is_wp_error( $catCount ) ) $catCount = 0;
 
 
 
103
  /**
104
  * @TODO count products by type
105
  * @see wc_get_product_types();
106
  */
107
- $this->insights->add_extra( [
108
- 'products' => $this->insights->get_post_count( 'product' ),
109
- 'variations' => $this->insights->get_post_count( 'product_variation' ),
110
- 'batch_limit' => get_option( 'woo_feed_per_batch' ),
111
- 'feed_configs' => json_encode( $result ),
112
-
 
 
 
 
 
 
113
  'product_cat_num' => $catCount,
114
- ] );
 
 
 
115
  $projectSlug = $this->client->getSlug();
116
  add_filter( $projectSlug . '_what_tracked', [ $this, 'data_we_collect' ], 10, 1 );
117
  add_filter( "WebAppick_{$projectSlug}_Support_Ticket_Recipient_Email", function(){
@@ -155,6 +173,7 @@ if( ! class_exists( 'WooFeedWebAppickAPI' ) ) {
155
  $response .= sprintf( '<h3>%s</h3>', esc_html__( 'Thank you -- Support Ticket Submitted.', 'woo-feed' ) );
156
  $ticketSubmitted = esc_html__( 'Your ticket has been successfully submitted.', 'woo-feed' );
157
  $twenty4Hours = sprintf( '<strong>%s</strong>', esc_html__( '24 hours', 'woo-feed' ) );
 
158
  $notification = sprintf( esc_html__( 'You will receive an email notification from "support@webappick.com" in your inbox within %s.', 'woo-feed' ), $twenty4Hours );
159
  $followUp = esc_html__( 'Please Follow the email and WebAppick Support Team will get back with you shortly.', 'woo-feed' );
160
  $response .= sprintf( '<p>%s %s %s</p>', $ticketSubmitted, $notification, $followUp );
@@ -164,7 +183,8 @@ if( ! class_exists( 'WooFeedWebAppickAPI' ) ) {
164
  $response .= '<br><br><br>';
165
  $toc = sprintf( '<a href="https://webappick.com/terms-and-conditions/" target="_blank">%s</a>', esc_html__( 'Terms & Conditions', 'woo-feed' ) );
166
  $pp = sprintf( '<a href="https://webappick.com/privacy-policy/" target="_blank">%s</a>', esc_html__( 'Privacy Policy', 'woo-feed' ) );
167
- $policy = sprintf( esc_html__( 'Please read our %s and %s', 'woo-feed' ), $toc, $pp );
 
168
  $response .= sprintf( '<p style="font-size: 12px;">%s</p>', $policy );
169
  return $response;
170
  }
@@ -195,11 +215,15 @@ if( ! class_exists( 'WooFeedWebAppickAPI' ) ) {
195
  esc_html__( 'Feed Configuration.', 'woo-feed' ),
196
  esc_html__( 'Site name, language and url.', 'woo-feed' ),
197
  esc_html__( 'Number of active and inactive plugins.', 'woo-feed' ),
198
- esc_html__( 'Your name and email address.', 'woo-feed' )
199
  ] );
200
  return $data;
201
  }
202
 
 
 
 
 
203
  public function get_data_collection_description() {
204
  return $this->insights->get_data_collection_description();
205
  }
@@ -212,7 +236,7 @@ if( ! class_exists( 'WooFeedWebAppickAPI' ) ) {
212
  * @return void
213
  */
214
  public function trackerOptIn( $override = false ) {
215
- $this->insights->optIn( true );
216
  }
217
 
218
  /**
@@ -230,6 +254,166 @@ if( ! class_exists( 'WooFeedWebAppickAPI' ) ) {
230
  public function is_tracking_allowed() {
231
  return $this->insights->is_tracking_allowed();
232
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
233
  }
234
  }
235
  // End of file class-woo-feed-webappick-api.php
5
  * @since 3.1.41
6
  * @version 1.0.2
7
  */
8
+ if ( ! defined( 'ABSPATH' ) ) die();
9
 
10
+ if ( ! class_exists( 'WooFeedWebAppickAPI' ) ) {
11
  /**
12
  * Class WooFeedWebAppickAPI
13
  */
52
  * @return WooFeedWebAppickAPI
53
  */
54
  public static function getInstance() {
55
+ if ( is_null( self::$instance ) ) self::$instance = new self();
56
  return self::$instance;
57
  }
58
 
80
  // Initialize
81
  $this->insightInit();
82
  $this->promotion->init();
83
+
84
+ // Housekeeping.
85
+ add_action( 'admin_menu', [ $this, 'premium_features' ], 999 );
86
+ add_action( 'admin_notices', [ $this, 'woo_feed_review_notice' ] );
87
+ add_action('wp_ajax_woo_feed_save_review_notice', [ $this, 'woo_feed_save_review_notice' ] );
88
+ add_action('wp_ajax_woo_feed_hide_notice', [ $this, 'woo_feed_hide_notice' ] );
89
  }
90
 
91
  /**
93
  * @since 1.0.2
94
  */
95
  public function __clone() {
96
+ _doing_it_wrong( __FUNCTION__, esc_html__( 'Cloning is forbidden.', 'woo-feed' ), '1.0.2' );
97
  }
98
 
99
  /**
102
  */
103
  private function insightInit() {
104
  global $wpdb;
105
+ $result = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->options WHERE option_name LIKE %s;", "wf_feed_%"), 'ARRAY_A' ); // phpcs:ignore
106
+ if ( ! is_array( $result ) ) $result = [];
107
+ $catCount = wp_count_terms( 'product_cat', [
108
+ 'hide_empty' => false,
109
+ 'parent' => 0,
110
+ ] );
111
+ if ( is_wp_error( $catCount ) ) $catCount = 0;
112
  /**
113
  * @TODO count products by type
114
  * @see wc_get_product_types();
115
  */
116
+ // update_option( 'woo_feed_review_notice', $value );
117
+ // $notices = [ 'rp-wcdpd', 'wpml', 'rating', 'product_limit' ];
118
+ //
119
+ $hidden_notices = [];
120
+ foreach ( [ 'rp-wcdpd', 'wpml', 'rating', 'product_limit' ] as $which ) {
121
+ $hidden_notices[ $which ] = (int) get_option( sprintf( 'woo_feed_%s_notice_hidden', $which ), 0 );
122
+ }
123
+ $tracker_extra = [
124
+ 'products' => $this->insights->get_post_count( 'product' ),
125
+ 'variations' => $this->insights->get_post_count( 'product_variation' ),
126
+ 'batch_limit' => get_option( 'woo_feed_per_batch' ),
127
+ 'feed_configs' => wp_json_encode( $result ),
128
  'product_cat_num' => $catCount,
129
+ 'review_notice' => wp_json_encode( get_option( 'woo_feed_review_notice', [] ) ),
130
+ 'hidden_notices' => $hidden_notices,
131
+ ];
132
+ $this->insights->add_extra( $tracker_extra );
133
  $projectSlug = $this->client->getSlug();
134
  add_filter( $projectSlug . '_what_tracked', [ $this, 'data_we_collect' ], 10, 1 );
135
  add_filter( "WebAppick_{$projectSlug}_Support_Ticket_Recipient_Email", function(){
173
  $response .= sprintf( '<h3>%s</h3>', esc_html__( 'Thank you -- Support Ticket Submitted.', 'woo-feed' ) );
174
  $ticketSubmitted = esc_html__( 'Your ticket has been successfully submitted.', 'woo-feed' );
175
  $twenty4Hours = sprintf( '<strong>%s</strong>', esc_html__( '24 hours', 'woo-feed' ) );
176
+ /* translators: %s: Approx. time to response after ticket submission. */
177
  $notification = sprintf( esc_html__( 'You will receive an email notification from "support@webappick.com" in your inbox within %s.', 'woo-feed' ), $twenty4Hours );
178
  $followUp = esc_html__( 'Please Follow the email and WebAppick Support Team will get back with you shortly.', 'woo-feed' );
179
  $response .= sprintf( '<p>%s %s %s</p>', $ticketSubmitted, $notification, $followUp );
183
  $response .= '<br><br><br>';
184
  $toc = sprintf( '<a href="https://webappick.com/terms-and-conditions/" target="_blank">%s</a>', esc_html__( 'Terms & Conditions', 'woo-feed' ) );
185
  $pp = sprintf( '<a href="https://webappick.com/privacy-policy/" target="_blank">%s</a>', esc_html__( 'Privacy Policy', 'woo-feed' ) );
186
+ /* translators: 1: Link to the Trams And Condition Page, 2: Link to the Privacy Policy Page */
187
+ $policy = sprintf( esc_html__( 'Please read our %1$s and %2$s', 'woo-feed' ), $toc, $pp );
188
  $response .= sprintf( '<p style="font-size: 12px;">%s</p>', $policy );
189
  return $response;
190
  }
215
  esc_html__( 'Feed Configuration.', 'woo-feed' ),
216
  esc_html__( 'Site name, language and url.', 'woo-feed' ),
217
  esc_html__( 'Number of active and inactive plugins.', 'woo-feed' ),
218
+ esc_html__( 'Your name and email address.', 'woo-feed' ),
219
  ] );
220
  return $data;
221
  }
222
 
223
+ /**
224
+ * Get Tracker Data Collection Description Array
225
+ * @return array
226
+ */
227
  public function get_data_collection_description() {
228
  return $this->insights->get_data_collection_description();
229
  }
236
  * @return void
237
  */
238
  public function trackerOptIn( $override = false ) {
239
+ $this->insights->optIn( $override );
240
  }
241
 
242
  /**
254
  public function is_tracking_allowed() {
255
  return $this->insights->is_tracking_allowed();
256
  }
257
+
258
+ public function premium_features() {
259
+ add_submenu_page( 'webappick-manage-feeds', esc_html__('Premium', 'woo-feed'), '<span class="woo-feed-premium">' . esc_html__('Premium', 'woo-feed') . '</span>', 'manage_woocommerce', 'webappick-feed-pro-vs-free', [ $this, 'woo_feed_pro_vs_free' ] );
260
+ add_action( 'admin_head', [ $this, 'remove_admin_notices' ], 9999 );
261
+ }
262
+
263
+ /**
264
+ * Render Premium Feature Comparison Page
265
+ * @return void
266
+ */
267
+ public function woo_feed_pro_vs_free(){
268
+ /** @define "WOO_FEED_FREE_ADMIN_PATH" "./../../admin/" */ // phpcs:ignore
269
+ require WOO_FEED_FREE_ADMIN_PATH . 'partials/woo-feed-pro-vs-free.php';
270
+ }
271
+
272
+ /**
273
+ * Remove Admin Notice in pro features page.
274
+ * @global string $pagenow
275
+ * @global string $plugin_page
276
+ * @return void
277
+ */
278
+ public function remove_admin_notices() {
279
+ global $pagenow, $plugin_page;
280
+ if ( 'admin.php' == $pagenow && 'webappick-feed-pro-vs-free' == $plugin_page ) {
281
+ remove_all_actions( 'admin_notices' );
282
+ }
283
+ }
284
+
285
+ /**
286
+ * Show Review And Compatibility Notice For Pro Features
287
+ * @global string $plugin_page
288
+ * @return void
289
+ */
290
+ public function woo_feed_review_notice() {
291
+ global $plugin_page;
292
+ $options = get_option( 'woo_feed_review_notice' );
293
+ $installDate = get_option( 'woo-feed-free-activation-time' );
294
+ $installDate = strtotime( '-16 days', $installDate );
295
+ $pluginName = sprintf( '<b>%s</b>', esc_html__( 'WooCommerce Product Feed', 'woo-feed' ) );
296
+ $proLink = sprintf( '<b><a href="http://bit.ly/2KIwvTt" target="_blank">%s</a></b>', esc_html__( 'Premium', 'woo-feed' ) );
297
+ $review_notice = (
298
+ false === get_option( 'woo_feed_rating_notice' ) &&
299
+ (
300
+ ! $options && time() >= $installDate + ( DAY_IN_SECONDS * 15 ) ||
301
+ (
302
+ is_array( $options ) &&
303
+ (
304
+ ! array_key_exists( 'review_notice', $options ) ||
305
+ (
306
+ 'later' == $options['review_notice'] &&
307
+ time() >= ( $options['updated_at'] + ( DAY_IN_SECONDS * 30 ) )
308
+ )
309
+ )
310
+ )
311
+ )
312
+ );
313
+ // Review Notice.
314
+ if ( $review_notice ) {
315
+ ?>
316
+ <div class="woo-feed-notice notice notice-info is-dismissible" data-which="rating">
317
+ <p><?php
318
+ printf(
319
+ /* translators: 1: plugin name,2: Slightly Smiling Face (Emoji), 3: line break 'br' tag */
320
+ esc_html__( '%2$s We have spent countless hours developing this free plugin for you, and we would really appreciate it if you dropped us a quick rating. Your opinion matters a lot to us.%3$s It helps us to get better. Thanks for using %1$s.', 'woo-feed' ),
321
+ $pluginName, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
322
+ '<span style="font-size: 16px;">🙂</span>',
323
+ '<br>'
324
+ );
325
+ ?></p>
326
+ <p>
327
+ <a class="button button-secondary" data-response="later" href="#"><?php esc_html_e( 'Remind me later', 'woo-feed' ); ?></a>
328
+ <a class="button button-secondary" data-response="never" href="#"><?php esc_html_e( 'I would not', 'woo-feed' ); ?></a>
329
+ <a class="button button-primary" data-response="given" href="#" target="_blank"><?php esc_html_e( 'Review Here', 'woo-feed' ); ?></a>
330
+ </p>
331
+ </div>
332
+ <?php
333
+ }
334
+ // Pro Limit Notice
335
+ $limit_notice_pages = [ 'webappick-manage-feeds', 'webappick-new-feed', 'webappick-feed-settings' ];
336
+ if ( in_array( $plugin_page, $limit_notice_pages ) && false === get_option( 'woo_feed_product_limit_notice_hidden' ) ) {
337
+ ?>
338
+ <div class="woo-feed-notice notice notice-warning is-dismissible" data-which="product_limit">
339
+ <p><?php
340
+ printf(
341
+ /* translators: 1: This plugin name, 2: Opening Bold Tag 3: Closing Bold Tad */
342
+ esc_html__( 'You are awesome for using %1$s. Free version works great for up to %2$s2000 products including variations.%3$s', 'woo-feed' ),
343
+ $pluginName, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
344
+ '<b>',
345
+ '</b>'
346
+ );
347
+ ?></p>
348
+ </div>
349
+ <?php
350
+ }
351
+ // Compatibility Notices.
352
+ if ( class_exists( 'SitePress' ) && false === get_option( 'woo_feed_wpml_notice_hidden' ) ) {
353
+ ?>
354
+ <div class="woo-feed-notice notice notice-success is-dismissible" data-which="wpml">
355
+ <p><?php
356
+ printf(
357
+ /* translators: 1: This plugin name, 2: Pro version purchase link */
358
+ esc_html__( 'You are awesome for using %1$s. Using the %2$s version you can make multilingual feed for your WPML languages.', 'woo-feed' ),
359
+ $pluginName, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
360
+ $proLink // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
361
+ );
362
+ ?></p>
363
+ </div>
364
+ <?php
365
+ }
366
+ if ( class_exists( 'RP_WCDPD', false ) && false === get_option( 'woo_feed_rp-wcdpd_notice_hidden' ) ) {
367
+ ?>
368
+ <div class="woo-feed-notice notice notice-success is-dismissible" data-which="rp-wcdpd">
369
+ <p><?php
370
+ printf(
371
+ /* translators: 1: This plugin Name, 2: Incompatible plugin name, 3: Pro version purchase link */
372
+ esc_html__( '%1$s isn\'t fully compatible with %2$s. Get the %3$s version for full support.', 'woo-feed' ),
373
+ $pluginName, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
374
+ '<b>'.esc_html__( 'WooCommerce Dynamic Pricing & Discounts', 'woo-feed' ).'</b>',
375
+ $proLink // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
376
+ );
377
+ ?></p>
378
+ </div>
379
+ <?php
380
+ }
381
+ }
382
+
383
+ /**
384
+ * Show Review request admin notice
385
+ */
386
+ public function woo_feed_save_review_notice() {
387
+ check_ajax_referer( 'wpf_feed_nonce' );
388
+ $review_actions = [ 'later', 'never', 'given' ];
389
+ if ( isset( $_POST['notice'] ) && ! empty( $_POST['notice'] ) && in_array( $_POST['notice'], $review_actions ) ) {
390
+ $value = [
391
+ 'review_notice' => sanitize_text_field( $_POST['notice'] ),
392
+ 'updated_at' => time(),
393
+ ];
394
+ update_option( 'woo_feed_review_notice', $value );
395
+ wp_send_json_success( $value );
396
+ wp_die();
397
+ }
398
+ wp_send_json_error( esc_html__( 'Invalid Request.', 'woo-feed' ) );
399
+ wp_die();
400
+ }
401
+
402
+ /**
403
+ * Ajax Action For Hiding Compatibility Notices
404
+ */
405
+ public function woo_feed_hide_notice() {
406
+ check_ajax_referer( 'wpf_feed_nonce' );
407
+ $notices = [ 'rp-wcdpd', 'wpml', 'rating', 'product_limit' ];
408
+ if ( isset( $_REQUEST['which'] ) && ! empty( $_REQUEST['which'] ) && in_array( $_REQUEST['which'], $notices ) ) {
409
+ $which = sanitize_text_field( $_REQUEST['which'] );
410
+ update_option( sprintf( 'woo_feed_%s_notice_hidden', $which ), '1', false );
411
+ wp_send_json_success( esc_html__( 'Request Successful.', 'woo-feed' ) );
412
+ wp_die();
413
+ }
414
+ wp_send_json_error( esc_html__( 'Invalid Request.', 'woo-feed' ) );
415
+ wp_die();
416
+ }
417
  }
418
  }
419
  // End of file class-woo-feed-webappick-api.php
includes/feeds/class-woo-feed-custom.php CHANGED
@@ -47,12 +47,11 @@ class Woo_Feed_Custom
47
  * @var Woo_Generate_Feed $feedRule Contain Feed Configuration
48
  * @since 1.0.0
49
  */
50
- public function __construct($feedRule)
51
- {
52
  $this->products = new Woo_Feed_Products_v3($feedRule);
53
  # When update via cron job then set productIds
54
- if(!isset($feedRule['productIds'])){
55
- $feedRule['productIds']=$this->products->query_products();
56
  }
57
  $this->products->get_products($feedRule['productIds']);
58
  $this->rules = $feedRule;
@@ -71,14 +70,13 @@ class Woo_Feed_Custom
71
  * Prepare Feed For XML Output
72
  *
73
  */
74
- public function mapAttributeForXML()
75
- {
76
  $i = 0;
77
  $cdata = true;
78
- if ($this->products) {
79
- foreach ($this->products as $no => $product) {
80
- foreach ($product as $key => $value) {
81
- $this->products[$no][$key] = $this->formatXMLLine($key, $value);
82
  }
83
  $i++;
84
  }
@@ -93,19 +91,17 @@ class Woo_Feed_Custom
93
  * @param string $space
94
  * @return string
95
  */
96
- function formatXMLLine($attribute, $value, $space ="")
97
- {
98
  $attribute = str_replace(" ", "_", $attribute);
99
  //Make child node for XML
100
- if(!empty($value))
101
- $value=trim($value);
102
- if (strpos($value, "<![CDATA[") === false && substr(trim($value), 0, 4) == "http") {
103
  $value = "<![CDATA[$value]]>";
104
- } elseif (strpos($value, "<![CDATA[") === false && !is_numeric(trim($value)) && !empty($value)) {
105
  $value = "<![CDATA[$value]]>";
106
  }
107
- if($this->rules['provider'] == 'myshopping.com.au' && $attribute == "Category")
108
- {
109
  return "$space<$attribute xml:space=\"preserve\">$value</$attribute>";
110
  }
111
  return "
@@ -117,52 +113,49 @@ class Woo_Feed_Custom
117
  *
118
  * @return array|bool|string
119
  */
120
- public function returnFinalProduct()
121
- {
122
- if(!empty($this->products)) {
123
- if ($this->rules['feedType'] == 'xml') {
124
  //return $engine->get_feed($this->products);
125
- $feed=array(
126
- "body"=>$this->products->feedBody,
127
- "header"=>$this->products->feedHeader,
128
- "footer"=>$this->products->feedFooter,
129
  );
130
  //echo "<pre>";print_r($feed);die();
131
  return $feed;
132
- } else if ($this->rules['feedType'] == 'txt') {
133
  //return $engine->get_txt_feed();
134
- $feed=array(
135
- "body"=>$this->products->feedBody,
136
- "header"=>$this->products->feedHeader,
137
- "footer"=>"",
138
  );
139
  return $feed;
140
- } elseif ($this->rules['feedType'] == 'csv') {
141
  //return $engine->get_csv_feed();
142
- $feed=array(
143
- "body"=>$this->products->feedBody,
144
- "header"=>$this->products->feedHeader,
145
- "footer"=>"",
146
  );
147
  //echo "<pre>";print_r($feed);die();
148
  return $feed;
149
  }
150
  }
151
 
152
- $feed=array(
153
- "body"=>"",
154
- "header"=>"",
155
- "footer"=>"",
156
  );
157
  return $feed;
158
  }
159
 
160
- public function get_header($engine)
161
- {
162
- $datetime_now = date("Y-m-d H:i:s");
163
 
164
- if($this->rules['provider'] == 'zap.co.il')
165
- {
166
  $zap = "<STORE>
167
  <datetime>$datetime_now</datetime>
168
  <title>". get_bloginfo('name') ."</title>
@@ -172,60 +165,63 @@ class Woo_Feed_Custom
172
  <email>". get_bloginfo('admin_email') ."</email>";
173
  return $zap;
174
  }
175
- else if($this->rules['provider'] == 'myshopping.com.au')
176
- {
177
  return "<productset>";
178
  }
179
- else if( in_array($this->rules['provider'], ['fruugo.au', 'stylight.com', 'nextad', 'skinflint.co.uk',
180
- 'comparer.be', 'dooyoo', 'hintaseuranta.fi', 'incurvy', 'kijiji.ca', 'marktplaats.nl', 'rakuten.de',
181
- 'shopalike.fr', 'spartoo.fi', 'webmarchand']) )
182
- {
 
 
 
 
 
 
 
 
 
 
 
 
183
  return "<products version=\"1.0\" standalone=\"yes\">
184
  <datetime>$datetime_now</datetime>
185
  <title>". get_bloginfo('name') ."</title>
186
  <link>". get_bloginfo('url') ."</link>
187
  <description>". get_bloginfo('description') ."</description>";
188
  }
189
- else if($this->rules['provider'] == "fashiola.de")
190
- {
191
  return "<products version=\"1.0\" standalone=\"yes\">
192
  <datetime>$datetime_now</datetime>
193
  <title>". get_bloginfo('name') ."</title>
194
  <link>". get_bloginfo('url') ."</link>
195
  <description>". get_bloginfo('description') ."</description>";
196
  }
197
- else if($this->rules['provider'] == 'criteo')
198
- {
199
  return "<channel>
200
  <title>". get_bloginfo('name') ."</title>
201
  <link>". get_bloginfo('url') ."</link>
202
  <description>". get_bloginfo('description') ."</description>";
203
  }
204
- else
205
- {
206
  return $engine->get_xml_feed_header();
207
  }
208
  }
209
 
210
- public function get_footer($engine)
211
- {
212
- if(in_array($this->rules['provider'], ['fruugo.au', 'stylight.com', 'nextad', 'skinflint.co.uk', 'comparer.be', 'dooyoo', 'hintaseuranta.fi', 'incurvy', 'kijiji.ca', 'marktplaats.nl', 'rakuten.de', 'shopalike.fr', 'spartoo.fi', 'webmarchand', 'fashiola.de'])) {
213
  return "</products>";
214
  }
215
- else if($this->rules['provider'] == 'zap.co.il')
216
- {
217
  return "</STORE>";
218
  }
219
- else if($this->rules['provider'] == 'myshopping.com.au')
220
- {
221
  return "</productset>";
222
  }
223
- else if($this->rules['provider'] == 'criteo')
224
- {
225
  return "</channel>";
226
  }
227
- else
228
- {
229
  return $engine->get_xml_feed_footer();
230
  }
231
  }
47
  * @var Woo_Generate_Feed $feedRule Contain Feed Configuration
48
  * @since 1.0.0
49
  */
50
+ public function __construct( $feedRule ) {
 
51
  $this->products = new Woo_Feed_Products_v3($feedRule);
52
  # When update via cron job then set productIds
53
+ if ( ! isset($feedRule['productIds']) ) {
54
+ $feedRule['productIds'] = $this->products->query_products();
55
  }
56
  $this->products->get_products($feedRule['productIds']);
57
  $this->rules = $feedRule;
70
  * Prepare Feed For XML Output
71
  *
72
  */
73
+ public function mapAttributeForXML() {
 
74
  $i = 0;
75
  $cdata = true;
76
+ if ( $this->products ) {
77
+ foreach ( $this->products as $no => $product ) {
78
+ foreach ( $product as $key => $value ) {
79
+ $this->products[ $no ][ $key ] = $this->formatXMLLine($key, $value);
80
  }
81
  $i++;
82
  }
91
  * @param string $space
92
  * @return string
93
  */
94
+ function formatXMLLine( $attribute, $value, $space ="" ) {
 
95
  $attribute = str_replace(" ", "_", $attribute);
96
  //Make child node for XML
97
+ if ( ! empty($value))
98
+ $value = trim($value);
99
+ if ( strpos($value, "<![CDATA[") === false && substr(trim($value), 0, 4) == "http" ) {
100
  $value = "<![CDATA[$value]]>";
101
+ } elseif ( strpos($value, "<![CDATA[") === false && ! is_numeric(trim($value)) && ! empty($value) ) {
102
  $value = "<![CDATA[$value]]>";
103
  }
104
+ if ( $this->rules['provider'] == 'myshopping.com.au' && $attribute == "Category" ) {
 
105
  return "$space<$attribute xml:space=\"preserve\">$value</$attribute>";
106
  }
107
  return "
113
  *
114
  * @return array|bool|string
115
  */
116
+ public function returnFinalProduct() {
117
+ if ( ! empty($this->products) ) {
118
+ if ( $this->rules['feedType'] == 'xml' ) {
 
119
  //return $engine->get_feed($this->products);
120
+ $feed = array(
121
+ "body" => $this->products->feedBody,
122
+ "header" => $this->products->feedHeader,
123
+ "footer" => $this->products->feedFooter,
124
  );
125
  //echo "<pre>";print_r($feed);die();
126
  return $feed;
127
+ } elseif ( $this->rules['feedType'] == 'txt' ) {
128
  //return $engine->get_txt_feed();
129
+ $feed = array(
130
+ "body" => $this->products->feedBody,
131
+ "header" => $this->products->feedHeader,
132
+ "footer" => "",
133
  );
134
  return $feed;
135
+ } elseif ( $this->rules['feedType'] == 'csv' ) {
136
  //return $engine->get_csv_feed();
137
+ $feed = array(
138
+ "body" => $this->products->feedBody,
139
+ "header" => $this->products->feedHeader,
140
+ "footer" => "",
141
  );
142
  //echo "<pre>";print_r($feed);die();
143
  return $feed;
144
  }
145
  }
146
 
147
+ $feed = array(
148
+ "body" => "",
149
+ "header" => "",
150
+ "footer" => "",
151
  );
152
  return $feed;
153
  }
154
 
155
+ public function get_header( $engine ) {
156
+ $datetime_now = gmdate("Y-m-d H:i:s");
 
157
 
158
+ if ( $this->rules['provider'] == 'zap.co.il' ) {
 
159
  $zap = "<STORE>
160
  <datetime>$datetime_now</datetime>
161
  <title>". get_bloginfo('name') ."</title>
165
  <email>". get_bloginfo('admin_email') ."</email>";
166
  return $zap;
167
  }
168
+ elseif ( $this->rules['provider'] == 'myshopping.com.au' ) {
 
169
  return "<productset>";
170
  }
171
+ elseif ( in_array($this->rules['provider'], [
172
+ 'fruugo.au',
173
+ 'stylight.com',
174
+ 'nextad',
175
+ 'skinflint.co.uk',
176
+ 'comparer.be',
177
+ 'dooyoo',
178
+ 'hintaseuranta.fi',
179
+ 'incurvy',
180
+ 'kijiji.ca',
181
+ 'marktplaats.nl',
182
+ 'rakuten.de',
183
+ 'shopalike.fr',
184
+ 'spartoo.fi',
185
+ 'webmarchand',
186
+ ]) ) {
187
  return "<products version=\"1.0\" standalone=\"yes\">
188
  <datetime>$datetime_now</datetime>
189
  <title>". get_bloginfo('name') ."</title>
190
  <link>". get_bloginfo('url') ."</link>
191
  <description>". get_bloginfo('description') ."</description>";
192
  }
193
+ elseif ( $this->rules['provider'] == "fashiola.de" ) {
 
194
  return "<products version=\"1.0\" standalone=\"yes\">
195
  <datetime>$datetime_now</datetime>
196
  <title>". get_bloginfo('name') ."</title>
197
  <link>". get_bloginfo('url') ."</link>
198
  <description>". get_bloginfo('description') ."</description>";
199
  }
200
+ elseif ( $this->rules['provider'] == 'criteo' ) {
 
201
  return "<channel>
202
  <title>". get_bloginfo('name') ."</title>
203
  <link>". get_bloginfo('url') ."</link>
204
  <description>". get_bloginfo('description') ."</description>";
205
  }
206
+ else {
 
207
  return $engine->get_xml_feed_header();
208
  }
209
  }
210
 
211
+ public function get_footer( $engine ) {
212
+ if ( in_array($this->rules['provider'], [ 'fruugo.au', 'stylight.com', 'nextad', 'skinflint.co.uk', 'comparer.be', 'dooyoo', 'hintaseuranta.fi', 'incurvy', 'kijiji.ca', 'marktplaats.nl', 'rakuten.de', 'shopalike.fr', 'spartoo.fi', 'webmarchand', 'fashiola.de' ]) ) {
 
213
  return "</products>";
214
  }
215
+ elseif ( $this->rules['provider'] == 'zap.co.il' ) {
 
216
  return "</STORE>";
217
  }
218
+ elseif ( $this->rules['provider'] == 'myshopping.com.au' ) {
 
219
  return "</productset>";
220
  }
221
+ elseif ( $this->rules['provider'] == 'criteo' ) {
 
222
  return "</channel>";
223
  }
224
+ else {
 
225
  return $engine->get_xml_feed_footer();
226
  }
227
  }
includes/feeds/class-woo-feed-facebook.php CHANGED
@@ -83,14 +83,13 @@ class Woo_Feed_Facebook
83
  * @var Woo_Generate_Feed $feedRule Contain Feed Configuration
84
  * @since 1.0.0
85
  */
86
- public function __construct($feedRule)
87
- {
88
- $feedRule['itemWrapper']=$this->feedWrapper;
89
  $this->products = new Woo_Feed_Products_v3($feedRule);
90
 
91
  # When update via cron job then set productIds
92
- if(!isset($feedRule['productIds'])){
93
- $feedRule['productIds']=$this->products->query_products();
94
  }
95
  $this->products->get_products($feedRule['productIds']);
96
  $this->rules = $feedRule;
@@ -113,42 +112,41 @@ class Woo_Feed_Facebook
113
  *
114
  * @return array|bool|string
115
  */
116
- public function returnFinalProduct()
117
- {
118
- if(!empty($this->products)){
119
 
120
- if ($this->rules['feedType'] == 'xml') {
121
  //return $this->get_feed($this->products);
122
- $feed=array(
123
- "header"=>$this->get_xml_feed_header(),
124
- "body"=>$this->products->feedBody,
125
- "footer"=>$this->get_xml_feed_footer(),
126
  );
127
  return $feed;
128
- } elseif ($this->rules['feedType'] == 'txt') {
129
 
130
- $feed=array(
131
- "body"=>$this->products->feedBody,
132
- "header"=>$this->products->feedHeader,
133
- "footer"=>"",
134
  );
135
  //echo "<pre>";print_r($feed);die();
136
  return $feed;
137
- } elseif ($this->rules['feedType'] == 'csv') {
138
 
139
- $feed=array(
140
- "body"=>$this->products->feedBody,
141
- "header"=>$this->products->feedHeader,
142
- "footer"=>"",
143
  );
144
  return $feed;
145
  }
146
  }
147
 
148
- $feed=array(
149
- "body"=>"",
150
- "header"=>"",
151
- "footer"=>"",
152
  );
153
  return $feed;
154
  }
@@ -156,86 +154,85 @@ class Woo_Feed_Facebook
156
  /**
157
  * Configure merchant attributes for XML feed
158
  */
159
- public function mapAttributeForXML()
160
- {
161
 
162
  $googleXMLAttribute = array(
163
- "id" => array("g:id", false),
164
- "title" => array("g:title", true),
165
- "description" => array("g:description", true),
166
- "link" => array("g:link", true),
167
- "mobile_link" => array("g:mobile_link", true),
168
- "product_type" => array("g:product_type", true),
169
- "current_category" => array("g:google_product_category", true),
170
- "image" => array("g:image_link", true),
171
- "images" => array("g:additional_image_link", false),
172
- "images_1" => array("g:additional_image_link_1", true),
173
- "images_2" => array("g:additional_image_link_2", true),
174
- "images_3" => array("g:additional_image_link_3", true),
175
- "images_4" => array("g:additional_image_link_4", true),
176
- "images_5" => array("g:additional_image_link_5", true),
177
- "images_6" => array("g:additional_image_link_6", true),
178
- "images_7" => array("g:additional_image_link_7", true),
179
- "images_8" => array("g:additional_image_link_8", true),
180
- "images_9" => array("g:additional_image_link_9", true),
181
- "images_10" => array("g:additional_image_link_10", true),
182
- "condition" => array("g:condition", false),
183
- "availability" => array("g:availability", false),
184
- "inventory" => array("g:inventory", false),
185
- "override" => array("g:override", false),
186
- "price" => array("g:price", true),
187
- "sale_price" => array("g:sale_price", true),
188
- "sale_price_effective_date" => array("g:sale_price_effective_date", true),
189
- "brand" => array("g:brand", true),
190
- "sku" => array("g:mpn", true),
191
- "upc" => array("g:gtin", true),
192
- "identifier_exists" => array("g:identifier_exists", true),
193
- "item_group_id" => array("g:item_group_id", false),
194
- "color" => array("g:color", true),
195
- "gender" => array("g:gender", true),
196
- "age_group" => array("g:age_group", true),
197
- "material" => array("g:material", true),
198
- "pattern" => array("g:pattern", true),
199
- "size" => array("g:size", true),
200
- "size_type" => array("g:size_type", true),
201
- "size_system" => array("g:size_system", true),
202
- "tax" => array("tax", true),
203
- "weight" => array("g:shipping_weight", false),
204
- "length" => array("g:shipping_length", false),
205
- "width" => array("g:shipping_width", false),
206
- "height" => array("g:shipping_height", false),
207
- "shipping_label" => array("g:shipping_label", false),
208
- "shipping_country" => array("g:shipping_country", false),
209
- "shipping_service" => array("g:shipping_service", false),
210
- "shipping_price" => array("g:shipping_price", false),
211
- "shipping_region" => array("g:shipping_region", false),
212
- "multipack" => array("g:multipack", true),
213
- "is_bundle" => array("g:is_bundle", true),
214
- "adult" => array("g:adult", true),
215
- "adwords_redirect" => array("g:adwords_redirect", true),
216
- "custom_label_0" => array("g:custom_label_0", true),
217
- "custom_label_1" => array("g:custom_label_1", true),
218
- "custom_label_2" => array("g:custom_label_2", true),
219
- "custom_label_3" => array("g:custom_label_3", true),
220
- "custom_label_4" => array("g:custom_label_4", true),
221
- "excluded_destination" => array("g:excluded_destination", true),
222
- "expiration_date" => array("g:expiration_date", true),
223
- "unit_pricing_measure" => array("g:unit_pricing_measure", true),
224
- "unit_pricing_base_measure" => array("g:unit_pricing_base_measure", true),
225
- "energy_efficiency_class" => array("g:energy_efficiency_class", true),
226
- "loyalty_points" => array("g:loyalty_points", true),
227
- "installment" => array("g:installment", true),
228
- "promotion_id" => array("g:promotion_id", true),
229
- "cost_of_goods_sold" => array("g:cost_of_goods_sold", true),
230
- "availability_date" => array("g:availability_date", true),
231
- "tax_category" => array("g:tax_category", true),
232
- "included_destination" => array("g:included_destination", true),
233
  );
234
 
235
- if ( !empty($this->products) ) {
236
- foreach ($this->products as $no => $product) {
237
- foreach ($product as $key => $value) {
238
- $this->mapAttribute($no, $key, $googleXMLAttribute[$key][0], $value, $googleXMLAttribute[$key][0]);
239
  }
240
  $this->process_google_shipping_attribute_for_xml($no);
241
  }
@@ -245,86 +242,85 @@ class Woo_Feed_Facebook
245
  /**
246
  * Configure merchant attributes for XML feed
247
  */
248
- public function mapAttributeForCSVTXT()
249
- {
250
  //Basic product information
251
  $googleCSVTXTAttribute = array(
252
- "id" => array("id", false),
253
- "title" => array("title", true),
254
- "description" => array("description", true),
255
- "link" => array("link", true),
256
- "mobile_link" => array("mobile_link", true),
257
- "product_type" => array("product type", true),
258
- "current_category" => array("google product category", true),
259
- "image" => array("image link", true),
260
- "images" => array("additional image link", true),
261
- "images_1" => array("additional image link 1", true),
262
- "images_2" => array("additional image link 2", true),
263
- "images_3" => array("additional image link 3", true),
264
- "images_4" => array("additional image link 4", true),
265
- "images_5" => array("additional image link 5", true),
266
- "images_6" => array("additional image link 6", true),
267
- "images_7" => array("additional image link 7", true),
268
- "images_8" => array("additional image link 8", true),
269
- "images_9" => array("additional image link 9", true),
270
- "images_10" => array("additional image link 10", true),
271
- "condition" => array("condition", false),
272
- "availability" => array("availability", false),
273
- "inventory" => array("inventory", false),
274
- "override" => array("override", false),
275
- "price" => array("price", true),
276
- "sale_price" => array("sale price", true),
277
- "sale_price_effective_date" => array("sale price effective date", true),
278
- "brand" => array("brand", true),
279
- "sku" => array("mpn", true),
280
- "upc" => array("gtin", true),
281
- "identifier_exists" => array("identifier exists", true),
282
- "item_group_id" => array("item group id", false),
283
- "color" => array("color", true),
284
- "gender" => array("gender", true),
285
- "age_group" => array("age group", true),
286
- "material" => array("material", true),
287
- "pattern" => array("pattern", true),
288
- "size" => array("size", true),
289
- "size_type" => array("size type", true),
290
- "size_system" => array("size system", true),
291
- "tax" => array("tax", true),
292
- "weight" => array("shipping weight", false),
293
- "length" => array("shipping length", false),
294
- "width" => array("shipping width", false),
295
- "height" => array("shipping height", false),
296
- "shipping_label" => array("shipping label", false),
297
- "shipping_country" => array("shipping country", false),
298
- "shipping_service" => array("shipping service", false),
299
- "shipping_price" => array("shipping price", false),
300
- "shipping_region" => array("shipping region", false),
301
- "multipack" => array("multipack", true),
302
- "is_bundle" => array("is bundle", true),
303
- "adult" => array("adult", true),
304
- "adwords_redirect" => array("adwords redirect", true),
305
- "custom_label_0" => array("custom label 0", true),
306
- "custom_label_1" => array("custom label 1", true),
307
- "custom_label_2" => array("custom label 2", true),
308
- "custom_label_3" => array("custom label 3", true),
309
- "custom_label_4" => array("custom label 4", true),
310
- "excluded_destination" => array("excluded destination", true),
311
- "expiration_date" => array("expiration date", true),
312
- "unit_pricing_measure" => array("unit pricing measure", true),
313
- "unit_pricing_base_measure" => array("unit pricing base measure", true),
314
- "energy_efficiency_class" => array("energy efficiency class", true),
315
- "loyalty_points" => array("loyalty points", true),
316
- "installment" => array("installment", true),
317
- "promotion_id" => array("promotion id", true),
318
- "cost_of_goods_sold" => array("cost of goods sold", true),
319
- "availability_date" => array("availability date", true),
320
- "tax_category" => array("tax category", true),
321
- "included_destination" => array("included destination", true),
322
  );
323
 
324
- if ( !empty($this->products) ) {
325
- foreach ($this->products as $no => $product) {
326
- foreach ($product as $key => $value) {
327
- $this->mapAttribute($no, $key, str_replace(" ", "_", $googleCSVTXTAttribute[$key][0]), $value, $googleCSVTXTAttribute[$key][0]);
328
  }
329
  $this->process_google_shipping_attribute_for_CSVTXT($no);
330
  }
@@ -340,64 +336,61 @@ class Woo_Feed_Facebook
340
  * @param bool $cdata
341
  * @return array
342
  */
343
- public function mapAttribute($no, $from, $to, $value, $cdata = false)
344
- {
345
- unset($this->products[$no][$from]);
346
- if ($this->rules['feedType'] == 'xml') {
347
- return $this->products[$no][$to] = $this->formatXMLLine($to, $value, $cdata);
348
  } else {
349
- return $this->products[$no][$to] = $value;
350
  }
351
  }
352
 
353
 
354
  public
355
- function process_google_shipping_attribute_for_xml($no)
356
- {
357
- $shipping = array('g:shipping_country', 'g:shipping_service', 'g:shipping_price', 'g:shipping_region');
358
  $shippingAttr = array();
359
- $products = $this->products[$no];
360
- foreach ($products as $keyAttr => $valueAttr) {
361
- if (in_array($keyAttr, $shipping)) {
362
- array_push($shippingAttr, array($keyAttr => $valueAttr));
363
- unset($this->products[$no][$keyAttr]);
364
  }
365
  }
366
- if (count($shippingAttr)) {
367
  $str = "";
368
- foreach ($shippingAttr as $key => $attributes) {
369
- foreach ($attributes as $keyAttr => $valueAttr) {
370
  $str .= str_replace("shipping_", "", $valueAttr);
371
  }
372
  }
373
- return $this->products[$no]['g:shipping'] = $this->formatXMLLine("g:shipping", $str, false);
374
  }
375
  return false;
376
  }
377
 
378
  public
379
- function process_google_shipping_attribute_for_CSVTXT($no)
380
- {
381
- $shipping = array('shipping_country', 'shipping_service', 'shipping_price', 'shipping_region');
382
  $shippingAttr = array();
383
- $products = $this->products[$no];
384
- foreach ($products as $keyAttr => $valueAttr) {
385
- if (in_array($keyAttr, $shipping)) {
386
- array_push($shippingAttr, array($keyAttr => $valueAttr));
387
- unset($this->products[$no][$keyAttr]);
388
  }
389
  }
390
- if (count($shippingAttr)) {
391
  $str = "";
392
- foreach ($shippingAttr as $key => $attributes) {
393
- foreach ($attributes as $keyAttr => $valueAttr) {
394
  $country = ($keyAttr == "shipping_country") ? $str .= $valueAttr . ":" : "";
395
  $service = ($keyAttr == "shipping_service") ? $str .= $valueAttr . ":" : "";
396
  $price = ($keyAttr == "shipping_price") ? $str .= $valueAttr : "";
397
  $region = ($keyAttr == "shipping_region") ? $str .= $valueAttr . ":" : "";
398
  }
399
  }
400
- return $this->products[$no]['shipping(country:region:service:price)'] = str_replace(" : ", ":", $str);
401
  }
402
  return false;
403
  }
@@ -411,24 +404,23 @@ class Woo_Feed_Facebook
411
  * @param string $space
412
  * @return string
413
  */
414
- function formatXMLLine($attribute, $value, $cdata, $space = "")
415
- {
416
  //Make single XML node
417
- if (!empty($value))
418
  $value = trim($value);
419
  if (gettype($value) == 'array')
420
  $value = json_encode($value);
421
- if (strpos($value, "<![CDATA[") === false && substr(trim($value), 0, 4) == "http") {
422
  $value = "<![CDATA[$value]]>";
423
- } elseif (strpos($value, "<![CDATA[") === false && $cdata === true && !empty($value)) {
424
  $value = "<![CDATA[$value]]>";
425
- } elseif ($cdata) {
426
- if(!empty($value)){
427
  $value = "<![CDATA[$value]]>";
428
  }
429
  }
430
 
431
- if (substr($attribute, 0, 23) == 'g:additional_image_link') {
432
  $attribute = "g:additional_image_link";
433
  }
434
 
@@ -441,8 +433,7 @@ class Woo_Feed_Facebook
441
  * Make XML Feed Header
442
  * @return string
443
  */
444
- public function get_xml_feed_header()
445
- {
446
  $output = '<?xml version="1.0" encoding="UTF-8" ?>
447
  <rss xmlns:g="http://base.google.com/ns/1.0" version="2.0">
448
  <channel>
@@ -456,16 +447,15 @@ class Woo_Feed_Facebook
456
  * @param $items
457
  * @return bool|string
458
  */
459
- public function get_xml_feed_body($items)
460
- {
461
  $feed = "";
462
  //$feed .= $this->get_feed_header();
463
  $feed .= "\n";
464
- if ($items) {
465
- foreach ($items as $item => $products) {
466
  $feed .= " <".$this->feedWrapper.">";
467
- foreach ($products as $key => $value) {
468
- if (!empty($value)){
469
  $feed .= $value;
470
  }
471
  }
@@ -482,8 +472,7 @@ class Woo_Feed_Facebook
482
  * Make XML Feed Footer
483
  * @return string
484
  */
485
- public function get_xml_feed_footer()
486
- {
487
  $footer = " </channel>
488
  </rss>";
489
  return $footer;
@@ -493,16 +482,15 @@ class Woo_Feed_Facebook
493
  * Short Products
494
  * @return array
495
  */
496
- public function short_products()
497
- {
498
- if ($this->products) {
499
  update_option('wpf_progress', "Shorting Products");
500
  sleep(1);
501
  $array = array();
502
  $ij = 0;
503
- foreach ($this->products as $key => $item) {
504
- $array[$ij] = $item;
505
- unset($this->products[$key]);
506
  $ij++;
507
  }
508
  return $this->products = $array;
@@ -514,18 +502,17 @@ class Woo_Feed_Facebook
514
  * Responsible to make CSV feed
515
  * @return string
516
  */
517
- public function get_csv_feed()
518
- {
519
- if ($this->products) {
520
  $headers = array_keys($this->products[0]);
521
  $feed[] = $headers;
522
- foreach ($this->products as $no => $product) {
523
  $row = array();
524
- foreach ($headers as $key => $header) {
525
- if (strpos($header, "additional image link") !== false) {
526
  $header = "additional image link";
527
  }
528
- $row[] = isset($product[$header]) ? $product[$header] : "";;
529
  }
530
  $feed[] = $row;
531
  }
83
  * @var Woo_Generate_Feed $feedRule Contain Feed Configuration
84
  * @since 1.0.0
85
  */
86
+ public function __construct( $feedRule ) {
87
+ $feedRule['itemWrapper'] = $this->feedWrapper;
 
88
  $this->products = new Woo_Feed_Products_v3($feedRule);
89
 
90
  # When update via cron job then set productIds
91
+ if ( ! isset($feedRule['productIds']) ) {
92
+ $feedRule['productIds'] = $this->products->query_products();
93
  }
94
  $this->products->get_products($feedRule['productIds']);
95
  $this->rules = $feedRule;
112
  *
113
  * @return array|bool|string
114
  */
115
+ public function returnFinalProduct() {
116
+ if ( ! empty($this->products) ) {
 
117
 
118
+ if ( $this->rules['feedType'] == 'xml' ) {
119
  //return $this->get_feed($this->products);
120
+ $feed = array(
121
+ "header" => $this->get_xml_feed_header(),
122
+ "body" => $this->products->feedBody,
123
+ "footer" => $this->get_xml_feed_footer(),
124
  );
125
  return $feed;
126
+ } elseif ( $this->rules['feedType'] == 'txt' ) {
127
 
128
+ $feed = array(
129
+ "body" => $this->products->feedBody,
130
+ "header" => $this->products->feedHeader,
131
+ "footer" => "",
132
  );
133
  //echo "<pre>";print_r($feed);die();
134
  return $feed;
135
+ } elseif ( $this->rules['feedType'] == 'csv' ) {
136
 
137
+ $feed = array(
138
+ "body" => $this->products->feedBody,
139
+ "header" => $this->products->feedHeader,
140
+ "footer" => "",
141
  );
142
  return $feed;
143
  }
144
  }
145
 
146
+ $feed = array(
147
+ "body" => "",
148
+ "header" => "",
149
+ "footer" => "",
150
  );
151
  return $feed;
152
  }
154
  /**
155
  * Configure merchant attributes for XML feed
156
  */
157
+ public function mapAttributeForXML() {
 
158
 
159
  $googleXMLAttribute = array(
160
+ "id" => array( "g:id", false ),
161
+ "title" => array( "g:title", true ),
162
+ "description" => array( "g:description", true ),
163
+ "link" => array( "g:link", true ),
164
+ "mobile_link" => array( "g:mobile_link", true ),
165
+ "product_type" => array( "g:product_type", true ),
166
+ "current_category" => array( "g:google_product_category", true ),
167
+ "image" => array( "g:image_link", true ),
168
+ "images" => array( "g:additional_image_link", false ),
169
+ "images_1" => array( "g:additional_image_link_1", true ),
170
+ "images_2" => array( "g:additional_image_link_2", true ),
171
+ "images_3" => array( "g:additional_image_link_3", true ),
172
+ "images_4" => array( "g:additional_image_link_4", true ),
173
+ "images_5" => array( "g:additional_image_link_5", true ),
174
+ "images_6" => array( "g:additional_image_link_6", true ),
175
+ "images_7" => array( "g:additional_image_link_7", true ),
176
+ "images_8" => array( "g:additional_image_link_8", true ),
177
+ "images_9" => array( "g:additional_image_link_9", true ),
178
+ "images_10" => array( "g:additional_image_link_10", true ),
179
+ "condition" => array( "g:condition", false ),
180
+ "availability" => array( "g:availability", false ),
181
+ "inventory" => array( "g:inventory", false ),
182
+ "override" => array( "g:override", false ),
183
+ "price" => array( "g:price", true ),
184
+ "sale_price" => array( "g:sale_price", true ),
185
+ "sale_price_effective_date" => array( "g:sale_price_effective_date", true ),
186
+ "brand" => array( "g:brand", true ),
187
+ "sku" => array( "g:mpn", true ),
188
+ "upc" => array( "g:gtin", true ),
189
+ "identifier_exists" => array( "g:identifier_exists", true ),
190
+ "item_group_id" => array( "g:item_group_id", false ),
191
+ "color" => array( "g:color", true ),
192
+ "gender" => array( "g:gender", true ),
193
+ "age_group" => array( "g:age_group", true ),
194
+ "material" => array( "g:material", true ),
195
+ "pattern" => array( "g:pattern", true ),
196
+ "size" => array( "g:size", true ),
197
+ "size_type" => array( "g:size_type", true ),
198
+ "size_system" => array( "g:size_system", true ),
199
+ "tax" => array( "tax", true ),
200
+ "weight" => array( "g:shipping_weight", false ),
201
+ "length" => array( "g:shipping_length", false ),
202
+ "width" => array( "g:shipping_width", false ),
203
+ "height" => array( "g:shipping_height", false ),
204
+ "shipping_label" => array( "g:shipping_label", false ),
205
+ "shipping_country" => array( "g:shipping_country", false ),
206
+ "shipping_service" => array( "g:shipping_service", false ),
207
+ "shipping_price" => array( "g:shipping_price", false ),
208
+ "shipping_region" => array( "g:shipping_region", false ),
209
+ "multipack" => array( "g:multipack", true ),
210
+ "is_bundle" => array( "g:is_bundle", true ),
211
+ "adult" => array( "g:adult", true ),
212
+ "adwords_redirect" => array( "g:adwords_redirect", true ),
213
+ "custom_label_0" => array( "g:custom_label_0", true ),
214
+ "custom_label_1" => array( "g:custom_label_1", true ),
215
+ "custom_label_2" => array( "g:custom_label_2", true ),
216
+ "custom_label_3" => array( "g:custom_label_3", true ),
217
+ "custom_label_4" => array( "g:custom_label_4", true ),
218
+ "excluded_destination" => array( "g:excluded_destination", true ),
219
+ "expiration_date" => array( "g:expiration_date", true ),
220
+ "unit_pricing_measure" => array( "g:unit_pricing_measure", true ),
221
+ "unit_pricing_base_measure" => array( "g:unit_pricing_base_measure", true ),
222
+ "energy_efficiency_class" => array( "g:energy_efficiency_class", true ),
223
+ "loyalty_points" => array( "g:loyalty_points", true ),
224
+ "installment" => array( "g:installment", true ),
225
+ "promotion_id" => array( "g:promotion_id", true ),
226
+ "cost_of_goods_sold" => array( "g:cost_of_goods_sold", true ),
227
+ "availability_date" => array( "g:availability_date", true ),
228
+ "tax_category" => array( "g:tax_category", true ),
229
+ "included_destination" => array( "g:included_destination", true ),
230
  );
231
 
232
+ if ( ! empty($this->products) ) {
233
+ foreach ( $this->products as $no => $product ) {
234
+ foreach ( $product as $key => $value ) {
235
+ $this->mapAttribute($no, $key, $googleXMLAttribute[ $key ][0], $value, $googleXMLAttribute[ $key ][0]);
236
  }
237
  $this->process_google_shipping_attribute_for_xml($no);
238
  }
242
  /**
243
  * Configure merchant attributes for XML feed
244
  */
245
+ public function mapAttributeForCSVTXT() {
 
246
  //Basic product information
247
  $googleCSVTXTAttribute = array(
248
+ "id" => array( "id", false ),
249
+ "title" => array( "title", true ),
250
+ "description" => array( "description", true ),
251
+ "link" => array( "link", true ),
252
+ "mobile_link" => array( "mobile_link", true ),
253
+ "product_type" => array( "product type", true ),
254
+ "current_category" => array( "google product category", true ),
255
+ "image" => array( "image link", true ),
256
+ "images" => array( "additional image link", true ),
257
+ "images_1" => array( "additional image link 1", true ),
258
+ "images_2" => array( "additional image link 2", true ),
259
+ "images_3" => array( "additional image link 3", true ),
260
+ "images_4" => array( "additional image link 4", true ),
261
+ "images_5" => array( "additional image link 5", true ),
262
+ "images_6" => array( "additional image link 6", true ),
263
+ "images_7" => array( "additional image link 7", true ),
264
+ "images_8" => array( "additional image link 8", true ),
265
+ "images_9" => array( "additional image link 9", true ),
266
+ "images_10" => array( "additional image link 10", true ),
267
+ "condition" => array( "condition", false ),
268
+ "availability" => array( "availability", false ),
269
+ "inventory" => array( "inventory", false ),
270
+ "override" => array( "override", false ),
271
+ "price" => array( "price", true ),
272
+ "sale_price" => array( "sale price", true ),
273
+ "sale_price_effective_date" => array( "sale price effective date", true ),
274
+ "brand" => array( "brand", true ),
275
+ "sku" => array( "mpn", true ),
276
+ "upc" => array( "gtin", true ),
277
+ "identifier_exists" => array( "identifier exists", true ),
278
+ "item_group_id" => array( "item group id", false ),
279
+ "color" => array( "color", true ),
280
+ "gender" => array( "gender", true ),
281
+ "age_group" => array( "age group", true ),
282
+ "material" => array( "material", true ),
283
+ "pattern" => array( "pattern", true ),
284
+ "size" => array( "size", true ),
285
+ "size_type" => array( "size type", true ),
286
+ "size_system" => array( "size system", true ),
287
+ "tax" => array( "tax", true ),
288
+ "weight" => array( "shipping weight", false ),
289
+ "length" => array( "shipping length", false ),
290
+ "width" => array( "shipping width", false ),
291
+ "height" => array( "shipping height", false ),
292
+ "shipping_label" => array( "shipping label", false ),
293
+ "shipping_country" => array( "shipping country", false ),
294
+ "shipping_service" => array( "shipping service", false ),
295
+ "shipping_price" => array( "shipping price", false ),
296
+ "shipping_region" => array( "shipping region", false ),
297
+ "multipack" => array( "multipack", true ),
298
+ "is_bundle" => array( "is bundle", true ),
299
+ "adult" => array( "adult", true ),
300
+ "adwords_redirect" => array( "adwords redirect", true ),
301
+ "custom_label_0" => array( "custom label 0", true ),
302
+ "custom_label_1" => array( "custom label 1", true ),
303
+ "custom_label_2" => array( "custom label 2", true ),
304
+ "custom_label_3" => array( "custom label 3", true ),
305
+ "custom_label_4" => array( "custom label 4", true ),
306
+ "excluded_destination" => array( "excluded destination", true ),
307
+ "expiration_date" => array( "expiration date", true ),
308
+ "unit_pricing_measure" => array( "unit pricing measure", true ),
309
+ "unit_pricing_base_measure" => array( "unit pricing base measure", true ),
310
+ "energy_efficiency_class" => array( "energy efficiency class", true ),
311
+ "loyalty_points" => array( "loyalty points", true ),
312
+ "installment" => array( "installment", true ),
313
+ "promotion_id" => array( "promotion id", true ),
314
+ "cost_of_goods_sold" => array( "cost of goods sold", true ),
315
+ "availability_date" => array( "availability date", true ),
316
+ "tax_category" => array( "tax category", true ),
317
+ "included_destination" => array( "included destination", true ),
318
  );
319
 
320
+ if ( ! empty($this->products) ) {
321
+ foreach ( $this->products as $no => $product ) {
322
+ foreach ( $product as $key => $value ) {
323
+ $this->mapAttribute($no, $key, str_replace(" ", "_", $googleCSVTXTAttribute[ $key ][0]), $value, $googleCSVTXTAttribute[ $key ][0]);
324
  }
325
  $this->process_google_shipping_attribute_for_CSVTXT($no);
326
  }
336
  * @param bool $cdata
337
  * @return array
338
  */
339
+ public function mapAttribute( $no, $from, $to, $value, $cdata = false ) {
340
+ unset($this->products[ $no ][ $from ]);
341
+ if ( $this->rules['feedType'] == 'xml' ) {
342
+ return $this->products[ $no ][ $to ] = $this->formatXMLLine($to, $value, $cdata);
 
343
  } else {
344
+ return $this->products[ $no ][ $to ] = $value;
345
  }
346
  }
347
 
348
 
349
  public
350
+ function process_google_shipping_attribute_for_xml( $no ) {
351
+ $shipping = array( 'g:shipping_country', 'g:shipping_service', 'g:shipping_price', 'g:shipping_region' );
 
352
  $shippingAttr = array();
353
+ $products = $this->products[ $no ];
354
+ foreach ( $products as $keyAttr => $valueAttr ) {
355
+ if ( in_array($keyAttr, $shipping) ) {
356
+ array_push($shippingAttr, array( $keyAttr => $valueAttr ));
357
+ unset($this->products[ $no ][ $keyAttr ]);
358
  }
359
  }
360
+ if ( count($shippingAttr) ) {
361
  $str = "";
362
+ foreach ( $shippingAttr as $key => $attributes ) {
363
+ foreach ( $attributes as $keyAttr => $valueAttr ) {
364
  $str .= str_replace("shipping_", "", $valueAttr);
365
  }
366
  }
367
+ return $this->products[ $no ]['g:shipping'] = $this->formatXMLLine("g:shipping", $str, false);
368
  }
369
  return false;
370
  }
371
 
372
  public
373
+ function process_google_shipping_attribute_for_CSVTXT( $no ) {
374
+ $shipping = array( 'shipping_country', 'shipping_service', 'shipping_price', 'shipping_region' );
 
375
  $shippingAttr = array();
376
+ $products = $this->products[ $no ];
377
+ foreach ( $products as $keyAttr => $valueAttr ) {
378
+ if ( in_array($keyAttr, $shipping) ) {
379
+ array_push($shippingAttr, array( $keyAttr => $valueAttr ));
380
+ unset($this->products[ $no ][ $keyAttr ]);
381
  }
382
  }
383
+ if ( count($shippingAttr) ) {
384
  $str = "";
385
+ foreach ( $shippingAttr as $key => $attributes ) {
386
+ foreach ( $attributes as $keyAttr => $valueAttr ) {
387
  $country = ($keyAttr == "shipping_country") ? $str .= $valueAttr . ":" : "";
388
  $service = ($keyAttr == "shipping_service") ? $str .= $valueAttr . ":" : "";
389
  $price = ($keyAttr == "shipping_price") ? $str .= $valueAttr : "";
390
  $region = ($keyAttr == "shipping_region") ? $str .= $valueAttr . ":" : "";
391
  }
392
  }
393
+ return $this->products[ $no ]['shipping(country:region:service:price)'] = str_replace(" : ", ":", $str);
394
  }
395
  return false;
396
  }
404
  * @param string $space
405
  * @return string
406
  */
407
+ function formatXMLLine( $attribute, $value, $cdata, $space = "" ) {
 
408
  //Make single XML node
409
+ if ( ! empty($value))
410
  $value = trim($value);
411
  if (gettype($value) == 'array')
412
  $value = json_encode($value);
413
+ if ( strpos($value, "<![CDATA[") === false && substr(trim($value), 0, 4) == "http" ) {
414
  $value = "<![CDATA[$value]]>";
415
+ } elseif ( strpos($value, "<![CDATA[") === false && $cdata === true && ! empty($value) ) {
416
  $value = "<![CDATA[$value]]>";
417
+ } elseif ( $cdata ) {
418
+ if ( ! empty($value) ) {
419
  $value = "<![CDATA[$value]]>";
420
  }
421
  }
422
 
423
+ if ( substr($attribute, 0, 23) == 'g:additional_image_link' ) {
424
  $attribute = "g:additional_image_link";
425
  }
426
 
433
  * Make XML Feed Header
434
  * @return string
435
  */
436
+ public function get_xml_feed_header() {
 
437
  $output = '<?xml version="1.0" encoding="UTF-8" ?>
438
  <rss xmlns:g="http://base.google.com/ns/1.0" version="2.0">
439
  <channel>
447
  * @param $items
448
  * @return bool|string
449
  */
450
+ public function get_xml_feed_body( $items ) {
 
451
  $feed = "";
452
  //$feed .= $this->get_feed_header();
453
  $feed .= "\n";
454
+ if ( $items ) {
455
+ foreach ( $items as $item => $products ) {
456
  $feed .= " <".$this->feedWrapper.">";
457
+ foreach ( $products as $key => $value ) {
458
+ if ( ! empty($value) ) {
459
  $feed .= $value;
460
  }
461
  }
472
  * Make XML Feed Footer
473
  * @return string
474
  */
475
+ public function get_xml_feed_footer() {
 
476
  $footer = " </channel>
477
  </rss>";
478
  return $footer;
482
  * Short Products
483
  * @return array
484
  */
485
+ public function short_products() {
486
+ if ( $this->products ) {
 
487
  update_option('wpf_progress', "Shorting Products");
488
  sleep(1);
489
  $array = array();
490
  $ij = 0;
491
+ foreach ( $this->products as $key => $item ) {
492
+ $array[ $ij ] = $item;
493
+ unset($this->products[ $key ]);
494
  $ij++;
495
  }
496
  return $this->products = $array;
502
  * Responsible to make CSV feed
503
  * @return string
504
  */
505
+ public function get_csv_feed() {
506
+ if ( $this->products ) {
 
507
  $headers = array_keys($this->products[0]);
508
  $feed[] = $headers;
509
+ foreach ( $this->products as $no => $product ) {
510
  $row = array();
511
+ foreach ( $headers as $key => $header ) {
512
+ if ( strpos($header, "additional image link") !== false ) {
513
  $header = "additional image link";
514
  }
515
+ $row[] = isset($product[ $header ]) ? $product[ $header ] : "";
516
  }
517
  $feed[] = $row;
518
  }
includes/feeds/class-woo-feed-generate.php CHANGED
@@ -14,13 +14,11 @@ class Woo_Generate_Feed
14
  * @param string $feedService
15
  * @param array $feedRule
16
  */
17
- public function __construct($feedService, $feedRule)
18
- {
19
  $this->service = new $feedService($feedRule);
20
  }
21
 
22
- public function getProducts()
23
- {
24
  return $this->service->returnFinalProduct();
25
  }
26
  }
14
  * @param string $feedService
15
  * @param array $feedRule
16
  */
17
+ public function __construct( $feedService, $feedRule ) {
 
18
  $this->service = new $feedService($feedRule);
19
  }
20
 
21
+ public function getProducts() {
 
22
  return $this->service->returnFinalProduct();
23
  }
24
  }
includes/feeds/class-woo-feed-google.php CHANGED
@@ -92,14 +92,13 @@ class Woo_Feed_Google
92
  * @var Woo_Generate_Feed $feedRule Contain Feed Configuration
93
  * @since 1.0.0
94
  */
95
- public function __construct($feedRule)
96
- {
97
- $feedRule['itemWrapper']=$this->feedWrapper;
98
  $this->products = new Woo_Feed_Products_v3($feedRule);
99
 
100
  # When update via cron job then set productIds
101
- if(!isset($feedRule['productIds'])){
102
- $feedRule['productIds']=$this->products->query_products();
103
  }
104
  $this->products->get_products($feedRule['productIds']);
105
  $this->rules = $feedRule;
@@ -126,42 +125,41 @@ class Woo_Feed_Google
126
  * @return array
127
  */
128
  //echo "<pre>";print_r($feed);die();
129
- public function returnFinalProduct()
130
- {
131
- if(!empty($this->products)){
132
 
133
- if ($this->rules['feedType'] == 'xml') {
134
  //return $this->get_feed($this->products);
135
- $feed=array(
136
- "body"=>$this->products->feedBody,
137
- "header"=>$this->get_xml_feed_header(),
138
- "footer"=>$this->get_xml_feed_footer(),
139
  );
140
  return $feed;
141
- } elseif ($this->rules['feedType'] == 'txt') {
142
 
143
- $feed=array(
144
- "body"=>$this->products->feedBody,
145
- "header"=>$this->products->feedHeader,
146
- "footer"=>"",
147
  );
148
  //echo "<pre>";print_r($feed);die();
149
  return $feed;
150
- } elseif ($this->rules['feedType'] == 'csv') {
151
 
152
- $feed=array(
153
- "body"=>$this->products->feedBody,
154
- "header"=>$this->products->feedHeader,
155
- "footer"=>"",
156
  );
157
  return $feed;
158
  }
159
  }
160
 
161
- $feed=array(
162
- "body"=>"",
163
- "header"=>"",
164
- "footer"=>"",
165
  );
166
  return $feed;
167
  }
@@ -169,90 +167,89 @@ class Woo_Feed_Google
169
  /**
170
  * Configure merchant attributes for XML feed
171
  */
172
- public function mapAttributeForXML()
173
- {
174
 
175
  $googleXMLAttribute = array(
176
- "id" => array("g:id", false),
177
- "title" => array("title", true),
178
- "description" => array("description", true),
179
- "link" => array("link", true),
180
- "mobile_link" => array("mobile_link", true),
181
- "product_type" => array("g:product_type", true),
182
- "current_category" => array("g:google_product_category", true),
183
- "image" => array("g:image_link", true),
184
- "images" => array("g:additional_image_link", false),
185
- "images_1" => array("g:additional_image_link_1", true),
186
- "images_2" => array("g:additional_image_link_2", true),
187
- "images_3" => array("g:additional_image_link_3", true),
188
- "images_4" => array("g:additional_image_link_4", true),
189
- "images_5" => array("g:additional_image_link_5", true),
190
- "images_6" => array("g:additional_image_link_6", true),
191
- "images_7" => array("g:additional_image_link_7", true),
192
- "images_8" => array("g:additional_image_link_8", true),
193
- "images_9" => array("g:additional_image_link_9", true),
194
- "images_10" => array("g:additional_image_link_10", true),
195
- "condition" => array("g:condition", false),
196
- "availability" => array("g:availability", false),
197
- "availability_date" => array("g:availability_date", false),
198
- "inventory" => array("g:inventory", false),
199
- "price" => array("g:price", true),
200
- "sale_price" => array("g:sale_price", true),
201
- "sale_price_effective_date" => array("g:sale_price_effective_date", true),
202
- "brand" => array("g:brand", true),
203
- "sku" => array("g:mpn", true),
204
- "upc" => array("g:gtin", true),
205
- "identifier_exists" => array("g:identifier_exists", true),
206
- "item_group_id" => array("g:item_group_id", false),
207
- "color" => array("g:color", true),
208
- "gender" => array("g:gender", true),
209
- "age_group" => array("g:age_group", true),
210
- "material" => array("g:material", true),
211
- "pattern" => array("g:pattern", true),
212
- "size" => array("g:size", true),
213
- "size_type" => array("g:size_type", true),
214
- "size_system" => array("g:size_system", true),
215
- "tax" => array("tax", true),
216
- "tax_country" => array("g:tax_country", true),
217
- "tax_region" => array("g:tax_region", true),
218
- "tax_rate" => array("g:tax_rate", true),
219
- "tax_ship" => array("g:tax_ship", true),
220
- "tax_category" => array("g:tax_category", true),
221
- "weight" => array("g:shipping_weight", false),
222
- "length" => array("g:shipping_length", false),
223
- "width" => array("g:shipping_width", false),
224
- "height" => array("g:shipping_height", false),
225
- "shipping_label" => array("g:shipping_label", false),
226
- "shipping_country" => array("g:shipping_country", false),
227
- "shipping_service" => array("g:shipping_service", false),
228
- "shipping_price" => array("g:shipping_price", false),
229
- "shipping_region" => array("g:shipping_region", false),
230
- "multipack" => array("g:multipack", true),
231
- "is_bundle" => array("g:is_bundle", true),
232
- "adult" => array("g:adult", true),
233
- "adwords_redirect" => array("g:adwords_redirect", true),
234
- "custom_label_0" => array("g:custom_label_0", true),
235
- "custom_label_1" => array("g:custom_label_1", true),
236
- "custom_label_2" => array("g:custom_label_2", true),
237
- "custom_label_3" => array("g:custom_label_3", true),
238
- "custom_label_4" => array("g:custom_label_4", true),
239
- "excluded_destination" => array("g:excluded_destination", true),
240
- "included_destination" => array("g:included_destination", true),
241
- "expiration_date" => array("g:expiration_date", true),
242
- "unit_pricing_measure" => array("g:unit_pricing_measure", true),
243
- "unit_pricing_base_measure" => array("g:unit_pricing_base_measure", true),
244
- "energy_efficiency_class" => array("g:energy_efficiency_class", true),
245
- "loyalty_points" => array("g:loyalty_points", true),
246
- "installment" => array("g:installment", true),
247
- "promotion_id" => array("g:promotion_id", true),
248
- "cost_of_goods_sold" => array("g:cost_of_goods_sold", true),
249
  );
250
 
251
- if ( !empty($this->products) ) {
252
- foreach ($this->products as $no => $product) {
253
  $this->identifier_status_add($no);
254
- foreach ($product as $key => $value) {
255
- $this->mapAttribute($no, $key, $googleXMLAttribute[$key][0], $value, $googleXMLAttribute[$key][0]);
256
  }
257
 
258
  $this->process_google_shipping_attribute_for_xml($no);
@@ -264,89 +261,88 @@ class Woo_Feed_Google
264
  /**
265
  * Configure merchant attributes for XML feed
266
  */
267
- public function mapAttributeForCSVTXT()
268
- {
269
  //Basic product information
270
  $googleCSVTXTAttribute = array(
271
- "id" => array("id", false),
272
- "title" => array("title", true),
273
- "description" => array("description", true),
274
- "link" => array("link", true),
275
- "mobile_link" => array("mobile_link", true),
276
- "product_type" => array("product type", true),
277
- "current_category" => array("google product category", true),
278
- "image" => array("image link", true),
279
- "images" => array("additional image link", true),
280
- "images_1" => array("additional image link 1", true),
281
- "images_2" => array("additional image link 2", true),
282
- "images_3" => array("additional image link 3", true),
283
- "images_4" => array("additional image link 4", true),
284
- "images_5" => array("additional image link 5", true),
285
- "images_6" => array("additional image link 6", true),
286
- "images_7" => array("additional image link 7", true),
287
- "images_8" => array("additional image link 8", true),
288
- "images_9" => array("additional image link 9", true),
289
- "images_10" => array("additional image link 10", true),
290
- "condition" => array("condition", false),
291
- "availability" => array("availability", false),
292
- "availability_date" => array("availability date", false),
293
- "inventory" => array("inventory", false),
294
- "price" => array("price", true),
295
- "sale_price" => array("sale price", true),
296
- "sale_price_effective_date" => array("sale price effective date", true),
297
- "brand" => array("brand", true),
298
- "sku" => array("mpn", true),
299
- "upc" => array("gtin", true),
300
- "identifier_exists" => array("identifier exists", true),
301
- "item_group_id" => array("item group id", false),
302
- "color" => array("color", true),
303
- "gender" => array("gender", true),
304
- "age_group" => array("age group", true),
305
- "material" => array("material", true),
306
- "pattern" => array("pattern", true),
307
- "size" => array("size", true),
308
- "size_type" => array("size type", true),
309
- "size_system" => array("size system", true),
310
- "tax" => array("tax", true),
311
- "tax_country" => array("tax country", true),
312
- "tax_region" => array("tax region", true),
313
- "tax_rate" => array("tax rate", true),
314
- "tax_ship" => array("tax ship", true),
315
- "tax_category" => array("tax category", true),
316
- "weight" => array("shipping weight", false),
317
- "length" => array("shipping length", false),
318
- "width" => array("shipping width", false),
319
- "height" => array("shipping height", false),
320
- "shipping_label" => array("shipping label", false),
321
- "shipping_country" => array("shipping country", false),
322
- "shipping_service" => array("shipping service", false),
323
- "shipping_price" => array("shipping price", false),
324
- "shipping_region" => array("shipping region", false),
325
- "multipack" => array("multipack", true),
326
- "is_bundle" => array("is bundle", true),
327
- "adult" => array("adult", true),
328
- "adwords_redirect" => array("adwords redirect", true),
329
- "custom_label_0" => array("custom label 0", true),
330
- "custom_label_1" => array("custom label 1", true),
331
- "custom_label_2" => array("custom label 2", true),
332
- "custom_label_3" => array("custom label 3", true),
333
- "custom_label_4" => array("custom label 4", true),
334
- "excluded_destination" => array("excluded destination", true),
335
- "included_destination" => array("included destination", true),
336
- "expiration_date" => array("expiration date", true),
337
- "unit_pricing_measure" => array("unit pricing measure", true),
338
- "unit_pricing_base_measure" => array("unit pricing base measure", true),
339
- "energy_efficiency_class" => array("energy efficiency class", true),
340
- "loyalty_points" => array("loyalty points", true),
341
- "installment" => array("installment", true),
342
- "promotion_id" => array("promotion id", true),
343
- "cost_of_goods_sold" => array("cost of goods sold", true),
344
  );
345
 
346
- if ( !empty($this->products) ) {
347
- foreach ($this->products as $no => $product) {
348
- foreach ($product as $key => $value) {
349
- $this->mapAttribute($no, $key, $googleCSVTXTAttribute[$key][0], $value, $googleCSVTXTAttribute[$key][0]);
350
  }
351
  $this->process_google_shipping_attribute_for_CSVTXT($no);
352
  }
@@ -362,50 +358,48 @@ class Woo_Feed_Google
362
  * @param bool $cdata
363
  * @return array
364
  */
365
- public function mapAttribute($no, $from, $to, $value, $cdata = false)
366
- {
367
- unset($this->products[$no][$from]);
368
- if($to=='g:color'){
369
- $value=str_replace(",","/",$value);
370
  }
371
- if ($this->rules['feedType'] == 'xml') {
372
- return $this->products[$no][$to] = $this->formatXMLLine($to, $value, $cdata);
373
  } else {
374
- return $this->products[$no][$to] = $value;
375
  }
376
  }
377
 
378
- public function identifier_status_add($no)
379
- {
380
- $identifier = array('brand', 'upc', 'sku', 'mpn', 'gtin');
381
- $product = $this->products[$no];
382
 
383
- if(!array_key_exists('g:identifier_exists',$product)) {
384
- if (count(array_intersect_key(array_flip($identifier), $product)) >= 2) {
385
  # Any 2 required keys exist!
386
- $countIdentifier=0;
387
- if(array_key_exists('brand',$product) && !empty($product['brand'])){
388
  $countIdentifier++;
389
  }
390
- if(array_key_exists('upc',$product) && !empty($product['upc'])){
391
  $countIdentifier++;
392
  }
393
- if(array_key_exists('sku',$product) && !empty($product['sku'])){
394
  $countIdentifier++;
395
  }
396
- if(array_key_exists('mpn',$product) && !empty($product['mpn'])){
397
  $countIdentifier++;
398
  }
399
- if(array_key_exists('gtin',$product) && !empty($product['gtin'])){
400
  $countIdentifier++;
401
  }
402
- if($countIdentifier>=2){
403
- $this->products[$no]["g:identifier_exists"] = $this->formatXMLLine("g:identifier_exists", "yes", $cdata = true);
404
- }else{
405
- $this->products[$no]["g:identifier_exists"] = $this->formatXMLLine("g:identifier_exists", "no", $cdata = true);
406
  }
407
  } else {
408
- $this->products[$no]["g:identifier_exists"] = $this->formatXMLLine("g:identifier_exists", "no", $cdata = true);
409
  }
410
  }
411
  }
@@ -416,45 +410,43 @@ class Woo_Feed_Google
416
  * @return bool|string
417
  */
418
  public
419
- function process_google_shipping_attribute_for_xml($no)
420
- {
421
- $shipping = array('g:shipping_country', 'g:shipping_service', 'g:shipping_price', 'g:shipping_region');
422
  $shippingAttr = array();
423
- $products = $this->products[$no];
424
- foreach ($products as $keyAttr => $valueAttr) {
425
- if (in_array($keyAttr, $shipping)) {
426
- array_push($shippingAttr, array($keyAttr => $valueAttr));
427
- unset($this->products[$no][$keyAttr]);
428
  }
429
  }
430
- if (count($shippingAttr)) {
431
  $str = "";
432
- foreach ($shippingAttr as $key => $attributes) {
433
- foreach ($attributes as $keyAttr => $valueAttr) {
434
  $str .= str_replace("shipping_", "", $valueAttr);
435
  }
436
  }
437
- return $this->products[$no]['g:shipping'] = $this->formatXMLLine("g:shipping", $str, false);
438
  }
439
  return false;
440
  }
441
 
442
  public
443
- function process_google_tax_attribute_for_xml($no)
444
- {
445
- $tax = array('g:tax_country', 'g:tax_region', 'g:tax_rate', 'g:tax_ship');
446
  $taxAttr = array();
447
- $products = $this->products[$no];
448
- foreach ($products as $keyAttr => $valueAttr) {
449
- if (in_array($keyAttr, $tax)) {
450
- array_push($taxAttr, array($keyAttr => $valueAttr));
451
- unset($this->products[$no][$keyAttr]);
452
  }
453
  }
454
- if (count($taxAttr)) {
455
  $str = "";
456
- foreach ($taxAttr as $key => $attributes) {
457
- foreach ($attributes as $keyAttr => $valueAttr) {
458
  // if($keyAttr != "g:tax_ship")
459
  // {
460
  $str .= str_replace("tax_", "", $valueAttr);
@@ -466,7 +458,7 @@ class Woo_Feed_Google
466
  // }
467
  }
468
  }
469
- return $this->products[$no]['g:tax'] = $this->formatXMLLine("g:tax", $str, false);
470
  }
471
  return false;
472
  }
@@ -476,77 +468,74 @@ class Woo_Feed_Google
476
  * @return bool|mixed
477
  */
478
  public
479
- function process_google_shipping_attribute_for_CSVTXT($no)
480
- {
481
- $shipping = array('shipping country', 'shipping service', 'shipping price', 'shipping region');
482
  $shippingAttr = array();
483
- $products = $this->products[$no];
484
- foreach ($products as $keyAttr => $valueAttr) {
485
- if (in_array($keyAttr, $shipping)) {
486
- array_push($shippingAttr, array($keyAttr => $valueAttr));
487
- unset($this->products[$no][$keyAttr]);
488
  }
489
  }
490
- if (count($shippingAttr)) {
491
  $str = "";
492
- foreach ($shippingAttr as $key => $attributes) {
493
- foreach ($attributes as $keyAttr => $valueAttr) {
494
  $country = ($keyAttr == "shipping country") ? $str .= $valueAttr . ":" : "";
495
  $service = ($keyAttr == "shipping service") ? $str .= $valueAttr . ":" : "";
496
  $price = ($keyAttr == "shipping price") ? $str .= $valueAttr : "";
497
  $region = ($keyAttr == "shipping region") ? $str .= $valueAttr . ":" : "";
498
  }
499
  }
500
- return $this->products[$no]['shipping(country:region:service:price)'] = str_replace(" : ",":", $str);
501
  }
502
  return false;
503
  }
504
 
505
  public
506
- function process_google_tax_attribute_for_CSVTXT($no)
507
- {
508
- $tax = array('tax country', 'tax region', 'tax rate', 'tax ship');
509
  $taxAttr = array();
510
- $products = $this->products[$no];
511
- foreach ($products as $keyAttr => $valueAttr) {
512
- if (in_array($keyAttr, $tax)) {
513
- array_push($taxAttr, array($keyAttr => $valueAttr));
514
- unset($this->products[$no][$keyAttr]);
515
  }
516
  }
517
- if (count($taxAttr)) {
518
  $str = "";
519
- foreach ($taxAttr as $key => $attributes) {
520
- foreach ($attributes as $keyAttr => $valueAttr) {
521
  $country = ($keyAttr == "tax country") ? $str .= $valueAttr . ":" : "";
522
  $region = ($keyAttr == "tax region") ? $str .= $valueAttr . ":" : "";
523
- $rate = ($keyAttr == "tax rate") ? $str .= $valueAttr . ":": "";
524
  $ship = ($keyAttr == "tax ship") ? $str .= $valueAttr . ":" : "";
525
  }
526
  }
527
- return $this->products[$no]['tax(country:region:rate:tax_ship)'] = str_replace(" : ",":", $str);
528
  }
529
  return false;
530
  }
531
 
532
- function formatXMLLine($attribute, $value, $cdata, $space = "")
533
- {
534
  //Make single XML node
535
- if (!empty($value))
536
  $value = trim($value);
537
  if (gettype($value) == 'array')
538
  $value = json_encode($value);
539
- if (strpos($value, "<![CDATA[") === false && substr(trim($value), 0, 4) == "http") {
540
  $value = "<![CDATA[$value]]>";
541
- } elseif (strpos($value, "<![CDATA[") === false && $cdata === true && !empty($value)) {
542
  $value = "<![CDATA[$value]]>";
543
- } else if ($cdata) {
544
- if(!empty($value)){
545
  $value = "<![CDATA[$value]]>";
546
  }
547
  }
548
 
549
- if (substr($attribute, 0, 23) == 'g:additional_image_link') {
550
  $attribute = "g:additional_image_link";
551
  }
552
 
@@ -556,8 +545,7 @@ class Woo_Feed_Google
556
 
557
 
558
 
559
- public function get_xml_feed_header()
560
- {
561
  $output = '<?xml version="1.0" encoding="UTF-8" ?>
562
  <rss version="2.0" xmlns:g="http://base.google.com/ns/1.0" xmlns:c="http://base.google.com/cns/1.0">
563
  <channel>
@@ -567,17 +555,16 @@ class Woo_Feed_Google
567
  return $output;
568
  }
569
 
570
- public function get_xml_feed($items)
571
- {
572
  $feed = "";
573
  //$feed .= $this->get_feed_header();
574
  $feed .= "\n";
575
- if ($items) {
576
- foreach ($items as $item => $products) {
577
  $feed .= " <" . $this->feedWrapper . ">";
578
 
579
- foreach ($products as $key => $value) {
580
- if (!empty($value)){
581
  $feed .= $value;
582
  }
583
  }
@@ -590,23 +577,21 @@ class Woo_Feed_Google
590
  return false;
591
  }
592
 
593
- public function get_xml_feed_footer()
594
- {
595
  $footer = " </channel>
596
  </rss>";
597
  return $footer;
598
  }
599
 
600
- public function short_products()
601
- {
602
- if ($this->products) {
603
  update_option('wpf_progress', "Shorting Products");
604
  sleep(1);
605
  $array = array();
606
  $ij = 0;
607
- foreach ($this->products as $key => $item) {
608
- $array[$ij] = $item;
609
- unset($this->products[$key]);
610
  $ij++;
611
  }
612
  return $this->products = $array;
@@ -618,18 +603,17 @@ class Woo_Feed_Google
618
  * Responsible to make CSV feed
619
  * @return string
620
  */
621
- public function get_csv_feed()
622
- {
623
- if ($this->products) {
624
  $headers = array_keys($this->products[0]);
625
  $feed[] = $headers;
626
- foreach ($this->products as $no => $product) {
627
  $row = array();
628
- foreach ($headers as $key => $header) {
629
- if (strpos($header, "additional image link") !== false) {
630
  $header = "additional image link";
631
  }
632
- $row[] = isset($product[$header]) ? $product[$header] : "";;
633
  }
634
  $feed[] = $row;
635
  }
92
  * @var Woo_Generate_Feed $feedRule Contain Feed Configuration
93
  * @since 1.0.0
94
  */
95
+ public function __construct( $feedRule ) {
96
+ $feedRule['itemWrapper'] = $this->feedWrapper;
 
97
  $this->products = new Woo_Feed_Products_v3($feedRule);
98
 
99
  # When update via cron job then set productIds
100
+ if ( ! isset($feedRule['productIds']) ) {
101
+ $feedRule['productIds'] = $this->products->query_products();
102
  }
103
  $this->products->get_products($feedRule['productIds']);
104
  $this->rules = $feedRule;
125
  * @return array
126
  */
127
  //echo "<pre>";print_r($feed);die();
128
+ public function returnFinalProduct() {
129
+ if ( ! empty($this->products) ) {
 
130
 
131
+ if ( $this->rules['feedType'] == 'xml' ) {
132
  //return $this->get_feed($this->products);
133
+ $feed = array(
134
+ "body" => $this->products->feedBody,
135
+ "header" => $this->get_xml_feed_header(),
136
+ "footer" => $this->get_xml_feed_footer(),
137
  );
138
  return $feed;
139
+ } elseif ( $this->rules['feedType'] == 'txt' ) {
140
 
141
+ $feed = array(
142
+ "body" => $this->products->feedBody,
143
+ "header" => $this->products->feedHeader,
144
+ "footer" => "",
145
  );
146
  //echo "<pre>";print_r($feed);die();
147
  return $feed;
148
+ } elseif ( $this->rules['feedType'] == 'csv' ) {
149
 
150
+ $feed = array(
151
+ "body" => $this->products->feedBody,
152
+ "header" => $this->products->feedHeader,
153
+ "footer" => "",
154
  );
155
  return $feed;
156
  }
157
  }
158
 
159
+ $feed = array(
160
+ "body" => "",
161
+ "header" => "",
162
+ "footer" => "",
163
  );
164
  return $feed;
165
  }
167
  /**
168
  * Configure merchant attributes for XML feed
169
  */
170
+ public function mapAttributeForXML() {
 
171
 
172
  $googleXMLAttribute = array(
173
+ "id" => array( "g:id", false ),
174
+ "title" => array( "title", true ),
175
+ "description" => array( "description", true ),
176
+ "link" => array( "link", true ),
177
+ "mobile_link" => array( "mobile_link", true ),
178
+ "product_type" => array( "g:product_type", true ),
179
+ "current_category" => array( "g:google_product_category", true ),
180
+ "image" => array( "g:image_link", true ),
181
+ "images" => array( "g:additional_image_link", false ),
182
+ "images_1" => array( "g:additional_image_link_1", true ),
183
+ "images_2" => array( "g:additional_image_link_2", true ),
184
+ "images_3" => array( "g:additional_image_link_3", true ),
185
+ "images_4" => array( "g:additional_image_link_4", true ),
186
+ "images_5" => array( "g:additional_image_link_5", true ),
187
+ "images_6" => array( "g:additional_image_link_6", true ),
188
+ "images_7" => array( "g:additional_image_link_7", true ),
189
+ "images_8" => array( "g:additional_image_link_8", true ),
190
+ "images_9" => array( "g:additional_image_link_9", true ),
191
+ "images_10" => array( "g:additional_image_link_10", true ),
192
+ "condition" => array( "g:condition", false ),
193
+ "availability" => array( "g:availability", false ),
194
+ "availability_date" => array( "g:availability_date", false ),
195
+ "inventory" => array( "g:inventory", false ),
196
+ "price" => array( "g:price", true ),
197
+ "sale_price" => array( "g:sale_price", true ),
198
+ "sale_price_effective_date" => array( "g:sale_price_effective_date", true ),
199
+ "brand" => array( "g:brand", true ),
200
+ "sku" => array( "g:mpn", true ),
201
+ "upc" => array( "g:gtin", true ),
202
+ "identifier_exists" => array( "g:identifier_exists", true ),
203
+ "item_group_id" => array( "g:item_group_id", false ),
204
+ "color" => array( "g:color", true ),
205
+ "gender" => array( "g:gender", true ),
206
+ "age_group" => array( "g:age_group", true ),
207
+ "material" => array( "g:material", true ),
208
+ "pattern" => array( "g:pattern", true ),
209
+ "size" => array( "g:size", true ),
210
+ "size_type" => array( "g:size_type", true ),
211
+ "size_system" => array( "g:size_system", true ),
212
+ "tax" => array( "tax", true ),
213
+ "tax_country" => array( "g:tax_country", true ),
214
+ "tax_region" => array( "g:tax_region", true ),
215
+ "tax_rate" => array( "g:tax_rate", true ),
216
+ "tax_ship" => array( "g:tax_ship", true ),
217
+ "tax_category" => array( "g:tax_category", true ),
218
+ "weight" => array( "g:shipping_weight", false ),
219
+ "length" => array( "g:shipping_length", false ),
220
+ "width" => array( "g:shipping_width", false ),
221
+ "height" => array( "g:shipping_height", false ),
222
+ "shipping_label" => array( "g:shipping_label", false ),
223
+ "shipping_country" => array( "g:shipping_country", false ),
224
+ "shipping_service" => array( "g:shipping_service", false ),
225
+ "shipping_price" => array( "g:shipping_price", false ),
226
+ "shipping_region" => array( "g:shipping_region", false ),
227
+ "multipack" => array( "g:multipack", true ),
228
+ "is_bundle" => array( "g:is_bundle", true ),
229
+ "adult" => array( "g:adult", true ),
230
+ "adwords_redirect" => array( "g:adwords_redirect", true ),
231
+ "custom_label_0" => array( "g:custom_label_0", true ),
232
+ "custom_label_1" => array( "g:custom_label_1", true ),
233
+ "custom_label_2" => array( "g:custom_label_2", true ),
234
+ "custom_label_3" => array( "g:custom_label_3", true ),
235
+ "custom_label_4" => array( "g:custom_label_4", true ),
236
+ "excluded_destination" => array( "g:excluded_destination", true ),
237
+ "included_destination" => array( "g:included_destination", true ),
238
+ "expiration_date" => array( "g:expiration_date", true ),
239
+ "unit_pricing_measure" => array( "g:unit_pricing_measure", true ),
240
+ "unit_pricing_base_measure" => array( "g:unit_pricing_base_measure", true ),
241
+ "energy_efficiency_class" => array( "g:energy_efficiency_class", true ),
242
+ "loyalty_points" => array( "g:loyalty_points", true ),
243
+ "installment" => array( "g:installment", true ),
244
+ "promotion_id" => array( "g:promotion_id", true ),
245
+ "cost_of_goods_sold" => array( "g:cost_of_goods_sold", true ),
246
  );
247
 
248
+ if ( ! empty($this->products) ) {
249
+ foreach ( $this->products as $no => $product ) {
250
  $this->identifier_status_add($no);
251
+ foreach ( $product as $key => $value ) {
252
+ $this->mapAttribute($no, $key, $googleXMLAttribute[ $key ][0], $value, $googleXMLAttribute[ $key ][0]);
253
  }
254
 
255
  $this->process_google_shipping_attribute_for_xml($no);
261
  /**
262
  * Configure merchant attributes for XML feed
263
  */
264
+ public function mapAttributeForCSVTXT() {
 
265
  //Basic product information
266
  $googleCSVTXTAttribute = array(
267
+ "id" => array( "id", false ),
268
+ "title" => array( "title", true ),
269
+ "description" => array( "description", true ),
270
+ "link" => array( "link", true ),
271
+ "mobile_link" => array( "mobile_link", true ),
272
+ "product_type" => array( "product type", true ),
273
+ "current_category" => array( "google product category", true ),
274
+ "image" => array( "image link", true ),
275
+ "images" => array( "additional image link", true ),
276
+ "images_1" => array( "additional image link 1", true ),
277
+ "images_2" => array( "additional image link 2", true ),
278
+ "images_3" => array( "additional image link 3", true ),
279
+ "images_4" => array( "additional image link 4", true ),
280
+ "images_5" => array( "additional image link 5", true ),
281
+ "images_6" => array( "additional image link 6", true ),
282
+ "images_7" => array( "additional image link 7", true ),
283
+ "images_8" => array( "additional image link 8", true ),
284
+ "images_9" => array( "additional image link 9", true ),
285
+ "images_10" => array( "additional image link 10", true ),
286
+ "condition" => array( "condition", false ),
287
+ "availability" => array( "availability", false ),
288
+ "availability_date" => array( "availability date", false ),
289
+ "inventory" => array( "inventory", false ),
290
+ "price" => array( "price", true ),
291
+ "sale_price" => array( "sale price", true ),
292
+ "sale_price_effective_date" => array( "sale price effective date", true ),
293
+ "brand" => array( "brand", true ),
294
+ "sku" => array( "mpn", true ),
295
+ "upc" => array( "gtin", true ),
296
+ "identifier_exists" => array( "identifier exists", true ),
297
+ "item_group_id" => array( "item group id", false ),
298
+ "color" => array( "color", true ),
299
+ "gender" => array( "gender", true ),
300
+ "age_group" => array( "age group", true ),
301
+ "material" => array( "material", true ),
302
+ "pattern" => array( "pattern", true ),
303
+ "size" => array( "size", true ),
304
+ "size_type" => array( "size type", true ),
305
+ "size_system" => array( "size system", true ),
306
+ "tax" => array( "tax", true ),
307
+ "tax_country" => array( "tax country", true ),
308
+ "tax_region" => array( "tax region", true ),
309
+ "tax_rate" => array( "tax rate", true ),
310
+ "tax_ship" => array( "tax ship", true ),
311
+ "tax_category" => array( "tax category", true ),
312
+ "weight" => array( "shipping weight", false ),
313
+ "length" => array( "shipping length", false ),
314
+ "width" => array( "shipping width", false ),
315
+ "height" => array( "shipping height", false ),
316
+ "shipping_label" => array( "shipping label", false ),
317
+ "shipping_country" => array( "shipping country", false ),
318
+ "shipping_service" => array( "shipping service", false ),
319
+ "shipping_price" => array( "shipping price", false ),
320
+ "shipping_region" => array( "shipping region", false ),
321
+ "multipack" => array( "multipack", true ),
322
+ "is_bundle" => array( "is bundle", true ),
323
+ "adult" => array( "adult", true ),
324
+ "adwords_redirect" => array( "adwords redirect", true ),
325
+ "custom_label_0" => array( "custom label 0", true ),
326
+ "custom_label_1" => array( "custom label 1", true ),
327
+ "custom_label_2" => array( "custom label 2", true ),
328
+ "custom_label_3" => array( "custom label 3", true ),
329
+ "custom_label_4" => array( "custom label 4", true ),
330
+ "excluded_destination" => array( "excluded destination", true ),
331
+ "included_destination" => array( "included destination", true ),
332
+ "expiration_date" => array( "expiration date", true ),
333
+ "unit_pricing_measure" => array( "unit pricing measure", true ),
334
+ "unit_pricing_base_measure" => array( "unit pricing base measure", true ),
335
+ "energy_efficiency_class" => array( "energy efficiency class", true ),
336
+ "loyalty_points" => array( "loyalty points", true ),
337
+ "installment" => array( "installment", true ),
338
+ "promotion_id" => array( "promotion id", true ),
339
+ "cost_of_goods_sold" => array( "cost of goods sold", true ),
340
  );
341
 
342
+ if ( ! empty($this->products) ) {
343
+ foreach ( $this->products as $no => $product ) {
344
+ foreach ( $product as $key => $value ) {
345
+ $this->mapAttribute($no, $key, $googleCSVTXTAttribute[ $key ][0], $value, $googleCSVTXTAttribute[ $key ][0]);
346
  }
347
  $this->process_google_shipping_attribute_for_CSVTXT($no);
348
  }
358
  * @param bool $cdata
359
  * @return array
360
  */
361
+ public function mapAttribute( $no, $from, $to, $value, $cdata = false ) {
362
+ unset($this->products[ $no ][ $from ]);
363
+ if ( $to == 'g:color' ) {
364
+ $value = str_replace(",","/",$value);
 
365
  }
366
+ if ( $this->rules['feedType'] == 'xml' ) {
367
+ return $this->products[ $no ][ $to ] = $this->formatXMLLine($to, $value, $cdata);
368
  } else {
369
+ return $this->products[ $no ][ $to ] = $value;
370
  }
371
  }
372
 
373
+ public function identifier_status_add( $no ) {
374
+ $identifier = array( 'brand', 'upc', 'sku', 'mpn', 'gtin' );
375
+ $product = $this->products[ $no ];
 
376
 
377
+ if ( ! array_key_exists('g:identifier_exists',$product) ) {
378
+ if ( count(array_intersect_key(array_flip($identifier), $product)) >= 2 ) {
379
  # Any 2 required keys exist!
380
+ $countIdentifier = 0;
381
+ if ( array_key_exists('brand',$product) && ! empty($product['brand']) ) {
382
  $countIdentifier++;
383
  }
384
+ if ( array_key_exists('upc',$product) && ! empty($product['upc']) ) {
385
  $countIdentifier++;
386
  }
387
+ if ( array_key_exists('sku',$product) && ! empty($product['sku']) ) {
388
  $countIdentifier++;
389
  }
390
+ if ( array_key_exists('mpn',$product) && ! empty($product['mpn']) ) {
391
  $countIdentifier++;
392
  }
393
+ if ( array_key_exists('gtin',$product) && ! empty($product['gtin']) ) {
394
  $countIdentifier++;
395
  }
396
+ if ( $countIdentifier >= 2 ) {
397
+ $this->products[ $no ]["g:identifier_exists"] = $this->formatXMLLine("g:identifier_exists", "yes", $cdata = true);
398
+ }else {
399
+ $this->products[ $no ]["g:identifier_exists"] = $this->formatXMLLine("g:identifier_exists", "no", $cdata = true);
400
  }
401
  } else {
402
+ $this->products[ $no ]["g:identifier_exists"] = $this->formatXMLLine("g:identifier_exists", "no", $cdata = true);
403
  }
404
  }
405
  }
410
  * @return bool|string
411
  */
412
  public
413
+ function process_google_shipping_attribute_for_xml( $no ) {
414
+ $shipping = array( 'g:shipping_country', 'g:shipping_service', 'g:shipping_price', 'g:shipping_region' );
 
415
  $shippingAttr = array();
416
+ $products = $this->products[ $no ];
417
+ foreach ( $products as $keyAttr => $valueAttr ) {
418
+ if ( in_array($keyAttr, $shipping) ) {
419
+ array_push($shippingAttr, array( $keyAttr => $valueAttr ));
420
+ unset($this->products[ $no ][ $keyAttr ]);
421
  }
422
  }
423
+ if ( count($shippingAttr) ) {
424
  $str = "";
425
+ foreach ( $shippingAttr as $key => $attributes ) {
426
+ foreach ( $attributes as $keyAttr => $valueAttr ) {
427
  $str .= str_replace("shipping_", "", $valueAttr);
428
  }
429
  }
430
+ return $this->products[ $no ]['g:shipping'] = $this->formatXMLLine("g:shipping", $str, false);
431
  }
432
  return false;
433
  }
434
 
435
  public
436
+ function process_google_tax_attribute_for_xml( $no ) {
437
+ $tax = array( 'g:tax_country', 'g:tax_region', 'g:tax_rate', 'g:tax_ship' );
 
438
  $taxAttr = array();
439
+ $products = $this->products[ $no ];
440
+ foreach ( $products as $keyAttr => $valueAttr ) {
441
+ if ( in_array($keyAttr, $tax) ) {
442
+ array_push($taxAttr, array( $keyAttr => $valueAttr ));
443
+ unset($this->products[ $no ][ $keyAttr ]);
444
  }
445
  }
446
+ if ( count($taxAttr) ) {
447
  $str = "";
448
+ foreach ( $taxAttr as $key => $attributes ) {
449
+ foreach ( $attributes as $keyAttr => $valueAttr ) {
450
  // if($keyAttr != "g:tax_ship")
451
  // {
452
  $str .= str_replace("tax_", "", $valueAttr);
458
  // }
459
  }
460
  }
461
+ return $this->products[ $no ]['g:tax'] = $this->formatXMLLine("g:tax", $str, false);
462
  }
463
  return false;
464
  }
468
  * @return bool|mixed
469
  */
470
  public
471
+ function process_google_shipping_attribute_for_CSVTXT( $no ) {
472
+ $shipping = array( 'shipping country', 'shipping service', 'shipping price', 'shipping region' );
 
473
  $shippingAttr = array();
474
+ $products = $this->products[ $no ];
475
+ foreach ( $products as $keyAttr => $valueAttr ) {
476
+ if ( in_array($keyAttr, $shipping) ) {
477
+ array_push($shippingAttr, array( $keyAttr => $valueAttr ));
478
+ unset($this->products[ $no ][ $keyAttr ]);
479
  }
480
  }
481
+ if ( count($shippingAttr) ) {
482
  $str = "";
483
+ foreach ( $shippingAttr as $key => $attributes ) {
484
+ foreach ( $attributes as $keyAttr => $valueAttr ) {
485
  $country = ($keyAttr == "shipping country") ? $str .= $valueAttr . ":" : "";
486
  $service = ($keyAttr == "shipping service") ? $str .= $valueAttr . ":" : "";
487
  $price = ($keyAttr == "shipping price") ? $str .= $valueAttr : "";
488
  $region = ($keyAttr == "shipping region") ? $str .= $valueAttr . ":" : "";
489
  }
490
  }
491
+ return $this->products[ $no ]['shipping(country:region:service:price)'] = str_replace(" : ",":", $str);
492
  }
493
  return false;
494
  }
495
 
496
  public
497
+ function process_google_tax_attribute_for_CSVTXT( $no ) {
498
+ $tax = array( 'tax country', 'tax region', 'tax rate', 'tax ship' );
 
499
  $taxAttr = array();
500
+ $products = $this->products[ $no ];
501
+ foreach ( $products as $keyAttr => $valueAttr ) {
502
+ if ( in_array($keyAttr, $tax) ) {
503
+ array_push($taxAttr, array( $keyAttr => $valueAttr ));
504
+ unset($this->products[ $no ][ $keyAttr ]);
505
  }
506
  }
507
+ if ( count($taxAttr) ) {
508
  $str = "";
509
+ foreach ( $taxAttr as $key => $attributes ) {
510
+ foreach ( $attributes as $keyAttr => $valueAttr ) {
511
  $country = ($keyAttr == "tax country") ? $str .= $valueAttr . ":" : "";
512
  $region = ($keyAttr == "tax region") ? $str .= $valueAttr . ":" : "";
513
+ $rate = ($keyAttr == "tax rate") ? $str .= $valueAttr . ":" : "";
514
  $ship = ($keyAttr == "tax ship") ? $str .= $valueAttr . ":" : "";
515
  }
516
  }
517
+ return $this->products[ $no ]['tax(country:region:rate:tax_ship)'] = str_replace(" : ",":", $str);
518
  }
519
  return false;
520
  }
521
 
522
+ function formatXMLLine( $attribute, $value, $cdata, $space = "" ) {
 
523
  //Make single XML node
524
+ if ( ! empty($value))
525
  $value = trim($value);
526
  if (gettype($value) == 'array')
527
  $value = json_encode($value);
528
+ if ( strpos($value, "<![CDATA[") === false && substr(trim($value), 0, 4) == "http" ) {
529
  $value = "<![CDATA[$value]]>";
530
+ } elseif ( strpos($value, "<![CDATA[") === false && $cdata === true && ! empty($value) ) {
531
  $value = "<![CDATA[$value]]>";
532
+ } elseif ( $cdata ) {
533
+ if ( ! empty($value) ) {
534
  $value = "<![CDATA[$value]]>";
535
  }
536
  }
537
 
538
+ if ( substr($attribute, 0, 23) == 'g:additional_image_link' ) {
539
  $attribute = "g:additional_image_link";
540
  }
541
 
545
 
546
 
547
 
548
+ public function get_xml_feed_header() {
 
549
  $output = '<?xml version="1.0" encoding="UTF-8" ?>
550
  <rss version="2.0" xmlns:g="http://base.google.com/ns/1.0" xmlns:c="http://base.google.com/cns/1.0">
551
  <channel>
555
  return $output;
556
  }
557
 
558
+ public function get_xml_feed( $items ) {
 
559
  $feed = "";
560
  //$feed .= $this->get_feed_header();
561
  $feed .= "\n";
562
+ if ( $items ) {
563
+ foreach ( $items as $item => $products ) {
564
  $feed .= " <" . $this->feedWrapper . ">";
565
 
566
+ foreach ( $products as $key => $value ) {
567
+ if ( ! empty($value) ) {
568
  $feed .= $value;
569
  }
570
  }
577
  return false;
578
  }
579
 
580
+ public function get_xml_feed_footer() {
 
581
  $footer = " </channel>
582
  </rss>";
583
  return $footer;
584
  }
585
 
586
+ public function short_products() {
587
+ if ( $this->products ) {
 
588
  update_option('wpf_progress', "Shorting Products");
589
  sleep(1);
590
  $array = array();
591
  $ij = 0;
592
+ foreach ( $this->products as $key => $item ) {
593
+ $array[ $ij ] = $item;
594
+ unset($this->products[ $key ]);
595
  $ij++;
596
  }
597
  return $this->products = $array;
603
  * Responsible to make CSV feed
604
  * @return string
605
  */
606
+ public function get_csv_feed() {
607
+ if ( $this->products ) {
 
608
  $headers = array_keys($this->products[0]);
609
  $feed[] = $headers;
610
+ foreach ( $this->products as $no => $product ) {
611
  $row = array();
612
+ foreach ( $headers as $key => $header ) {
613
+ if ( strpos($header, "additional image link") !== false ) {
614
  $header = "additional image link";
615
  }
616
+ $row[] = isset($product[ $header ]) ? $product[ $header ] : "";
617
  }
618
  $feed[] = $row;
619
  }
includes/feeds/class-woo-feed-pinterest.php CHANGED
@@ -83,14 +83,13 @@ class Woo_Feed_Pinterest
83
  * @var Woo_Generate_Feed $feedRule Contain Feed Configuration
84
  * @since 1.0.0
85
  */
86
- public function __construct($feedRule)
87
- {
88
- $feedRule['itemWrapper']=$this->feedWrapper;
89
  $this->products = new Woo_Feed_Products_v3($feedRule);
90
 
91
  # When update via cron job then set productIds
92
- if(!isset($feedRule['productIds'])){
93
- $feedRule['productIds']=$this->products->query_products();
94
  }
95
  $this->products->get_products($feedRule['productIds']);
96
  $this->rules = $feedRule;
@@ -115,42 +114,41 @@ class Woo_Feed_Pinterest
115
  * Return Feed
116
  * @return array
117
  */
118
- public function returnFinalProduct()
119
- {
120
- if(!empty($this->products)){
121
 
122
- if ($this->rules['feedType'] == 'xml') {
123
  //return $this->get_feed($this->products);
124
- $feed=array(
125
- "header"=>$this->get_xml_feed_header(),
126
- "body"=>$this->products->feedBody,
127
- "footer"=>$this->get_xml_feed_footer(),
128
  );
129
  return $feed;
130
- } elseif ($this->rules['feedType'] == 'txt') {
131
 
132
- $feed=array(
133
- "body"=>$this->products->feedBody,
134
- "header"=>$this->products->feedHeader,
135
- "footer"=>"",
136
  );
137
  //echo "<pre>";print_r($feed);die();
138
  return $feed;
139
- } elseif ($this->rules['feedType'] == 'csv') {
140
 
141
- $feed=array(
142
- "body"=>$this->products->feedBody,
143
- "header"=>$this->products->feedHeader,
144
- "footer"=>"",
145
  );
146
  return $feed;
147
  }
148
  }
149
 
150
- $feed=array(
151
- "body"=>"",
152
- "header"=>"",
153
- "footer"=>"",
154
  );
155
  return $feed;
156
  }
@@ -158,92 +156,91 @@ class Woo_Feed_Pinterest
158
  /**
159
  * Configure merchant attributes for XML feed
160
  */
161
- public function mapAttributeForXML()
162
- {
163
 
164
  $googleXMLAttribute = array(
165
- "id" => array("g:id", false),
166
- "title" => array("title", true),
167
- "description" => array("description", true),
168
- "link" => array("link", true),
169
- "mobile_link" => array("mobile_link", true),
170
- "product_type" => array("g:product_type", true),
171
- "current_category" => array("g:google_product_category", true),
172
- "image" => array("g:image_link", true),
173
- "images" => array("g:additional_image_link", false),
174
- "images_1" => array("g:additional_image_link_1", true),
175
- "images_2" => array("g:additional_image_link_2", true),
176
- "images_3" => array("g:additional_image_link_3", true),
177
- "images_4" => array("g:additional_image_link_4", true),
178
- "images_5" => array("g:additional_image_link_5", true),
179
- "images_6" => array("g:additional_image_link_6", true),
180
- "images_7" => array("g:additional_image_link_7", true),
181
- "images_8" => array("g:additional_image_link_8", true),
182
- "images_9" => array("g:additional_image_link_9", true),
183
- "images_10" => array("g:additional_image_link_10", true),
184
- "condition" => array("g:condition", false),
185
- "availability" => array("g:availability", false),
186
- "availability_date" => array("g:availability_date", false),
187
- "inventory" => array("g:inventory", false),
188
- "price" => array("g:price", true),
189
- "sale_price" => array("g:sale_price", true),
190
- "sale_price_effective_date" => array("g:sale_price_effective_date", true),
191
- "brand" => array("g:brand", true),
192
- "sku" => array("g:mpn", true),
193
- "upc" => array("g:gtin", true),
194
- "identifier_exists" => array("g:identifier_exists", true),
195
- "item_group_id" => array("g:item_group_id", false),
196
- "color" => array("g:color", true),
197
- "gender" => array("g:gender", true),
198
- "age_group" => array("g:age_group", true),
199
- "material" => array("g:material", true),
200
- "pattern" => array("g:pattern", true),
201
- "size" => array("g:size", true),
202
- "size_type" => array("g:size_type", true),
203
- "size_system" => array("g:size_system", true),
204
- "tax" => array("tax", true),
205
- "tax_country" => array("g:tax_country", true),
206
- "tax_region" => array("g:tax_region", true),
207
- "tax_rate" => array("g:tax_rate", true),
208
- "tax_ship" => array("g:tax_ship", true),
209
- "tax_category" => array("g:tax_category", true),
210
- "weight" => array("g:shipping_weight", false),
211
- "length" => array("g:shipping_length", false),
212
- "width" => array("g:shipping_width", false),
213
- "height" => array("g:shipping_height", false),
214
- "shipping_label" => array("g:shipping_label", false),
215
- "shipping_country" => array("g:shipping_country", false),
216
- "shipping_service" => array("g:shipping_service", false),
217
- "shipping_price" => array("g:shipping_price", false),
218
- "shipping_region" => array("g:shipping_region", false),
219
- "multipack" => array("g:multipack", true),
220
- "is_bundle" => array("g:is_bundle", true),
221
- "adult" => array("g:adult", true),
222
- "adwords_redirect" => array("g:adwords_redirect", true),
223
- "custom_label_0" => array("g:custom_label_0", true),
224
- "custom_label_1" => array("g:custom_label_1", true),
225
- "custom_label_2" => array("g:custom_label_2", true),
226
- "custom_label_3" => array("g:custom_label_3", true),
227
- "custom_label_4" => array("g:custom_label_4", true),
228
- "excluded_destination" => array("g:excluded_destination", true),
229
- "included_destination" => array("g:included_destination", true),
230
- "expiration_date" => array("g:expiration_date", true),
231
- "unit_pricing_measure" => array("g:unit_pricing_measure", true),
232
- "unit_pricing_base_measure" => array("g:unit_pricing_base_measure", true),
233
- "energy_efficiency_class" => array("g:energy_efficiency_class", true),
234
- "loyalty_points" => array("g:loyalty_points", true),
235
- "installment" => array("g:installment", true),
236
- "promotion_id" => array("g:promotion_id", true),
237
- "cost_of_goods_sold" => array("g:cost_of_goods_sold", true),
238
  );
239
 
240
- if ( !empty($this->products) ) {
241
- foreach ($this->products as $no => $product) {
242
  //echo "<pre>";
243
  //print_r($product);die();
244
  $this->identifier_status_add($no);
245
- foreach ($product as $key => $value) {
246
- $this->mapAttribute($no, $key, $googleXMLAttribute[$key][0], $value, $googleXMLAttribute[$key][0]);
247
  }
248
 
249
  $this->process_google_shipping_attribute_for_xml($no);
@@ -255,89 +252,88 @@ class Woo_Feed_Pinterest
255
  /**
256
  * Configure merchant attributes for XML feed
257
  */
258
- public function mapAttributeForCSVTXT()
259
- {
260
  //Basic product information
261
  $googleCSVTXTAttribute = array(
262
- "id" => array("id", false),
263
- "title" => array("title", true),
264
- "description" => array("description", true),
265
- "link" => array("link", true),
266
- "mobile_link" => array("mobile_link", true),
267
- "product_type" => array("product_type", true),
268
- "current_category" => array("google_product_category", true),
269
- "image" => array("image_link", true),
270
- "images" => array("additional_image_link", true),
271
- "images_1" => array("additional_image_link_1", true),
272
- "images_2" => array("additional_image_link_2", true),
273
- "images_3" => array("additional_image_link_3", true),
274
- "images_4" => array("additional_image_link_4", true),
275
- "images_5" => array("additional_image_link_5", true),
276
- "images_6" => array("additional_image_link_6", true),
277
- "images_7" => array("additional_image_link_7", true),
278
- "images_8" => array("additional_image_link_8", true),
279
- "images_9" => array("additional_image_link_9", true),
280
- "images_10" => array("additional_image_link_10", true),
281
- "condition" => array("condition", false),
282
- "availability" => array("availability", false),
283
- "availability_date" => array("availability_date", false),
284
- "inventory" => array("inventory", false),
285
- "price" => array("price", true),
286
- "sale_price" => array("sale_price", true),
287
- "sale_price_effective_date" => array("sale_price_effective_date", true),
288
- "brand" => array("brand", true),
289
- "sku" => array("mpn", true),
290
- "upc" => array("gtin", true),
291
- "identifier_exists" => array("identifier exists", true),
292
- "item_group_id" => array("item_group_id", false),
293
- "color" => array("color", true),
294
- "gender" => array("gender", true),
295
- "age_group" => array("age_group", true),
296
- "material" => array("material", true),
297
- "pattern" => array("pattern", true),
298
- "size" => array("size", true),
299
- "size_type" => array("size_type", true),
300
- "size_system" => array("size_system", true),
301
- "tax" => array("tax", true),
302
- "tax_country" => array("tax_country", true),
303
- "tax_region" => array("tax_region", true),
304
- "tax_rate" => array("tax_rate", true),
305
- "tax_ship" => array("tax_ship", true),
306
- "tax_category" => array("tax_category", true),
307
- "weight" => array("shipping_weight", false),
308
- "length" => array("shipping_length", false),
309
- "width" => array("shipping_width", false),
310
- "height" => array("shipping_height", false),
311
- "shipping_label" => array("shipping_label", false),
312
- "shipping_country" => array("shipping_country", false),
313
- "shipping_service" => array("shipping_service", false),
314
- "shipping_price" => array("shipping_price", false),
315
- "shipping_region" => array("shipping_region", false),
316
- "multipack" => array("multipack", true),
317
- "is_bundle" => array("is_bundle", true),
318
- "adult" => array("adult", true),
319
- "adwords_redirect" => array("adwords_redirect", true),
320
- "custom_label_0" => array("custom_label_0", true),
321
- "custom_label_1" => array("custom_label_1", true),
322
- "custom_label_2" => array("custom_label_2", true),
323
- "custom_label_3" => array("custom_label_3", true),
324
- "custom_label_4" => array("custom_label_4", true),
325
- "excluded_destination" => array("excluded_destination", true),
326
- "included_destination" => array("included_destination", true),
327
- "expiration_date" => array("expiration_date", true),
328
- "unit_pricing_measure" => array("unit_pricing_measure", true),
329
- "unit_pricing_base_measure" => array("unit_pricing_base_measure", true),
330
- "energy_efficiency_class" => array("energy_efficiency_class", true),
331
- "loyalty_points" => array("loyalty_points", true),
332
- "installment" => array("installment", true),
333
- "promotion_id" => array("promotion_id", true),
334
- "cost_of_goods_sold" => array("cost_of_goods_sold", true),
335
  );
336
 
337
- if ( !empty($this->products) ) {
338
- foreach ($this->products as $no => $product) {
339
- foreach ($product as $key => $value) {
340
- $this->mapAttribute($no, $key, $googleCSVTXTAttribute[$key][0], $value, $googleCSVTXTAttribute[$key][0]);
341
  }
342
  $this->process_google_shipping_attribute_for_CSVTXT($no);
343
  $this->process_google_tax_attribute_for_CSVTXT($no);
@@ -354,50 +350,48 @@ class Woo_Feed_Pinterest
354
  * @param bool $cdata
355
  * @return array
356
  */
357
- public function mapAttribute($no, $from, $to, $value, $cdata = false)
358
- {
359
- unset($this->products[$no][$from]);
360
- if($to=='g:color'){
361
- $value=str_replace(",","/",$value);
362
  }
363
- if ($this->rules['feedType'] == 'xml') {
364
- return $this->products[$no][$to] = $this->formatXMLLine($to, $value, $cdata);
365
  } else {
366
- return $this->products[$no][$to] = $value;
367
  }
368
  }
369
 
370
- public function identifier_status_add($no)
371
- {
372
- $identifier = array('brand', 'upc', 'sku', 'mpn', 'gtin');
373
- $product = $this->products[$no];
374
 
375
- if(!array_key_exists('g:identifier_exists',$product)) {
376
- if (count(array_intersect_key(array_flip($identifier), $product)) >= 2) {
377
  # Any 2 required keys exist!
378
- $countIdentifier=0;
379
- if(array_key_exists('brand',$product) && !empty($product['brand'])){
380
  $countIdentifier++;
381
  }
382
- if(array_key_exists('upc',$product) && !empty($product['upc'])){
383
  $countIdentifier++;
384
  }
385
- if(array_key_exists('sku',$product) && !empty($product['sku'])){
386
  $countIdentifier++;
387
  }
388
- if(array_key_exists('mpn',$product) && !empty($product['mpn'])){
389
  $countIdentifier++;
390
  }
391
- if(array_key_exists('gtin',$product) && !empty($product['gtin'])){
392
  $countIdentifier++;
393
  }
394
- if($countIdentifier>=2){
395
- $this->products[$no]["g:identifier_exists"] = $this->formatXMLLine("g:identifier_exists", "yes", $cdata = true);
396
- }else{
397
- $this->products[$no]["g:identifier_exists"] = $this->formatXMLLine("g:identifier_exists", "no", $cdata = true);
398
  }
399
  } else {
400
- $this->products[$no]["g:identifier_exists"] = $this->formatXMLLine("g:identifier_exists", "no", $cdata = true);
401
  }
402
  }
403
  }
@@ -405,45 +399,43 @@ class Woo_Feed_Pinterest
405
 
406
 
407
  public
408
- function process_google_shipping_attribute_for_xml($no)
409
- {
410
- $shipping = array('g:shipping_country', 'g:shipping_service', 'g:shipping_price', 'g:shipping_region');
411
  $shippingAttr = array();
412
- $products = $this->products[$no];
413
- foreach ($products as $keyAttr => $valueAttr) {
414
- if (in_array($keyAttr, $shipping)) {
415
- array_push($shippingAttr, array($keyAttr => $valueAttr));
416
- unset($this->products[$no][$keyAttr]);
417
  }
418
  }
419
- if (count($shippingAttr)) {
420
  $str = "";
421
- foreach ($shippingAttr as $key => $attributes) {
422
- foreach ($attributes as $keyAttr => $valueAttr) {
423
  $str .= str_replace("shipping_", "", $valueAttr);
424
  }
425
  }
426
- return $this->products[$no]['g:shipping'] = $this->formatXMLLine("g:shipping", $str, false);
427
  }
428
  return false;
429
  }
430
 
431
  public
432
- function process_google_tax_attribute_for_xml($no)
433
- {
434
- $tax = array('g:tax_country', 'g:tax_region', 'g:tax_rate', 'g:tax_ship');
435
  $taxAttr = array();
436
- $products = $this->products[$no];
437
- foreach ($products as $keyAttr => $valueAttr) {
438
- if (in_array($keyAttr, $tax)) {
439
- array_push($taxAttr, array($keyAttr => $valueAttr));
440
- unset($this->products[$no][$keyAttr]);
441
  }
442
  }
443
- if (count($taxAttr)) {
444
  $str = "";
445
- foreach ($taxAttr as $key => $attributes) {
446
- foreach ($attributes as $keyAttr => $valueAttr) {
447
  // if($keyAttr != "g:tax_ship")
448
  // {
449
  $str .= str_replace("tax_", "", $valueAttr);
@@ -455,82 +447,79 @@ class Woo_Feed_Pinterest
455
  // }
456
  }
457
  }
458
- return $this->products[$no]['g:tax'] = $this->formatXMLLine("g:tax", $str, false);
459
  }
460
  return false;
461
  }
462
 
463
  public
464
- function process_google_shipping_attribute_for_CSVTXT($no)
465
- {
466
- $shipping = array('shipping country', 'shipping service', 'shipping price', 'shipping region');
467
  $shippingAttr = array();
468
- $products = $this->products[$no];
469
- foreach ($products as $keyAttr => $valueAttr) {
470
- if (in_array($keyAttr, $shipping)) {
471
- array_push($shippingAttr, array($keyAttr => $valueAttr));
472
- unset($this->products[$no][$keyAttr]);
473
  }
474
  }
475
- if (count($shippingAttr)) {
476
  $str = "";
477
- foreach ($shippingAttr as $key => $attributes) {
478
- foreach ($attributes as $keyAttr => $valueAttr) {
479
  $country = ($keyAttr == "shipping country") ? $str .= $valueAttr . ":" : "";
480
  $service = ($keyAttr == "shipping service") ? $str .= $valueAttr . ":" : "";
481
  $price = ($keyAttr == "shipping price") ? $str .= $valueAttr : "";
482
  $region = ($keyAttr == "shipping region") ? $str .= $valueAttr . ":" : "";
483
  }
484
  }
485
- return $this->products[$no]['shipping(country:region:service:price)'] = str_replace(" : ", ":", $str);
486
  }
487
  return false;
488
  }
489
 
490
  public
491
- function process_google_tax_attribute_for_CSVTXT($no)
492
- {
493
- $tax = array('tax country', 'tax region', 'tax rate', 'tax ship');
494
  $taxAttr = array();
495
- $products = $this->products[$no];
496
- foreach ($products as $keyAttr => $valueAttr) {
497
- if (in_array($keyAttr, $tax)) {
498
- array_push($taxAttr, array($keyAttr => $valueAttr));
499
- unset($this->products[$no][$keyAttr]);
500
  }
501
  }
502
- if (count($taxAttr)) {
503
  $str = "";
504
- foreach ($taxAttr as $key => $attributes) {
505
- foreach ($attributes as $keyAttr => $valueAttr) {
506
  $country = ($keyAttr == "tax country") ? $str .= $valueAttr . ":" : "";
507
  $region = ($keyAttr == "tax region") ? $str .= $valueAttr . ":" : "";
508
- $rate = ($keyAttr == "tax rate") ? $str .= $valueAttr . ":": "";
509
  $ship = ($keyAttr == "tax ship") ? $str .= $valueAttr . ":" : "";
510
  }
511
  }
512
- return $this->products[$no]['tax(country:region:rate:tax_ship)'] = str_replace(" : ",":", $str);
513
  }
514
  return false;
515
  }
516
 
517
- function formatXMLLine($attribute, $value, $cdata, $space = "")
518
- {
519
  //Make single XML node
520
- if (!empty($value))
521
  $value = trim($value);
522
  if (gettype($value) == 'array')
523
  $value = json_encode($value);
524
- if (strpos($value, "<![CDATA[") === false && substr(trim($value), 0, 4) == "http") {
525
  $value = "<![CDATA[$value]]>";
526
- } elseif (strpos($value, "<![CDATA[") === false && $cdata === true && !empty($value)) {
527
  $value = "<![CDATA[$value]]>";
528
- } else if ($cdata) {
529
- if(!empty($value)){
530
  $value = "<![CDATA[$value]]>";
531
  }
532
  }
533
- if (substr($attribute, 0, 23) == 'g:additional_image_link') {
534
  $attribute = "g:additional_image_link";
535
  }
536
  return "
@@ -539,8 +528,7 @@ class Woo_Feed_Pinterest
539
 
540
 
541
  public
542
- function get_xml_feed_header()
543
- {
544
  $output = '<?xml version="1.0" encoding="UTF-8" ?>
545
  <rss version="2.0" xmlns:g="http://base.google.com/ns/1.0" xmlns:c="http://base.google.com/cns/1.0">
546
  <channel>
@@ -551,16 +539,15 @@ class Woo_Feed_Pinterest
551
  }
552
 
553
  public
554
- function get_xml_feed($items)
555
- {
556
  $feed = "";
557
  //$feed .= $this->get_feed_header();
558
  $feed .= "\n";
559
- if ($items) {
560
- foreach ($items as $item => $products) {
561
  $feed .= " <" . $this->feedWrapper . ">";
562
- foreach ($products as $key => $value) {
563
- if (!empty($value)){
564
  $feed .= $value;
565
  }
566
  }
@@ -574,24 +561,22 @@ class Woo_Feed_Pinterest
574
  }
575
 
576
  public
577
- function get_xml_feed_footer()
578
- {
579
  $footer = " </channel>
580
  </rss>";
581
  return $footer;
582
  }
583
 
584
  public
585
- function short_products()
586
- {
587
- if ($this->products) {
588
  update_option('wpf_progress', "Shorting Products");
589
  sleep(1);
590
  $array = array();
591
  $ij = 0;
592
- foreach ($this->products as $key => $item) {
593
- $array[$ij] = $item;
594
- unset($this->products[$key]);
595
  $ij++;
596
  }
597
  return $this->products = $array;
@@ -604,18 +589,17 @@ class Woo_Feed_Pinterest
604
  * @return string
605
  */
606
  public
607
- function get_csv_feed()
608
- {
609
- if ($this->products) {
610
  $headers = array_keys($this->products[0]);
611
  $feed[] = $headers;
612
- foreach ($this->products as $no => $product) {
613
  $row = array();
614
- foreach ($headers as $key => $header) {
615
- if (strpos($header, "additional_image_link") !== false) {
616
  $header = "additional_image_link";
617
  }
618
- $row[] = isset($product[$header]) ? $product[$header] : "";;
619
  }
620
  $feed[] = $row;
621
  }
83
  * @var Woo_Generate_Feed $feedRule Contain Feed Configuration
84
  * @since 1.0.0
85
  */
86
+ public function __construct( $feedRule ) {
87
+ $feedRule['itemWrapper'] = $this->feedWrapper;
 
88
  $this->products = new Woo_Feed_Products_v3($feedRule);
89
 
90
  # When update via cron job then set productIds
91
+ if ( ! isset($feedRule['productIds']) ) {
92
+ $feedRule['productIds'] = $this->products->query_products();
93
  }
94
  $this->products->get_products($feedRule['productIds']);
95
  $this->rules = $feedRule;
114
  * Return Feed
115
  * @return array
116
  */
117
+ public function returnFinalProduct() {
118
+ if ( ! empty($this->products) ) {
 
119
 
120
+ if ( $this->rules['feedType'] == 'xml' ) {
121
  //return $this->get_feed($this->products);
122
+ $feed = array(
123
+ "header" => $this->get_xml_feed_header(),
124
+ "body" => $this->products->feedBody,
125
+ "footer" => $this->get_xml_feed_footer(),
126
  );
127
  return $feed;
128
+ } elseif ( $this->rules['feedType'] == 'txt' ) {
129
 
130
+ $feed = array(
131
+ "body" => $this->products->feedBody,
132
+ "header" => $this->products->feedHeader,
133
+ "footer" => "",
134
  );
135
  //echo "<pre>";print_r($feed);die();
136
  return $feed;
137
+ } elseif ( $this->rules['feedType'] == 'csv' ) {
138
 
139
+ $feed = array(
140
+ "body" => $this->products->feedBody,
141
+ "header" => $this->products->feedHeader,
142
+ "footer" => "",
143
  );
144
  return $feed;
145
  }
146
  }
147
 
148
+ $feed = array(
149
+ "body" => "",
150
+ "header" => "",
151
+ "footer" => "",
152
  );
153
  return $feed;
154
  }
156
  /**
157
  * Configure merchant attributes for XML feed
158
  */
159
+ public function mapAttributeForXML() {
 
160
 
161
  $googleXMLAttribute = array(
162
+ "id" => array( "g:id", false ),
163
+ "title" => array( "title", true ),
164
+ "description" => array( "description", true ),
165
+ "link" => array( "link", true ),
166
+ "mobile_link" => array( "mobile_link", true ),
167
+ "product_type" => array( "g:product_type", true ),
168
+ "current_category" => array( "g:google_product_category", true ),
169
+ "image" => array( "g:image_link", true ),
170
+ "images" => array( "g:additional_image_link", false ),
171
+ "images_1" => array( "g:additional_image_link_1", true ),
172
+ "images_2" => array( "g:additional_image_link_2", true ),
173
+ "images_3" => array( "g:additional_image_link_3", true ),
174
+ "images_4" => array( "g:additional_image_link_4", true ),
175
+ "images_5" => array( "g:additional_image_link_5", true ),
176
+ "images_6" => array( "g:additional_image_link_6", true ),
177
+ "images_7" => array( "g:additional_image_link_7", true ),
178
+ "images_8" => array( "g:additional_image_link_8", true ),
179
+ "images_9" => array( "g:additional_image_link_9", true ),
180
+ "images_10" => array( "g:additional_image_link_10", true ),
181
+ "condition" => array( "g:condition", false ),
182
+ "availability" => array( "g:availability", false ),
183
+ "availability_date" => array( "g:availability_date", false ),
184
+ "inventory" => array( "g:inventory", false ),
185
+ "price" => array( "g:price", true ),
186
+ "sale_price" => array( "g:sale_price", true ),
187
+ "sale_price_effective_date" => array( "g:sale_price_effective_date", true ),
188
+ "brand" => array( "g:brand", true ),
189
+ "sku" => array( "g:mpn", true ),
190
+ "upc" => array( "g:gtin", true ),
191
+ "identifier_exists" => array( "g:identifier_exists", true ),
192
+ "item_group_id" => array( "g:item_group_id", false ),
193
+ "color" => array( "g:color", true ),
194
+ "gender" => array( "g:gender", true ),
195
+ "age_group" => array( "g:age_group", true ),
196
+ "material" => array( "g:material", true ),
197
+ "pattern" => array( "g:pattern", true ),
198
+ "size" => array( "g:size", true ),
199
+ "size_type" => array( "g:size_type", true ),
200
+ "size_system" => array( "g:size_system", true ),
201
+ "tax" => array( "tax", true ),
202
+ "tax_country" => array( "g:tax_country", true ),
203
+ "tax_region" => array( "g:tax_region", true ),
204
+ "tax_rate" => array( "g:tax_rate", true ),
205
+ "tax_ship" => array( "g:tax_ship", true ),
206
+ "tax_category" => array( "g:tax_category", true ),
207
+ "weight" => array( "g:shipping_weight", false ),
208
+ "length" => array( "g:shipping_length", false ),
209
+ "width" => array( "g:shipping_width", false ),
210
+ "height" => array( "g:shipping_height", false ),
211
+ "shipping_label" => array( "g:shipping_label", false ),
212
+ "shipping_country" => array( "g:shipping_country", false ),
213
+ "shipping_service" => array( "g:shipping_service", false ),
214
+ "shipping_price" => array( "g:shipping_price", false ),
215
+ "shipping_region" => array( "g:shipping_region", false ),
216
+ "multipack" => array( "g:multipack", true ),
217
+ "is_bundle" => array( "g:is_bundle", true ),
218
+ "adult" => array( "g:adult", true ),
219
+ "adwords_redirect" => array( "g:adwords_redirect", true ),
220
+ "custom_label_0" => array( "g:custom_label_0", true ),
221
+ "custom_label_1" => array( "g:custom_label_1", true ),
222
+ "custom_label_2" => array( "g:custom_label_2", true ),
223
+ "custom_label_3" => array( "g:custom_label_3", true ),
224
+ "custom_label_4" => array( "g:custom_label_4", true ),
225
+ "excluded_destination" => array( "g:excluded_destination", true ),
226
+ "included_destination" => array( "g:included_destination", true ),
227
+ "expiration_date" => array( "g:expiration_date", true ),
228
+ "unit_pricing_measure" => array( "g:unit_pricing_measure", true ),
229
+ "unit_pricing_base_measure" => array( "g:unit_pricing_base_measure", true ),
230
+ "energy_efficiency_class" => array( "g:energy_efficiency_class", true ),
231
+ "loyalty_points" => array( "g:loyalty_points", true ),
232
+ "installment" => array( "g:installment", true ),
233
+ "promotion_id" => array( "g:promotion_id", true ),
234
+ "cost_of_goods_sold" => array( "g:cost_of_goods_sold", true ),
235
  );
236
 
237
+ if ( ! empty($this->products) ) {
238
+ foreach ( $this->products as $no => $product ) {
239
  //echo "<pre>";
240
  //print_r($product);die();
241
  $this->identifier_status_add($no);
242
+ foreach ( $product as $key => $value ) {
243
+ $this->mapAttribute($no, $key, $googleXMLAttribute[ $key ][0], $value, $googleXMLAttribute[ $key ][0]);
244
  }
245
 
246
  $this->process_google_shipping_attribute_for_xml($no);
252
  /**
253
  * Configure merchant attributes for XML feed
254
  */
255
+ public function mapAttributeForCSVTXT() {
 
256
  //Basic product information
257
  $googleCSVTXTAttribute = array(
258
+ "id" => array( "id", false ),
259
+ "title" => array( "title", true ),
260
+ "description" => array( "description", true ),
261
+ "link" => array( "link", true ),
262
+ "mobile_link" => array( "mobile_link", true ),
263
+ "product_type" => array( "product_type", true ),
264
+ "current_category" => array( "google_product_category", true ),
265
+ "image" => array( "image_link", true ),
266
+ "images" => array( "additional_image_link", true ),
267
+ "images_1" => array( "additional_image_link_1", true ),
268
+ "images_2" => array( "additional_image_link_2", true ),
269
+ "images_3" => array( "additional_image_link_3", true ),
270
+ "images_4" => array( "additional_image_link_4", true ),
271
+ "images_5" => array( "additional_image_link_5", true ),
272
+ "images_6" => array( "additional_image_link_6", true ),
273
+ "images_7" => array( "additional_image_link_7", true ),
274
+ "images_8" => array( "additional_image_link_8", true ),
275
+ "images_9" => array( "additional_image_link_9", true ),
276
+ "images_10" => array( "additional_image_link_10", true ),
277
+ "condition" => array( "condition", false ),
278
+ "availability" => array( "availability", false ),
279
+ "availability_date" => array( "availability_date", false ),
280
+ "inventory" => array( "inventory", false ),
281
+ "price" => array( "price", true ),
282
+ "sale_price" => array( "sale_price", true ),
283
+ "sale_price_effective_date" => array( "sale_price_effective_date", true ),
284
+ "brand" => array( "brand", true ),
285
+ "sku" => array( "mpn", true ),
286
+ "upc" => array( "gtin", true ),
287
+ "identifier_exists" => array( "identifier exists", true ),
288
+ "item_group_id" => array( "item_group_id", false ),
289
+ "color" => array( "color", true ),
290
+ "gender" => array( "gender", true ),
291
+ "age_group" => array( "age_group", true ),
292
+ "material" => array( "material", true ),
293
+ "pattern" => array( "pattern", true ),
294
+ "size" => array( "size", true ),
295
+ "size_type" => array( "size_type", true ),
296
+ "size_system" => array( "size_system", true ),
297
+ "tax" => array( "tax", true ),
298
+ "tax_country" => array( "tax_country", true ),
299
+ "tax_region" => array( "tax_region", true ),
300
+ "tax_rate" => array( "tax_rate", true ),
301
+ "tax_ship" => array( "tax_ship", true ),
302
+ "tax_category" => array( "tax_category", true ),
303
+ "weight" => array( "shipping_weight", false ),
304
+ "length" => array( "shipping_length", false ),
305
+ "width" => array( "shipping_width", false ),
306
+ "height" => array( "shipping_height", false ),
307
+ "shipping_label" => array( "shipping_label", false ),
308
+ "shipping_country" => array( "shipping_country", false ),
309
+ "shipping_service" => array( "shipping_service", false ),
310
+ "shipping_price" => array( "shipping_price", false ),
311
+ "shipping_region" => array( "shipping_region", false ),
312
+ "multipack" => array( "multipack", true ),
313
+ "is_bundle" => array( "is_bundle", true ),
314
+ "adult" => array( "adult", true ),
315
+ "adwords_redirect" => array( "adwords_redirect", true ),
316
+ "custom_label_0" => array( "custom_label_0", true ),
317
+ "custom_label_1" => array( "custom_label_1", true ),
318
+ "custom_label_2" => array( "custom_label_2", true ),
319
+ "custom_label_3" => array( "custom_label_3", true ),
320
+ "custom_label_4" => array( "custom_label_4", true ),
321
+ "excluded_destination" => array( "excluded_destination", true ),
322
+ "included_destination" => array( "included_destination", true ),
323
+ "expiration_date" => array( "expiration_date", true ),
324
+ "unit_pricing_measure" => array( "unit_pricing_measure", true ),
325
+ "unit_pricing_base_measure" => array( "unit_pricing_base_measure", true ),
326
+ "energy_efficiency_class" => array( "energy_efficiency_class", true ),
327
+ "loyalty_points" => array( "loyalty_points", true ),
328
+ "installment" => array( "installment", true ),
329
+ "promotion_id" => array( "promotion_id", true ),
330
+ "cost_of_goods_sold" => array( "cost_of_goods_sold", true ),
331
  );
332
 
333
+ if ( ! empty($this->products) ) {
334
+ foreach ( $this->products as $no => $product ) {
335
+ foreach ( $product as $key => $value ) {
336
+ $this->mapAttribute($no, $key, $googleCSVTXTAttribute[ $key ][0], $value, $googleCSVTXTAttribute[ $key ][0]);
337
  }
338
  $this->process_google_shipping_attribute_for_CSVTXT($no);
339
  $this->process_google_tax_attribute_for_CSVTXT($no);
350
  * @param bool $cdata
351
  * @return array
352
  */
353
+ public function mapAttribute( $no, $from, $to, $value, $cdata = false ) {
354
+ unset($this->products[ $no ][ $from ]);
355
+ if ( $to == 'g:color' ) {
356
+ $value = str_replace(",","/",$value);
 
357
  }
358
+ if ( $this->rules['feedType'] == 'xml' ) {
359
+ return $this->products[ $no ][ $to ] = $this->formatXMLLine($to, $value, $cdata);
360
  } else {
361
+ return $this->products[ $no ][ $to ] = $value;
362
  }
363
  }
364
 
365
+ public function identifier_status_add( $no ) {
366
+ $identifier = array( 'brand', 'upc', 'sku', 'mpn', 'gtin' );
367
+ $product = $this->products[ $no ];
 
368
 
369
+ if ( ! array_key_exists('g:identifier_exists',$product) ) {
370
+ if ( count(array_intersect_key(array_flip($identifier), $product)) >= 2 ) {
371
  # Any 2 required keys exist!
372
+ $countIdentifier = 0;
373
+ if ( array_key_exists('brand',$product) && ! empty($product['brand']) ) {
374
  $countIdentifier++;
375
  }
376
+ if ( array_key_exists('upc',$product) && ! empty($product['upc']) ) {
377
  $countIdentifier++;
378
  }
379
+ if ( array_key_exists('sku',$product) && ! empty($product['sku']) ) {
380
  $countIdentifier++;
381
  }
382
+ if ( array_key_exists('mpn',$product) && ! empty($product['mpn']) ) {
383
  $countIdentifier++;
384
  }
385
+ if ( array_key_exists('gtin',$product) && ! empty($product['gtin']) ) {
386
  $countIdentifier++;
387
  }
388
+ if ( $countIdentifier >= 2 ) {
389
+ $this->products[ $no ]["g:identifier_exists"] = $this->formatXMLLine("g:identifier_exists", "yes", $cdata = true);
390
+ }else {
391
+ $this->products[ $no ]["g:identifier_exists"] = $this->formatXMLLine("g:identifier_exists", "no", $cdata = true);
392
  }
393
  } else {
394
+ $this->products[ $no ]["g:identifier_exists"] = $this->formatXMLLine("g:identifier_exists", "no", $cdata = true);
395
  }
396
  }
397
  }
399
 
400
 
401
  public
402
+ function process_google_shipping_attribute_for_xml( $no ) {
403
+ $shipping = array( 'g:shipping_country', 'g:shipping_service', 'g:shipping_price', 'g:shipping_region' );
 
404
  $shippingAttr = array();
405
+ $products = $this->products[ $no ];
406
+ foreach ( $products as $keyAttr => $valueAttr ) {
407
+ if ( in_array($keyAttr, $shipping) ) {
408
+ array_push($shippingAttr, array( $keyAttr => $valueAttr ));
409
+ unset($this->products[ $no ][ $keyAttr ]);
410
  }
411
  }
412
+ if ( count($shippingAttr) ) {
413
  $str = "";
414
+ foreach ( $shippingAttr as $key => $attributes ) {
415
+ foreach ( $attributes as $keyAttr => $valueAttr ) {
416
  $str .= str_replace("shipping_", "", $valueAttr);
417
  }
418
  }
419
+ return $this->products[ $no ]['g:shipping'] = $this->formatXMLLine("g:shipping", $str, false);
420
  }
421
  return false;
422
  }
423
 
424
  public
425
+ function process_google_tax_attribute_for_xml( $no ) {
426
+ $tax = array( 'g:tax_country', 'g:tax_region', 'g:tax_rate', 'g:tax_ship' );
 
427
  $taxAttr = array();
428
+ $products = $this->products[ $no ];
429
+ foreach ( $products as $keyAttr => $valueAttr ) {
430
+ if ( in_array($keyAttr, $tax) ) {
431
+ array_push($taxAttr, array( $keyAttr => $valueAttr ));
432
+ unset($this->products[ $no ][ $keyAttr ]);
433
  }
434
  }
435
+ if ( count($taxAttr) ) {
436
  $str = "";
437
+ foreach ( $taxAttr as $key => $attributes ) {
438
+ foreach ( $attributes as $keyAttr => $valueAttr ) {
439
  // if($keyAttr != "g:tax_ship")
440
  // {
441
  $str .= str_replace("tax_", "", $valueAttr);
447
  // }
448
  }
449
  }
450
+ return $this->products[ $no ]['g:tax'] = $this->formatXMLLine("g:tax", $str, false);
451
  }
452
  return false;
453
  }
454
 
455
  public
456
+ function process_google_shipping_attribute_for_CSVTXT( $no ) {
457
+ $shipping = array( 'shipping country', 'shipping service', 'shipping price', 'shipping region' );
 
458
  $shippingAttr = array();
459
+ $products = $this->products[ $no ];
460
+ foreach ( $products as $keyAttr => $valueAttr ) {
461
+ if ( in_array($keyAttr, $shipping) ) {
462
+ array_push($shippingAttr, array( $keyAttr => $valueAttr ));
463
+ unset($this->products[ $no ][ $keyAttr ]);
464
  }
465
  }
466
+ if ( count($shippingAttr) ) {
467
  $str = "";
468
+ foreach ( $shippingAttr as $key => $attributes ) {
469
+ foreach ( $attributes as $keyAttr => $valueAttr ) {
470
  $country = ($keyAttr == "shipping country") ? $str .= $valueAttr . ":" : "";
471
  $service = ($keyAttr == "shipping service") ? $str .= $valueAttr . ":" : "";
472
  $price = ($keyAttr == "shipping price") ? $str .= $valueAttr : "";
473
  $region = ($keyAttr == "shipping region") ? $str .= $valueAttr . ":" : "";
474
  }
475
  }
476
+ return $this->products[ $no ]['shipping(country:region:service:price)'] = str_replace(" : ", ":", $str);
477
  }
478
  return false;
479
  }
480
 
481
  public
482
+ function process_google_tax_attribute_for_CSVTXT( $no ) {
483
+ $tax = array( 'tax country', 'tax region', 'tax rate', 'tax ship' );
 
484
  $taxAttr = array();
485
+ $products = $this->products[ $no ];
486
+ foreach ( $products as $keyAttr => $valueAttr ) {
487
+ if ( in_array($keyAttr, $tax) ) {
488
+ array_push($taxAttr, array( $keyAttr => $valueAttr ));
489
+ unset($this->products[ $no ][ $keyAttr ]);
490
  }
491
  }
492
+ if ( count($taxAttr) ) {
493
  $str = "";
494
+ foreach ( $taxAttr as $key => $attributes ) {
495
+ foreach ( $attributes as $keyAttr => $valueAttr ) {
496
  $country = ($keyAttr == "tax country") ? $str .= $valueAttr . ":" : "";
497
  $region = ($keyAttr == "tax region") ? $str .= $valueAttr . ":" : "";
498
+ $rate = ($keyAttr == "tax rate") ? $str .= $valueAttr . ":" : "";
499
  $ship = ($keyAttr == "tax ship") ? $str .= $valueAttr . ":" : "";
500
  }
501
  }
502
+ return $this->products[ $no ]['tax(country:region:rate:tax_ship)'] = str_replace(" : ",":", $str);
503
  }
504
  return false;
505
  }
506
 
507
+ function formatXMLLine( $attribute, $value, $cdata, $space = "" ) {
 
508
  //Make single XML node
509
+ if ( ! empty($value))
510
  $value = trim($value);
511
  if (gettype($value) == 'array')
512
  $value = json_encode($value);
513
+ if ( strpos($value, "<![CDATA[") === false && substr(trim($value), 0, 4) == "http" ) {
514
  $value = "<![CDATA[$value]]>";
515
+ } elseif ( strpos($value, "<![CDATA[") === false && $cdata === true && ! empty($value) ) {
516
  $value = "<![CDATA[$value]]>";
517
+ } elseif ( $cdata ) {
518
+ if ( ! empty($value) ) {
519
  $value = "<![CDATA[$value]]>";
520
  }
521
  }
522
+ if ( substr($attribute, 0, 23) == 'g:additional_image_link' ) {
523
  $attribute = "g:additional_image_link";
524
  }
525
  return "
528
 
529
 
530
  public
531
+ function get_xml_feed_header() {
 
532
  $output = '<?xml version="1.0" encoding="UTF-8" ?>
533
  <rss version="2.0" xmlns:g="http://base.google.com/ns/1.0" xmlns:c="http://base.google.com/cns/1.0">
534
  <channel>
539
  }
540
 
541
  public
542
+ function get_xml_feed( $items ) {
 
543
  $feed = "";
544
  //$feed .= $this->get_feed_header();
545
  $feed .= "\n";
546
+ if ( $items ) {
547
+ foreach ( $items as $item => $products ) {
548
  $feed .= " <" . $this->feedWrapper . ">";
549
+ foreach ( $products as $key => $value ) {
550
+ if ( ! empty($value) ) {
551
  $feed .= $value;
552
  }
553
  }
561
  }
562
 
563
  public
564
+ function get_xml_feed_footer() {
 
565
  $footer = " </channel>
566
  </rss>";
567
  return $footer;
568
  }
569
 
570
  public
571
+ function short_products() {
572
+ if ( $this->products ) {
 
573
  update_option('wpf_progress', "Shorting Products");
574
  sleep(1);
575
  $array = array();
576
  $ij = 0;
577
+ foreach ( $this->products as $key => $item ) {
578
+ $array[ $ij ] = $item;
579
+ unset($this->products[ $key ]);
580
  $ij++;
581
  }
582
  return $this->products = $array;
589
  * @return string
590
  */
591
  public
592
+ function get_csv_feed() {
593
+ if ( $this->products ) {
 
594
  $headers = array_keys($this->products[0]);
595
  $feed[] = $headers;
596
+ foreach ( $this->products as $no => $product ) {
597
  $row = array();
598
+ foreach ( $headers as $key => $header ) {
599
+ if ( strpos($header, "additional_image_link") !== false ) {
600
  $header = "additional_image_link";
601
  }
602
+ $row[] = isset($product[ $header ]) ? $product[ $header ] : "";
603
  }
604
  $feed[] = $row;
605
  }
includes/helper.php CHANGED
@@ -8,9 +8,9 @@
8
  * @author KD <mhamudul.hk@gmail.com>
9
  * @copyright WebAppick
10
  */
11
- if( ! defined( 'ABSPATH' ) ) die(); // Silence...
12
 
13
- if( ! function_exists( 'woo_feed_maybe_define_constant' ) ) {
14
  /**
15
  * Define a constant if it is not already defined.
16
  *
@@ -26,7 +26,7 @@ if( ! function_exists( 'woo_feed_maybe_define_constant' ) ) {
26
  }
27
  }
28
  }
29
- if( ! function_exists( 'woo_feed_doing_it_wrong' ) ) {
30
  /**
31
  * Wrapper for _doing_it_wrong.
32
  *
@@ -37,7 +37,7 @@ if( ! function_exists( 'woo_feed_doing_it_wrong' ) ) {
37
  *
38
  * @return void
39
  */
40
- function woo_feed_doing_it_wrong( $function, $message, $version ){
41
  // @codingStandardsIgnoreStart
42
  $message .= ' Backtrace: ' . wp_debug_backtrace_summary();
43
 
@@ -50,7 +50,7 @@ if( ! function_exists( 'woo_feed_doing_it_wrong' ) ) {
50
  // @codingStandardsIgnoreEnd
51
  }
52
  }
53
- if( ! function_exists( 'is_ajax' ) ) {
54
 
55
  /**
56
  * Is_ajax - Returns true when the page is loaded via ajax.
@@ -61,7 +61,7 @@ if( ! function_exists( 'is_ajax' ) ) {
61
  return function_exists( 'wp_doing_ajax' ) ? wp_doing_ajax() : defined( 'DOING_AJAX' );
62
  }
63
  }
64
- if( ! function_exists( 'wooFeed_is_plugin_active' ) ) {
65
  /**
66
  * Determines whether a plugin is active.
67
  * @since 3.1.41
@@ -70,11 +70,11 @@ if( ! function_exists( 'wooFeed_is_plugin_active' ) ) {
70
  * @return bool True, if in the active plugins list. False, not in the list.
71
  */
72
  function wooFeed_is_plugin_active( $plugin ) {
73
- if( !function_exists('is_plugin_active') ) include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
74
  return is_plugin_active( $plugin );
75
  }
76
  }
77
- if( ! function_exists( 'wooFeed_is_plugin_inactive' ) ) {
78
  /**
79
  * Determines whether the plugin is inactive.
80
  * @since 3.1.41
@@ -87,7 +87,7 @@ if( ! function_exists( 'wooFeed_is_plugin_inactive' ) ) {
87
  return ! wooFeed_is_plugin_active( $plugin );
88
  }
89
  }
90
- if( ! function_exists( 'wooFeed_deactivate_plugins' ) ) {
91
  /**
92
  * Deactivate a single plugin or multiple plugins.
93
  * Wrapper for core deactivate_plugins() function
@@ -102,7 +102,7 @@ if( ! function_exists( 'wooFeed_deactivate_plugins' ) ) {
102
  deactivate_plugins( $plugins, $silent, $network_wide );
103
  }
104
  }
105
- if( ! function_exists( 'wooFeed_is_supported_php' ) ) {
106
  /**
107
  * Check if server php version meet minimum requirement
108
  * @since 3.1.41
@@ -113,18 +113,18 @@ if( ! function_exists( 'wooFeed_is_supported_php' ) ) {
113
  return ! version_compare( PHP_VERSION, WOO_FEED_MIN_PHP_VERSION, '<' );
114
  }
115
  }
116
- if( ! function_exists( 'wooFeed_check_WC' ) ) {
117
  function wooFeed_check_WC(){
118
  return class_exists( 'WooCommerce', false );
119
  }
120
  }
121
- if( ! function_exists( 'wooFeed_is_WC_supported' ) ) {
122
  function wooFeed_is_WC_supported() {
123
  // Ensure WC is loaded before checking version
124
  return ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, WOO_FEED_MIN_WC_VERSION, '>=' ) );
125
  }
126
  }
127
- if( ! function_exists( 'woo_feed_wc_version_check' ) ) {
128
  /**
129
  * Check WooCommerce Version
130
  * @param string $version
@@ -135,9 +135,9 @@ if( ! function_exists( 'woo_feed_wc_version_check' ) ) {
135
  require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
  }
137
 
138
- $plugins=get_plugins();
139
- if ( array_key_exists('woocommerce/woocommerce.php',$plugins)) {
140
- $currentVersion=$plugins['woocommerce/woocommerce.php']['Version'];
141
  if ( version_compare( $currentVersion, $version, ">=" ) ) {
142
  return true;
143
  }
@@ -145,7 +145,7 @@ if( ! function_exists( 'woo_feed_wc_version_check' ) ) {
145
  return false;
146
  }
147
  }
148
- if( ! function_exists( 'woo_feed_wpml_version_check' ) ) {
149
  /**
150
  * Check WooCommerce Version
151
  * @param string $version
@@ -161,7 +161,7 @@ if( ! function_exists( 'woo_feed_wpml_version_check' ) ) {
161
  return false;
162
  }
163
  }
164
- if( ! function_exists( 'wooFeed_Admin_Notices' ) ) {
165
  /**
166
  * Display Admin Messages
167
  * @hooked admin_notices
@@ -177,12 +177,12 @@ if( ! function_exists( 'wooFeed_Admin_Notices' ) ) {
177
  $plugin_url = sprintf( '<a href="%s">%s</a>', $plugin_url, esc_html__( 'WooCommerce', 'woocommerce' ) );
178
  $plugin_name = sprintf( '<code>%s</code>', esc_html__( 'WooCommerce Product Feed', 'woo-feed' ) );
179
  $wc_name = sprintf( '<code>%s</code>', esc_html__( 'WooCommerce', 'woocommerce' ) );
180
- $message = sprintf( esc_html__( '%s requires %s to be installed and active. You can installed/activate %s here.', 'woo-feed' ), $plugin_name, $wc_name, $plugin_url );
181
  printf( '<div class="error"><p><strong>%1$s</strong></p></div>', $message );
182
  }
183
- if( wooFeed_check_WC() && ! wooFeed_is_WC_supported() ) {
184
  $plugin_url = self_admin_url( 'plugin-install.php?s=woocommerce&tab=search&type=term' );
185
- $wcVersion = defined( 'WC_VERSION' ) ? '<code>'.WC_VERSION.'</code>' : '<code>UNKNOWN</code>';
186
  $minVersion = '<code>'.WOO_FEED_MIN_WC_VERSION.'</code>';
187
  /** @noinspection HtmlUnknownTarget */
188
  $plugin_url = sprintf( '<a href="%s">%s</a>', $plugin_url, esc_html__( 'WooCommerce', 'woocommerce' ) );
@@ -194,7 +194,7 @@ if( ! function_exists( 'wooFeed_Admin_Notices' ) ) {
194
  }
195
  }
196
  }
197
- if( ! function_exists( 'checkFTP_connection' ) ) {
198
  /**
199
  * Verify if ftp module enabled
200
  * @TODO improve module detection
@@ -204,7 +204,7 @@ if( ! function_exists( 'checkFTP_connection' ) ) {
204
  return ( extension_loaded('ftp' ) || function_exists( 'ftp_connect' ) );
205
  }
206
  }
207
- if( ! function_exists( 'checkSFTP_connection' ) ) {
208
  /**
209
  * Verify if ssh/sftp module enabled
210
  * @TODO improve module detection
@@ -214,7 +214,7 @@ if( ! function_exists( 'checkSFTP_connection' ) ) {
214
  return ( extension_loaded('ssh2' ) || function_exists( 'ssh2_connect' ) );
215
  }
216
  }
217
- if( ! function_exists( 'array_splice_assoc' ) ) {
218
  /**
219
  * Array Splice Associative Array
220
  * @see https://www.php.net/manual/en/function.array-splice.php#111204
@@ -225,14 +225,14 @@ if( ! function_exists( 'array_splice_assoc' ) ) {
225
  *
226
  * @return array
227
  */
228
- function array_splice_assoc( $input, $offset, $length, $replacement) {
229
  $replacement = (array) $replacement;
230
  $key_indices = array_flip(array_keys($input));
231
- if (isset($input[$offset]) && is_string($offset)) {
232
- $offset = $key_indices[$offset];
233
  }
234
- if (isset($input[$length]) && is_string($length)) {
235
- $length = $key_indices[$length] - $offset;
236
  }
237
 
238
  $input = array_slice($input, 0, $offset, TRUE)
@@ -243,7 +243,7 @@ if( ! function_exists( 'array_splice_assoc' ) ) {
243
  }
244
 
245
  // The Editor
246
- if( ! function_exists( 'register_and_do_woo_feed_meta_boxes' ) ) {
247
  /**
248
  * Registers the default Feed Editor MetaBoxes, and runs the `do_meta_boxes` actions.
249
  *
@@ -265,7 +265,7 @@ if( ! function_exists( 'register_and_do_woo_feed_meta_boxes' ) ) {
265
  $screen = convert_to_screen( $screen );
266
  }
267
  // edit page MetaBoxes
268
- if( 'woo-feed_page_webappick-new-feed' === $screen->id || 'toplevel_page_webappick-manage-feeds' === $screen->id ) {
269
  add_meta_box( 'feed_merchant_info', 'Feed Merchant Info', 'woo_feed_merchant_info_metabox', null, 'side', 'default' );
270
  }
271
  /**
@@ -279,33 +279,33 @@ if( ! function_exists( 'register_and_do_woo_feed_meta_boxes' ) ) {
279
  do_action( 'do_meta_boxes', $screen->id, 'side', $feedRules );
280
  }
281
  }
282
- if( ! function_exists( 'woo_feed_ajax_merchant_info' ) ) {
283
  add_action( 'wp_ajax_woo_feed_get_merchant_info', 'woo_feed_ajax_merchant_info' );
284
  function woo_feed_ajax_merchant_info() {
285
- if( isset( $_REQUEST['nonce'] ) && wp_verify_nonce( $_REQUEST['nonce'], 'wpf_feed_nonce' ) ) {
286
  $provider = ( isset( $_REQUEST['provider'] ) && ! empty( $_REQUEST['provider'] ) ) ? sanitize_text_field( $_REQUEST['provider'] ) : '';
287
  $merchantInfo = new Woo_Feed_Merchant();
288
  $data = [];
289
  $na = esc_html__( 'N/A', 'woo-feed' );
290
- foreach( $merchantInfo->getInfo( $provider ) as $k => $v ) {
291
- if( $k == 'link' ) {
292
  /** @noinspection HtmlUnknownTarget */
293
  $data[ $k ] = empty( $v ) ? $na : sprintf( '<a href="%s" target="_blank">%s</a>', esc_url( $v ), esc_html__( 'Read Article', 'woo-feed' ) );
294
- } else if( $k == 'video' ) {
295
  /** @noinspection HtmlUnknownTarget */
296
  $data[ $k ] = empty( $v ) ? $na : sprintf( '<a href="%s" target="_blank">%s</a>', esc_url( $v ), esc_html__( 'Watch Now', 'woo-feed' ) );
297
- } else if( $k == 'feed_file_type' ) {
298
- if( ! empty( $v ) ) {
299
  $v = array_map( function( $type ) {
300
  return strtoupper( $type );
301
  }, (array) $v );
302
- $data[$k] = esc_html( implode( ', ', $v ) );
303
  } else {
304
- $data[$k] = $na;
305
  }
306
- } else if( $k == 'doc' ) {
307
  $links = '';
308
- foreach( $v as $label => $link ) {
309
  /** @noinspection HtmlUnknownTarget */
310
  $links .= sprintf( '<li><a href="%s" target="_blank">%s</a></li>', esc_url( $link ), esc_html( $label ) );
311
  }
@@ -319,7 +319,7 @@ if( ! function_exists( 'woo_feed_ajax_merchant_info' ) ) {
319
  die();
320
  }
321
  }
322
- if( ! function_exists( 'woo_feed_merchant_info_metabox' ) ) {
323
  /**
324
  * Render Merchant Info Metabox
325
  * @param array $feedConfig
@@ -331,36 +331,36 @@ if( ! function_exists( 'woo_feed_merchant_info_metabox' ) ) {
331
  ?>
332
  <span class="spinner"></span>
333
  <div class="merchant-infos">
334
- <?php foreach( $merchantInfo->getInfo( $provider ) as $k => $v ) { ?>
335
  <div class="merchant-info-section <?php echo esc_attr( $k ); ?>">
336
- <?php if( $k == 'link' ) { ?>
337
  <span class="dashicons dashicons-media-document" style="color: #82878c;" aria-hidden="true"></span>
338
  <span><?php esc_html_e( 'Feed Specification:', 'woo-feed' ) ?></span>
339
  <strong class="data"><?php
340
  /** @noinspection HtmlUnknownTarget */
341
  ( empty( $v ) ) ? esc_html_e( 'N/A', 'woo-feed' ) : printf( '<a href="%s" target="_blank">%s</a>', esc_url( $v ), esc_html__( 'Read Article', 'woo-feed' ) );
342
  ?></strong>
343
- <?php } else if( $k == 'video' ) { ?>
344
  <span class="dashicons dashicons-video-alt3" style="color: #82878c;" aria-hidden="true"></span>
345
  <span><?php esc_html_e( 'Video Documentation:', 'woo-feed' ) ?></span>
346
  <strong class="data"><?php
347
  /** @noinspection HtmlUnknownTarget */
348
  ( empty( $v ) ) ? esc_html_e( 'N/A', 'woo-feed' ) : printf( '<a href="%s" target="_blank">%s</a>', esc_url( $v ), esc_html__( 'Watch now', 'woo-feed' ) );
349
  ?></strong>
350
- <?php } else if( $k == 'feed_file_type' ) { ?>
351
  <span class="dashicons dashicons-media-text" style="color: #82878c;" aria-hidden="true"></span> <?php esc_html_e( 'Format Supported:', 'woo-feed' ) ?>
352
  <strong class="data"><?php echo ( empty( $v ) ) ? esc_html__( 'N/A', 'woo-feed' ) : esc_html( implode( ', ', array_map( function( $type ) {
353
  return strtoupper( $type );
354
  }, (array) $v ) ) ); ?></strong>
355
  <?php
356
- } else if( $k == 'doc' ) { ?>
357
  <span class="dashicons dashicons-editor-help" style="color: #82878c;" aria-hidden="true"></span>
358
  <span><?php esc_html_e( 'Support Docs:', 'woo-feed' ); ?></span>
359
  <ul class="data">
360
  <?php
361
- if( empty( $v ) ) esc_html_e( 'N/A', 'woo-feed' );
362
  else {
363
- foreach( $v as $label => $link ) {
364
  /** @noinspection HtmlUnknownTarget */
365
  printf( '<li><a href="%s" target="_blank">%s</a></li>', esc_url( $link ), esc_html( $label ) );
366
  }
@@ -377,7 +377,7 @@ if( ! function_exists( 'woo_feed_merchant_info_metabox' ) ) {
377
  }
378
 
379
  // Sanitization
380
- if( ! function_exists( 'woo_feed_check_google_category' ) ) {
381
  /**
382
  * @param array $feedInfo
383
  *
@@ -388,23 +388,23 @@ if( ! function_exists( 'woo_feed_check_google_category' ) ) {
388
  $checkCategory = isset( $feedInfo['feedrules']['mattributes'] ) ? $feedInfo['feedrules']['mattributes'] : [];
389
  $checkCategoryType = isset( $feedInfo['feedrules']['type'] ) ? $feedInfo['feedrules']['type'] : [];
390
  $merchant = isset( $feedInfo['feedrules']['provider'] ) ? $feedInfo['feedrules']['provider'] : [];
391
- $cat="yes";
392
- if(in_array($merchant,array('google','facebook' ) ) && in_array("current_category",$checkCategory)){
393
- $catKey=array_search('current_category',$checkCategory);
394
- if($checkCategoryType[$catKey]=="pattern"){
395
- $checkCategoryValue=$feedInfo['feedrules']['default'];
396
- }else{
397
- $checkCategoryValue=$feedInfo['feedrules']['attributes'];
398
  }
399
 
400
- if(empty($checkCategoryValue[$catKey])){
401
- $cat="no";
402
  }
403
  }
404
  return $cat;
405
  }
406
  }
407
- if( ! function_exists( 'woo_feed_array_sanitize' ) ) {
408
  /**
409
  * Sanitize array post
410
  *
@@ -420,41 +420,41 @@ if( ! function_exists( 'woo_feed_array_sanitize' ) ) {
420
  foreach ( $value as $key2 => $value2 ) {
421
  if ( is_array( $value2 ) ) {
422
  foreach ( $value2 as $key3 => $value3 ) {
423
- $newArray[$key][$key2][$key3] = sanitize_text_field( $value3 );
424
  }
425
  } else {
426
- $newArray[$key][$key2] = sanitize_text_field( $value2 );
427
  }
428
  }
429
  } else {
430
- $newArray[$key] = sanitize_text_field( $value );
431
  }
432
  }
433
  }
434
  return $newArray;
435
  }
436
  }
437
- if( ! function_exists( 'woo_feed_sanitize_form_fields' ) ) {
438
  /**
439
  * Sanitize Form Fields ($_POST Array)
440
  * @param array $data
441
  * @return array
442
  */
443
  function woo_feed_sanitize_form_fields( $data ) {
444
- foreach( $data as $k => $v ) {
445
- if( true === apply_filters( 'woo_feed_sanitize_form_fields', true, $k, $v, $data ) ) {
446
- if( is_array( $v ) ) {
447
  $v = woo_feed_sanitize_form_fields( $v );
448
  } else {
449
  //$v = sanitize_text_field( $v ); #TODO should not trim Prefix and Suffix field
450
  }
451
  }
452
- $data[$k] = apply_filters( 'woo_feed_sanitize_form_field', $v, $k );
453
  }
454
  return $data;
455
  }
456
  }
457
- if( ! function_exists( 'woo_feed_unique_feed_slug' ) ) {
458
  /**
459
  * Generate Unique slug for feed.
460
  * @see wp_unique_post_slug()
@@ -467,18 +467,18 @@ if( ! function_exists( 'woo_feed_unique_feed_slug' ) ) {
467
  global $wpdb;
468
  /** @noinspection SpellCheckingInspection */
469
  $disallowed = array( 'siteurl', 'home', 'blogname', 'blogdescription', 'users_can_register', 'admin_email' );
470
- if( $feedId && $feedId > 0 ) {
471
  $checkSql = "SELECT option_name FROM $wpdb->options WHERE option_name = %s AND option_id != %d LIMIT 1";
472
  $nameCheck = $wpdb->get_var( $wpdb->prepare( $checkSql, $prefix . $slug, $feedId ) );
473
  } else {
474
  $checkSql = "SELECT option_name FROM $wpdb->options WHERE option_name = %s LIMIT 1";
475
  $nameCheck = $wpdb->get_var( $wpdb->prepare( $checkSql, $prefix . $slug ) );
476
  }
477
- if( $nameCheck || in_array( $slug, $disallowed ) ) {
478
  $suffix = 2;
479
  do {
480
  $altName = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
481
- if( $feedId && $feedId > 0 ) {
482
  $nameCheck = $wpdb->get_var( $wpdb->prepare( $checkSql, $prefix . $altName, $feedId ) );
483
  } else {
484
  $nameCheck = $wpdb->get_var( $wpdb->prepare( $checkSql, $prefix . $altName ) );
@@ -490,7 +490,7 @@ if( ! function_exists( 'woo_feed_unique_feed_slug' ) ) {
490
  return $slug;
491
  }
492
  }
493
- if( ! function_exists( 'generate_unique_feed_file_name' ) ) {
494
  function generate_unique_feed_file_name( $filename, $type, $provider ) {
495
 
496
  $feedDir = woo_feed_get_file_dir( $provider, $type );
@@ -505,7 +505,7 @@ if( ! function_exists( 'generate_unique_feed_file_name' ) ) {
505
  }
506
 
507
  // File process
508
- if( ! function_exists( 'woo_feed_save_feed_config_data' ) ) {
509
  /**
510
  * Sanitize And Save Feed config data (array) to db (option table)
511
  * @param array $data data to be saved in db
@@ -515,16 +515,16 @@ if( ! function_exists( 'woo_feed_save_feed_config_data' ) ) {
515
  * @return bool|string return false if failed to update. return filename if success
516
  */
517
  function woo_feed_save_feed_config_data( $data, $fileName = null, $configOnly = true ) {
518
- if( ! is_array( $data ) ) return false;
519
- if( ! isset( $data['filename'], $data['feedType'], $data['provider'], $data['mattributes'] ) ) return false;
520
  // unnecessary form fields to remove
521
  $removables = [ 'closedpostboxesnonce', '_wpnonce', '_wp_http_referer', 'save_feed_config', 'edit-feed' ];
522
  foreach ( $removables as $removable ) {
523
- if( isset( $data[$removable] ) ) unset( $data[$removable] );
524
  }
525
  // Sanitize Fields
526
  $data = woo_feed_sanitize_form_fields( $data );
527
- if( empty( $fileName ) ) {
528
  $fileName = generate_unique_feed_file_name( $data['filename'], $data['feedType'], $data['provider'] );
529
  } else {
530
  $fileName = str_replace( [ 'wf_feed_', 'wf_config' ], '', $fileName );
@@ -539,13 +539,13 @@ if( ! function_exists( 'woo_feed_save_feed_config_data' ) ) {
539
  # Store Config
540
  $update = update_option( "wf_config" . $fileName, $data, false );
541
  // save if config update ok...
542
- if( $update && $configOnly === false ) {
543
  $oldFeed = maybe_unserialize( get_option( "wf_feed_" . $fileName ) );
544
  $feedData = array(
545
- 'feedrules' => $data,
546
- 'url' => woo_feed_get_file_url( $fileName, $data['provider'], $data['feedType'] ),
547
  'last_updated' => date("Y-m-d H:i:s"),
548
- 'status' => isset( $oldFeed['status'] ) ? $oldFeed['status'] : 1,
549
  );
550
  $update = update_option( 'wf_feed_' . $fileName, maybe_serialize( $feedData ), false );
551
  }
@@ -553,7 +553,7 @@ if( ! function_exists( 'woo_feed_save_feed_config_data' ) ) {
553
  return $update ? $fileName : $update;
554
  }
555
  }
556
- if( ! function_exists( 'woo_feed_get_file_url' ) ) {
557
  /**
558
  * Get Feed File URL
559
  * @param string $fileName
@@ -567,7 +567,7 @@ if( ! function_exists( 'woo_feed_get_file_url' ) ) {
567
  return esc_url( sprintf( '%s/woo-feed/%s/%s/%s.%s', $upload_dir['baseurl'], $provider, $type, $fileName, $type ) );
568
  }
569
  }
570
- if( ! function_exists( 'woo_feed_check_feed_file' ) ) {
571
  /**
572
  * Check if feed file exists
573
  * @param string $fileName
@@ -581,7 +581,7 @@ if( ! function_exists( 'woo_feed_check_feed_file' ) ) {
581
  return file_exists( sprintf( '%s/woo-feed/%s/%s/%s.%s', $upload_dir['basedir'], $provider, $type, $fileName, $type ) );
582
  }
583
  }
584
- if( ! function_exists( 'woo_feed_get_file_dir' ) ) {
585
  /**
586
  * Get Feed Directory
587
  * @param string $provider
@@ -594,7 +594,7 @@ if( ! function_exists( 'woo_feed_get_file_dir' ) ) {
594
  return $base . "/woo-feed/" . $provider . "/" . $feedType;
595
  }
596
  }
597
- if( ! function_exists( 'woo_feed_save_batch_feed_info' ) ) {
598
  /**
599
  * Save Feed Batch Chunk
600
  * @param string $feedService
@@ -630,7 +630,7 @@ if( ! function_exists( 'woo_feed_save_batch_feed_info' ) ) {
630
  return $status;
631
  }
632
  }
633
- if( ! function_exists( 'woo_feed_get_batch_feed_info' ) ) {
634
  /**
635
  * @param string $feedService
636
  * @param string $type
@@ -642,28 +642,28 @@ if( ! function_exists( 'woo_feed_get_batch_feed_info' ) ) {
642
  $upload_dir = wp_upload_dir();
643
  $base = $upload_dir['basedir'];
644
  $ext = $type;
645
- if( $type == "csv" ) $ext="json";
646
  # Save File
647
  $path = $base . "/woo-feed/" . $feedService . "/" . $type;
648
  $file = $path . "/" . $fileName . "." . $ext;
649
  if ( $type == "csv" && file_exists( $file ) ) {
650
- return (file_get_contents($file))?json_decode(file_get_contents($file),true):false;
651
- }else if( file_exists( $file ) ) {
652
  return file_get_contents($file);
653
  }
654
  return false;
655
  }
656
  }
657
- if( ! function_exists( 'woo_feed_unlink_tempFiles' ) ) {
658
  /**
659
  * Remove temporary feed files
660
  * @param array $files
661
  * @return bool
662
  */
663
  function woo_feed_unlink_tempFiles( $files ) {
664
- if( ! empty( $files ) ){
665
- foreach ($files as $key => $file ) {
666
- if( file_exists( $file ) ) {
667
  @unlink($file);
668
  }
669
  }
@@ -674,7 +674,7 @@ if( ! function_exists( 'woo_feed_unlink_tempFiles' ) ) {
674
  }
675
 
676
  // Mics..
677
- if( ! function_exists( 'woo_feed_remove_query_args' ) ) {
678
  /**
679
  * Add more items to the removable query args array...
680
  * @param array $removable_query_args
@@ -682,7 +682,7 @@ if( ! function_exists( 'woo_feed_remove_query_args' ) ) {
682
  * @return array
683
  */
684
  function woo_feed_remove_query_args( $removable_query_args ) {
685
- if( isset( $_GET['page'] ) && 'webappick-manage-feeds' == $_GET['page'] ) {
686
  $removable_query_args[] = 'feed_created';
687
  $removable_query_args[] = 'feed_updated';
688
  $removable_query_args[] = 'feed_regenerate';
@@ -700,7 +700,7 @@ if( ! function_exists( 'woo_feed_remove_query_args' ) ) {
700
  }
701
 
702
  // Feed Functions
703
- if( ! function_exists( 'woo_feed_get_field_output_type_options' ) ) {
704
  function woo_feed_get_field_output_type_options() {
705
  return apply_filters( 'woo_feed_field_output_options', [
706
  1 => esc_html__( 'Default', 'woo-feed' ),
@@ -716,38 +716,38 @@ if( ! function_exists( 'woo_feed_get_field_output_type_options' ) ) {
716
  ] );
717
  }
718
  }
719
- if( ! function_exists( 'woo_feed_get_schedule_interval_options' ) ) {
720
  function woo_feed_get_schedule_interval_options(){
721
  return apply_filters( 'woo_feed_schedule_interval_options', [
722
- WEEK_IN_SECONDS => esc_html__( '1 Week', 'woo-feed' ),
723
- DAY_IN_SECONDS => esc_html__( '24 Hours', 'woo-feed' ),
724
- 12 * HOUR_IN_SECONDS => esc_html__( '12 Hours', 'woo-feed' ),
725
- 6 * HOUR_IN_SECONDS => esc_html__( '6 Hours', 'woo-feed' ),
726
- HOUR_IN_SECONDS => esc_html__( '1 Hours', 'woo-feed' ),
727
- 15 * MINUTE_IN_SECONDS => esc_html__( '15 Minutes', 'woo-feed' ),
728
  ] );
729
  }
730
  }
731
- if( ! function_exists( 'woo_feed_get_minimum_interval_option' ) ) {
732
  function woo_feed_get_minimum_interval_option(){
733
  $intervals = array_keys( woo_feed_get_schedule_interval_options() );
734
- if( ! empty( $intervals ) ) return end( $intervals );
735
- return 15* MINUTE_IN_SECONDS;
736
  }
737
  }
738
- if( ! function_exists('woo_feed_stripInvalidXml' ) ) {
739
  /**
740
  * Remove non supported xml character
741
  * @param string $value
742
  * @return string
743
  */
744
- function woo_feed_stripInvalidXml($value) {
745
  $ret = "";
746
  if (empty($value)) return $ret;
747
  $length = strlen($value);
748
- for ($i = 0; $i < $length; $i++) {
749
- $current = ord($value{$i});
750
- if (($current == 0x9) || ($current == 0xA) || ($current == 0xD) || (($current >= 0x20) && ($current <= 0xD7FF)) || (($current >= 0xE000) && ($current <= 0xFFFD)) || (($current >= 0x10000) && ($current <= 0x10FFFF))) {
751
  $ret .= chr($current);
752
  } else {
753
  $ret .= "";
@@ -756,17 +756,16 @@ if( ! function_exists('woo_feed_stripInvalidXml' ) ) {
756
  return $ret;
757
  }
758
  }
759
- if( ! function_exists('woo_feed_get_formatted_url' ) ) {
760
  /**
761
  * Get Formatted URL
762
  * @param string $url
763
  *
764
  * @return string
765
  */
766
- function woo_feed_get_formatted_url($url = "")
767
- {
768
- if( ! empty($url)) {
769
- if (substr(trim($url), 0, 4) === "http" || substr(trim($url), 0, 3) === "ftp" || substr(trim($url), 0, 4) === "sftp") {
770
  return rtrim($url, "/");
771
  } else {
772
  $base = get_site_url();
@@ -777,48 +776,46 @@ if( ! function_exists('woo_feed_get_formatted_url' ) ) {
777
  return "";
778
  }
779
  }
780
- if( ! function_exists('array_value_first' ) ) {
781
  /**
782
  * Get First Value of an array
783
  * @since 3.0.0
784
  * @param array $arr
785
  * @return mixed|null
786
  */
787
- function array_value_first(array $arr)
788
- {
789
- foreach ($arr as $key => $unused) {
790
  return $unused;
791
  }
792
  return NULL;
793
  }
794
  }
795
- if( ! function_exists('woo_feed_make_url_with_parameter' ) ) {
796
  /**
797
  * Make proper URL using parameters
798
  * @param string $output
799
  * @param string $suffix
800
  * @return string
801
  */
802
- function woo_feed_make_url_with_parameter($output = '', $suffix = '')
803
- {
804
- if(empty($output) || empty($suffix)){
805
  return $output;
806
  }
807
 
808
  $getParam = explode('?', $output);
809
  $URLParam = array();
810
- if (isset($getParam[1])) {
811
  $URLParam = woo_feed_parse_string($getParam[1]);
812
  }
813
 
814
  $EXTRAParam = array();
815
- if( ! empty($suffix)) {
816
  $suffix = str_replace("?", "", $suffix);
817
  $EXTRAParam = woo_feed_parse_string($suffix);
818
  }
819
 
820
  $params = array_merge($URLParam, $EXTRAParam);
821
- if( ! empty($params) && $output != "") {
822
  $params = http_build_query($params);
823
  $baseURL = isset($getParam) ? $getParam[0] : $output;
824
  $output = $baseURL . "?" . $params;
@@ -827,55 +824,54 @@ if( ! function_exists('woo_feed_make_url_with_parameter' ) ) {
827
  return $output;
828
  }
829
  }
830
- if( ! function_exists('woo_feed_parse_string' ) ) {
831
  /**
832
  * Parse URL parameter
833
  * @param string $str
834
  * @return array
835
  */
836
- function woo_feed_parse_string($str = "")
837
- {
838
 
839
  # result array
840
  $arr = array();
841
 
842
- if (empty($str)) {
843
  return $arr;
844
  }
845
 
846
  # split on outer delimiter
847
  $pairs = explode('&', $str);
848
 
849
- if( ! empty($pairs)) {
850
 
851
  # loop through each pair
852
- foreach ($pairs as $i) {
853
  # split into name and value
854
  list($name, $value) = explode('=', $i, 2);
855
 
856
  # if name already exists
857
- if (isset($arr[$name])) {
858
  # stick multiple values into an array
859
- if (is_array($arr[$name])) {
860
- $arr[$name][] = $value;
861
  } else {
862
- $arr[$name] = array($arr[$name], $value);
863
  }
864
  } # otherwise, simply stick it in a scalar
865
  else {
866
- $arr[$name] = $value;
867
  }
868
  }
869
- } elseif( ! empty($str)) {
870
  list($name, $value) = explode('=', $str, 2);
871
- $arr[$name] = $value;
872
  }
873
 
874
  # return result array
875
  return $arr;
876
  }
877
  }
878
- if( ! function_exists('woo_feed_replace_to_merchant_attribute' ) ) {
879
  /**
880
  * Parse URL parameter
881
  * @param string $pluginAttribute
@@ -883,32 +879,31 @@ if( ! function_exists('woo_feed_replace_to_merchant_attribute' ) ) {
883
  * @param string feedType CSV XML TXT
884
  * @return string
885
  */
886
- function woo_feed_replace_to_merchant_attribute($pluginAttribute,$merchant,$feedType)
887
- {
888
- $attributeClass=new Woo_Feed_Default_Attributes();
889
- $merchantAttributes="";
890
- if($merchant=="google" && $feedType=='xml'){
891
- $merchantAttributes=$attributeClass->googleXMLAttribute;
892
- }elseif ($merchant=="google" && ($feedType=='csv' || $feedType=='txt' ) ){
893
- $merchantAttributes=$attributeClass->googleCSVTXTAttribute;
894
- }elseif ($merchant=="facebook" && $feedType=='xml'){
895
- $merchantAttributes=$attributeClass->facebookXMLAttribute;
896
- }elseif ($merchant=="facebook" && ($feedType=='csv' || $feedType=='txt' ) ){
897
- $merchantAttributes=$attributeClass->facebookCSVTXTAttribute;
898
- }elseif ($merchant=="pinterest" && $feedType=='xml'){
899
- $merchantAttributes=$attributeClass->pinterestXMLAttribute;
900
- }elseif ($merchant=="pinterest" && ($feedType=='csv' || $feedType=='txt' ) ){
901
- $merchantAttributes=$attributeClass->pinterestCSVTXTAttribute;
902
  }
903
 
904
- if(!empty($merchantAttributes) && array_key_exists($pluginAttribute,$merchantAttributes)){
905
- return $merchantAttributes[$pluginAttribute][0];
906
  }
907
 
908
  return $pluginAttribute;
909
  }
910
  }
911
- if( ! function_exists('woo_feed_add_cdata' ) ) {
912
  /**
913
  * Parse URL parameter
914
  * @param string $pluginAttribute
@@ -916,33 +911,31 @@ if( ! function_exists('woo_feed_add_cdata' ) ) {
916
  * @param string $merchant
917
  * @return string
918
  */
919
- function woo_feed_add_cdata($pluginAttribute,$attributeValue,$merchant)
920
- {
921
- if (strpos($attributeValue, "<![CDATA[") !== false){
922
  return "$attributeValue";
923
  }
924
 
925
- $attributeClass=new Woo_Feed_Default_Attributes();
926
- $merchantAttributes="";
927
- if($merchant=="google"){
928
- $merchantAttributes=$attributeClass->googleXMLAttribute;
929
- }elseif ($merchant=="facebook"){
930
- $merchantAttributes=$attributeClass->facebookXMLAttribute;
931
- }elseif ($merchant=="pinterest"){
932
- $merchantAttributes=$attributeClass->pinterestXMLAttribute;
933
  }
934
 
935
- if(!empty($merchantAttributes) && array_key_exists($pluginAttribute,$merchantAttributes)){
936
- if($merchantAttributes[$pluginAttribute][1]=='true'){
937
  return "<![CDATA[$attributeValue]]>";
938
- }else{
939
  return "$attributeValue";
940
  }
941
- }elseif (strpos($attributeValue, "&") !== false ||
942
- substr(trim($attributeValue), 0, 4) == "http")
943
- {
944
  return "<![CDATA[$attributeValue]]>";
945
- }else{
946
  return "$attributeValue";
947
  }
948
  }
@@ -1026,7 +1019,7 @@ if ( ! function_exists( 'woo_feed_log' ) ) {
1026
  'warning',
1027
  'notice',
1028
  'info',
1029
- 'debug'
1030
  ] ) ) {
1031
  return;
1032
  }
8
  * @author KD <mhamudul.hk@gmail.com>
9
  * @copyright WebAppick
10
  */
11
+ if ( ! defined( 'ABSPATH' ) ) die(); // Silence...
12
 
13
+ if ( ! function_exists( 'woo_feed_maybe_define_constant' ) ) {
14
  /**
15
  * Define a constant if it is not already defined.
16
  *
26
  }
27
  }
28
  }
29
+ if ( ! function_exists( 'woo_feed_doing_it_wrong' ) ) {
30
  /**
31
  * Wrapper for _doing_it_wrong.
32
  *
37
  *
38
  * @return void
39
  */
40
+ function woo_feed_doing_it_wrong( $function, $message, $version ) {
41
  // @codingStandardsIgnoreStart
42
  $message .= ' Backtrace: ' . wp_debug_backtrace_summary();
43
 
50
  // @codingStandardsIgnoreEnd
51
  }
52
  }
53
+ if ( ! function_exists( 'is_ajax' ) ) {
54
 
55
  /**
56
  * Is_ajax - Returns true when the page is loaded via ajax.
61
  return function_exists( 'wp_doing_ajax' ) ? wp_doing_ajax() : defined( 'DOING_AJAX' );
62
  }
63
  }
64
+ if ( ! function_exists( 'wooFeed_is_plugin_active' ) ) {
65
  /**
66
  * Determines whether a plugin is active.
67
  * @since 3.1.41
70
  * @return bool True, if in the active plugins list. False, not in the list.
71
  */
72
  function wooFeed_is_plugin_active( $plugin ) {
73
+ if ( ! function_exists('is_plugin_active') ) include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
74
  return is_plugin_active( $plugin );
75
  }
76
  }
77
+ if ( ! function_exists( 'wooFeed_is_plugin_inactive' ) ) {
78
  /**
79
  * Determines whether the plugin is inactive.
80
  * @since 3.1.41
87
  return ! wooFeed_is_plugin_active( $plugin );
88
  }
89
  }
90
+ if ( ! function_exists( 'wooFeed_deactivate_plugins' ) ) {
91
  /**
92
  * Deactivate a single plugin or multiple plugins.
93
  * Wrapper for core deactivate_plugins() function
102
  deactivate_plugins( $plugins, $silent, $network_wide );
103
  }
104
  }
105
+ if ( ! function_exists( 'wooFeed_is_supported_php' ) ) {
106
  /**
107
  * Check if server php version meet minimum requirement
108
  * @since 3.1.41
113
  return ! version_compare( PHP_VERSION, WOO_FEED_MIN_PHP_VERSION, '<' );
114
  }
115
  }
116
+ if ( ! function_exists( 'wooFeed_check_WC' ) ) {
117
  function wooFeed_check_WC(){
118
  return class_exists( 'WooCommerce', false );
119
  }
120
  }
121
+ if ( ! function_exists( 'wooFeed_is_WC_supported' ) ) {
122
  function wooFeed_is_WC_supported() {
123
  // Ensure WC is loaded before checking version
124
  return ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, WOO_FEED_MIN_WC_VERSION, '>=' ) );
125
  }
126
  }
127
+ if ( ! function_exists( 'woo_feed_wc_version_check' ) ) {
128
  /**
129
  * Check WooCommerce Version
130
  * @param string $version
135
  require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
  }
137
 
138
+ $plugins = get_plugins();
139
+ if ( array_key_exists('woocommerce/woocommerce.php',$plugins) ) {
140
+ $currentVersion = $plugins['woocommerce/woocommerce.php']['Version'];
141
  if ( version_compare( $currentVersion, $version, ">=" ) ) {
142
  return true;
143
  }
145
  return false;
146
  }
147
  }
148
+ if ( ! function_exists( 'woo_feed_wpml_version_check' ) ) {
149
  /**
150
  * Check WooCommerce Version
151
  * @param string $version
161
  return false;
162
  }
163
  }
164
+ if ( ! function_exists( 'wooFeed_Admin_Notices' ) ) {
165
  /**
166
  * Display Admin Messages
167
  * @hooked admin_notices
177
  $plugin_url = sprintf( '<a href="%s">%s</a>', $plugin_url, esc_html__( 'WooCommerce', 'woocommerce' ) );
178
  $plugin_name = sprintf( '<code>%s</code>', esc_html__( 'WooCommerce Product Feed', 'woo-feed' ) );
179
  $wc_name = sprintf( '<code>%s</code>', esc_html__( 'WooCommerce', 'woocommerce' ) );
180
+ $message = sprintf( esc_html__( '%1$s requires %2$s to be installed and active. You can installed/activate %3$s here.', 'woo-feed' ), $plugin_name, $wc_name, $plugin_url );
181
  printf( '<div class="error"><p><strong>%1$s</strong></p></div>', $message );
182
  }
183
+ if ( wooFeed_check_WC() && ! wooFeed_is_WC_supported() ) {
184
  $plugin_url = self_admin_url( 'plugin-install.php?s=woocommerce&tab=search&type=term' );
185
+ $wcVersion = defined( 'WC_VERSION' ) ? '<code>'.WC_VERSION.'</code>' : '<code>UNKNOWN</code>';
186
  $minVersion = '<code>'.WOO_FEED_MIN_WC_VERSION.'</code>';
187
  /** @noinspection HtmlUnknownTarget */
188
  $plugin_url = sprintf( '<a href="%s">%s</a>', $plugin_url, esc_html__( 'WooCommerce', 'woocommerce' ) );
194
  }
195
  }
196
  }
197
+ if ( ! function_exists( 'checkFTP_connection' ) ) {
198
  /**
199
  * Verify if ftp module enabled
200
  * @TODO improve module detection
204
  return ( extension_loaded('ftp' ) || function_exists( 'ftp_connect' ) );
205
  }
206
  }
207
+ if ( ! function_exists( 'checkSFTP_connection' ) ) {
208
  /**
209
  * Verify if ssh/sftp module enabled
210
  * @TODO improve module detection
214
  return ( extension_loaded('ssh2' ) || function_exists( 'ssh2_connect' ) );
215
  }
216
  }
217
+ if ( ! function_exists( 'array_splice_assoc' ) ) {
218
  /**
219
  * Array Splice Associative Array
220
  * @see https://www.php.net/manual/en/function.array-splice.php#111204
225
  *
226
  * @return array
227
  */
228
+ function array_splice_assoc( $input, $offset, $length, $replacement ) {
229
  $replacement = (array) $replacement;
230
  $key_indices = array_flip(array_keys($input));
231
+ if ( isset($input[ $offset ]) && is_string($offset) ) {
232
+ $offset = $key_indices[ $offset ];
233
  }
234
+ if ( isset($input[ $length ]) && is_string($length) ) {
235
+ $length = $key_indices[ $length ] - $offset;
236
  }
237
 
238
  $input = array_slice($input, 0, $offset, TRUE)
243
  }
244
 
245
  // The Editor
246
+ if ( ! function_exists( 'register_and_do_woo_feed_meta_boxes' ) ) {
247
  /**
248
  * Registers the default Feed Editor MetaBoxes, and runs the `do_meta_boxes` actions.
249
  *
265
  $screen = convert_to_screen( $screen );
266
  }
267
  // edit page MetaBoxes
268
+ if ( 'woo-feed_page_webappick-new-feed' === $screen->id || 'toplevel_page_webappick-manage-feeds' === $screen->id ) {
269
  add_meta_box( 'feed_merchant_info', 'Feed Merchant Info', 'woo_feed_merchant_info_metabox', null, 'side', 'default' );
270
  }
271
  /**
279
  do_action( 'do_meta_boxes', $screen->id, 'side', $feedRules );
280
  }
281
  }
282
+ if ( ! function_exists( 'woo_feed_ajax_merchant_info' ) ) {
283
  add_action( 'wp_ajax_woo_feed_get_merchant_info', 'woo_feed_ajax_merchant_info' );
284
  function woo_feed_ajax_merchant_info() {
285
+ if ( isset( $_REQUEST['nonce'] ) && wp_verify_nonce( $_REQUEST['nonce'], 'wpf_feed_nonce' ) ) {
286
  $provider = ( isset( $_REQUEST['provider'] ) && ! empty( $_REQUEST['provider'] ) ) ? sanitize_text_field( $_REQUEST['provider'] ) : '';
287
  $merchantInfo = new Woo_Feed_Merchant();
288
  $data = [];
289
  $na = esc_html__( 'N/A', 'woo-feed' );
290
+ foreach ( $merchantInfo->getInfo( $provider ) as $k => $v ) {
291
+ if ( $k == 'link' ) {
292
  /** @noinspection HtmlUnknownTarget */
293
  $data[ $k ] = empty( $v ) ? $na : sprintf( '<a href="%s" target="_blank">%s</a>', esc_url( $v ), esc_html__( 'Read Article', 'woo-feed' ) );
294
+ } elseif ( $k == 'video' ) {
295
  /** @noinspection HtmlUnknownTarget */
296
  $data[ $k ] = empty( $v ) ? $na : sprintf( '<a href="%s" target="_blank">%s</a>', esc_url( $v ), esc_html__( 'Watch Now', 'woo-feed' ) );
297
+ } elseif ( $k == 'feed_file_type' ) {
298
+ if ( ! empty( $v ) ) {
299
  $v = array_map( function( $type ) {
300
  return strtoupper( $type );
301
  }, (array) $v );
302
+ $data[ $k ] = esc_html( implode( ', ', $v ) );
303
  } else {
304
+ $data[ $k ] = $na;
305
  }
306
+ } elseif ( $k == 'doc' ) {
307
  $links = '';
308
+ foreach ( $v as $label => $link ) {
309
  /** @noinspection HtmlUnknownTarget */
310
  $links .= sprintf( '<li><a href="%s" target="_blank">%s</a></li>', esc_url( $link ), esc_html( $label ) );
311
  }
319
  die();
320
  }
321
  }
322
+ if ( ! function_exists( 'woo_feed_merchant_info_metabox' ) ) {
323
  /**
324
  * Render Merchant Info Metabox
325
  * @param array $feedConfig
331
  ?>
332
  <span class="spinner"></span>
333
  <div class="merchant-infos">
334
+ <?php foreach ( $merchantInfo->getInfo( $provider ) as $k => $v ) { ?>
335
  <div class="merchant-info-section <?php echo esc_attr( $k ); ?>">
336
+ <?php if ( $k == 'link' ) { ?>
337
  <span class="dashicons dashicons-media-document" style="color: #82878c;" aria-hidden="true"></span>
338
  <span><?php esc_html_e( 'Feed Specification:', 'woo-feed' ) ?></span>
339
  <strong class="data"><?php
340
  /** @noinspection HtmlUnknownTarget */
341
  ( empty( $v ) ) ? esc_html_e( 'N/A', 'woo-feed' ) : printf( '<a href="%s" target="_blank">%s</a>', esc_url( $v ), esc_html__( 'Read Article', 'woo-feed' ) );
342
  ?></strong>
343
+ <?php } elseif ( $k == 'video' ) { ?>
344
  <span class="dashicons dashicons-video-alt3" style="color: #82878c;" aria-hidden="true"></span>
345
  <span><?php esc_html_e( 'Video Documentation:', 'woo-feed' ) ?></span>
346
  <strong class="data"><?php
347
  /** @noinspection HtmlUnknownTarget */
348
  ( empty( $v ) ) ? esc_html_e( 'N/A', 'woo-feed' ) : printf( '<a href="%s" target="_blank">%s</a>', esc_url( $v ), esc_html__( 'Watch now', 'woo-feed' ) );
349
  ?></strong>
350
+ <?php } elseif ( $k == 'feed_file_type' ) { ?>
351
  <span class="dashicons dashicons-media-text" style="color: #82878c;" aria-hidden="true"></span> <?php esc_html_e( 'Format Supported:', 'woo-feed' ) ?>
352
  <strong class="data"><?php echo ( empty( $v ) ) ? esc_html__( 'N/A', 'woo-feed' ) : esc_html( implode( ', ', array_map( function( $type ) {
353
  return strtoupper( $type );
354
  }, (array) $v ) ) ); ?></strong>
355
  <?php
356
+ } elseif ( $k == 'doc' ) { ?>
357
  <span class="dashicons dashicons-editor-help" style="color: #82878c;" aria-hidden="true"></span>
358
  <span><?php esc_html_e( 'Support Docs:', 'woo-feed' ); ?></span>
359
  <ul class="data">
360
  <?php
361
+ if ( empty( $v ) ) esc_html_e( 'N/A', 'woo-feed' );
362
  else {
363
+ foreach ( $v as $label => $link ) {
364
  /** @noinspection HtmlUnknownTarget */
365
  printf( '<li><a href="%s" target="_blank">%s</a></li>', esc_url( $link ), esc_html( $label ) );
366
  }
377
  }
378
 
379
  // Sanitization
380
+ if ( ! function_exists( 'woo_feed_check_google_category' ) ) {
381
  /**
382
  * @param array $feedInfo
383
  *
388
  $checkCategory = isset( $feedInfo['feedrules']['mattributes'] ) ? $feedInfo['feedrules']['mattributes'] : [];
389
  $checkCategoryType = isset( $feedInfo['feedrules']['type'] ) ? $feedInfo['feedrules']['type'] : [];
390
  $merchant = isset( $feedInfo['feedrules']['provider'] ) ? $feedInfo['feedrules']['provider'] : [];
391
+ $cat = "yes";
392
+ if ( in_array($merchant,array( 'google', 'facebook' ) ) && in_array("current_category",$checkCategory) ) {
393
+ $catKey = array_search('current_category',$checkCategory);
394
+ if ( $checkCategoryType[ $catKey ] == "pattern" ) {
395
+ $checkCategoryValue = $feedInfo['feedrules']['default'];
396
+ }else {
397
+ $checkCategoryValue = $feedInfo['feedrules']['attributes'];
398
  }
399
 
400
+ if ( empty($checkCategoryValue[ $catKey ]) ) {
401
+ $cat = "no";
402
  }
403
  }
404
  return $cat;
405
  }
406
  }
407
+ if ( ! function_exists( 'woo_feed_array_sanitize' ) ) {
408
  /**
409
  * Sanitize array post
410
  *
420
  foreach ( $value as $key2 => $value2 ) {
421
  if ( is_array( $value2 ) ) {
422
  foreach ( $value2 as $key3 => $value3 ) {
423
+ $newArray[ $key ][ $key2 ][ $key3 ] = sanitize_text_field( $value3 );
424
  }
425
  } else {
426
+ $newArray[ $key ][ $key2 ] = sanitize_text_field( $value2 );
427
  }
428
  }
429
  } else {
430
+ $newArray[ $key ] = sanitize_text_field( $value );
431
  }
432
  }
433
  }
434
  return $newArray;
435
  }
436
  }
437
+ if ( ! function_exists( 'woo_feed_sanitize_form_fields' ) ) {
438
  /**
439
  * Sanitize Form Fields ($_POST Array)
440
  * @param array $data
441
  * @return array
442
  */
443
  function woo_feed_sanitize_form_fields( $data ) {
444
+ foreach ( $data as $k => $v ) {
445
+ if ( true === apply_filters( 'woo_feed_sanitize_form_fields', true, $k, $v, $data ) ) {
446
+ if ( is_array( $v ) ) {
447
  $v = woo_feed_sanitize_form_fields( $v );
448
  } else {
449
  //$v = sanitize_text_field( $v ); #TODO should not trim Prefix and Suffix field
450
  }
451
  }
452
+ $data[ $k ] = apply_filters( 'woo_feed_sanitize_form_field', $v, $k );
453
  }
454
  return $data;
455
  }
456
  }
457
+ if ( ! function_exists( 'woo_feed_unique_feed_slug' ) ) {
458
  /**
459
  * Generate Unique slug for feed.
460
  * @see wp_unique_post_slug()
467
  global $wpdb;
468
  /** @noinspection SpellCheckingInspection */
469
  $disallowed = array( 'siteurl', 'home', 'blogname', 'blogdescription', 'users_can_register', 'admin_email' );
470
+ if ( $feedId && $feedId > 0 ) {
471
  $checkSql = "SELECT option_name FROM $wpdb->options WHERE option_name = %s AND option_id != %d LIMIT 1";
472
  $nameCheck = $wpdb->get_var( $wpdb->prepare( $checkSql, $prefix . $slug, $feedId ) );
473
  } else {
474
  $checkSql = "SELECT option_name FROM $wpdb->options WHERE option_name = %s LIMIT 1";
475
  $nameCheck = $wpdb->get_var( $wpdb->prepare( $checkSql, $prefix . $slug ) );
476
  }
477
+ if ( $nameCheck || in_array( $slug, $disallowed ) ) {
478
  $suffix = 2;
479
  do {
480
  $altName = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
481
+ if ( $feedId && $feedId > 0 ) {
482
  $nameCheck = $wpdb->get_var( $wpdb->prepare( $checkSql, $prefix . $altName, $feedId ) );
483
  } else {
484
  $nameCheck = $wpdb->get_var( $wpdb->prepare( $checkSql, $prefix . $altName ) );
490
  return $slug;
491
  }
492
  }
493
+ if ( ! function_exists( 'generate_unique_feed_file_name' ) ) {
494
  function generate_unique_feed_file_name( $filename, $type, $provider ) {
495
 
496
  $feedDir = woo_feed_get_file_dir( $provider, $type );
505
  }
506
 
507
  // File process
508
+ if ( ! function_exists( 'woo_feed_save_feed_config_data' ) ) {
509
  /**
510
  * Sanitize And Save Feed config data (array) to db (option table)
511
  * @param array $data data to be saved in db
515
  * @return bool|string return false if failed to update. return filename if success
516
  */
517
  function woo_feed_save_feed_config_data( $data, $fileName = null, $configOnly = true ) {
518
+ if ( ! is_array( $data ) ) return false;
519
+ if ( ! isset( $data['filename'], $data['feedType'], $data['provider'], $data['mattributes'] ) ) return false;
520
  // unnecessary form fields to remove
521
  $removables = [ 'closedpostboxesnonce', '_wpnonce', '_wp_http_referer', 'save_feed_config', 'edit-feed' ];
522
  foreach ( $removables as $removable ) {
523
+ if ( isset( $data[ $removable ] ) ) unset( $data[ $removable ] );
524
  }
525
  // Sanitize Fields
526
  $data = woo_feed_sanitize_form_fields( $data );
527
+ if ( empty( $fileName ) ) {
528
  $fileName = generate_unique_feed_file_name( $data['filename'], $data['feedType'], $data['provider'] );
529
  } else {
530
  $fileName = str_replace( [ 'wf_feed_', 'wf_config' ], '', $fileName );
539
  # Store Config
540
  $update = update_option( "wf_config" . $fileName, $data, false );
541
  // save if config update ok...
542
+ if ( $update && $configOnly === false ) {
543
  $oldFeed = maybe_unserialize( get_option( "wf_feed_" . $fileName ) );
544
  $feedData = array(
545
+ 'feedrules' => $data,
546
+ 'url' => woo_feed_get_file_url( $fileName, $data['provider'], $data['feedType'] ),
547
  'last_updated' => date("Y-m-d H:i:s"),
548
+ 'status' => isset( $oldFeed['status'] ) ? $oldFeed['status'] : 1,
549
  );
550
  $update = update_option( 'wf_feed_' . $fileName, maybe_serialize( $feedData ), false );
551
  }
553
  return $update ? $fileName : $update;
554
  }
555
  }
556
+ if ( ! function_exists( 'woo_feed_get_file_url' ) ) {
557
  /**
558
  * Get Feed File URL
559
  * @param string $fileName
567
  return esc_url( sprintf( '%s/woo-feed/%s/%s/%s.%s', $upload_dir['baseurl'], $provider, $type, $fileName, $type ) );
568
  }
569
  }
570
+ if ( ! function_exists( 'woo_feed_check_feed_file' ) ) {
571
  /**
572
  * Check if feed file exists
573
  * @param string $fileName
581
  return file_exists( sprintf( '%s/woo-feed/%s/%s/%s.%s', $upload_dir['basedir'], $provider, $type, $fileName, $type ) );
582
  }
583
  }
584
+ if ( ! function_exists( 'woo_feed_get_file_dir' ) ) {
585
  /**
586
  * Get Feed Directory
587
  * @param string $provider
594
  return $base . "/woo-feed/" . $provider . "/" . $feedType;
595
  }
596
  }
597
+ if ( ! function_exists( 'woo_feed_save_batch_feed_info' ) ) {
598
  /**
599
  * Save Feed Batch Chunk
600
  * @param string $feedService
630
  return $status;
631
  }
632
  }
633
+ if ( ! function_exists( 'woo_feed_get_batch_feed_info' ) ) {
634
  /**
635
  * @param string $feedService
636
  * @param string $type
642
  $upload_dir = wp_upload_dir();
643
  $base = $upload_dir['basedir'];
644
  $ext = $type;
645
+ if ( $type == "csv" ) $ext = "json";
646
  # Save File
647
  $path = $base . "/woo-feed/" . $feedService . "/" . $type;
648
  $file = $path . "/" . $fileName . "." . $ext;
649
  if ( $type == "csv" && file_exists( $file ) ) {
650
+ return (file_get_contents($file)) ? json_decode(file_get_contents($file),true) : false;
651
+ }elseif ( file_exists( $file ) ) {
652
  return file_get_contents($file);
653
  }
654
  return false;
655
  }
656
  }
657
+ if ( ! function_exists( 'woo_feed_unlink_tempFiles' ) ) {
658
  /**
659
  * Remove temporary feed files
660
  * @param array $files
661
  * @return bool
662
  */
663
  function woo_feed_unlink_tempFiles( $files ) {
664
+ if ( ! empty( $files ) ) {
665
+ foreach ( $files as $key => $file ) {
666
+ if ( file_exists( $file ) ) {
667
  @unlink($file);
668
  }
669
  }
674
  }
675
 
676
  // Mics..
677
+ if ( ! function_exists( 'woo_feed_remove_query_args' ) ) {
678
  /**
679
  * Add more items to the removable query args array...
680
  * @param array $removable_query_args
682
  * @return array
683
  */
684
  function woo_feed_remove_query_args( $removable_query_args ) {
685
+ if ( isset( $_GET['page'] ) && 'webappick-manage-feeds' == $_GET['page'] ) {
686
  $removable_query_args[] = 'feed_created';
687
  $removable_query_args[] = 'feed_updated';
688
  $removable_query_args[] = 'feed_regenerate';
700
  }
701
 
702
  // Feed Functions
703
+ if ( ! function_exists( 'woo_feed_get_field_output_type_options' ) ) {
704
  function woo_feed_get_field_output_type_options() {
705
  return apply_filters( 'woo_feed_field_output_options', [
706
  1 => esc_html__( 'Default', 'woo-feed' ),
716
  ] );
717
  }
718
  }
719
+ if ( ! function_exists( 'woo_feed_get_schedule_interval_options' ) ) {
720
  function woo_feed_get_schedule_interval_options(){
721
  return apply_filters( 'woo_feed_schedule_interval_options', [
722
+ WEEK_IN_SECONDS => esc_html__( '1 Week', 'woo-feed' ),
723
+ DAY_IN_SECONDS => esc_html__( '24 Hours', 'woo-feed' ),
724
+ 12 * HOUR_IN_SECONDS => esc_html__( '12 Hours', 'woo-feed' ),
725
+ 6 * HOUR_IN_SECONDS => esc_html__( '6 Hours', 'woo-feed' ),
726
+ HOUR_IN_SECONDS => esc_html__( '1 Hours', 'woo-feed' ),
727
+ 15 * MINUTE_IN_SECONDS => esc_html__( '15 Minutes', 'woo-feed' ),
728
  ] );
729
  }
730
  }
731
+ if ( ! function_exists( 'woo_feed_get_minimum_interval_option' ) ) {
732
  function woo_feed_get_minimum_interval_option(){
733
  $intervals = array_keys( woo_feed_get_schedule_interval_options() );
734
+ if ( ! empty( $intervals ) ) return end( $intervals );
735
+ return 15 * MINUTE_IN_SECONDS;
736
  }
737
  }
738
+ if ( ! function_exists('woo_feed_stripInvalidXml' ) ) {
739
  /**
740
  * Remove non supported xml character
741
  * @param string $value
742
  * @return string
743
  */
744
+ function woo_feed_stripInvalidXml( $value ) {
745
  $ret = "";
746
  if (empty($value)) return $ret;
747
  $length = strlen($value);
748
+ for ( $i = 0; $i < $length; $i++ ) {
749
+ $current = ord($value[ $i ]);
750
+ if ( ($current == 0x9) || ($current == 0xA) || ($current == 0xD) || (($current >= 0x20) && ($current <= 0xD7FF)) || (($current >= 0xE000) && ($current <= 0xFFFD)) || (($current >= 0x10000) && ($current <= 0x10FFFF)) ) {
751
  $ret .= chr($current);
752
  } else {
753
  $ret .= "";
756
  return $ret;
757
  }
758
  }
759
+ if ( ! function_exists('woo_feed_get_formatted_url' ) ) {
760
  /**
761
  * Get Formatted URL
762
  * @param string $url
763
  *
764
  * @return string
765
  */
766
+ function woo_feed_get_formatted_url( $url = "" ) {
767
+ if ( ! empty($url) ) {
768
+ if ( substr(trim($url), 0, 4) === "http" || substr(trim($url), 0, 3) === "ftp" || substr(trim($url), 0, 4) === "sftp" ) {
 
769
  return rtrim($url, "/");
770
  } else {
771
  $base = get_site_url();
776
  return "";
777
  }
778
  }
779
+ if ( ! function_exists('array_value_first' ) ) {
780
  /**
781
  * Get First Value of an array
782
  * @since 3.0.0
783
  * @param array $arr
784
  * @return mixed|null
785
  */
786
+ function array_value_first( array $arr ) {
787
+ foreach ( $arr as $key => $unused ) {
 
788
  return $unused;
789
  }
790
  return NULL;
791
  }
792
  }
793
+ if ( ! function_exists('woo_feed_make_url_with_parameter' ) ) {
794
  /**
795
  * Make proper URL using parameters
796
  * @param string $output
797
  * @param string $suffix
798
  * @return string
799
  */
800
+ function woo_feed_make_url_with_parameter( $output = '', $suffix = '' ) {
801
+ if ( empty($output) || empty($suffix) ) {
 
802
  return $output;
803
  }
804
 
805
  $getParam = explode('?', $output);
806
  $URLParam = array();
807
+ if ( isset($getParam[1]) ) {
808
  $URLParam = woo_feed_parse_string($getParam[1]);
809
  }
810
 
811
  $EXTRAParam = array();
812
+ if ( ! empty($suffix) ) {
813
  $suffix = str_replace("?", "", $suffix);
814
  $EXTRAParam = woo_feed_parse_string($suffix);
815
  }
816
 
817
  $params = array_merge($URLParam, $EXTRAParam);
818
+ if ( ! empty($params) && $output != "" ) {
819
  $params = http_build_query($params);
820
  $baseURL = isset($getParam) ? $getParam[0] : $output;
821
  $output = $baseURL . "?" . $params;
824
  return $output;
825
  }
826
  }
827
+ if ( ! function_exists('woo_feed_parse_string' ) ) {
828
  /**
829
  * Parse URL parameter
830
  * @param string $str
831
  * @return array
832
  */
833
+ function woo_feed_parse_string( $str = "" ) {
 
834
 
835
  # result array
836
  $arr = array();
837
 
838
+ if ( empty($str) ) {
839
  return $arr;
840
  }
841
 
842
  # split on outer delimiter
843
  $pairs = explode('&', $str);
844
 
845
+ if ( ! empty($pairs) ) {
846
 
847
  # loop through each pair
848
+ foreach ( $pairs as $i ) {
849
  # split into name and value
850
  list($name, $value) = explode('=', $i, 2);
851
 
852
  # if name already exists
853
+ if ( isset($arr[ $name ]) ) {
854
  # stick multiple values into an array
855
+ if ( is_array($arr[ $name ]) ) {
856
+ $arr[ $name ][] = $value;
857
  } else {
858
+ $arr[ $name ] = array( $arr[ $name ], $value );
859
  }
860
  } # otherwise, simply stick it in a scalar
861
  else {
862
+ $arr[ $name ] = $value;
863
  }
864
  }
865
+ } elseif ( ! empty($str) ) {
866
  list($name, $value) = explode('=', $str, 2);
867
+ $arr[ $name ] = $value;
868
  }
869
 
870
  # return result array
871
  return $arr;
872
  }
873
  }
874
+ if ( ! function_exists('woo_feed_replace_to_merchant_attribute' ) ) {
875
  /**
876
  * Parse URL parameter
877
  * @param string $pluginAttribute
879
  * @param string feedType CSV XML TXT
880
  * @return string
881
  */
882
+ function woo_feed_replace_to_merchant_attribute( $pluginAttribute,$merchant,$feedType ) {
883
+ $attributeClass = new Woo_Feed_Default_Attributes();
884
+ $merchantAttributes = "";
885
+ if ( $merchant == "google" && $feedType == 'xml' ) {
886
+ $merchantAttributes = $attributeClass->googleXMLAttribute;
887
+ }elseif ( $merchant == "google" && ($feedType == 'csv' || $feedType == 'txt' ) ) {
888
+ $merchantAttributes = $attributeClass->googleCSVTXTAttribute;
889
+ }elseif ( $merchant == "facebook" && $feedType == 'xml' ) {
890
+ $merchantAttributes = $attributeClass->facebookXMLAttribute;
891
+ }elseif ( $merchant == "facebook" && ($feedType == 'csv' || $feedType == 'txt' ) ) {
892
+ $merchantAttributes = $attributeClass->facebookCSVTXTAttribute;
893
+ }elseif ( $merchant == "pinterest" && $feedType == 'xml' ) {
894
+ $merchantAttributes = $attributeClass->pinterestXMLAttribute;
895
+ }elseif ( $merchant == "pinterest" && ($feedType == 'csv' || $feedType == 'txt' ) ) {
896
+ $merchantAttributes = $attributeClass->pinterestCSVTXTAttribute;
 
897
  }
898
 
899
+ if ( ! empty($merchantAttributes) && array_key_exists($pluginAttribute,$merchantAttributes) ) {
900
+ return $merchantAttributes[ $pluginAttribute ][0];
901
  }
902
 
903
  return $pluginAttribute;
904
  }
905
  }
906
+ if ( ! function_exists('woo_feed_add_cdata' ) ) {
907
  /**
908
  * Parse URL parameter
909
  * @param string $pluginAttribute
911
  * @param string $merchant
912
  * @return string
913
  */
914
+ function woo_feed_add_cdata( $pluginAttribute,$attributeValue,$merchant ) {
915
+ if ( strpos($attributeValue, "<![CDATA[") !== false ) {
 
916
  return "$attributeValue";
917
  }
918
 
919
+ $attributeClass = new Woo_Feed_Default_Attributes();
920
+ $merchantAttributes = "";
921
+ if ( $merchant == "google" ) {
922
+ $merchantAttributes = $attributeClass->googleXMLAttribute;
923
+ }elseif ( $merchant == "facebook" ) {
924
+ $merchantAttributes = $attributeClass->facebookXMLAttribute;
925
+ }elseif ( $merchant == "pinterest" ) {
926
+ $merchantAttributes = $attributeClass->pinterestXMLAttribute;
927
  }
928
 
929
+ if ( ! empty($merchantAttributes) && array_key_exists($pluginAttribute,$merchantAttributes) ) {
930
+ if ( $merchantAttributes[ $pluginAttribute ][1] == 'true' ) {
931
  return "<![CDATA[$attributeValue]]>";
932
+ }else {
933
  return "$attributeValue";
934
  }
935
+ }elseif ( strpos($attributeValue, "&") !== false ||
936
+ substr(trim($attributeValue), 0, 4) == "http" ) {
 
937
  return "<![CDATA[$attributeValue]]>";
938
+ }else {
939
  return "$attributeValue";
940
  }
941
  }
1019
  'warning',
1020
  'notice',
1021
  'info',
1022
+ 'debug',
1023
  ] ) ) {
1024
  return;
1025
  }
libs/WebAppick/AppServices/Client.php CHANGED
@@ -1,15 +1,22 @@
1
  <?php
2
- namespace WebAppick\AppServices;
3
- use WP_Error;
4
- if( ! defined( 'ABSPATH' ) ) die();
5
  /**
6
  * WebAppick Services Client
7
- * @package WebAppick
8
  * @version 1.0.2
 
 
9
  * This Package is based on AppSero project by weDevs
10
  * @see https://github.com/WebAppick/client
11
  * @license MIT
12
  */
 
 
 
 
 
 
 
 
 
13
  /**
14
  * Class Client
15
  */
@@ -92,10 +99,10 @@ class Client {
92
  /**
93
  * Initialize the class
94
  *
95
- * @param string $hash hash of the Plugin/Theme
96
- * @param string $name readable name of the Plugin/Theme
97
- * @param string $file main Plugin/Theme file path
98
- * @param string $ProjectId Store Product id for pro product
99
  */
100
  public function __construct( $hash, $name, $file, $ProjectId = null ) {
101
  $this->hash = $hash;
@@ -112,15 +119,19 @@ class Client {
112
  */
113
  public function insights() {
114
 
115
- if ( ! class_exists( __NAMESPACE__ . '\Insights') ) {
116
  require_once __DIR__ . '/Insights.php';
117
  }
118
 
119
  return new Insights( $this );
120
  }
121
 
 
 
 
 
122
  public function promotions() {
123
- if( ! class_exists( __NAMESPACE__ . '\Promotions' ) ) {
124
  require_once __DIR__ . '/Promotions.php';
125
  }
126
  return new Promotions( $this );
@@ -128,7 +139,7 @@ class Client {
128
 
129
  /**
130
  * Initialize Plugin/Theme updater
131
- * @param License $license
132
  * @return Updater
133
  */
134
  public function updater( License $license ) {
@@ -155,7 +166,7 @@ class Client {
155
  /**
156
  * API Endpoint
157
  *
158
- * @param string $route route to send the request
159
  *
160
  * @return string
161
  */
@@ -198,19 +209,19 @@ class Client {
198
  */
199
  protected function set_basename_and_slug() {
200
 
201
- if( strpos( $this->file, WP_CONTENT_DIR . '/themes/' ) === false ) {
202
 
203
  $this->basename = plugin_basename( $this->file );
204
  /** @noinspection SpellCheckingInspection, PhpUnusedLocalVariableInspection */
205
  list( $this->slug, $mainfile ) = explode( '/', $this->basename );
206
- if( ! function_exists( 'get_plugin_data' ) ) require_once ABSPATH . 'wp-admin/includes/plugin.php';
207
  $plugin_data = get_plugin_data( $this->file );
208
  $this->project_version = $plugin_data['Version'];
209
  $this->type = 'plugin';
210
  } else {
211
  $this->basename = str_replace( WP_CONTENT_DIR . '/themes/', '', $this->file );
212
- /** @noinspection SpellCheckingInspection, PhpUnusedLocalVariableInspection */
213
- list( $this->slug, $mainfile) = explode( '/', $this->basename );
214
  $theme = wp_get_theme( $this->slug );
215
  $this->project_version = $theme->version;
216
  $this->type = 'theme';
@@ -228,9 +239,10 @@ class Client {
228
  /**
229
  * Send request to remote endpoint
230
  *
231
- * @param array $params
232
- * @param string $route
233
- * @param bool $blocking
 
234
  * @return array|WP_Error Array of results including HTTP headers or WP_Error if the request failed.
235
  */
236
  public function send_request( $params, $route = '', $blocking = false ) {
@@ -239,6 +251,7 @@ class Client {
239
  'user-agent' => $this->__user_agent(),
240
  'Accept' => 'application/json',
241
  );
 
242
  /**
243
  * before request to api server
244
  * @since 1.0.2
@@ -249,7 +262,7 @@ class Client {
249
  * @param string $url
250
  */
251
  do_action( $this->getSlug() . '_before_request', $params, $route, $headers, $this->clientVersion, $url );
252
- if( ! empty( $route ) ) {
253
  /**
254
  * before request to api server to route
255
  * @since 1.0.2
@@ -268,16 +281,19 @@ class Client {
268
  * @param bool $blocking
269
  */
270
  $blocking = (bool) apply_filters( $this->getSlug() . '_request_blocking_mode', $blocking );
271
- $response = wp_remote_post( esc_url( $url ), array(
272
- 'method' => 'POST',
273
- 'timeout' => 45,
274
- 'redirection' => 5,
275
- 'httpversion' => '1.0',
276
- 'blocking' => $blocking,
277
- 'headers' => $headers,
278
- 'body' => array_merge( $params, array( 'client' => $this->clientVersion ) ),
279
- 'cookies' => array()
280
- ) );
 
 
 
281
  /**
282
  * after request to api server
283
  * @since 1.0.2
@@ -285,7 +301,7 @@ class Client {
285
  * @param string $route
286
  */
287
  do_action( $this->getSlug() . '_after_request', $response, $route );
288
- if( ! empty( $route ) ) {
289
  /**
290
  * after request to api server to route
291
  * @since 1.0.2
@@ -297,7 +313,7 @@ class Client {
297
  return $response;
298
  }
299
 
300
- //===> Getters
301
 
302
  /**
303
  * Get Version of this client
@@ -387,4 +403,4 @@ class Client {
387
  return $this->type;
388
  }
389
  }
390
- // End of file Insights.php
1
  <?php
 
 
 
2
  /**
3
  * WebAppick Services Client
 
4
  * @version 1.0.2
5
+ * @package WebAppick
6
+ * @subpackage AppServices
7
  * This Package is based on AppSero project by weDevs
8
  * @see https://github.com/WebAppick/client
9
  * @license MIT
10
  */
11
+
12
+ namespace WebAppick\AppServices;
13
+
14
+ use WP_Error;
15
+
16
+ if ( ! defined( 'ABSPATH' ) ) {
17
+ die();
18
+ }
19
+
20
  /**
21
  * Class Client
22
  */
99
  /**
100
  * Initialize the class
101
  *
102
+ * @param string $hash hash of the Plugin/Theme.
103
+ * @param string $name readable name of the Plugin/Theme.
104
+ * @param string $file main Plugin/Theme file path.
105
+ * @param string $ProjectId Store Product id for pro product.
106
  */
107
  public function __construct( $hash, $name, $file, $ProjectId = null ) {
108
  $this->hash = $hash;
119
  */
120
  public function insights() {
121
 
122
+ if ( ! class_exists( __NAMESPACE__ . '\Insights' ) ) {
123
  require_once __DIR__ . '/Insights.php';
124
  }
125
 
126
  return new Insights( $this );
127
  }
128
 
129
+ /**
130
+ * Initialize Promotions class
131
+ * @return Promotions
132
+ */
133
  public function promotions() {
134
+ if ( ! class_exists( __NAMESPACE__ . '\Promotions' ) ) {
135
  require_once __DIR__ . '/Promotions.php';
136
  }
137
  return new Promotions( $this );
139
 
140
  /**
141
  * Initialize Plugin/Theme updater
142
+ * @param License $license The license class.
143
  * @return Updater
144
  */
145
  public function updater( License $license ) {
166
  /**
167
  * API Endpoint
168
  *
169
+ * @param string $route route to send the request.
170
  *
171
  * @return string
172
  */
209
  */
210
  protected function set_basename_and_slug() {
211
 
212
+ if ( false === strpos( $this->file, WP_CONTENT_DIR . '/themes/' ) ) {
213
 
214
  $this->basename = plugin_basename( $this->file );
215
  /** @noinspection SpellCheckingInspection, PhpUnusedLocalVariableInspection */
216
  list( $this->slug, $mainfile ) = explode( '/', $this->basename );
217
+ if ( ! function_exists( 'get_plugin_data' ) ) require_once ABSPATH . 'wp-admin/includes/plugin.php';
218
  $plugin_data = get_plugin_data( $this->file );
219
  $this->project_version = $plugin_data['Version'];
220
  $this->type = 'plugin';
221
  } else {
222
  $this->basename = str_replace( WP_CONTENT_DIR . '/themes/', '', $this->file );
223
+
224
+ list( $this->slug, $main_file ) = explode( '/', $this->basename );
225
  $theme = wp_get_theme( $this->slug );
226
  $this->project_version = $theme->version;
227
  $this->type = 'theme';
239
  /**
240
  * Send request to remote endpoint
241
  *
242
+ * @param array $params Parameters/Data that being sent.
243
+ * @param string $route Route to send the request to.
244
+ * @param bool $blocking Block Execution Until the server response back or timeout.
245
+ *
246
  * @return array|WP_Error Array of results including HTTP headers or WP_Error if the request failed.
247
  */
248
  public function send_request( $params, $route = '', $blocking = false ) {
251
  'user-agent' => $this->__user_agent(),
252
  'Accept' => 'application/json',
253
  );
254
+
255
  /**
256
  * before request to api server
257
  * @since 1.0.2
262
  * @param string $url
263
  */
264
  do_action( $this->getSlug() . '_before_request', $params, $route, $headers, $this->clientVersion, $url );
265
+ if ( ! empty( $route ) ) {
266
  /**
267
  * before request to api server to route
268
  * @since 1.0.2
281
  * @param bool $blocking
282
  */
283
  $blocking = (bool) apply_filters( $this->getSlug() . '_request_blocking_mode', $blocking );
284
+ $response = wp_safe_remote_post(
285
+ esc_url( $url ),
286
+ [
287
+ 'method' => 'POST',
288
+ 'timeout' => 45, // phpcs:ignore
289
+ 'redirection' => 5,
290
+ 'httpversion' => '1.0',
291
+ 'blocking' => $blocking,
292
+ 'headers' => $headers,
293
+ 'body' => array_merge( $params, [ 'client' => $this->clientVersion ] ),
294
+ 'cookies' => [],
295
+ ]
296
+ );
297
  /**
298
  * after request to api server
299
  * @since 1.0.2
301
  * @param string $route
302
  */
303
  do_action( $this->getSlug() . '_after_request', $response, $route );
304
+ if ( ! empty( $route ) ) {
305
  /**
306
  * after request to api server to route
307
  * @since 1.0.2
313
  return $response;
314
  }
315
 
316
+ //===> Getters.
317
 
318
  /**
319
  * Get Version of this client
403
  return $this->type;
404
  }
405
  }
406
+ // End of file Client.php.
libs/WebAppick/AppServices/Insights.php CHANGED
@@ -1,18 +1,29 @@
1
  <?php
2
- namespace WebAppick\AppServices;
3
- use mysql_xdevapi\Exception;
4
- use WP_Theme;
5
- use WP_User;
6
- if ( ! defined( 'ABSPATH' ) ) die();
7
  /**
8
  * WebAppick Insights
9
  *
10
  * @version 1.0.1
 
 
11
  *
12
  * This is a tracker class to track plugin usage based on if the customer has opted in.
13
  * No personal information is being tracked by this class, only general settings, active plugins, environment details
14
  * and admin email.
15
  */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  class Insights {
17
 
18
  /**
@@ -67,15 +78,24 @@ class Insights {
67
  */
68
  protected $supportResponse = '';
69
 
 
 
 
 
70
  protected $supportErrorResponse = '';
 
 
 
 
 
71
  protected $supportURL = '';
72
 
73
  /**
74
  * Initialize the class
75
  *
76
- * @param Client $client
77
- * @param string $name
78
- * @param string $file
79
  */
80
  public function __construct( $client, $name = null, $file = null ) {
81
  if ( is_string( $client ) && ! empty( $name ) && ! empty( $file ) ) {
@@ -100,7 +120,7 @@ class Insights {
100
  /**
101
  * Add extra data if needed
102
  *
103
- * @param array $data
104
  *
105
  * @return Insights
106
  */
@@ -113,7 +133,7 @@ class Insights {
113
  /**
114
  * Set custom notice text
115
  *
116
- * @param string $text
117
  *
118
  * @return Insights
119
  */
@@ -129,33 +149,37 @@ class Insights {
129
  * @return void
130
  */
131
  public function init() {
132
- // Env Setup
133
  $projectSlug = $this->client->getSlug();
134
  /**
135
  * Support Page URL
136
  * @param string $supportURL
137
  */
138
- if( false !== ( $supportURL = apply_filters( "WebAppick_{$projectSlug}_Support_Page_URL" , false ) ) ) {
 
139
  $supportURL = esc_url_raw( $supportURL, [ 'http', 'https' ] );
140
- if( ! empty( $supportURL ) ) $this->supportURL = $supportURL;
 
 
141
  }
142
  /**
143
  * Set Ticket Recipient Email
144
  * @param string $ticketRecipient
145
  */
146
  $ticketRecipient = apply_filters( "WebAppick_{$projectSlug}_Support_Ticket_Recipient_Email" , false );
147
- if( FALSE !== $ticketRecipient && is_email( $ticketRecipient ) ) {
148
  $this->ticketRecipient = sanitize_email( $ticketRecipient );
149
  }
150
  /**
151
  * Set Support Ticket Template For sending the email query.
152
  * @param string $ticketTemplate
153
  */
154
- if( false !== ( $ticketTemplate = apply_filters( "WebAppick_{$projectSlug}_Support_Ticket_Email_Template" , false ) ) ) {
 
155
  $this->ticketTemplate = $ticketTemplate;
156
  }
157
 
158
- // initialize
159
  if ( $this->client->getType() == 'plugin' ) {
160
  $this->init_plugin();
161
  } elseif ( $this->client->getType() == 'theme' ) {
@@ -182,7 +206,7 @@ class Insights {
182
  * @return void
183
  */
184
  private function init_plugin() {
185
- // plugin deactivate popup
186
  if ( ! $this->__is_local_server() ) {
187
  add_action( 'plugin_action_links_' . $this->client->getBasename(), [ $this, 'plugin_action_links' ] );
188
  add_action( 'admin_footer', [ $this, 'deactivate_scripts' ] );
@@ -201,36 +225,35 @@ class Insights {
201
  */
202
  protected function init_common() {
203
  if ( $this->show_notice ) {
204
- // tracking notice
205
  add_action( 'admin_notices', [ $this, 'admin_notice' ] );
206
  }
207
  add_action( 'admin_init', [ $this, 'handle_optIn_optOut' ] );
208
  add_action( 'removable_query_args', [ $this, 'add_removable_query_args' ], 10, 1 );
209
- // uninstall reason
210
  add_action( 'wp_ajax_' . $this->client->getSlug() . '_submit-uninstall-reason', [ $this, 'uninstall_reason_submission' ] );
211
  add_action( 'wp_ajax_' . $this->client->getSlug() . '_submit-support-ticket', [ $this, 'support_ticket_submission' ] );
212
- // cron events
213
  add_filter( 'cron_schedules', [ $this, 'add_weekly_schedule' ] );
214
  add_action( $this->client->getSlug() . '_tracker_send_event', [ $this, 'send_tracking_data' ] );
215
- //add_action( 'admin_init', [ $this, 'send_tracking_data' ] ); // test
216
  }
217
 
218
  /**
219
  * Send tracking data to WebAppick server
220
  *
221
- * @param boolean $override
222
  *
223
  * @return void
224
  */
225
  public function send_tracking_data( $override = false ) {
226
- // skip on AJAX Requests
227
  if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
228
  return;
229
  }
230
  if ( ! $this->is_tracking_allowed() && ! $override ) {
231
  return;
232
  }
233
- // Send a maximum of once per week
234
  $last_send = $this->__get_last_send();
235
  /**
236
  * Tracking interval
@@ -244,7 +267,7 @@ class Insights {
244
  try {
245
  $intervalCheck = strtotime( $trackingInterval );
246
  } catch ( Exception $e ) {
247
- // fallback to default 1 week if filter returned unusable data
248
  $intervalCheck = strtotime( '-1 week' );
249
  }
250
  if ( $last_send && $last_send > $intervalCheck && ! $override ) {
@@ -276,14 +299,14 @@ class Insights {
276
  'hash' => $this->client->getHash(),
277
  'server' => $this->__get_server_info(),
278
  'wp' => $this->__get_wp_info(),
279
- //'users' => $this->__get_user_counts(),
280
  'active_plugins' => $all_plugins['active_plugins'],
281
  'inactive_plugins' => $all_plugins['inactive_plugins'],
282
  'ip_address' => $this->__get_user_ip_address(),
283
  'theme' => get_stylesheet(),
284
  ];
285
- // for child classes
286
- if ( $extra = $this->get_extra_data() ) {
 
287
  $data['extra'] = $extra;
288
  }
289
 
@@ -313,6 +336,10 @@ class Insights {
313
  return $data;
314
  }
315
 
 
 
 
 
316
  public function get_data_collection_description() {
317
  return $this->data_we_collect();
318
  }
@@ -323,13 +350,15 @@ class Insights {
323
  * @return WP_User
324
  */
325
  private function __get_admin() {
326
- $admins = get_users( [
327
- 'role' => 'administrator',
328
- 'orderby' => 'ID',
329
- 'order' => 'ASC',
330
- 'number' => 1,
331
- 'paged' => 1,
332
- ] );
 
 
333
 
334
  return ( is_array( $admins ) && ! empty( $admins ) ) ? $admins[0] : new WP_User();
335
  }
@@ -372,7 +401,9 @@ class Insights {
372
  * @return boolean
373
  */
374
  private function __is_local_server() {
 
375
  return apply_filters( 'WebAppick_is_local', in_array( $_SERVER['REMOTE_ADDR'], [ '127.0.0.1', '::1' ] ) );
 
376
  }
377
 
378
  /**
@@ -413,32 +444,31 @@ class Insights {
413
  return;
414
  }
415
 
416
- // don't show tracking if a local server
417
  if ( ! $this->__is_local_server() ) {
418
 
419
  if ( empty( $this->notice ) ) {
420
- $notice = sprintf( apply_filters( $this->client->getSlug() . '_tracking_default_notice_message',
421
- esc_html__( 'Want to help make %1$s even more awesome? Allow %1$s to collect non-sensitive diagnostic data and usage information.',
422
- 'webappick' ) ),
423
- '<strong>' . $this->client->getName() . '</strong>' );
 
 
 
 
424
  } else {
425
  $notice = $this->notice;
426
  }
427
 
428
- $notice .= ' (<a class="' . $this->client->getSlug() . '-insights-data-we-collect" href="#">' . esc_html__( 'what we collect',
429
- 'webappick' ) . '</a>)';
430
- $notice .= '<p class="description" style="display:none;">' . implode( ', ',
431
- $this->data_we_collect() ) . '. ' . esc_html__( 'No sensitive data is tracked.',
432
- 'webappick' ) . '</p>';
433
  echo '<div class="updated"><p>';
434
- echo $notice;
435
  echo '</p><p class="submit">';
436
- echo '&nbsp;<a href="' . esc_url( $this->get_opt_out_url() ) . '" class="button button-secondary">' . esc_html__( 'No thanks',
437
- 'webappick' ) . '</a>';
438
- echo '&nbsp;<a href="' . esc_url( $this->get_opt_in_url() ) . '" class="button button-primary">' . esc_html__( 'Allow',
439
- 'webappick' ) . '</a>';
440
  echo '</p></div>';
441
- echo "<script type='text/javascript'>jQuery('." . $this->client->getSlug() . "-insights-data-we-collect').on('click', function(e) {
442
  e.preventDefault();
443
  jQuery(this).parents('.updated').find('p.description').slideToggle('fast');
444
  });</script>";
@@ -450,7 +480,12 @@ class Insights {
450
  * @return string
451
  */
452
  public function get_opt_in_url() {
453
- return add_query_arg( $this->client->getSlug() . '_tracker_optIn', 'true' );
 
 
 
 
 
454
  }
455
 
456
  /**
@@ -458,7 +493,12 @@ class Insights {
458
  * @return string
459
  */
460
  public function get_opt_out_url() {
461
- return add_query_arg( $this->client->getSlug() . '_tracker_optOut', 'true' );
 
 
 
 
 
462
  }
463
 
464
  /**
@@ -467,29 +507,33 @@ class Insights {
467
  * @return void
468
  */
469
  public function handle_optIn_optOut() {
470
-
471
- if ( isset( $_GET[ $this->client->getSlug() . '_tracker_optIn' ] ) && $_GET[ $this->client->getSlug() . '_tracker_optIn' ] == 'true' ) {
472
- $this->optIn();
473
- wp_redirect( remove_query_arg( $this->client->getSlug() . '_tracker_optIn' ) );
474
- exit;
475
- }
476
- if ( isset( $_GET[ $this->client->getSlug() . '_tracker_optOut' ] ) && $_GET[ $this->client->getSlug() . '_tracker_optOut' ] == 'true' ) {
477
- $this->optOut();
478
- wp_redirect( remove_query_arg( $this->client->getSlug() . '_tracker_optOut' ) );
479
- exit;
 
 
480
  }
481
  }
482
 
483
  /**
484
  * Add query vars to removable query args array
485
  *
486
- * @param array $removable_query_args
487
  *
488
  * @return array
489
  */
490
  public function add_removable_query_args( $removable_query_args ) {
491
- return array_merge( $removable_query_args,
492
- [ $this->client->getSlug() . '_tracker_optIn', $this->client->getSlug() . '_tracker_optOut' ] );
 
 
493
  }
494
 
495
  /**
@@ -522,15 +566,20 @@ class Insights {
522
  /**
523
  * Get the number of post counts
524
  *
525
- * @param string $post_type
526
  *
527
  * @return integer
528
  */
529
  public function get_post_count( $post_type ) {
530
  global $wpdb;
531
-
532
- return (int) $wpdb->get_var( $wpdb->prepare( "SELECT count(ID) FROM $wpdb->posts WHERE post_type = %s and post_status = 'publish'",
533
- $post_type ) );
 
 
 
 
 
534
  }
535
 
536
  /**
@@ -541,10 +590,10 @@ class Insights {
541
  private function __get_server_info() {
542
  global $wpdb;
543
  $server_data = [
544
- 'software' => ( isset( $_SERVER['SERVER_SOFTWARE'] ) && ! empty( $_SERVER['SERVER_SOFTWARE'] ) ) ? $_SERVER['SERVER_SOFTWARE'] : 'N/A',
545
  'php_version' => ( function_exists( 'phpversion' ) ) ? phpversion() : 'N/A',
546
  'mysql_version' => $wpdb->db_version(),
547
- 'php_execution_time' => @ini_get( 'max_execution_time' ),
548
  'php_max_upload_size' => size_format( wp_max_upload_size() ),
549
  'php_default_timezone' => date_default_timezone_get(),
550
  'php_soap' => class_exists( 'SoapClient' ) ? 'Yes' : 'No',
@@ -588,21 +637,24 @@ class Insights {
588
  foreach ( $plugins as $k => $v ) {
589
  // Take care of formatting the data how we want it.
590
  $formatted = [
591
- 'name' => strip_tags( $v['Name'] ),
592
- 'version' => isset( $v['Version'] ) ? strip_tags( $v['Version'] ) : 'N/A',
593
- 'author' => isset( $v['Author'] ) ? strip_tags( $v['Author'] ) : 'N/A',
594
- 'network' => isset( $v['Network'] ) ? strip_tags( $v['Network'] ) : 'N/A',
595
- 'plugin_uri' => isset( $v['PluginURI'] ) ? strip_tags( $v['PluginURI'] ) : 'N/A',
596
  ];
597
  if ( in_array( $k, $active_plugins_keys ) ) {
598
- unset( $plugins[ $k ] ); // Remove active plugins from list so we can show active and inactive separately
599
  $active_plugins[ $k ] = $formatted;
600
  } else {
601
  $plugins[ $k ] = $formatted;
602
  }
603
  }
604
 
605
- return [ 'active_plugins' => $active_plugins, 'inactive_plugins' => $plugins ];
 
 
 
606
  }
607
 
608
  /**
@@ -614,7 +666,7 @@ class Insights {
614
  $user_count = [];
615
  $user_count_data = count_users();
616
  $user_count['total'] = $user_count_data['total_users'];
617
- // Get user count based on user role
618
  foreach ( $user_count_data['avail_roles'] as $role => $count ) {
619
  $user_count[ $role ] = $count;
620
  }
@@ -625,7 +677,7 @@ class Insights {
625
  /**
626
  * Add weekly cron schedule
627
  *
628
- * @param array $schedules
629
  *
630
  * @return array
631
  */
@@ -645,13 +697,12 @@ class Insights {
645
  */
646
  public function activate_plugin() {
647
  $allowed = get_option( $this->client->getSlug() . '_allow_tracking', 'no' );
648
- // if it wasn't allowed before, do nothing
649
  if ( 'yes' !== $allowed ) {
650
  return;
651
  }
652
- // re-schedule and delete the last sent time so we could force send again
653
  wp_schedule_event( time(), 'weekly', $this->client->getSlug() . '_tracker_send_event' );
654
- // wp_schedule_event( time(), 'daily', $this->client->getSlug() . '_license_check_event' );
655
  delete_option( $this->client->getSlug() . '_tracking_last_send' );
656
  $this->send_tracking_data( true );
657
  }
@@ -663,7 +714,6 @@ class Insights {
663
  */
664
  public function deactivation_cleanup() {
665
  $this->__clear_schedule_event();
666
- // wp_clear_scheduled_hook( $this->client->getSlug() . '_license_check_event' );
667
  if ( 'theme' == $this->client->getType() ) {
668
  delete_option( $this->client->getSlug() . '_tracking_last_send' );
669
  delete_option( $this->client->getSlug() . '_allow_tracking' );
@@ -674,16 +724,14 @@ class Insights {
674
  /**
675
  * Hook into action links and modify the deactivate link
676
  *
677
- * @param array $links
678
  *
679
  * @return array
680
  */
681
  public function plugin_action_links( $links ) {
682
 
683
  if ( array_key_exists( 'deactivate', $links ) ) {
684
- $links['deactivate'] = str_replace( '<a',
685
- '<a class="' . $this->client->getSlug() . '-deactivate-link"',
686
- $links['deactivate'] );
687
  }
688
 
689
  return $links;
@@ -710,8 +758,7 @@ class Insights {
710
  ],
711
  [
712
  'id' => 'not-have-that-feature',
713
- 'text' => esc_html__( 'The plugin is great, but I need specific feature that you don\'t support',
714
- 'webappick' ),
715
  'type' => 'textarea',
716
  'placeholder' => esc_html__( 'Could you tell us more about that feature?', 'webappick' ),
717
  ],
@@ -747,8 +794,8 @@ class Insights {
747
  ],
748
  ];
749
  $extra = apply_filters( $this->client->getSlug() . '_extra_uninstall_reasons', [], $reasons );
750
- if( is_array( $extra ) && ! empty( $extra ) ) {
751
- // extract the last (other) reason and add after extras
752
  $other = array_pop( $reasons );
753
  $reasons = array_merge( $reasons, $extra, [ $other ] );
754
  }
@@ -761,56 +808,63 @@ class Insights {
761
  * @return void
762
  */
763
  public function uninstall_reason_submission() {
764
-
765
- // if ( ! isset( $_POST['reason_id'] ) ) wp_send_json_error();
766
-
 
 
767
  $current_user = wp_get_current_user();
768
  global $wpdb;
769
  // @TODO remove deprecated data after server update
770
  $data = [
771
  'hash' => $this->client->getHash(),
772
  'reason_id' => isset( $_REQUEST['reason_id'] ) && ! empty( $_REQUEST['reason_id'] ) ? sanitize_text_field( $_REQUEST['reason_id'] ) : '',
773
- // WPCS: CSRF ok, Input var ok.
774
  'reason_info' => isset( $_REQUEST['reason_info'] ) ? trim( sanitize_textarea_field( $_REQUEST['reason_info'] ) ) : '',
775
- // WPCS: CSRF ok, Input var ok.
776
  'plugin' => $this->client->getName(),
777
  'site' => $this->__get_site_name(),
778
  'url' => esc_url( home_url() ),
779
  'admin_email' => get_option( 'admin_email' ),
780
  'user_email' => $current_user->user_email,
781
  'user_name' => $current_user->display_name,
782
- // deprecated
783
  'first_name' => ( ! empty( $current_user->first_name ) ) ? $current_user->first_name : $current_user->display_name,
784
  'last_name' => $current_user->last_name,
785
  'server' => $this->__get_server_info(),
786
- 'software' => $_SERVER['SERVER_SOFTWARE'],
787
- // deprecated, using $data['server'] for wp info
788
- 'php_version' => phpversion(),
789
- // deprecated, using $data['server'] for wp info
790
- 'mysql_version' => $wpdb->db_version(),
791
- // deprecated, using $data['server'] for wp info
792
  'wp' => $this->__get_wp_info(),
793
- 'wp_version' => get_bloginfo( 'version' ),
794
- // deprecated, using $data['wp'] for wp info
795
- 'locale' => get_locale(),
796
- // deprecated, using $data['wp'] for wp info
797
- 'multisite' => is_multisite() ? 'Yes' : 'No',
798
- // deprecated, using $data['wp'] for wp info
799
  'ip_address' => $this->__get_user_ip_address(),
800
  'version' => $this->client->getProjectVersion(),
801
  ];
802
- // Add extra data
803
- if ( $extra = $this->get_extra_data() ) {
 
804
  $data['extra'] = $extra;
805
  }
806
  $this->client->send_request( $data, 'reason' );
807
  wp_send_json_success();
 
808
  }
809
 
 
 
 
 
810
  public function support_ticket_submission() {
811
- if( empty( $this->ticketTemplate ) || empty( $this->ticketRecipient ) || empty( $this->supportURL ) ) {
812
- wp_send_json_error( sprintf( '<p class="mui-error">%s<br>%s</p>', esc_html__( 'Something Went Wrong.', 'webappick' ), esc_html__( 'Please try again after sometime.', 'webappick' ) ) );
813
- wp_die(-1 );
 
 
 
 
 
 
 
814
  }
815
  if (
816
  isset( $_REQUEST['name'], $_REQUEST['email'], $_REQUEST['subject'], $_REQUEST['website'], $_REQUEST['message'] ) &&
@@ -824,31 +878,41 @@ class Insights {
824
  ) {
825
  $headers = [
826
  'Content-Type: text/html; charset=UTF-8',
827
- sprintf( 'From: %s <%s>',
 
828
  sanitize_text_field( $_REQUEST['name'] ),
829
- sanitize_email( $_REQUEST['email'] ) ),
830
- sprintf( 'Reply-To: %s <%s>',
 
 
831
  sanitize_text_field( $_REQUEST['name'] ),
832
- sanitize_text_field( $_REQUEST['email'] ) ),
 
833
  ];
834
 
835
  foreach ( $_REQUEST as $k => $v ) {
836
  $sanitizer = 'sanitize_text_field';
837
- if( $k == 'email' ) $sanitizer = 'sanitize_email';
838
- if( $k == 'website' ) $sanitizer = 'esc_url';
839
- $v = call_user_func_array( $sanitizer, [$v] );
840
- $_REQUEST[$k] = $v; // sanitized.
841
- $k = '__' . strtoupper( $k ) . '__';
 
 
 
 
842
  $this->ticketTemplate = str_replace( [ $k ], [ $v ], $this->ticketTemplate );
843
  }
844
  $projectSlug = $this->client->getSlug();
845
- if ( wp_mail( $this->ticketRecipient, sanitize_text_field( $_REQUEST['subject'] ), sprintf( '<div>%s</div>', $this->ticketTemplate ), $headers ) ) {
 
846
  /**
847
  * Set Ajax Success Response for Support Ticket Submission
848
  * @param string $supportResponse
849
  * @param array $_REQUEST
850
  */
851
- if( false !== ( $supportResponse = apply_filters( "WebAppick_{$projectSlug}_Support_Request_Ajax_Success_Response" , false, $_REQUEST ) ) ) {
 
852
  $this->supportResponse = $supportResponse;
853
  } else {
854
  $this->supportResponse = sprintf(
@@ -857,13 +921,15 @@ class Insights {
857
  );
858
  }
859
  wp_send_json_success( $this->supportResponse );
 
860
  } else {
861
  /**
862
  * Set Support Ticket Ajax Error Response.
863
  * @param string $supportErrorResponse
864
  * @param array $_REQUEST
865
  */
866
- if( false !== ( $supportErrorResponse = apply_filters( "WebAppick_{$projectSlug}_Support_Request_Ajax_Error_Response" , false, $_REQUEST ) ) ) {
 
867
  $this->supportErrorResponse = $supportErrorResponse;
868
  } else {
869
  $this->supportErrorResponse = sprintf(
@@ -876,7 +942,7 @@ class Insights {
876
  } else {
877
  wp_send_json_error( sprintf( '<p class="mui-error">%s</p>', esc_html__( 'Missing Required Fields.', 'webappick' ) ) );
878
  }
879
- die();
880
  }
881
 
882
  /**
@@ -892,10 +958,10 @@ class Insights {
892
  $reasons = $this->__get_uninstall_reasons();
893
  $admin_user = $this->__get_admin();
894
  $displayName = ( ! empty( $admin_user->first_name ) && ! empty( $admin_user->last_name ) ) ? $admin_user->first_name . ' ' . $admin_user->last_name : $admin_user->display_name;
895
- $showSupportTicket = ( ! empty( $this->ticketTemplate ) && ! empty( $this->ticketRecipient ) && ! empty( $this->supportURL) );
896
  ?>
897
- <div class="wapk-dr-modal" id="<?php echo $this->client->getSlug(); ?>-wapk-dr-modal" aria-label="<?php printf( esc_attr__( '&ldquo;%s&rdquo; Uninstall Confirmation', 'webappick' ), $this->client->getName() ); ?>" role="dialog" aria-modal="true">
898
- <?php if( $showSupportTicket ) { ?>
899
  <div class="wapk-dr-modal-wrap support" style="display: none;">
900
  <div class="wapk-dr-modal-header">
901
  <h3><?php esc_html_e( 'Submit Support Ticket.', 'webappick' ); ?></h3>
@@ -936,7 +1002,7 @@ class Insights {
936
  <div class="wapk-row mui">
937
  <label for="wapk-support-message"><?php esc_html_e( 'Message', 'webappick' ); ?></label>
938
  <div class="wapk-form-control">
939
- <textarea id="wapk-support-message" name="message" rows="11" required></textarea>
940
  </div>
941
  </div>
942
  <div class="response">
@@ -969,7 +1035,7 @@ class Insights {
969
  </ul>
970
  <div class="response" style="<?php echo ( $showSupportTicket ) ? 'display: block;' : ''; ?>">
971
  <div class="wrapper">
972
- <?php if( $showSupportTicket ) { ?>
973
  <p><?php esc_html_e( 'In trouble? Please submit a support request.', 'webappick' ); ?></p>
974
  <p>
975
  <a href="#" class="button button-secondary not-interested"><?php esc_html_e( 'Not Interested', 'webappick' ); ?></a>
@@ -1075,7 +1141,10 @@ class Insights {
1075
  return $.ajax({
1076
  url: ajaxurl,
1077
  type: 'POST',
1078
- data: $.fn.extend({}, {action: '<?php echo $this->client->getSlug(); ?>_submit-uninstall-reason'}, data), // add default action if action is empty.
 
 
 
1079
  beforeSend: function () {
1080
  buttonElem.addClass("disabled");
1081
  buttonElem.text('<?php esc_html_e( 'Processing...', 'webappick' ); ?>');
@@ -1089,8 +1158,8 @@ class Insights {
1089
  }
1090
  });
1091
  }
1092
- // Variables
1093
- var modal = $('#<?php echo $this->client->getSlug(); ?>-wapk-dr-modal'),
1094
  deactivateLink = '',
1095
  reason = modal.find('.reason'),
1096
  support = modal.find('.support'),
@@ -1182,7 +1251,7 @@ class Insights {
1182
  });
1183
  }
1184
  // the clicker
1185
- $('#the-list').on('click', 'a.<?php echo $this->client->getSlug(); ?>-deactivate-link', function (e) {
1186
  preventDefault(e);
1187
  modal.addClass('modal-active');
1188
  deactivateLink = $(this).attr('href');
@@ -1241,7 +1310,7 @@ class Insights {
1241
  if (!validMessage) return;
1242
  var buttonElem = $(this),
1243
  __BTN_TEXT__ = buttonElem.text(),
1244
- data = {action: '<?php echo $this->client->getSlug(); ?>_submit-support-ticket',};
1245
  mui.each( function () { data[$(this).attr('name')] = $(this).val() } );
1246
  _ajax(data, $(this), function (jqXhr) {
1247
  var response = jqXhr.event.responseJSON;
@@ -1270,28 +1339,30 @@ class Insights {
1270
  /**
1271
  * Run after theme deactivated
1272
  *
1273
- * @param string $new_name
1274
- * @param WP_Theme $new_theme
1275
- * @param WP_Theme $old_theme
1276
  *
1277
  * @return void
1278
  */
1279
  public function theme_deactivated( $new_name, $new_theme, $old_theme ) {
1280
- // Make sure this is WebAppick theme
1281
  if ( $old_theme->get_template() == $this->client->getSlug() ) {
1282
  $current_user = wp_get_current_user();
1283
  /** @noinspection PhpUndefinedFieldInspection */
1284
  $data = [
1285
  'hash' => $this->client->getHash(),
1286
  'reason_id' => 'none',
1287
- 'reason_info' => json_encode( [
1288
- 'new_theme' => [
1289
- 'name' => $new_name,
1290
- 'version' => $new_theme->version,
1291
- 'parent_theme' => $new_name->parent_theme,
1292
- 'author' => $new_name->parent_theme,
1293
- ],
1294
- ] ),
 
 
1295
  'site' => $this->__get_site_name(),
1296
  'url' => esc_url( home_url() ),
1297
  'admin_email' => get_option( 'admin_email' ),
@@ -1312,7 +1383,7 @@ class Insights {
1312
  * @return string
1313
  */
1314
  private function __get_user_ip_address() {
1315
- $response = wp_remote_get( 'https://icanhazip.com/' );
1316
  if ( is_wp_error( $response ) ) {
1317
  return '';
1318
  }
@@ -1341,4 +1412,4 @@ class Insights {
1341
  return $site_name;
1342
  }
1343
  }
1344
- // End of file Insights.php
1
  <?php
 
 
 
 
 
2
  /**
3
  * WebAppick Insights
4
  *
5
  * @version 1.0.1
6
+ * @package WebAppick
7
+ * @subpackage AppServices
8
  *
9
  * This is a tracker class to track plugin usage based on if the customer has opted in.
10
  * No personal information is being tracked by this class, only general settings, active plugins, environment details
11
  * and admin email.
12
  */
13
+
14
+ namespace WebAppick\AppServices;
15
+
16
+ use Exception;
17
+ use WP_Theme;
18
+ use WP_User;
19
+
20
+ if ( ! defined( 'ABSPATH' ) ) {
21
+ die();
22
+ }
23
+
24
+ /**
25
+ * Class Insights
26
+ */
27
  class Insights {
28
 
29
  /**
78
  */
79
  protected $supportResponse = '';
80
 
81
+ /**
82
+ * Error Response for the support ticket
83
+ * @var string
84
+ */
85
  protected $supportErrorResponse = '';
86
+
87
+ /**
88
+ * Support Page URL
89
+ * @var string
90
+ */
91
  protected $supportURL = '';
92
 
93
  /**
94
  * Initialize the class
95
  *
96
+ * @param Client $client The client.
97
+ * @param string $name readable name of the Plugin/Theme.
98
+ * @param string $file main Plugin/Theme file path.
99
  */
100
  public function __construct( $client, $name = null, $file = null ) {
101
  if ( is_string( $client ) && ! empty( $name ) && ! empty( $file ) ) {
120
  /**
121
  * Add extra data if needed
122
  *
123
+ * @param array $data Extra data.
124
  *
125
  * @return Insights
126
  */
133
  /**
134
  * Set custom notice text
135
  *
136
+ * @param string $text Admin Notice Test.
137
  *
138
  * @return Insights
139
  */
149
  * @return void
150
  */
151
  public function init() {
152
+ // Env Setup.
153
  $projectSlug = $this->client->getSlug();
154
  /**
155
  * Support Page URL
156
  * @param string $supportURL
157
  */
158
+ $supportURL = apply_filters( "WebAppick_{$projectSlug}_Support_Page_URL" , false );
159
+ if ( FALSE !== $supportURL ) {
160
  $supportURL = esc_url_raw( $supportURL, [ 'http', 'https' ] );
161
+ if ( ! empty( $supportURL ) ) {
162
+ $this->supportURL = $supportURL;
163
+ }
164
  }
165
  /**
166
  * Set Ticket Recipient Email
167
  * @param string $ticketRecipient
168
  */
169
  $ticketRecipient = apply_filters( "WebAppick_{$projectSlug}_Support_Ticket_Recipient_Email" , false );
170
+ if ( FALSE !== $ticketRecipient && is_email( $ticketRecipient ) ) {
171
  $this->ticketRecipient = sanitize_email( $ticketRecipient );
172
  }
173
  /**
174
  * Set Support Ticket Template For sending the email query.
175
  * @param string $ticketTemplate
176
  */
177
+ $ticketTemplate = apply_filters( "WebAppick_{$projectSlug}_Support_Ticket_Email_Template", false );
178
+ if ( FALSE !== $ticketTemplate ) {
179
  $this->ticketTemplate = $ticketTemplate;
180
  }
181
 
182
+ // initialize.
183
  if ( $this->client->getType() == 'plugin' ) {
184
  $this->init_plugin();
185
  } elseif ( $this->client->getType() == 'theme' ) {
206
  * @return void
207
  */
208
  private function init_plugin() {
209
+ // plugin deactivate popup.
210
  if ( ! $this->__is_local_server() ) {
211
  add_action( 'plugin_action_links_' . $this->client->getBasename(), [ $this, 'plugin_action_links' ] );
212
  add_action( 'admin_footer', [ $this, 'deactivate_scripts' ] );
225
  */
226
  protected function init_common() {
227
  if ( $this->show_notice ) {
228
+ // tracking notice.
229
  add_action( 'admin_notices', [ $this, 'admin_notice' ] );
230
  }
231
  add_action( 'admin_init', [ $this, 'handle_optIn_optOut' ] );
232
  add_action( 'removable_query_args', [ $this, 'add_removable_query_args' ], 10, 1 );
233
+ // uninstall reason.
234
  add_action( 'wp_ajax_' . $this->client->getSlug() . '_submit-uninstall-reason', [ $this, 'uninstall_reason_submission' ] );
235
  add_action( 'wp_ajax_' . $this->client->getSlug() . '_submit-support-ticket', [ $this, 'support_ticket_submission' ] );
236
+ // cron events.
237
  add_filter( 'cron_schedules', [ $this, 'add_weekly_schedule' ] );
238
  add_action( $this->client->getSlug() . '_tracker_send_event', [ $this, 'send_tracking_data' ] );
 
239
  }
240
 
241
  /**
242
  * Send tracking data to WebAppick server
243
  *
244
+ * @param boolean $override override current settings.
245
  *
246
  * @return void
247
  */
248
  public function send_tracking_data( $override = false ) {
249
+ // skip on AJAX Requests.
250
  if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
251
  return;
252
  }
253
  if ( ! $this->is_tracking_allowed() && ! $override ) {
254
  return;
255
  }
256
+ // Send a maximum of once per week.
257
  $last_send = $this->__get_last_send();
258
  /**
259
  * Tracking interval
267
  try {
268
  $intervalCheck = strtotime( $trackingInterval );
269
  } catch ( Exception $e ) {
270
+ // fallback to default 1 week if filter returned unusable data.
271
  $intervalCheck = strtotime( '-1 week' );
272
  }
273
  if ( $last_send && $last_send > $intervalCheck && ! $override ) {
299
  'hash' => $this->client->getHash(),
300
  'server' => $this->__get_server_info(),
301
  'wp' => $this->__get_wp_info(),
 
302
  'active_plugins' => $all_plugins['active_plugins'],
303
  'inactive_plugins' => $all_plugins['inactive_plugins'],
304
  'ip_address' => $this->__get_user_ip_address(),
305
  'theme' => get_stylesheet(),
306
  ];
307
+ // for child classes.
308
+ $extra = $this->get_extra_data();
309
+ if ( ! empty( $extra ) ) {
310
  $data['extra'] = $extra;
311
  }
312
 
336
  return $data;
337
  }
338
 
339
+ /**
340
+ * Get the message array of what data being collected
341
+ * @return array
342
+ */
343
  public function get_data_collection_description() {
344
  return $this->data_we_collect();
345
  }
350
  * @return WP_User
351
  */
352
  private function __get_admin() {
353
+ $admins = get_users(
354
+ [
355
+ 'role' => 'administrator',
356
+ 'orderby' => 'ID',
357
+ 'order' => 'ASC',
358
+ 'number' => 1,
359
+ 'paged' => 1,
360
+ ]
361
+ );
362
 
363
  return ( is_array( $admins ) && ! empty( $admins ) ) ? $admins[0] : new WP_User();
364
  }
401
  * @return boolean
402
  */
403
  private function __is_local_server() {
404
+ // phpcs:disable
405
  return apply_filters( 'WebAppick_is_local', in_array( $_SERVER['REMOTE_ADDR'], [ '127.0.0.1', '::1' ] ) );
406
+ // phpcs:enable
407
  }
408
 
409
  /**
444
  return;
445
  }
446
 
447
+ // don't show tracking if a local server.
448
  if ( ! $this->__is_local_server() ) {
449
 
450
  if ( empty( $this->notice ) ) {
451
+ $notice = sprintf(
452
+ apply_filters(
453
+ $this->client->getSlug() . '_tracking_default_notice_message',
454
+ /* translators: 1: plugin name */
455
+ esc_html__( 'Want to help make %1$s even more awesome? Allow %1$s to collect non-sensitive diagnostic data and usage information.', 'webappick' )
456
+ ),
457
+ '<strong>' . esc_html( $this->client->getName() ) . '</strong>'
458
+ );
459
  } else {
460
  $notice = $this->notice;
461
  }
462
 
463
+ $notice .= ' (<a class="' . $this->client->getSlug() . '-insights-data-we-collect" href="#">' . esc_html__( 'what we collect', 'webappick' ) . '</a>)';
464
+ $notice .= '<p class="description" style="display:none;">' . implode( ', ', $this->data_we_collect() ) . '. ' . esc_html__( 'No sensitive data is tracked.', 'webappick' ) . '</p>';
 
 
 
465
  echo '<div class="updated"><p>';
466
+ echo $notice; // phpcs:ignore xss ok
467
  echo '</p><p class="submit">';
468
+ echo '&nbsp;<a href="' . esc_url( $this->get_opt_out_url() ) . '" class="button button-secondary">' . esc_html__( 'No thanks', 'webappick' ) . '</a>';
469
+ echo '&nbsp;<a href="' . esc_url( $this->get_opt_in_url() ) . '" class="button button-primary">' . esc_html__( 'Allow', 'webappick' ) . '</a>';
 
 
470
  echo '</p></div>';
471
+ echo "<script type='text/javascript'>jQuery('." . esc_attr( $this->client->getSlug() ) . "-insights-data-we-collect').on('click', function(e) {
472
  e.preventDefault();
473
  jQuery(this).parents('.updated').find('p.description').slideToggle('fast');
474
  });</script>";
480
  * @return string
481
  */
482
  public function get_opt_in_url() {
483
+ return add_query_arg(
484
+ [
485
+ $this->client->getSlug() . '_tracker_optIn' => 'true',
486
+ '_wpnonce' => wp_create_nonce( $this->client->getSlug() . '_insight_action' ),
487
+ ]
488
+ );
489
  }
490
 
491
  /**
493
  * @return string
494
  */
495
  public function get_opt_out_url() {
496
+ return add_query_arg(
497
+ [
498
+ $this->client->getSlug() . '_tracker_optOut' => 'true',
499
+ '_wpnonce' => wp_create_nonce( $this->client->getSlug() . '_insight_action' ),
500
+ ]
501
+ );
502
  }
503
 
504
  /**
507
  * @return void
508
  */
509
  public function handle_optIn_optOut() {
510
+ if ( isset( $_REQUEST['_wpnonce'] ) && ( isset( $_GET[ $this->client->getSlug() . '_tracker_optIn' ] ) || isset( $_GET[ $this->client->getSlug() . '_tracker_optIn' ] ) ) ) {
511
+ check_admin_referer( $this->client->getSlug() . '_insight_action' );
512
+ if ( isset( $_GET[ $this->client->getSlug() . '_tracker_optIn' ] ) && 'true' == $_GET[ $this->client->getSlug() . '_tracker_optIn' ] ) {
513
+ $this->optIn();
514
+ wp_safe_redirect( remove_query_arg( $this->client->getSlug() . '_tracker_optIn' ) );
515
+ exit;
516
+ }
517
+ if ( isset( $_GET[ $this->client->getSlug() . '_tracker_optOut' ] ) && 'true' == $_GET[ $this->client->getSlug() . '_tracker_optOut' ] ) {
518
+ $this->optOut();
519
+ wp_safe_redirect( remove_query_arg( $this->client->getSlug() . '_tracker_optOut' ) );
520
+ exit;
521
+ }
522
  }
523
  }
524
 
525
  /**
526
  * Add query vars to removable query args array
527
  *
528
+ * @param array $removable_query_args array of removable args.
529
  *
530
  * @return array
531
  */
532
  public function add_removable_query_args( $removable_query_args ) {
533
+ return array_merge(
534
+ $removable_query_args,
535
+ [ $this->client->getSlug() . '_tracker_optIn', $this->client->getSlug() . '_tracker_optOut', '_wpnonce' ]
536
+ );
537
  }
538
 
539
  /**
566
  /**
567
  * Get the number of post counts
568
  *
569
+ * @param string $post_type PostType name to get count for.
570
  *
571
  * @return integer
572
  */
573
  public function get_post_count( $post_type ) {
574
  global $wpdb;
575
+ // phpcs:disable
576
+ return (int) $wpdb->get_var(
577
+ $wpdb->prepare(
578
+ "SELECT count(ID) FROM $wpdb->posts WHERE post_type = %s and post_status = 'publish'",
579
+ $post_type
580
+ )
581
+ );
582
+ // phpcs:enable
583
  }
584
 
585
  /**
590
  private function __get_server_info() {
591
  global $wpdb;
592
  $server_data = [
593
+ 'software' => ( isset( $_SERVER['SERVER_SOFTWARE'] ) && ! empty( $_SERVER['SERVER_SOFTWARE'] ) ) ? sanitize_text_field( $_SERVER['SERVER_SOFTWARE'] ) : 'N/A',
594
  'php_version' => ( function_exists( 'phpversion' ) ) ? phpversion() : 'N/A',
595
  'mysql_version' => $wpdb->db_version(),
596
+ 'php_execution_time' => @ini_get( 'max_execution_time' ), // phpcs:ignore
597
  'php_max_upload_size' => size_format( wp_max_upload_size() ),
598
  'php_default_timezone' => date_default_timezone_get(),
599
  'php_soap' => class_exists( 'SoapClient' ) ? 'Yes' : 'No',
637
  foreach ( $plugins as $k => $v ) {
638
  // Take care of formatting the data how we want it.
639
  $formatted = [
640
+ 'name' => isset( $v['Name'] ) ? wp_strip_all_tags( $v['Name'] ) : '',
641
+ 'version' => isset( $v['Version'] ) ? wp_strip_all_tags( $v['Version'] ) : 'N/A',
642
+ 'author' => isset( $v['Author'] ) ? wp_strip_all_tags( $v['Author'] ) : 'N/A',
643
+ 'network' => isset( $v['Network'] ) ? wp_strip_all_tags( $v['Network'] ) : 'N/A',
644
+ 'plugin_uri' => isset( $v['PluginURI'] ) ? wp_strip_all_tags( $v['PluginURI'] ) : 'N/A',
645
  ];
646
  if ( in_array( $k, $active_plugins_keys ) ) {
647
+ unset( $plugins[ $k ] ); // Remove active plugins from list so we can show active and inactive separately0
648
  $active_plugins[ $k ] = $formatted;
649
  } else {
650
  $plugins[ $k ] = $formatted;
651
  }
652
  }
653
 
654
+ return [
655
+ 'active_plugins' => $active_plugins,
656
+ 'inactive_plugins' => $plugins,
657
+ ];
658
  }
659
 
660
  /**
666
  $user_count = [];
667
  $user_count_data = count_users();
668
  $user_count['total'] = $user_count_data['total_users'];
669
+ // Get user count based on user role.
670
  foreach ( $user_count_data['avail_roles'] as $role => $count ) {
671
  $user_count[ $role ] = $count;
672
  }
677
  /**
678
  * Add weekly cron schedule
679
  *
680
+ * @param array $schedules Cron Schedules.
681
  *
682
  * @return array
683
  */
697
  */
698
  public function activate_plugin() {
699
  $allowed = get_option( $this->client->getSlug() . '_allow_tracking', 'no' );
700
+ // if it wasn't allowed before, do nothing.
701
  if ( 'yes' !== $allowed ) {
702
  return;
703
  }
704
+ // re-schedule and delete the last sent time so we could force send again.
705
  wp_schedule_event( time(), 'weekly', $this->client->getSlug() . '_tracker_send_event' );
 
706
  delete_option( $this->client->getSlug() . '_tracking_last_send' );
707
  $this->send_tracking_data( true );
708
  }
714
  */
715
  public function deactivation_cleanup() {
716
  $this->__clear_schedule_event();
 
717
  if ( 'theme' == $this->client->getType() ) {
718
  delete_option( $this->client->getSlug() . '_tracking_last_send' );
719
  delete_option( $this->client->getSlug() . '_allow_tracking' );
724
  /**
725
  * Hook into action links and modify the deactivate link
726
  *
727
+ * @param array $links Plugin Action Links.
728
  *
729
  * @return array
730
  */
731
  public function plugin_action_links( $links ) {
732
 
733
  if ( array_key_exists( 'deactivate', $links ) ) {
734
+ $links['deactivate'] = str_replace( '<a', '<a class="' . $this->client->getSlug() . '-deactivate-link"', $links['deactivate'] );
 
 
735
  }
736
 
737
  return $links;
758
  ],
759
  [
760
  'id' => 'not-have-that-feature',
761
+ 'text' => esc_html__( 'The plugin is great, but I need specific feature that you don\'t support', 'webappick' ),
 
762
  'type' => 'textarea',
763
  'placeholder' => esc_html__( 'Could you tell us more about that feature?', 'webappick' ),
764
  ],
794
  ],
795
  ];
796
  $extra = apply_filters( $this->client->getSlug() . '_extra_uninstall_reasons', [], $reasons );
797
+ if ( is_array( $extra ) && ! empty( $extra ) ) {
798
+ // extract the last (other) reason and add after extras.
799
  $other = array_pop( $reasons );
800
  $reasons = array_merge( $reasons, $extra, [ $other ] );
801
  }
808
  * @return void
809
  */
810
  public function uninstall_reason_submission() {
811
+ check_ajax_referer( $this->client->getSlug() . '_insight_action' );
812
+ if ( ! isset( $_POST['reason_id'] ) ) {
813
+ wp_send_json_error( esc_html__( 'Invalid Request', 'webappick' ) );
814
+ wp_die();
815
+ }
816
  $current_user = wp_get_current_user();
817
  global $wpdb;
818
  // @TODO remove deprecated data after server update
819
  $data = [
820
  'hash' => $this->client->getHash(),
821
  'reason_id' => isset( $_REQUEST['reason_id'] ) && ! empty( $_REQUEST['reason_id'] ) ? sanitize_text_field( $_REQUEST['reason_id'] ) : '',
 
822
  'reason_info' => isset( $_REQUEST['reason_info'] ) ? trim( sanitize_textarea_field( $_REQUEST['reason_info'] ) ) : '',
 
823
  'plugin' => $this->client->getName(),
824
  'site' => $this->__get_site_name(),
825
  'url' => esc_url( home_url() ),
826
  'admin_email' => get_option( 'admin_email' ),
827
  'user_email' => $current_user->user_email,
828
  'user_name' => $current_user->display_name,
829
+ // deprecated.
830
  'first_name' => ( ! empty( $current_user->first_name ) ) ? $current_user->first_name : $current_user->display_name,
831
  'last_name' => $current_user->last_name,
832
  'server' => $this->__get_server_info(),
833
+ 'software' => isset( $_SERVER['SERVER_SOFTWARE'] ) ? sanitize_text_field( $_SERVER['SERVER_SOFTWARE'] ) : 'Generic', // deprecated, using $data['server'] for wp info.
834
+ 'php_version' => phpversion(), // deprecated, using $data['server'] for wp info.
835
+ 'mysql_version' => $wpdb->db_version(), // deprecated, using $data['server'] for wp info.
 
 
 
836
  'wp' => $this->__get_wp_info(),
837
+ 'wp_version' => get_bloginfo( 'version' ), // deprecated, using $data['wp'] for wp info.
838
+ 'locale' => get_locale(), // deprecated, using $data['wp'] for wp info.
839
+ 'multisite' => is_multisite() ? 'Yes' : 'No', // deprecated, using $data['wp'] for wp info.
 
 
 
840
  'ip_address' => $this->__get_user_ip_address(),
841
  'version' => $this->client->getProjectVersion(),
842
  ];
843
+ // Add extra data.
844
+ $extra = $this->get_extra_data();
845
+ if ( ! empty( $extra ) ) {
846
  $data['extra'] = $extra;
847
  }
848
  $this->client->send_request( $data, 'reason' );
849
  wp_send_json_success();
850
+ wp_die();
851
  }
852
 
853
+ /**
854
+ * Handle Support Ticket Submission
855
+ * @return void
856
+ */
857
  public function support_ticket_submission() {
858
+ check_ajax_referer( $this->client->getSlug() . '_insight_action' );
859
+ if ( empty( $this->ticketTemplate ) || empty( $this->ticketRecipient ) || empty( $this->supportURL ) ) {
860
+ wp_send_json_error(
861
+ sprintf(
862
+ '<p class="mui-error">%s<br>%s</p>',
863
+ esc_html__( 'Something Went Wrong.', 'webappick' ),
864
+ esc_html__( 'Please try again after sometime.', 'webappick' )
865
+ )
866
+ );
867
+ wp_die();
868
  }
869
  if (
870
  isset( $_REQUEST['name'], $_REQUEST['email'], $_REQUEST['subject'], $_REQUEST['website'], $_REQUEST['message'] ) &&
878
  ) {
879
  $headers = [
880
  'Content-Type: text/html; charset=UTF-8',
881
+ sprintf(
882
+ 'From: %s <%s>',
883
  sanitize_text_field( $_REQUEST['name'] ),
884
+ sanitize_email( $_REQUEST['email'] )
885
+ ),
886
+ sprintf(
887
+ 'Reply-To: %s <%s>',
888
  sanitize_text_field( $_REQUEST['name'] ),
889
+ sanitize_text_field( $_REQUEST['email'] )
890
+ ),
891
  ];
892
 
893
  foreach ( $_REQUEST as $k => $v ) {
894
  $sanitizer = 'sanitize_text_field';
895
+ if ( 'email' == $k ) {
896
+ $sanitizer = 'sanitize_email';
897
+ }
898
+ if ( 'website' == $k ) {
899
+ $sanitizer = 'esc_url';
900
+ }
901
+ $v = call_user_func_array( $sanitizer, [ $v ] );
902
+ $_REQUEST[ $k ] = $v; // phpcs: sanitize ok.
903
+ $k = '__' . strtoupper( $k ) . '__';
904
  $this->ticketTemplate = str_replace( [ $k ], [ $v ], $this->ticketTemplate );
905
  }
906
  $projectSlug = $this->client->getSlug();
907
+ $isSent = wp_mail( $this->ticketRecipient, sanitize_text_field( $_REQUEST['subject'] ), sprintf( '<div>%s</div>', $this->ticketTemplate ), $headers );// phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.wp_mail_wp_mail
908
+ if ( $isSent ) {
909
  /**
910
  * Set Ajax Success Response for Support Ticket Submission
911
  * @param string $supportResponse
912
  * @param array $_REQUEST
913
  */
914
+ $supportResponse = apply_filters( "WebAppick_{$projectSlug}_Support_Request_Ajax_Success_Response" , false, $_REQUEST );
915
+ if ( false !== $supportResponse ) {
916
  $this->supportResponse = $supportResponse;
917
  } else {
918
  $this->supportResponse = sprintf(
921
  );
922
  }
923
  wp_send_json_success( $this->supportResponse );
924
+ wp_die();
925
  } else {
926
  /**
927
  * Set Support Ticket Ajax Error Response.
928
  * @param string $supportErrorResponse
929
  * @param array $_REQUEST
930
  */
931
+ $supportErrorResponse = apply_filters( "WebAppick_{$projectSlug}_Support_Request_Ajax_Error_Response" , false, $_REQUEST );
932
+ if ( false !== $supportErrorResponse ) {
933
  $this->supportErrorResponse = $supportErrorResponse;
934
  } else {
935
  $this->supportErrorResponse = sprintf(
942
  } else {
943
  wp_send_json_error( sprintf( '<p class="mui-error">%s</p>', esc_html__( 'Missing Required Fields.', 'webappick' ) ) );
944
  }
945
+ wp_die();
946
  }
947
 
948
  /**
958
  $reasons = $this->__get_uninstall_reasons();
959
  $admin_user = $this->__get_admin();
960
  $displayName = ( ! empty( $admin_user->first_name ) && ! empty( $admin_user->last_name ) ) ? $admin_user->first_name . ' ' . $admin_user->last_name : $admin_user->display_name;
961
+ $showSupportTicket = ( ! empty( $this->ticketTemplate ) && ! empty( $this->ticketRecipient ) && ! empty( $this->supportURL ) );
962
  ?>
963
+ <div class="wapk-dr-modal" id="<?php echo esc_attr( $this->client->getSlug() ); ?>-wapk-dr-modal" aria-label="<?php /* translators: 1: Plugin Name */ printf( esc_attr__( '&ldquo;%s&rdquo; Uninstall Confirmation', 'webappick' ), esc_attr( $this->client->getName() ) ); ?>" role="dialog" aria-modal="true">
964
+ <?php if ( $showSupportTicket ) { ?>
965
  <div class="wapk-dr-modal-wrap support" style="display: none;">
966
  <div class="wapk-dr-modal-header">
967
  <h3><?php esc_html_e( 'Submit Support Ticket.', 'webappick' ); ?></h3>
1002
  <div class="wapk-row mui">
1003
  <label for="wapk-support-message"><?php esc_html_e( 'Message', 'webappick' ); ?></label>
1004
  <div class="wapk-form-control">
1005
+ <textarea id="wapk-support-message" name='message' rows="11" required></textarea>
1006
  </div>
1007
  </div>
1008
  <div class="response">
1035
  </ul>
1036
  <div class="response" style="<?php echo ( $showSupportTicket ) ? 'display: block;' : ''; ?>">
1037
  <div class="wrapper">
1038
+ <?php if ( $showSupportTicket ) { ?>
1039
  <p><?php esc_html_e( 'In trouble? Please submit a support request.', 'webappick' ); ?></p>
1040
  <p>
1041
  <a href="#" class="button button-secondary not-interested"><?php esc_html_e( 'Not Interested', 'webappick' ); ?></a>
1141
  return $.ajax({
1142
  url: ajaxurl,
1143
  type: 'POST',
1144
+ data: $.fn.extend( {}, {
1145
+ action: '<?php echo esc_attr( $this->client->getSlug() ); ?>_submit-uninstall-reason',
1146
+ _wpnonce: '<?php echo esc_attr( wp_create_nonce( $this->client->getSlug() . '_insight_action' ) ); ?>'
1147
+ }, data ), // add default action if action is empty.
1148
  beforeSend: function () {
1149
  buttonElem.addClass("disabled");
1150
  buttonElem.text('<?php esc_html_e( 'Processing...', 'webappick' ); ?>');
1158
  }
1159
  });
1160
  }
1161
+ // Variables.
1162
+ var modal = $('#<?php echo esc_attr( $this->client->getSlug() ); ?>-wapk-dr-modal'),
1163
  deactivateLink = '',
1164
  reason = modal.find('.reason'),
1165
  support = modal.find('.support'),
1251
  });
1252
  }
1253
  // the clicker
1254
+ $('#the-list').on('click', 'a.<?php echo esc_attr( $this->client->getSlug() ); ?>-deactivate-link', function (e) {
1255
  preventDefault(e);
1256
  modal.addClass('modal-active');
1257
  deactivateLink = $(this).attr('href');
1310
  if (!validMessage) return;
1311
  var buttonElem = $(this),
1312
  __BTN_TEXT__ = buttonElem.text(),
1313
+ data = {action: '<?php echo esc_attr( $this->client->getSlug() ); ?>_submit-support-ticket',};
1314
  mui.each( function () { data[$(this).attr('name')] = $(this).val() } );
1315
  _ajax(data, $(this), function (jqXhr) {
1316
  var response = jqXhr.event.responseJSON;
1339
  /**
1340
  * Run after theme deactivated
1341
  *
1342
+ * @param string $new_name New Theme Name.
1343
+ * @param WP_Theme $new_theme New Theme WP_Theme Object.
1344
+ * @param WP_Theme $old_theme Old Theme WP_Theme Object.
1345
  *
1346
  * @return void
1347
  */
1348
  public function theme_deactivated( $new_name, $new_theme, $old_theme ) {
1349
+ // Make sure this is WebAppick theme.
1350
  if ( $old_theme->get_template() == $this->client->getSlug() ) {
1351
  $current_user = wp_get_current_user();
1352
  /** @noinspection PhpUndefinedFieldInspection */
1353
  $data = [
1354
  'hash' => $this->client->getHash(),
1355
  'reason_id' => 'none',
1356
+ 'reason_info' => wp_json_encode(
1357
+ [
1358
+ 'new_theme' => [
1359
+ 'name' => $new_name,
1360
+ 'version' => $new_theme->version,
1361
+ 'parent_theme' => $new_name->parent_theme,
1362
+ 'author' => $new_name->parent_theme,
1363
+ ],
1364
+ ]
1365
+ ),
1366
  'site' => $this->__get_site_name(),
1367
  'url' => esc_url( home_url() ),
1368
  'admin_email' => get_option( 'admin_email' ),
1383
  * @return string
1384
  */
1385
  private function __get_user_ip_address() {
1386
+ $response = wp_safe_remote_get( 'https://icanhazip.com/' );
1387
  if ( is_wp_error( $response ) ) {
1388
  return '';
1389
  }
1412
  return $site_name;
1413
  }
1414
  }
1415
+ // End of file Insights.php.
libs/WebAppick/AppServices/License.php CHANGED
@@ -1,10 +1,21 @@
1
  <?php
2
- namespace WebAppick\AppServices;
3
- if( ! defined( 'ABSPATH' ) ) die();
4
  /**
5
  * WebAppick License Checker
6
  *
7
  * This class will check, active and deactivate license
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  */
9
  class License {
10
 
@@ -90,14 +101,14 @@ class License {
90
  /**
91
  * Initialize the class
92
  *
93
- * @param Client
94
  */
95
  public function __construct( Client $client ) {
96
  $this->client = $client;
97
  $this->option_key = 'WebAppick_' . md5( $this->client->getSlug() ) . '_manage_license';
98
  $this->data_key = $this->client->getSlug() . '-license';
99
  $this->schedule_hook = $this->client->getSlug() . '_license_check_event';
100
- // load the license
101
  $this->getLicense();
102
  add_action( 'init', [ $this, 'handle_license_page_form' ], 10 );
103
  }
@@ -108,15 +119,15 @@ class License {
108
  * @return void
109
  */
110
  public function init() {
111
- // check the validity and save the state
112
  $this->is_valid();
113
- // Run hook to check license status daily
114
  add_action( $this->schedule_hook, array( $this, 'check_license_status' ) );
115
  $this->currentUserCanManage = $this->menu_args['capability'];
116
- $this->isLicensePage = isset( $_GET['page'] ) && $_GET['page'] === $this->menu_args['menu_slug'];
117
  add_action( 'plugin_action_links_' . $this->client->getBasename(), [ $this, 'plugin_action_links' ] );
118
  add_action( 'admin_notices', array( $this, '__admin_notices' ), 10 );
119
- // Activation/Deactivation hooks
120
  $this->activation_deactivation();
121
  $this->didInit = true;
122
  }
@@ -130,32 +141,58 @@ class License {
130
  return $this->license['key'];
131
  }
132
 
 
 
 
 
133
  public function __admin_notices() {
134
  if ( ! current_user_can( $this->currentUserCanManage ) ) return;
135
  if ( defined( 'WP_HTTP_BLOCK_EXTERNAL' ) && WP_HTTP_BLOCK_EXTERNAL === true ) {
136
- $host = parse_url( $this->__getLicenceAPI(), PHP_URL_HOST );
137
  if ( ! defined( 'WP_ACCESSIBLE_HOSTS' ) || ( defined( 'WP_ACCESSIBLE_HOSTS' ) && false === stristr( WP_ACCESSIBLE_HOSTS, $host ) ) ) {
138
- ?><div class="notice notice-error">
139
- <p><?php printf( __( '<b>Warning!</b> You\'re blocking external requests which means you won\'t be able to get %s updates. Please add %s to %s.', 'webappick' ), $this->client->getName(), '<strong>' . $host . '</strong>', '<code>WP_ACCESSIBLE_HOSTS</code>' ); ?></p>
140
- </div><?php
 
 
 
 
 
 
 
 
 
 
 
141
  }
142
  }
143
- if ( ! $this->isLicensePage && ! $this->is_valid() ) { ?>
 
144
  <div class="notice notice-error">
145
- <p><?php printf( __( 'The <strong>%s</strong> API Key has not been activated, so the %s is inactive! %sClick here%s to activate <strong>%s</strong>.', 'webappick' ), esc_attr( $this->client->getName() ), esc_attr( $this->client->getType() ), '<a href="' . esc_url( admin_url( 'admin.php?page=' . $this->menu_args['menu_slug'] ) ) . '">', '</a>', esc_attr( $this->client->getName() ) ); ?></p>
 
 
 
 
 
 
 
 
 
146
  </div>
147
- <?php }
 
148
  if ( ! empty( $this->error ) ) {
149
  ?>
150
  <div class="notice notice-error is-dismissible">
151
- <p><?php echo $this->error; ?></p>
152
  </div>
153
  <?php
154
  }
155
  if ( ! empty( $this->success ) ) {
156
  ?>
157
  <div class="notice notice-success is-dismissible">
158
- <p><?php echo $this->success; ?></p>
159
  </div>
160
  <?php
161
  }
@@ -163,11 +200,11 @@ class License {
163
 
164
  /**
165
  * Setup plugin action link to the license page
166
- * @param array $links
167
  * @return array
168
  */
169
  public function plugin_action_links( $links ) {
170
- if( ! empty( $this->menu_args['menu_slug'] ) && ! empty( $this->menu_args['menu_title'] ) ) {
171
  /** @noinspection HtmlUnknownTarget */
172
  $links[] = sprintf( '<a href="%s">%s</a>', esc_url( admin_url( 'admin.php?page=' . $this->menu_args['menu_slug'] ) ), esc_html( $this->menu_args['menu_title'] ) );
173
  }
@@ -190,13 +227,17 @@ class License {
190
  return $this->send_request( 'update', $this->license );
191
  }
192
 
 
 
 
 
193
  public function get_information() {
194
  return $this->send_request( 'information', $this->license );
195
  }
196
 
197
  /**
198
  * Active a license
199
- * @param array $license
200
  * @return array
201
  */
202
  public function activate( $license ) {
@@ -214,23 +255,23 @@ class License {
214
  /**
215
  * Send common request
216
  *
217
- * @param string $action request action
218
- * @param array $license license data
219
  *
220
  * @return array
221
  */
222
  protected function send_request( $action, $license = [] ) {
223
- // WC-AM Valid Actions and response data types
224
  $actions = [
225
  'activate' => 'json',
226
  'deactivate' => 'json',
227
  'status' => 'json',
228
  'information' => 'json',
229
  'update' => 'json',
230
- 'plugininformation' => 'serialize', // serialize option doesn't provide success status
231
  'pluginupdatecheck' => 'serialize',
232
  ];
233
- if( ! in_array( $action, array_keys( $actions ) ) ) {
234
  return [
235
  'success' => false,
236
  'error' => esc_html__( 'Invalid Request Action.', 'webappick' ),
@@ -238,13 +279,13 @@ class License {
238
  }
239
  // parse license data
240
  $license = wp_parse_args( $license, $this->getLicense() );
241
- if( empty( $license['key'] ) || empty( $license['instance'] ) ) {
242
  return [
243
  'success' => false,
244
  'error' => esc_html__( 'Invalid/Empty License Data.', 'webappick' ),
245
  ];
246
  }
247
- if( empty( $this->client->getProjectId() ) && empty( $this->client->getName() ) ) {
248
  return [
249
  'success' => false,
250
  'error' => esc_html__( 'A valid project name/id is required.', 'webappick' ),
@@ -255,7 +296,7 @@ class License {
255
  'api_key' => $license['key'],
256
  'version' => $this->client->getProjectVersion(),
257
  'instance' => $license['instance'],
258
- 'product_id' => $this->client->getName(),//$this->client->getProjectId(),
259
  'plugin_name' => $this->client->getBasename(),
260
  'wc_am_action' => $action,
261
  ];
@@ -264,11 +305,11 @@ class License {
264
  $this->restoreAPI_URL();
265
  if ( ! is_wp_error( $response ) ) {
266
  $response = wp_remote_retrieve_body( $response );
267
- if( $actions[$action] == 'json' ) {
268
  $response = json_decode( $response, true );
269
  } else {
270
  $response = maybe_unserialize( $response );
271
- //@TODO check wc-am error ..
272
  return $response;
273
  }
274
  if ( empty( $response ) || ! isset( $response['success'] ) ) {
@@ -321,19 +362,19 @@ class License {
321
  /**
322
  * Add settings page for license
323
  *
324
- * @param array $args
325
  *
326
  * @return void
327
  */
328
  public function add_settings_page( $args = array() ) {
329
- if( $this->didInit ) {
330
  _doing_it_wrong( __METHOD__, sprintf( '<code>%s</code> Should be called before License::init()', __METHOD__ ), '1.0.1' );
331
  return;
332
  }
333
  $defaults = [
334
- 'type' => 'menu', // Can be: menu, options, submenu
335
- 'page_title' => __( 'Manage License', 'webappick' ),
336
- 'menu_title' => __( 'Manage License', 'webappick' ),
337
  'capability' => 'manage_options',
338
  'menu_slug' => $this->client->getSlug() . '-manage-license',
339
  'icon_url' => '',
@@ -341,10 +382,12 @@ class License {
341
  'parent_slug' => '',
342
  ];
343
  $this->menu_args = wp_parse_args( $args, $defaults );
344
- if( ! in_array( $this->menu_args['type'], [ 'menu', 'options', 'submenu' ] ) ) {
345
- if( empty( $this->menu_args['parent_slug'] ) ) $this->menu_args['type'] = 'menu';
 
 
346
  }
347
- if( $this->menu_args['type'] == 'submenu' && empty( $this->menu_args['parent_slug'] ) ) {
348
  $this->menu_args['type'] = 'options';
349
  }
350
  add_action( 'admin_menu', array( $this, 'admin_menu' ), 999 );
@@ -359,14 +402,14 @@ class License {
359
  switch ( $this->menu_args['type'] ) {
360
  case 'submenu':
361
  $this->add_submenu_page();
362
- break;
363
  case 'options':
364
  $this->add_options_page();
365
- break;
366
  case 'menu':
367
  default:
368
  $this->add_menu_page();
369
- break;
370
  }
371
  }
372
 
@@ -384,14 +427,15 @@ class License {
384
  <div class="webappick-license-settings webappick-license-section">
385
  <?php $this->show_license_page_card_header(); ?>
386
  <div class="webappick-license-details">
387
- <?php if( $action == 'activate' ) { ?>
388
  <p><?php
389
- printf( esc_html__( 'Active %s by your license key to get professional support and automatic update from your WordPress dashboard.', 'webappick' ), '<strong>'.$this->client->getName().'</strong>' );
 
390
  ?></p>
391
  <?php } ?>
392
  <form method="post" action="<?php $this->formActionUrl(); ?>" novalidate="novalidate" spellcheck="false" autocomplete="off">
393
  <?php wp_nonce_field( $this->data_key ); ?>
394
- <input type="hidden" name="<?php echo esc_attr( $this->data_key); ?>[_action]" value="<?php echo esc_attr( $action ); ?>">
395
  <div class="license-input-fields">
396
  <div class="license-input-key">
397
  <svg enable-background="new 0 0 512 512" version="1.1" viewBox="0 0 512 512" xml:space="preserve" xmlns="http://www.w3.org/2000/svg">
@@ -399,12 +443,13 @@ class License {
399
  </svg>
400
  <label for="license_key" class="screen-reader-text"><?php esc_html_e( 'License Key', 'webappick' ); ?></label>
401
  <input class="regular-text" id="license_key" type="text"
402
- value="<?php echo $this->get_input_license_value( $action, $this->license ); ?>"
403
- placeholder="<?php esc_attr_e( 'Enter your license key to activate', 'webappick' ); ?>"
404
- name="<?php echo esc_attr( $this->data_key); ?>[license_key]"<?php readonly( ( 'deactivate' == $action ), true, true ) ?> autocomplete="off">
 
405
  </div>
406
- <button type="submit" name="<?php echo esc_attr( $this->data_key); ?>[submit]" class="<?php printf( esc_attr( '%s-button' ), $action );?>"><?php
407
- $action == 'activate' ? esc_html_e( 'Activate License', 'webappick' ) : esc_html_e( 'Deactivate License', 'webappick' ) ;
408
  ?></button>
409
  <a href="http://webappick.com/my-account/api-keys/" class="button button-primary button-hero" style="margin-left: 20px;font-size: 17px;line-height: 2.5;" target="_blank"><?php esc_html_e( 'Manage License', 'webappick' ); ?></a>
410
  </div>
@@ -422,11 +467,11 @@ class License {
422
  * @return void
423
  */
424
  public function handle_license_page_form() {
425
- if( isset( $_POST[$this->data_key] ) ) {
426
  check_admin_referer( $this->data_key );
427
- switch ( $_POST[$this->data_key]['_action'] ) {
428
  case 'activate':
429
- $this->activate_client_license( $_POST[$this->data_key] );
430
  break;
431
  case 'deactivate':
432
  $this->deactivate_client_license();
@@ -438,51 +483,60 @@ class License {
438
  }
439
 
440
  /**
441
- * Check license status on schedule
 
 
442
  */
443
  public function check_license_status() {
444
  // get current license data.
445
  $license = $this->getLicense();
446
  if ( $license ) {
447
- // check license
448
  $response = $this->check();
449
  if ( isset( $response['success'], $response['status_check'] ) && $response['success'] ) {
450
- // update license status
451
- $license = wp_parse_args( [
452
- 'status' => $response['status_check'] == 'active' ? 'active' : 'inactive',
453
- 'remaining' => isset( $response['data'], $response['data']['activations_remaining'] ) ? $response['data']['activations_remaining'] : 0,
454
- 'activations' => isset( $response['data'], $response['data']['total_activations'] ) ? $response['data']['total_activations'] : 0,
455
- 'limit' => isset( $response['data'], $response['data']['total_activations_purchased'] ) ? $response['data']['total_activations_purchased'] : 0,
456
- 'unlimited' => isset( $response['data'], $response['data']['unlimited_activations'] ) ? $response['data']['unlimited_activations'] : false,
457
- 'expiry_date' => 0, // wc-am doesn't sent remaining date
458
- ], $license );
 
 
 
459
  } else {
460
  // Don't reset the key.
461
  // keep it, if the user renew subscription update the status and reactivate the plugin.
462
- $license = wp_parse_args( [
463
- 'status' => 'inactive',
464
- 'remaining' => 0,
465
- 'activations' => 0,
466
- 'limit' => 0,
467
- 'unlimited' => false,
468
- 'expiry_date' => 0, // wc-am doesn't sent remaining date
469
- ], $license );
 
 
 
470
  }
471
- // update the license state & and save in db
472
  $this->setLicense( $license );
473
  }
474
  }
475
 
476
  /**
477
- * Check this is a valid license
 
478
  */
479
  public function is_valid() {
480
  if ( null !== $this->is_valid_license ) {
481
  return $this->is_valid_license;
482
  }
483
- // load the license if already not loaded
484
  $this->getLicense();
485
- if ( isset( $this->license['status'] ) && $this->license['status'] == 'active' ) {
486
  $this->is_valid_license = true;
487
  } else {
488
  $this->is_valid_license = false;
@@ -492,15 +546,13 @@ class License {
492
  }
493
 
494
  /**
495
- * Read WooCommerce API Manager Data, Convert to new license format and save in db
 
496
  * @return bool
497
  */
498
- public function migrate_license_from_wc_am() {
499
- // if( false === get_option( $this->option_key . '_wc_am_migrated', false ) ) return false;
500
- // is already migrated
501
- // api manager data prefix
502
- $wcAmPrefix = str_ireplace( array( ' ', '_', '&', '?' ), '_', strtolower( $this->client->getName() ) );
503
- /*// WC AM data structure
504
  [
505
  '_data' => [ 'api_key', 'activation_email', ], // api key & email
506
  '_product_id' => '', // product title or name
@@ -508,20 +560,34 @@ class License {
508
  '_activated' => '', // activation status => Activated|Deactivated
509
  '_deactivate_checkbox' => '', // deactivation check box state > On|Off
510
  ];*/
 
 
 
 
 
 
 
 
511
  $license = [
512
- 'key' => '',
513
- 'status' => 'deactivate', // activate
514
- 'instance' => '', // max len 190
515
  ];
516
- // get key
517
  $data = get_option( $wcAmPrefix . '_data', false );
518
- if( $data && isset( $data['api_key'] ) ) $license['key'] = $data['api_key'];
519
- // instance id
 
 
520
  $data = get_option( $wcAmPrefix . '_instance', false );
521
- if( $data ) $license['instance'] = $data;
522
- // activation status
 
 
523
  $data = get_option( $wcAmPrefix . '_activated', false );
524
- if( $data ) $license['status'] = strtolower( $data ) === 'activated' ? 'active' : 'inactive'; // Deactivated
 
 
525
  $this->setLicense( $license );
526
  $this->check_license_status();
527
  update_option( $this->option_key . '_wc_am_migrated', 1, false );
@@ -567,7 +633,7 @@ class License {
567
  * @return void
568
  */
569
  private function show_active_license_info() {
570
- $status = ( isset( $this->license['status'] ) && $this->license['status'] === 'active' ) ? 'active' : 'inactive';
571
  $limit = isset( $this->license['limit'] ) ? $this->license['limit'] : 0;
572
  $activations = isset( $this->license['activations'] ) ? $this->license['activations'] : 0;
573
  $remaining = isset( $this->license['remaining'] ) ? $this->license['remaining'] : 0;
@@ -576,7 +642,7 @@ class License {
576
  <div class="active-license-info">
577
  <div class="single-license-info">
578
  <h3><?php esc_html_e( 'Status:', 'webappick' ); ?></h3>
579
- <p class="<?php echo esc_attr( $status ); ?>"><?php $status == 'active' ? esc_html_e( 'Active', 'webappick' ) : esc_html_e( 'Inactive', 'webappick' ); ?></p>
580
  </div>
581
  <?php if ( false !== $unlimited ) { ?>
582
  <div class="single-license-info">
@@ -585,20 +651,24 @@ class License {
585
  </div>
586
  <div class="single-license-info">
587
  <h3><?php esc_html_e( 'Total Activation:', 'webappick' ); ?></h3>
588
- <p class="active"><?php echo $activations; ?></p>
589
  </div>
590
  <?php } else { ?>
591
  <div class="single-license-info">
592
  <h3><?php esc_html_e( 'Activation Remaining:', 'webappick' ); ?></h3>
593
  <p class="<?php echo $remaining ? 'active' : 'inactive'; ?>"><?php
594
- if( $status == 'active' ) printf( esc_html__( '%1$d out of %2$d', 'webappick' ), $remaining, $limit );
595
- else esc_html_e( 'N/A', 'webappick' );
 
 
 
 
596
  ?></p>
597
  </div>
598
  <?php } ?>
599
  <div class="single-license-info">
600
  <h3><?php esc_html_e( 'Automatic Update:', 'webappick' ); ?></h3>
601
- <p class="<?php echo $status; ?>"><?php $status == 'active' ? esc_html_e( 'Enabled', 'webappick' ) : esc_html_e( 'Disabled', 'webappick' ); ?></p>
602
  </div>
603
  </div>
604
  <?php
@@ -623,7 +693,7 @@ class License {
623
 
624
  /**
625
  * Active client license
626
- * @param array $postData $_POST Data
627
  * @return void
628
  */
629
  private function activate_client_license( $postData ) {
@@ -631,22 +701,22 @@ class License {
631
  $this->error = esc_html__('The license key field is required.', 'webappick' );
632
  return;
633
  }
634
- $key = sanitize_text_field( $postData['license_key'] );
635
  $license = (array) $this->getLicense();
636
- // check if it's a change request
637
- $updateKey = ( isset( $this->license['key'] ) && $key === $this->license['key'] ) ? true : false;
638
- if( $updateKey ) {
639
  $deactivate = $this->deactivate(); // deactivate first.
640
  if ( ! $deactivate['success'] ) {
641
- $check = $this->check(); // check api status
642
- if( $check['success'] && $check['status_check'] != 'inactive' ) {
643
  $this->error = $deactivate['error'] ? $deactivate['error'] : esc_html__( 'Unknown error occurred.', 'webappick' );
644
  return;
645
  }
646
  }
647
  }
648
- $license['key'] = $key;
649
- if( empty( $license['instance'] ) ) $license['instance'] = $this->generateInstanceId();
650
  $response = $this->activate( $license );
651
  if ( ! $response['success'] ) {
652
  $this->error = $response['error'] ? $response['error'] : esc_html__( 'Unknown error occurred.', 'webappick' );
@@ -654,16 +724,19 @@ class License {
654
  }
655
  // Don't reset the key.
656
  // keep it, if the user renew subscription update the status and reactivate the plugin.
657
- $license = array_merge( $license, [
658
- 'status' => isset( $response['activated'] ) && $response['activated'] ? 'active' : 'inactive',
659
- 'remaining' => isset( $response['data'], $response['data']['activations_remaining'] ) ? $response['data']['activations_remaining'] : 0,
660
- 'activations' => isset( $response['data'], $response['data']['total_activations'] ) ? $response['data']['total_activations'] : 0,
661
- 'limit' => isset( $response['data'], $response['data']['total_activations_purchased'] ) ? $response['data']['total_activations_purchased'] : 0,
662
- 'unlimited' => isset( $response['data'], $response['data']['unlimited_activations'] ) ? $response['data']['unlimited_activations'] : false,
663
- 'expiry_date' => 0, // wc-am doesn't sent remaining date
664
- ] );
 
 
 
665
  $this->setLicense( $license );
666
- if( ! $updateKey ) {
667
  $this->success = esc_html__( 'License activated successfully.', 'webappick' );
668
  } else {
669
  $this->success = esc_html__( 'License Updated successfully.', 'webappick' );
@@ -671,7 +744,8 @@ class License {
671
  }
672
 
673
  /**
674
- * deactivate client license
 
675
  */
676
  private function deactivate_client_license() {
677
  if ( ! isset( $this->license['key'] ) || empty( $this->license['key'] ) ) {
@@ -679,48 +753,59 @@ class License {
679
  } else {
680
  $response = $this->deactivate();
681
  if ( ! $response['success'] ) {
682
- // check api status
683
  $check = $this->check();
684
- if( $check['success'] && $check['status_check'] != 'inactive' ) {
685
  $this->error = $response['error'] ? $response['error'] : esc_html__( 'Unknown error occurred.', 'webappick' );
686
  }
687
  }
688
  }
689
- // keep the instance key for reference
690
  $this->setLicense( [ 'instance' => $this->license['instance'] ] );
691
  $this->success = esc_html__( 'License deactivated successfully.', 'webappick' );
692
  }
693
 
694
  /**
695
- * Add license menu page
 
696
  */
697
  private function add_menu_page() {
698
  add_menu_page(
699
- esc_html( $this->menu_args['page_title'] ), esc_html( $this->menu_args['menu_title'] ),
700
- $this->menu_args['capability'], $this->menu_args['menu_slug'],
 
 
701
  array( $this, 'menu_output' ),
702
- $this->menu_args['icon_url'], $this->menu_args['position']
 
703
  );
704
  }
705
 
706
  /**
707
- * Add submenu page
 
708
  */
709
  private function add_submenu_page() {
710
  add_submenu_page(
711
- $this->menu_args['parent_slug'], esc_html( $this->menu_args['page_title'] ),
712
- esc_html( $this->menu_args['menu_title'] ), $this->menu_args['capability'],
713
- $this->menu_args['menu_slug'], array( $this, 'menu_output' )
 
 
 
714
  );
715
  }
716
 
717
  /**
718
- * Add submenu page
 
719
  */
720
  private function add_options_page() {
721
  add_options_page(
722
- esc_html( $this->menu_args['page_title'] ), esc_html( $this->menu_args['menu_title'] ),
723
- $this->menu_args['capability'], $this->menu_args['menu_slug'],
 
 
724
  array( $this, 'menu_output' )
725
  );
726
  }
@@ -736,14 +821,15 @@ class License {
736
  }
737
 
738
  /**
739
- * Clear any scheduled hook
 
740
  */
741
  public function clear_scheduler() {
742
  wp_clear_scheduled_hook( $this->schedule_hook );
743
  }
744
 
745
  /**
746
- * Register Activation And Deactivation Hooks
747
  * @return void
748
  */
749
  private function activation_deactivation() {
@@ -763,6 +849,7 @@ class License {
763
 
764
  /**
765
  * Project Deactivation Callback.
 
766
  */
767
  public function project_deactivation() {
768
  $this->clear_scheduler();
@@ -773,40 +860,51 @@ class License {
773
  /**
774
  * Redirect to the license activation page after plugin/theme is activated.
775
  * @TODO make option for the plugin/theme (which is using this lib) can alter this method with their custom function.
776
- * @param string $param1 Plugin: base file|Theme: old theme name
777
- * @param bool|WP_Theme $param2 Plugin: network wide activation status|Theme: WP_Theme instance of the old theme
778
  * @return void
779
  */
780
  public function redirect_to_license_page( $param1, $param2 ) {
781
  $canRedirect = false;
782
- if( $this->client->getType() == 'plugin' ) $canRedirect = ( $param1 == $this->client->getBasename() );
783
- if( $this->client->getType() == 'theme' ) $canRedirect = ( ! get_option( 'theme_switched_via_customizer' ) );
784
- if( $canRedirect ) {
785
- wp_redirect( admin_url( 'admin.php?page=' . $this->menu_args['menu_slug'] ) );
 
 
 
 
786
  die();
787
  }
788
  }
789
 
790
  /**
791
  * Form action URL
 
792
  */
793
  private function formActionUrl() {
794
- echo add_query_arg(
795
- array( 'page' => sanitize_text_field( $_GET['page'] ) ),
796
- admin_url( basename( $_SERVER['SCRIPT_NAME'] ) )
 
 
 
 
797
  );
798
  }
799
 
800
  /**
801
  * Get input license key
802
- * @param string $action
803
- * @param array $license
804
  * @return string
805
  */
806
  private function get_input_license_value( $action, $license ) {
807
- //if ( 'deactivate' != $action ) return '';
808
- //$key_length = strlen( $license['key'] );
809
- //return str_pad( substr( $license['key'], 0, $key_length / 2 ), $key_length, '*' );
 
 
810
  return isset( $license['key'] ) ? $license['key'] : '';
811
  }
812
 
@@ -822,10 +920,12 @@ class License {
822
  * }
823
  */
824
  private function getLicense() {
825
- if( $this->license !== null ) return $this->license;
 
 
826
  $this->license = get_option( $this->option_key, false );
827
  // initialize blank inactive license data.
828
- if( false === $this->license ) {
829
  $this->setLicense();
830
  }
831
  return $this->license;
@@ -846,31 +946,31 @@ class License {
846
  */
847
  private function setLicense( $license = [] ) {
848
  $this->license = $this->parse_license_data( $license );
849
- // update in db
850
  return update_option( $this->option_key, $this->license, false );
851
  }
852
 
853
  /**
854
  * Parse License data.
855
- * @param array $data
856
  *
857
  * @return array
858
  */
859
  private function parse_license_data( $data = [] ) {
860
  $defaults = [
861
- 'key' => '', // license key
862
- 'status' => 'inactive', // current status
863
- 'instance' => '', // instance unique id
864
- 'remaining' => 0, // remaining activation
865
- 'activations' => 0, // total activation
866
- 'limit' => 0, // activation limit
867
- 'unlimited' => false, // is unlimited activation
868
- 'expiry_date' => 0, // expires set this to a unix timestamp
869
  ];
870
  // parse
871
  $data = wp_parse_args( $data, $defaults );
872
  $license = array();
873
- // sanitize data
874
  $license['key'] = sanitize_text_field( $data['key'] );
875
  $license['status'] = strtolower( $data['status'] ) === 'active' ? 'active' : 'inactive';
876
  $license['instance'] = sanitize_text_field( $data['instance'] );
@@ -888,12 +988,16 @@ class License {
888
  */
889
  private function generateInstanceId() {
890
  $id = false;
891
- if( function_exists( 'wp_generate_password' ) ) {
892
  $id = wp_generate_password( 12, false );
893
- if( 12 !== strlen( $id ) ) $id = false;
 
 
 
 
 
894
  }
895
- if( ! $id ) $id = md5( uniqid( rand( 100,100000 ), true ) );
896
  return $id;
897
  }
898
  }
899
- // End of file License.php
1
  <?php
 
 
2
  /**
3
  * WebAppick License Checker
4
  *
5
  * This class will check, active and deactivate license
6
+ * @version 1.0.0
7
+ * @package WebAppick
8
+ * @subpackage AppServices
9
+ */
10
+
11
+ namespace WebAppick\AppServices;
12
+
13
+ if ( ! defined( 'ABSPATH' ) ) {
14
+ die();
15
+ }
16
+
17
+ /**
18
+ * Class License
19
  */
20
  class License {
21
 
101
  /**
102
  * Initialize the class
103
  *
104
+ * @param Client $client The Client.
105
  */
106
  public function __construct( Client $client ) {
107
  $this->client = $client;
108
  $this->option_key = 'WebAppick_' . md5( $this->client->getSlug() ) . '_manage_license';
109
  $this->data_key = $this->client->getSlug() . '-license';
110
  $this->schedule_hook = $this->client->getSlug() . '_license_check_event';
111
+ // load the license.
112
  $this->getLicense();
113
  add_action( 'init', [ $this, 'handle_license_page_form' ], 10 );
114
  }
119
  * @return void
120
  */
121
  public function init() {
122
+ // check the validity and save the state.
123
  $this->is_valid();
124
+ // Run hook to check license status daily.
125
  add_action( $this->schedule_hook, array( $this, 'check_license_status' ) );
126
  $this->currentUserCanManage = $this->menu_args['capability'];
127
+ $this->isLicensePage = isset( $_GET['page'] ) && $_GET['page'] === $this->menu_args['menu_slug']; // phpcs:ignore
128
  add_action( 'plugin_action_links_' . $this->client->getBasename(), [ $this, 'plugin_action_links' ] );
129
  add_action( 'admin_notices', array( $this, '__admin_notices' ), 10 );
130
+ // Activation/Deactivation hooks.
131
  $this->activation_deactivation();
132
  $this->didInit = true;
133
  }
141
  return $this->license['key'];
142
  }
143
 
144
+ /**
145
+ * Display Admin Notices
146
+ * @return void
147
+ */
148
  public function __admin_notices() {
149
  if ( ! current_user_can( $this->currentUserCanManage ) ) return;
150
  if ( defined( 'WP_HTTP_BLOCK_EXTERNAL' ) && WP_HTTP_BLOCK_EXTERNAL === true ) {
151
+ $host = wp_parse_url( $this->__getLicenceAPI(), PHP_URL_HOST );
152
  if ( ! defined( 'WP_ACCESSIBLE_HOSTS' ) || ( defined( 'WP_ACCESSIBLE_HOSTS' ) && false === stristr( WP_ACCESSIBLE_HOSTS, $host ) ) ) {
153
+ ?>
154
+ <div class="notice notice-error">
155
+ <p><?php
156
+ printf(
157
+ /* translators: 1: Warning in bold tag, 2: This plugin name, 3: API Host Name, 4: WP_ACCESSIBLE_HOSTS constant */
158
+ esc_html__( '%1$s You\'re blocking external requests which means you won\'t be able to get %2$s updates. Please add %3$s to %4$s.', 'webappick' ),
159
+ '<b>'. esc_html__( 'Warning!', 'webappick' ).'</b>',
160
+ esc_html( $this->client->getName() ),
161
+ '<strong>' . esc_html( $host ) . '</strong>',
162
+ '<code>WP_ACCESSIBLE_HOSTS</code>'
163
+ );
164
+ ?></p>
165
+ </div>
166
+ <?php
167
  }
168
  }
169
+ if ( ! $this->isLicensePage && ! $this->is_valid() ) {
170
+ ?>
171
  <div class="notice notice-error">
172
+ <p><?php
173
+ printf(
174
+ /* translators: 1: This plugin name, 2: Plugin/Theme, 3: Activation Page URL, 4: This Plugin Name */
175
+ esc_html__( 'The %1$s API Key has not been activated, so the %2$s is inactive! %3$s to activate %4$s.', 'webappick' ),
176
+ '<strong>' . esc_attr( $this->client->getName() ) . '</strong>',
177
+ esc_attr( $this->client->getType() ),
178
+ '<a href="' . esc_url( admin_url( 'admin.php?page=' . $this->menu_args['menu_slug'] ) ) . '">'. esc_html__( 'Click here', 'woo-feed' ) .'</a>',
179
+ '<strong>' . esc_attr( $this->client->getName() ) . '</strong>'
180
+ );
181
+ ?></p>
182
  </div>
183
+ <?php
184
+ }
185
  if ( ! empty( $this->error ) ) {
186
  ?>
187
  <div class="notice notice-error is-dismissible">
188
+ <p><?php echo $this->error; // phpcs:ignore xss ok ?></p>
189
  </div>
190
  <?php
191
  }
192
  if ( ! empty( $this->success ) ) {
193
  ?>
194
  <div class="notice notice-success is-dismissible">
195
+ <p><?php echo $this->success; // phpcs:ignore xss ok ?></p>
196
  </div>
197
  <?php
198
  }
200
 
201
  /**
202
  * Setup plugin action link to the license page
203
+ * @param array $links plugin action links.
204
  * @return array
205
  */
206
  public function plugin_action_links( $links ) {
207
+ if ( ! empty( $this->menu_args['menu_slug'] ) && ! empty( $this->menu_args['menu_title'] ) ) {
208
  /** @noinspection HtmlUnknownTarget */
209
  $links[] = sprintf( '<a href="%s">%s</a>', esc_url( admin_url( 'admin.php?page=' . $this->menu_args['menu_slug'] ) ), esc_html( $this->menu_args['menu_title'] ) );
210
  }
227
  return $this->send_request( 'update', $this->license );
228
  }
229
 
230
+ /**
231
+ * Get Plugin data
232
+ * @return array
233
+ */
234
  public function get_information() {
235
  return $this->send_request( 'information', $this->license );
236
  }
237
 
238
  /**
239
  * Active a license
240
+ * @param array $license license data.
241
  * @return array
242
  */
243
  public function activate( $license ) {
255
  /**
256
  * Send common request
257
  *
258
+ * @param string $action request action.
259
+ * @param array $license license data.
260
  *
261
  * @return array
262
  */
263
  protected function send_request( $action, $license = [] ) {
264
+ // WC-AM Valid Actions and response data types.
265
  $actions = [
266
  'activate' => 'json',
267
  'deactivate' => 'json',
268
  'status' => 'json',
269
  'information' => 'json',
270
  'update' => 'json',
271
+ 'plugininformation' => 'serialize', // serialize option doesn't provide success status.
272
  'pluginupdatecheck' => 'serialize',
273
  ];
274
+ if ( ! in_array( $action, array_keys( $actions ) ) ) {
275
  return [
276
  'success' => false,
277
  'error' => esc_html__( 'Invalid Request Action.', 'webappick' ),
279
  }
280
  // parse license data
281
  $license = wp_parse_args( $license, $this->getLicense() );
282
+ if ( empty( $license['key'] ) || empty( $license['instance'] ) ) {
283
  return [
284
  'success' => false,
285
  'error' => esc_html__( 'Invalid/Empty License Data.', 'webappick' ),
286
  ];
287
  }
288
+ if ( empty( $this->client->getProjectId() ) && empty( $this->client->getName() ) ) {
289
  return [
290
  'success' => false,
291
  'error' => esc_html__( 'A valid project name/id is required.', 'webappick' ),
296
  'api_key' => $license['key'],
297
  'version' => $this->client->getProjectVersion(),
298
  'instance' => $license['instance'],
299
+ 'product_id' => $this->client->getName(),
300
  'plugin_name' => $this->client->getBasename(),
301
  'wc_am_action' => $action,
302
  ];
305
  $this->restoreAPI_URL();
306
  if ( ! is_wp_error( $response ) ) {
307
  $response = wp_remote_retrieve_body( $response );
308
+ if ( 'json' == $actions[ $action ] ) {
309
  $response = json_decode( $response, true );
310
  } else {
311
  $response = maybe_unserialize( $response );
312
+ // @TODO check wc-am error ..
313
  return $response;
314
  }
315
  if ( empty( $response ) || ! isset( $response['success'] ) ) {
362
  /**
363
  * Add settings page for license
364
  *
365
+ * @param array $args settings for rendering the menu.
366
  *
367
  * @return void
368
  */
369
  public function add_settings_page( $args = array() ) {
370
+ if ( $this->didInit ) {
371
  _doing_it_wrong( __METHOD__, sprintf( '<code>%s</code> Should be called before License::init()', __METHOD__ ), '1.0.1' );
372
  return;
373
  }
374
  $defaults = [
375
+ 'type' => 'menu', // Can be: menu, options, submenu.
376
+ 'page_title' => esc_html__( 'Manage License', 'webappick' ),
377
+ 'menu_title' => esc_html__( 'Manage License', 'webappick' ),
378
  'capability' => 'manage_options',
379
  'menu_slug' => $this->client->getSlug() . '-manage-license',
380
  'icon_url' => '',
382
  'parent_slug' => '',
383
  ];
384
  $this->menu_args = wp_parse_args( $args, $defaults );
385
+ if ( ! in_array( $this->menu_args['type'], [ 'menu', 'options', 'submenu' ] ) ) {
386
+ if ( empty( $this->menu_args['parent_slug'] ) ) {
387
+ $this->menu_args['type'] = 'menu';
388
+ }
389
  }
390
+ if ( 'submenu' == $this->menu_args['type'] && empty( $this->menu_args['parent_slug'] ) ) {
391
  $this->menu_args['type'] = 'options';
392
  }
393
  add_action( 'admin_menu', array( $this, 'admin_menu' ), 999 );
402
  switch ( $this->menu_args['type'] ) {
403
  case 'submenu':
404
  $this->add_submenu_page();
405
+ break;
406
  case 'options':
407
  $this->add_options_page();
408
+ break;
409
  case 'menu':
410
  default:
411
  $this->add_menu_page();
412
+ break;
413
  }
414
  }
415
 
427
  <div class="webappick-license-settings webappick-license-section">
428
  <?php $this->show_license_page_card_header(); ?>
429
  <div class="webappick-license-details">
430
+ <?php if ( 'activate' == $action ) { ?>
431
  <p><?php
432
+ /* translators: %s: This Plugin Name */
433
+ printf( esc_html__( 'Active %s by your license key to get professional support and automatic update from your WordPress dashboard.', 'webappick' ), '<strong>' . esc_html( $this->client->getName() ) . '</strong>' );
434
  ?></p>
435
  <?php } ?>
436
  <form method="post" action="<?php $this->formActionUrl(); ?>" novalidate="novalidate" spellcheck="false" autocomplete="off">
437
  <?php wp_nonce_field( $this->data_key ); ?>
438
+ <input type="hidden" name="<?php echo esc_attr( $this->data_key ); ?>[_action]" value="<?php echo esc_attr( $action ); ?>">
439
  <div class="license-input-fields">
440
  <div class="license-input-key">
441
  <svg enable-background="new 0 0 512 512" version="1.1" viewBox="0 0 512 512" xml:space="preserve" xmlns="http://www.w3.org/2000/svg">
443
  </svg>
444
  <label for="license_key" class="screen-reader-text"><?php esc_html_e( 'License Key', 'webappick' ); ?></label>
445
  <input class="regular-text" id="license_key" type="text"
446
+ value="<?php echo esc_attr( $this->get_input_license_value( $action, $this->license ) ); ?>"
447
+ placeholder="<?php esc_attr_e( 'Enter your license key to activate', 'webappick' ); ?>"
448
+ name="<?php echo esc_attr( $this->data_key ); ?>[license_key]"<?php readonly( ( 'deactivate' == $action ), true, true ); ?>
449
+ autocomplete="off">
450
  </div>
451
+ <button type="submit" name="<?php echo esc_attr( $this->data_key); ?>[submit]" class="<?php printf( '%s-button', esc_attr( $action ) );?>"><?php
452
+ 'activate' == $action ? esc_html_e( 'Activate License', 'webappick' ) : esc_html_e( 'Deactivate License', 'webappick' );
453
  ?></button>
454
  <a href="http://webappick.com/my-account/api-keys/" class="button button-primary button-hero" style="margin-left: 20px;font-size: 17px;line-height: 2.5;" target="_blank"><?php esc_html_e( 'Manage License', 'webappick' ); ?></a>
455
  </div>
467
  * @return void
468
  */
469
  public function handle_license_page_form() {
470
+ if ( isset( $_POST[ $this->data_key ], $_POST[ $this->data_key ]['_action'] ) ) {
471
  check_admin_referer( $this->data_key );
472
+ switch ( $_POST[ $this->data_key ]['_action'] ) {
473
  case 'activate':
474
+ $this->activate_client_license( array_map( 'sanitize_text_field', $_POST[ $this->data_key ] ) );
475
  break;
476
  case 'deactivate':
477
  $this->deactivate_client_license();
483
  }
484
 
485
  /**
486
+ * Check license status on schedule.
487
+ * Check and update license status on db
488
+ * @return void
489
  */
490
  public function check_license_status() {
491
  // get current license data.
492
  $license = $this->getLicense();
493
  if ( $license ) {
494
+ // check license.
495
  $response = $this->check();
496
  if ( isset( $response['success'], $response['status_check'] ) && $response['success'] ) {
497
+ // update license status.
498
+ $license = wp_parse_args(
499
+ [
500
+ 'status' => 'active' == $response['status_check'] ? 'active' : 'inactive',
501
+ 'remaining' => isset( $response['data'], $response['data']['activations_remaining'] ) ? $response['data']['activations_remaining'] : 0,
502
+ 'activations' => isset( $response['data'], $response['data']['total_activations'] ) ? $response['data']['total_activations'] : 0,
503
+ 'limit' => isset( $response['data'], $response['data']['total_activations_purchased'] ) ? $response['data']['total_activations_purchased'] : 0,
504
+ 'unlimited' => isset( $response['data'], $response['data']['unlimited_activations'] ) ? $response['data']['unlimited_activations'] : false,
505
+ 'expiry_date' => 0, // wc-am doesn't sent remaining date.
506
+ ],
507
+ $license
508
+ );
509
  } else {
510
  // Don't reset the key.
511
  // keep it, if the user renew subscription update the status and reactivate the plugin.
512
+ $license = wp_parse_args(
513
+ [
514
+ 'status' => 'inactive',
515
+ 'remaining' => 0,
516
+ 'activations' => 0,
517
+ 'limit' => 0,
518
+ 'unlimited' => false,
519
+ 'expiry_date' => 0, // wc-am doesn't sent remaining date.
520
+ ],
521
+ $license
522
+ );
523
  }
524
+ // update the license state & and save in db.
525
  $this->setLicense( $license );
526
  }
527
  }
528
 
529
  /**
530
+ * Check this is a valid license.
531
+ * @return bool
532
  */
533
  public function is_valid() {
534
  if ( null !== $this->is_valid_license ) {
535
  return $this->is_valid_license;
536
  }
537
+ // load the license if already not loaded.
538
  $this->getLicense();
539
+ if ( isset( $this->license['status'] ) && 'active' == $this->license['status'] ) {
540
  $this->is_valid_license = true;
541
  } else {
542
  $this->is_valid_license = false;
546
  }
547
 
548
  /**
549
+ * Read WooCommerce API Manager Data, Convert to new license format and save in db.
550
+ * @param bool $override override current settings.
551
  * @return bool
552
  */
553
+ public function migrate_license_from_wc_am( $override = false ) {
554
+ // phpcs:disable
555
+ /*// WC AM data structure.
 
 
 
556
  [
557
  '_data' => [ 'api_key', 'activation_email', ], // api key & email
558
  '_product_id' => '', // product title or name
560
  '_activated' => '', // activation status => Activated|Deactivated
561
  '_deactivate_checkbox' => '', // deactivation check box state > On|Off
562
  ];*/
563
+ // phpcs:enable
564
+ // check if already migrated || override.
565
+ if ( 1 == get_option( $this->option_key . '_wc_am_migrated', false ) && ! $override ) {
566
+ return false;
567
+ }
568
+ // is already migrated.
569
+ // api manager data prefix.
570
+ $wcAmPrefix = str_ireplace( array( ' ', '_', '&', '?' ), '_', strtolower( $this->client->getName() ) );
571
  $license = [
572
+ 'key' => '',
573
+ 'status' => 'deactivate', // activate.
574
+ 'instance' => '', // max len 190.
575
  ];
576
+ // get key.
577
  $data = get_option( $wcAmPrefix . '_data', false );
578
+ if ( $data && isset( $data['api_key'] ) ) {
579
+ $license['key'] = $data['api_key'];
580
+ }
581
+ // instance id.
582
  $data = get_option( $wcAmPrefix . '_instance', false );
583
+ if ( $data ) {
584
+ $license['instance'] = $data;
585
+ }
586
+ // activation status.
587
  $data = get_option( $wcAmPrefix . '_activated', false );
588
+ if ( $data ) {
589
+ $license['status'] = strtolower( $data ) === 'activated' ? 'active' : 'inactive'; // Deactivated.
590
+ }
591
  $this->setLicense( $license );
592
  $this->check_license_status();
593
  update_option( $this->option_key . '_wc_am_migrated', 1, false );
633
  * @return void
634
  */
635
  private function show_active_license_info() {
636
+ $status = ( isset( $this->license['status'] ) && 'active' === $this->license['status'] ) ? 'active' : 'inactive';
637
  $limit = isset( $this->license['limit'] ) ? $this->license['limit'] : 0;
638
  $activations = isset( $this->license['activations'] ) ? $this->license['activations'] : 0;
639
  $remaining = isset( $this->license['remaining'] ) ? $this->license['remaining'] : 0;
642
  <div class="active-license-info">
643
  <div class="single-license-info">
644
  <h3><?php esc_html_e( 'Status:', 'webappick' ); ?></h3>
645
+ <p class="<?php echo esc_attr( $status ); ?>"><?php 'active' == $status ? esc_html_e( 'Active', 'webappick' ) : esc_html_e( 'Inactive', 'webappick' ); ?></p>
646
  </div>
647
  <?php if ( false !== $unlimited ) { ?>
648
  <div class="single-license-info">
651
  </div>
652
  <div class="single-license-info">
653
  <h3><?php esc_html_e( 'Total Activation:', 'webappick' ); ?></h3>
654
+ <p class="active"><?php echo esc_attr( $activations ); ?></p>
655
  </div>
656
  <?php } else { ?>
657
  <div class="single-license-info">
658
  <h3><?php esc_html_e( 'Activation Remaining:', 'webappick' ); ?></h3>
659
  <p class="<?php echo $remaining ? 'active' : 'inactive'; ?>"><?php
660
+ if ( 'active' == $status ) {
661
+ /* translators: 1: Remaining activation, 2: Total activation */
662
+ printf( esc_html__( '%1$d out of %2$d', 'webappick' ), esc_attr( $remaining ), esc_attr( $limit ) );
663
+ } else {
664
+ esc_html_e( 'N/A', 'webappick' );
665
+ }
666
  ?></p>
667
  </div>
668
  <?php } ?>
669
  <div class="single-license-info">
670
  <h3><?php esc_html_e( 'Automatic Update:', 'webappick' ); ?></h3>
671
+ <p class="<?php echo esc_attr( $status ); ?>"><?php 'active' == $status ? esc_html_e( 'Enabled', 'webappick' ) : esc_html_e( 'Disabled', 'webappick' ); ?></p>
672
  </div>
673
  </div>
674
  <?php
693
 
694
  /**
695
  * Active client license
696
+ * @param array $postData Sanitized Form $_POST Data.
697
  * @return void
698
  */
699
  private function activate_client_license( $postData ) {
701
  $this->error = esc_html__('The license key field is required.', 'webappick' );
702
  return;
703
  }
704
+
705
  $license = (array) $this->getLicense();
706
+ // check if it's a change request.
707
+ $updateKey = ( isset( $this->license['key'] ) && $postData['license_key'] === $this->license['key'] ) ? true : false;
708
+ if ( $updateKey ) {
709
  $deactivate = $this->deactivate(); // deactivate first.
710
  if ( ! $deactivate['success'] ) {
711
+ $check = $this->check(); // check api status.
712
+ if ( $check['success'] && 'inactive' !== $check['status_check'] ) {
713
  $this->error = $deactivate['error'] ? $deactivate['error'] : esc_html__( 'Unknown error occurred.', 'webappick' );
714
  return;
715
  }
716
  }
717
  }
718
+ $license['key'] = $postData['license_key'];
719
+ if ( empty( $license['instance'] ) ) $license['instance'] = $this->generateInstanceId();
720
  $response = $this->activate( $license );
721
  if ( ! $response['success'] ) {
722
  $this->error = $response['error'] ? $response['error'] : esc_html__( 'Unknown error occurred.', 'webappick' );
724
  }
725
  // Don't reset the key.
726
  // keep it, if the user renew subscription update the status and reactivate the plugin.
727
+ $license = array_merge(
728
+ $license,
729
+ [
730
+ 'status' => isset( $response['activated'] ) && $response['activated'] ? 'active' : 'inactive',
731
+ 'remaining' => isset( $response['data'], $response['data']['activations_remaining'] ) ? $response['data']['activations_remaining'] : 0,
732
+ 'activations' => isset( $response['data'], $response['data']['total_activations'] ) ? $response['data']['total_activations'] : 0,
733
+ 'limit' => isset( $response['data'], $response['data']['total_activations_purchased'] ) ? $response['data']['total_activations_purchased'] : 0,
734
+ 'unlimited' => isset( $response['data'], $response['data']['unlimited_activations'] ) ? $response['data']['unlimited_activations'] : false,
735
+ 'expiry_date' => 0, // wc-am doesn't sent remaining date.
736
+ ]
737
+ );
738
  $this->setLicense( $license );
739
+ if ( ! $updateKey ) {
740
  $this->success = esc_html__( 'License activated successfully.', 'webappick' );
741
  } else {
742
  $this->success = esc_html__( 'License Updated successfully.', 'webappick' );
744
  }
745
 
746
  /**
747
+ * deactivate client license.
748
+ * @return void
749
  */
750
  private function deactivate_client_license() {
751
  if ( ! isset( $this->license['key'] ) || empty( $this->license['key'] ) ) {
753
  } else {
754
  $response = $this->deactivate();
755
  if ( ! $response['success'] ) {
756
+ // check api status.
757
  $check = $this->check();
758
+ if ( $check['success'] && 'inactive' !== $check['status_check'] ) {
759
  $this->error = $response['error'] ? $response['error'] : esc_html__( 'Unknown error occurred.', 'webappick' );
760
  }
761
  }
762
  }
763
+ // keep the instance key for reference.
764
  $this->setLicense( [ 'instance' => $this->license['instance'] ] );
765
  $this->success = esc_html__( 'License deactivated successfully.', 'webappick' );
766
  }
767
 
768
  /**
769
+ * Add license menu page.
770
+ * @return void
771
  */
772
  private function add_menu_page() {
773
  add_menu_page(
774
+ esc_html( $this->menu_args['page_title'] ),
775
+ esc_html( $this->menu_args['menu_title'] ),
776
+ $this->menu_args['capability'],
777
+ $this->menu_args['menu_slug'],
778
  array( $this, 'menu_output' ),
779
+ $this->menu_args['icon_url'],
780
+ $this->menu_args['position']
781
  );
782
  }
783
 
784
  /**
785
+ * Add submenu page.
786
+ * @return void
787
  */
788
  private function add_submenu_page() {
789
  add_submenu_page(
790
+ $this->menu_args['parent_slug'],
791
+ esc_html( $this->menu_args['page_title'] ),
792
+ esc_html( $this->menu_args['menu_title'] ),
793
+ $this->menu_args['capability'],
794
+ $this->menu_args['menu_slug'],
795
+ array( $this, 'menu_output' )
796
  );
797
  }
798
 
799
  /**
800
+ * Add submenu page.
801
+ * @return void
802
  */
803
  private function add_options_page() {
804
  add_options_page(
805
+ esc_html( $this->menu_args['page_title'] ),
806
+ esc_html( $this->menu_args['menu_title'] ),
807
+ $this->menu_args['capability'],
808
+ $this->menu_args['menu_slug'],
809
  array( $this, 'menu_output' )
810
  );
811
  }
821
  }
822
 
823
  /**
824
+ * Clear any scheduled hook.
825
+ * @return void
826
  */
827
  public function clear_scheduler() {
828
  wp_clear_scheduled_hook( $this->schedule_hook );
829
  }
830
 
831
  /**
832
+ * Register Activation And Deactivation Hooks.
833
  * @return void
834
  */
835
  private function activation_deactivation() {
849
 
850
  /**
851
  * Project Deactivation Callback.
852
+ * @return void
853
  */
854
  public function project_deactivation() {
855
  $this->clear_scheduler();
860
  /**
861
  * Redirect to the license activation page after plugin/theme is activated.
862
  * @TODO make option for the plugin/theme (which is using this lib) can alter this method with their custom function.
863
+ * @param string $param1 Plugin: base file|Theme: old theme name.
864
+ * @param bool|WP_Theme $param2 Plugin: network wide activation status|Theme: WP_Theme instance of the old theme.
865
  * @return void
866
  */
867
  public function redirect_to_license_page( $param1, $param2 ) {
868
  $canRedirect = false;
869
+ if ( 'plugin' == $this->client->getType() ) {
870
+ $canRedirect = ( $param1 == $this->client->getBasename() );
871
+ }
872
+ if ( 'theme' == $this->client->getType() ) {
873
+ $canRedirect = ( ! get_option( 'theme_switched_via_customizer' ) );
874
+ }
875
+ if ( $canRedirect ) {
876
+ wp_safe_redirect( admin_url( 'admin.php?page=' . $this->menu_args['menu_slug'] ) );
877
  die();
878
  }
879
  }
880
 
881
  /**
882
  * Form action URL
883
+ * @return void
884
  */
885
  private function formActionUrl() {
886
+ global $plugin_page;
887
+ if( ! isset( $_SERVER['SCRIPT_NAME'], $plugin_page ) ) return; // phpcs:ignore
888
+ echo esc_url(
889
+ add_query_arg(
890
+ array( 'page' => sanitize_text_field( $plugin_page ) ), // phpcs:ignore
891
+ admin_url( basename( sanitize_text_field( $_SERVER['SCRIPT_NAME'] ) ) )
892
+ )
893
  );
894
  }
895
 
896
  /**
897
  * Get input license key
898
+ * @param string $action current license action.
899
+ * @param array $license license data.
900
  * @return string
901
  */
902
  private function get_input_license_value( $action, $license ) {
903
+ // phpcs:disable
904
+ // if ( 'deactivate' != $action ) return '';
905
+ // $key_length = strlen( $license['key'] );
906
+ // return str_pad( substr( $license['key'], 0, $key_length / 2 ), $key_length, '*' );
907
+ // phpcs:enable
908
  return isset( $license['key'] ) ? $license['key'] : '';
909
  }
910
 
920
  * }
921
  */
922
  private function getLicense() {
923
+ if ( null !== $this->license ) {
924
+ return $this->license;
925
+ }
926
  $this->license = get_option( $this->option_key, false );
927
  // initialize blank inactive license data.
928
+ if ( false === $this->license ) {
929
  $this->setLicense();
930
  }
931
  return $this->license;
946
  */
947
  private function setLicense( $license = [] ) {
948
  $this->license = $this->parse_license_data( $license );
949
+ // update in db.
950
  return update_option( $this->option_key, $this->license, false );
951
  }
952
 
953
  /**
954
  * Parse License data.
955
+ * @param array $data license data.
956
  *
957
  * @return array
958
  */
959
  private function parse_license_data( $data = [] ) {
960
  $defaults = [
961
+ 'key' => '', // license key.
962
+ 'status' => 'inactive', // current status.
963
+ 'instance' => '', // instance unique id.
964
+ 'remaining' => 0, // remaining activation.
965
+ 'activations' => 0, // total activation.
966
+ 'limit' => 0, // activation limit.
967
+ 'unlimited' => false, // is unlimited activation.
968
+ 'expiry_date' => 0, // expires set this to a unix timestamp.
969
  ];
970
  // parse
971
  $data = wp_parse_args( $data, $defaults );
972
  $license = array();
973
+ // sanitize data.
974
  $license['key'] = sanitize_text_field( $data['key'] );
975
  $license['status'] = strtolower( $data['status'] ) === 'active' ? 'active' : 'inactive';
976
  $license['instance'] = sanitize_text_field( $data['instance'] );
988
  */
989
  private function generateInstanceId() {
990
  $id = false;
991
+ if ( function_exists( 'wp_generate_password' ) ) {
992
  $id = wp_generate_password( 12, false );
993
+ if ( 12 !== strlen( $id ) ) {
994
+ $id = false;
995
+ }
996
+ }
997
+ if ( ! $id ) {
998
+ $id = md5( uniqid( wp_rand( 100, 100000 ), true ) );
999
  }
 
1000
  return $id;
1001
  }
1002
  }
1003
+ // End of file License.php.
libs/WebAppick/AppServices/Promotions.php CHANGED
@@ -1,10 +1,17 @@
1
  <?php
2
- namespace WebAppick\AppServices;
3
- if( ! defined( 'ABSPATH' ) ) die();
4
  /**
5
  * Webappick Promotion handler
6
  * @version 1.0.0
 
 
7
  */
 
 
 
 
 
 
 
8
  /**
9
  * Class Promotions
10
  * Source Format
@@ -90,18 +97,18 @@ class Promotions {
90
 
91
  /**
92
  * Promotions constructor.
93
- * @param Client $client
94
- * @param string $data_source
95
  * @return void
96
  */
97
  public function __construct( Client $client, $data_source = null ) {
98
  $this->client = $client;
99
- if( ! is_null( $data_source ) ) $this->promotionSrc = esc_url( $data_source );
100
  }
101
 
102
  /**
103
  * Set JSON Source File URL For getting promotion data
104
- * @param $URL
105
  *
106
  * @return Promotions
107
  */
@@ -115,8 +122,8 @@ class Promotions {
115
  * @return void
116
  */
117
  public function init() {
118
- if( is_null( $this->promotionSrc ) ) {
119
- _doing_it_wrong( __METHOD__, __( 'Promotion Source URL Not Set. see Promotions::set_source( $URL )', 'webappick' ), '1.0.0' );
120
  }
121
  add_action( 'admin_init', [ $this, '__init_internal' ], 10 );
122
  }
@@ -127,10 +134,10 @@ class Promotions {
127
  */
128
  public function __init_internal() {
129
  $this->currentUser = get_current_user_id();
130
- $this->hiddenPromotions = get_user_option( $this->client->getSlug() . '_hidden_promos', $this->currentUser ) ?: [];
131
  $this->promotions = $this->__get_promos();
132
  // only run if there is active promotions.
133
- if( count( $this->promotions ) ) {
134
  add_action( 'admin_notices', [ $this, '__show_promos' ], 10 );
135
  add_action( 'wp_ajax_webappick_dismiss_promo', [ $this, '__webappick_dismiss_promo' ], 10 );
136
  add_action( 'admin_print_styles', [ $this, '__get_promo_styles' ], 99 );
@@ -144,43 +151,64 @@ class Promotions {
144
  * @return void
145
  */
146
  public function __show_promos() {
147
- foreach( $this->promotions as $promotion ) {
148
- $wrapperStyles = $buttonStyles = "";
149
- $is_dismissible = ! isset( $promotion->dismissible ) || isset( $promotion->dismissible ) && $promotion->dismissible == 0 ? false : true;
 
150
 
151
  $has_columns = isset( $promotion->button, $promotion->logo );
152
- if( isset( $promotion->color ) ) $wrapperStyles .= 'color: '.$promotion->color.';';
153
- if( isset( $promotion->wrapperPadding ) ) $wrapperStyles .= 'padding: '.$promotion->wrapperPadding.';';
154
- if( isset( $promotion->backgroundColor ) ) $wrapperStyles .= 'background-color: '.$promotion->backgroundColor.';';
155
- if( isset( $promotion->backgroundImage ) ) $wrapperStyles .= 'background-image: url("'. esc_url( $promotion->backgroundImage ) .'");';
156
- if( isset( $promotion->backgroundRepeat ) ) $wrapperStyles .= 'background-repeat: '.$promotion->backgroundRepeat.';';
157
- if( isset( $promotion->backgroundSize ) ) $wrapperStyles .= 'background-size: '.$promotion->backgroundSize.';';
158
- if( property_exists( $promotion, 'button' ) ) {
159
- if( isset( $promotion->button->backgroundColor ) ) $buttonStyles .= 'background-color: '.$promotion->button->backgroundColor.';border-color: '.$promotion->button->backgroundColor .';';
160
- if( isset( $promotion->button->color ) ) $buttonStyles .= 'color: '.$promotion->button->color.';';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
  }
162
  $noticeClasses = 'notice notice-success wapk-promo';
163
- if( $is_dismissible ) $noticeClasses .= ' is-dismissible';
 
 
164
  ?>
165
- <div class="<?php echo esc_attr( $noticeClasses ); ?> " id="<?php echo esc_attr( $promotion->hash ); ?>" data-nonce="<?php echo wp_create_nonce( 'wapk-dismiss-promo' ); ?>" style="<?php echo esc_attr( $wrapperStyles ); ?>">
166
- <div class="wapk-promo-wrap<?php if( ! $has_columns ) echo ' no-column'; ?>">
167
- <?php if( isset( $promotion->logo ) && ! empty( $promotion->logo ) ) { ?>
168
  <div class="wapk-logo wapk-column">
169
  <img src="<?php echo esc_url( $promotion->logo->src ); ?>" alt="<?php echo esc_attr( $promotion->logo->alt ); ?>">
170
  </div>
171
  <?php } ?>
172
- <div class="wapk-details<?php if( $has_columns ) echo ' wapk-column'; ?>">
173
  <?php echo wp_kses_post( $promotion->content ); ?>
174
  </div>
175
- <?php if( isset( $promotion->button ) && ! empty( $promotion->button ) ) { ?>
176
  <div class="wapk-btn-container wapk-column">
177
- <a href="<?php echo esc_url( $promotion->button->url ) ?>" class="button wapk-promo-btn" style="<?php echo esc_attr( $buttonStyles ); ?>" target="_blank"><?php echo wp_kses_post( $promotion->button->label ); ?></a>
178
- <?php if( isset( $promotion->button->after ) && ! empty( $promotion->button->after ) ) {
 
179
  echo wp_kses_post( $promotion->button->after );
180
- } ?>
 
181
  </div>
182
  <?php } ?>
183
- <?php if( isset( $promotion->button ) && ! empty( $promotion->button ) ) { ?>
184
  <?php } ?>
185
  </div>
186
  </div>
@@ -195,21 +223,23 @@ class Promotions {
195
  */
196
  private function __get_promos() {
197
  $promos = get_transient( $this->client->getSlug() . '_cached_promos' );
198
- if( empty( $promos ) ) {
199
- // get promotions data from json source
200
- $response = wp_remote_get( $this->promotionSrc, array( 'timeout' => 15 ) );
201
- $promos = wp_remote_retrieve_body( $response );
202
- if ( is_wp_error( $response ) || $response['response']['code'] != 200 ) $promos = '[]';
203
- // cache data
 
 
204
  set_transient( $this->client->getSlug() . '_cached_promos', $promos, 12 * HOUR_IN_SECONDS );
205
  }
206
- // decode to array
207
  $promos = json_decode( $promos );
208
 
209
- // filter promotions by date
210
  $promos = array_filter( $promos, [ $this, '__is_promo_active' ] );
211
- if( ! empty( $promos ) ) {
212
- // filter promotions by list of hidden promotions by the user
213
  $promos = array_filter( $promos, [ $this, '__is_promo_hidden' ] );
214
  }
215
  return $promos;
@@ -218,7 +248,7 @@ class Promotions {
218
  /**
219
  * Check if promotion is active by date.
220
  * must have start and end property
221
- * @param object $promo {
222
  * Single Promo Object
223
  * @type string $content string. required
224
  * @type string $start valid timestamp. required
@@ -228,12 +258,13 @@ class Promotions {
228
  * @return bool
229
  */
230
  public function __is_promo_active( $promo ) {
231
- return ( ! empty( $promo->content ) && strtotime( $promo->start ) < current_time( 'timestamp' ) && current_time( 'timestamp' ) < strtotime( $promo->end ) );
 
232
  }
233
 
234
  /**
235
  * Check if promo is hidden by current user
236
- * @param object $promo {
237
  * Single Promo Object
238
  * @type string $hash valid unique hash for a promo
239
  * }
@@ -258,7 +289,8 @@ class Promotions {
258
  * @return void
259
  */
260
  public function __get_promo_scripts() {
261
- ?><!--suppress ES6ConvertVarToLetConst -->
 
262
  <script>
263
  (function($){
264
  $('body').on('click', '.wapk-promo .notice-dismiss', function (e) {
@@ -271,7 +303,8 @@ class Promotions {
271
  });
272
  });
273
  })(jQuery);
274
- </script><?php
 
275
  }
276
 
277
  /**
@@ -279,7 +312,8 @@ class Promotions {
279
  * @return void
280
  */
281
  public function __get_promo_styles() {
282
- ?><!--suppress CssUnusedSymbol -->
 
283
  <style>
284
  .wapk-promo { border: none; padding: 15px 0; }
285
  .wapk-promo-wrap { display: flex; justify-content: center; align-items: center; text-align: center; color: inherit; max-width: 1820px; margin: 0 auto; }
@@ -296,7 +330,6 @@ class Promotions {
296
  .wapk-promo-wrap .wapk-promo-btn:hover,
297
  .wapk-promo-wrap .wapk-promo-btn:active { box-shadow: inset 3px 4px 6px 0 rgba(1, 9, 12, 0.25); }
298
  .wapk-promo-wrap .wapk-promo-btn:active { top: 1px; }
299
-
300
  @media screen and (max-width: 1200px) {
301
  .wapk-promo-wrap { display: block; overflow: hidden; }
302
  .wapk-column .wapk-logo { width: 100%; margin: 0 auto; }
@@ -308,7 +341,8 @@ class Promotions {
308
  .wapk-btn-container { float: none; width: 100%; margin-top: 32px; }
309
  .wapk-column.wapk-btn-container { width: 100%; float: right; margin-top: 42px; }
310
  }
311
- </style><?php
 
312
  }
313
 
314
  /**
@@ -318,15 +352,14 @@ class Promotions {
318
  public function __webappick_dismiss_promo() {
319
  if (
320
  isset( $_REQUEST['dismissed'], $_REQUEST['hash'], $_REQUEST['_wpnonce'] ) &&
321
- $_REQUEST['dismissed'] == 'true' &&
322
- ! empty( $_REQUEST['hash'] ) &&
323
- wp_verify_nonce( $_REQUEST['_wpnonce'], 'wapk-dismiss-promo' )
324
  ) {
325
  $this->hiddenPromotions = array_merge( $this->hiddenPromotions, [ sanitize_text_field( $_REQUEST['hash'] ) ] );
326
  update_user_option( $this->currentUser, $this->client->getSlug() . '_hidden_promos', $this->hiddenPromotions );
327
- wp_send_json_success( __( 'Promo hidden', 'webappick' ) );
328
  }
329
- wp_send_json_error( __( 'Invalid Request', 'webappick' ) );
330
  die();
331
  }
332
 
@@ -336,8 +369,8 @@ class Promotions {
336
  * @return bool
337
  */
338
  public function clear_hidden_promos() {
339
- if( ! did_action( 'admin_init' ) ) {
340
- _doing_it_wrong( __METHOD__, __( 'Method must be invoked inside admin_init action', 'webappick' ), '1.0.0' );
341
  }
342
  $this->currentUser = get_current_user_id();
343
  return delete_user_option( $this->currentUser, $this->client->getSlug() . '_hidden_promos' );
@@ -351,4 +384,4 @@ class Promotions {
351
  return delete_transient( $this->client->getSlug() . '_cached_promos' );
352
  }
353
  }
354
- // End of file class-woo-feed-promotions.php
1
  <?php
 
 
2
  /**
3
  * Webappick Promotion handler
4
  * @version 1.0.0
5
+ * @package WebAppick
6
+ * @subpackage AppServices
7
  */
8
+
9
+ namespace WebAppick\AppServices;
10
+
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ die();
13
+ }
14
+
15
  /**
16
  * Class Promotions
17
  * Source Format
97
 
98
  /**
99
  * Promotions constructor.
100
+ * @param Client $client The Client.
101
+ * @param string $data_source Data Source URL
102
  * @return void
103
  */
104
  public function __construct( Client $client, $data_source = null ) {
105
  $this->client = $client;
106
+ if ( ! is_null( $data_source ) ) $this->promotionSrc = esc_url( $data_source );
107
  }
108
 
109
  /**
110
  * Set JSON Source File URL For getting promotion data
111
+ * @param string $URL Set Data Source URL.
112
  *
113
  * @return Promotions
114
  */
122
  * @return void
123
  */
124
  public function init() {
125
+ if ( is_null( $this->promotionSrc ) ) {
126
+ _doing_it_wrong( __METHOD__, esc_html__( 'Promotion Source URL Not Set. see Promotions::set_source( $URL )', 'webappick' ), '1.0.0' );
127
  }
128
  add_action( 'admin_init', [ $this, '__init_internal' ], 10 );
129
  }
134
  */
135
  public function __init_internal() {
136
  $this->currentUser = get_current_user_id();
137
+ $this->hiddenPromotions = (array) get_user_option( $this->client->getSlug() . '_hidden_promos', $this->currentUser );
138
  $this->promotions = $this->__get_promos();
139
  // only run if there is active promotions.
140
+ if ( count( $this->promotions ) ) {
141
  add_action( 'admin_notices', [ $this, '__show_promos' ], 10 );
142
  add_action( 'wp_ajax_webappick_dismiss_promo', [ $this, '__webappick_dismiss_promo' ], 10 );
143
  add_action( 'admin_print_styles', [ $this, '__get_promo_styles' ], 99 );
151
  * @return void
152
  */
153
  public function __show_promos() {
154
+ foreach ( $this->promotions as $promotion ) {
155
+ $wrapperStyles = '';
156
+ $buttonStyles = '';
157
+ $is_dismissible = ! isset( $promotion->dismissible ) || isset( $promotion->dismissible ) && 0 == $promotion->dismissible ? false : true;
158
 
159
  $has_columns = isset( $promotion->button, $promotion->logo );
160
+ if ( isset( $promotion->color ) ) {
161
+ $wrapperStyles .= 'color: ' . $promotion->color . ';';
162
+ }
163
+ if ( isset( $promotion->wrapperPadding ) ) {
164
+ $wrapperStyles .= 'padding: ' . $promotion->wrapperPadding . ';';
165
+ }
166
+ if ( isset( $promotion->backgroundColor ) ) {
167
+ $wrapperStyles .= 'background-color: ' . $promotion->backgroundColor . ';';
168
+ }
169
+ if ( isset( $promotion->backgroundImage ) ) {
170
+ $wrapperStyles .= 'background-image: url("' . esc_url( $promotion->backgroundImage ) . '");';
171
+ }
172
+ if ( isset( $promotion->backgroundRepeat ) ) {
173
+ $wrapperStyles .= 'background-repeat: ' . $promotion->backgroundRepeat . ';';
174
+ }
175
+ if ( isset( $promotion->backgroundSize ) ) {
176
+ $wrapperStyles .= 'background-size: ' . $promotion->backgroundSize . ';';
177
+ }
178
+ if ( property_exists( $promotion, 'button' ) ) {
179
+ if ( isset( $promotion->button->backgroundColor ) ) {
180
+ $buttonStyles .= 'background-color: ' . $promotion->button->backgroundColor . ';border-color: ' . $promotion->button->backgroundColor . ';';
181
+ }
182
+ if ( isset( $promotion->button->color ) ) {
183
+ $buttonStyles .= 'color: ' . $promotion->button->color . ';';
184
+ }
185
  }
186
  $noticeClasses = 'notice notice-success wapk-promo';
187
+ if ( $is_dismissible ) {
188
+ $noticeClasses .= ' is-dismissible';
189
+ }
190
  ?>
191
+ <div class="<?php echo esc_attr( $noticeClasses ); ?> " id="<?php echo esc_attr( $promotion->hash ); ?>" data-nonce="<?php echo esc_attr( wp_create_nonce( 'wapk-dismiss-promo' ) ); ?>" style="<?php echo esc_attr( $wrapperStyles ); ?>">
192
+ <div class="wapk-promo-wrap<?php if ( ! $has_columns ) echo ' no-column'; ?>">
193
+ <?php if ( isset( $promotion->logo ) && ! empty( $promotion->logo ) ) { ?>
194
  <div class="wapk-logo wapk-column">
195
  <img src="<?php echo esc_url( $promotion->logo->src ); ?>" alt="<?php echo esc_attr( $promotion->logo->alt ); ?>">
196
  </div>
197
  <?php } ?>
198
+ <div class="wapk-details<?php if ( $has_columns ) echo ' wapk-column'; ?>">
199
  <?php echo wp_kses_post( $promotion->content ); ?>
200
  </div>
201
+ <?php if ( isset( $promotion->button ) && ! empty( $promotion->button ) ) { ?>
202
  <div class="wapk-btn-container wapk-column">
203
+ <a href="<?php echo esc_url( $promotion->button->url ); ?>" class="button wapk-promo-btn" style="<?php echo esc_attr( $buttonStyles ); ?>" target="_blank"><?php echo wp_kses_post( $promotion->button->label ); ?></a>
204
+ <?php
205
+ if ( isset( $promotion->button->after ) && ! empty( $promotion->button->after ) ) {
206
  echo wp_kses_post( $promotion->button->after );
207
+ }
208
+ ?>
209
  </div>
210
  <?php } ?>
211
+ <?php if ( isset( $promotion->button ) && ! empty( $promotion->button ) ) { ?>
212
  <?php } ?>
213
  </div>
214
  </div>
223
  */
224
  private function __get_promos() {
225
  $promos = get_transient( $this->client->getSlug() . '_cached_promos' );
226
+ if ( empty( $promos ) ) {
227
+ // get promotions data from json source.
228
+ $response = wp_safe_remote_get( $this->promotionSrc, array( 'timeout' => 15 ) ); // phpcs:ignore
229
+ $promos = wp_remote_retrieve_body( $response );
230
+ if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
231
+ $promos = '[]';
232
+ }
233
+ // cache data.
234
  set_transient( $this->client->getSlug() . '_cached_promos', $promos, 12 * HOUR_IN_SECONDS );
235
  }
236
+ // decode to array.
237
  $promos = json_decode( $promos );
238
 
239
+ // filter promotions by date.
240
  $promos = array_filter( $promos, [ $this, '__is_promo_active' ] );
241
+ if ( ! empty( $promos ) ) {
242
+ // filter promotions by list of hidden promotions by the user.
243
  $promos = array_filter( $promos, [ $this, '__is_promo_hidden' ] );
244
  }
245
  return $promos;
248
  /**
249
  * Check if promotion is active by date.
250
  * must have start and end property
251
+ * @param object $promo { the promo object.
252
  * Single Promo Object
253
  * @type string $content string. required
254
  * @type string $start valid timestamp. required
258
  * @return bool
259
  */
260
  public function __is_promo_active( $promo ) {
261
+ $ct = current_time( 'timestamp' ); // phpcs:ignore
262
+ return ( ! empty( $promo->content ) && strtotime( $promo->start ) < $ct && $ct < strtotime( $promo->end ) );
263
  }
264
 
265
  /**
266
  * Check if promo is hidden by current user
267
+ * @param object $promo { the promo object.
268
  * Single Promo Object
269
  * @type string $hash valid unique hash for a promo
270
  * }
289
  * @return void
290
  */
291
  public function __get_promo_scripts() {
292
+ ?>
293
+ <!--suppress ES6ConvertVarToLetConst -->
294
  <script>
295
  (function($){
296
  $('body').on('click', '.wapk-promo .notice-dismiss', function (e) {
303
  });
304
  });
305
  })(jQuery);
306
+ </script>
307
+ <?php
308
  }
309
 
310
  /**
312
  * @return void
313
  */
314
  public function __get_promo_styles() {
315
+ ?>
316
+ <!--suppress CssUnusedSymbol -->
317
  <style>
318
  .wapk-promo { border: none; padding: 15px 0; }
319
  .wapk-promo-wrap { display: flex; justify-content: center; align-items: center; text-align: center; color: inherit; max-width: 1820px; margin: 0 auto; }
330
  .wapk-promo-wrap .wapk-promo-btn:hover,
331
  .wapk-promo-wrap .wapk-promo-btn:active { box-shadow: inset 3px 4px 6px 0 rgba(1, 9, 12, 0.25); }
332
  .wapk-promo-wrap .wapk-promo-btn:active { top: 1px; }
 
333
  @media screen and (max-width: 1200px) {
334
  .wapk-promo-wrap { display: block; overflow: hidden; }
335
  .wapk-column .wapk-logo { width: 100%; margin: 0 auto; }
341
  .wapk-btn-container { float: none; width: 100%; margin-top: 32px; }
342
  .wapk-column.wapk-btn-container { width: 100%; float: right; margin-top: 42px; }
343
  }
344
+ </style>
345
+ <?php
346
  }
347
 
348
  /**
352
  public function __webappick_dismiss_promo() {
353
  if (
354
  isset( $_REQUEST['dismissed'], $_REQUEST['hash'], $_REQUEST['_wpnonce'] ) &&
355
+ 'true' == $_REQUEST['dismissed'] && ! empty( $_REQUEST['hash'] ) &&
356
+ wp_verify_nonce( sanitize_text_field( $_REQUEST['_wpnonce'] ), 'wapk-dismiss-promo' )
 
357
  ) {
358
  $this->hiddenPromotions = array_merge( $this->hiddenPromotions, [ sanitize_text_field( $_REQUEST['hash'] ) ] );
359
  update_user_option( $this->currentUser, $this->client->getSlug() . '_hidden_promos', $this->hiddenPromotions );
360
+ wp_send_json_success( esc_html__( 'Promo hidden', 'webappick' ) );
361
  }
362
+ wp_send_json_error( esc_html__( 'Invalid Request', 'webappick' ) );
363
  die();
364
  }
365
 
369
  * @return bool
370
  */
371
  public function clear_hidden_promos() {
372
+ if ( ! did_action( 'admin_init' ) ) {
373
+ _doing_it_wrong( __METHOD__, esc_html__( 'Method must be invoked inside admin_init action', 'webappick' ), '1.0.0' );
374
  }
375
  $this->currentUser = get_current_user_id();
376
  return delete_user_option( $this->currentUser, $this->client->getSlug() . '_hidden_promos' );
384
  return delete_transient( $this->client->getSlug() . '_cached_promos' );
385
  }
386
  }
387
+ // End of file Promotions.php.
libs/WebAppick/AppServices/Updater.php CHANGED
@@ -1,11 +1,24 @@
1
  <?php
2
- namespace WebAppick\AppServices;
3
- use stdClass;
4
- if( ! defined( 'ABSPATH' ) ) die();
5
  /**
6
  * WebAppick Updater
7
  *
8
  * This class will show new updates project
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  */
10
  class Updater {
11
 
@@ -38,8 +51,8 @@ class Updater {
38
  /**
39
  * Initialize the class
40
  *
41
- * @param Client $client
42
- * @param License $license
43
  */
44
  public function __construct( Client $client, License $license ) {
45
  $this->client = $client;
@@ -85,16 +98,18 @@ class Updater {
85
 
86
  /**
87
  * Check for Update for this specific project
88
- * @param object $transient_data
89
  * @return object
90
  */
91
  public function check_plugin_update( $transient_data ) {
92
  global $pagenow;
93
- //delete_site_transient( 'update_plugins' );
94
  if ( ! isset( $transient_data->checked ) || isset( $transient_data->checked ) && empty( $transient_data->checked ) ) {
95
  return $transient_data;
96
  }
97
- if ( ! is_object( $transient_data ) ) $transient_data = new stdClass;
 
 
98
  if ( 'plugins.php' == $pagenow && is_multisite() ) return $transient_data;
99
  if ( ! empty( $transient_data->response ) && ! empty( $transient_data->response[ $this->client->getBasename() ] ) ) {
100
  return $transient_data;
@@ -122,15 +137,15 @@ class Updater {
122
  */
123
  private function get_cached_version_info() {
124
  $info = get_transient( $this->cache_key );
125
- if( ! $info && ! isset( $info->name ) ) {
126
- return false; // Cache is expired
127
  }
128
  return $this->__children_to_array( $info, [ 'icons', 'banners', 'sections' ] );
129
  }
130
 
131
  /**
132
  * Set version info to database
133
- * @param string $value
134
  * @return void
135
  */
136
  private function set_cached_version_info( $value ) {
@@ -152,39 +167,45 @@ class Updater {
152
  */
153
  private function get_information() {
154
  $response = $this->license->check_update();
155
- // $fields = [
156
- // 'id',
157
- // 'name',
158
- // 'author',
159
- // 'author_profile',
160
- // 'slug',
161
- // 'plugin',
162
- // 'new_version',
163
- // 'url',
164
- // 'package',
165
- // 'icons',
166
- // 'banners',
167
- // 'banner_rtl',
168
- // 'upgrade_notice',
169
- // 'requires',
170
- // 'requires_php',
171
- // 'tested',
172
- // 'compatibility',
173
- // 'contributors',
174
- // 'ratings',
175
- // 'num_ratings',
176
- // 'last_updated',
177
- // 'homepage',
178
- // 'author_block_count',
179
- // 'author_block_rating',
180
- // ];
181
- if( isset( $response['success'] ) && $response['success'] ) {
 
 
 
 
182
  $data = $response['data']['package'];
183
  $response = $this->license->get_information();
184
- if( isset( $response['success'] ) && $response['success'] ) {
185
  $data = array_merge( $data, $response['data']['info'] );
186
  }
187
- if( isset( $data['product_id'] ) ) unset( $data['product_id'] );
 
 
188
  /**
189
  * Filter API Response Data
190
  * @param array $data
@@ -198,14 +219,16 @@ class Updater {
198
  /**
199
  * Updates information on the "View version x.x details" page with custom data.
200
  *
201
- * @param mixed $data
202
- * @param string $action
203
- * @param object $args
204
  *
205
  * @return object $data
206
  */
207
  public function plugins_api_filter( $data, $action = '', $args = null ) {
208
- if ( $action != 'plugin_information' ) return $data;
 
 
209
  if ( ! isset( $args->slug ) || ( $args->slug != $this->client->getSlug() ) ) return $data;
210
  $project_info = $this->get_cached_version_info();
211
  if ( false === $project_info ) {
@@ -217,12 +240,14 @@ class Updater {
217
 
218
  /**
219
  * Check theme update
220
- * @param object $transient_data
221
  * @return object
222
  */
223
  public function check_theme_update( $transient_data ) {
224
  global $pagenow;
225
- if ( ! is_object( $transient_data ) ) $transient_data = new stdClass;
 
 
226
  if ( 'themes.php' == $pagenow && is_multisite() ) return $transient_data;
227
  if ( ! empty( $transient_data->response ) && ! empty( $transient_data->response[ $this->client->getSlug() ] ) ) {
228
  return $transient_data;
@@ -245,25 +270,25 @@ class Updater {
245
  /**
246
  * Typecast child element to array or object
247
  * Utility method
248
- * @param array|object $object
249
- * @param array $children
250
- * @param string $castTo optional array or object
251
  *
252
  * @return mixed|array|object
253
  */
254
  private function __children_to_array( $object, $children = [], $castTo = 'array' ) {
255
- if( ! empty( $children ) && is_array( $children ) && ( is_object( $object ) || is_array( $object ) ) ) {
256
  $isObject = is_object( $object );
257
  $castTo = strtolower( $castTo ) == 'array' ? 'A' : 'O';
258
- foreach( $children as $child ) {
259
- if( $isObject && property_exists( $object, $child ) ) {
260
- $object->{$child} = $castTo === 'A' ? (array) $object->{$child} : (object) $object->{$child};
261
- } else if( array_key_exists( $child, $object ) ) {
262
- $object[$child] = $castTo === 'A' ? (array) $object[$child] : (object) $object[$child];
263
  }
264
  }
265
  }
266
  return $object;
267
  }
268
  }
269
- // End of file Updater.php
1
  <?php
 
 
 
2
  /**
3
  * WebAppick Updater
4
  *
5
  * This class will show new updates project
6
+ * @version 1.0.0
7
+ * @package WebAppick
8
+ * @subpackage AppServices
9
+ */
10
+
11
+ namespace WebAppick\AppServices;
12
+
13
+ use stdClass;
14
+
15
+ if ( ! defined( 'ABSPATH' ) ) {
16
+ die();
17
+ }
18
+
19
+ /**
20
+ * Class Updater
21
+ * @package WebAppick\AppServices
22
  */
23
  class Updater {
24
 
51
  /**
52
  * Initialize the class
53
  *
54
+ * @param Client $client The Client.
55
+ * @param License $license The license.
56
  */
57
  public function __construct( Client $client, License $license ) {
58
  $this->client = $client;
98
 
99
  /**
100
  * Check for Update for this specific project
101
+ * @param object $transient_data plugin update transient data.
102
  * @return object
103
  */
104
  public function check_plugin_update( $transient_data ) {
105
  global $pagenow;
106
+
107
  if ( ! isset( $transient_data->checked ) || isset( $transient_data->checked ) && empty( $transient_data->checked ) ) {
108
  return $transient_data;
109
  }
110
+ if ( ! is_object( $transient_data ) ) {
111
+ $transient_data = new stdClass();
112
+ }
113
  if ( 'plugins.php' == $pagenow && is_multisite() ) return $transient_data;
114
  if ( ! empty( $transient_data->response ) && ! empty( $transient_data->response[ $this->client->getBasename() ] ) ) {
115
  return $transient_data;
137
  */
138
  private function get_cached_version_info() {
139
  $info = get_transient( $this->cache_key );
140
+ if ( ! $info && ! isset( $info->name ) ) {
141
+ return false; // Cache is expired.
142
  }
143
  return $this->__children_to_array( $info, [ 'icons', 'banners', 'sections' ] );
144
  }
145
 
146
  /**
147
  * Set version info to database
148
+ * @param string $value data (version info) to cache.
149
  * @return void
150
  */
151
  private function set_cached_version_info( $value ) {
167
  */
168
  private function get_information() {
169
  $response = $this->license->check_update();
170
+ // phpcs:disable
171
+ /*
172
+ // Possible fields for plugin information.
173
+ $fields = [
174
+ 'id' => '',
175
+ 'name' => '',
176
+ 'author' => '',
177
+ 'author_profile' => '',
178
+ 'slug' => '',
179
+ 'plugin' => '',
180
+ 'new_version' => '',
181
+ 'url' => '',
182
+ 'package' => '',
183
+ 'icons' => '',
184
+ 'banners' => '',
185
+ 'banner_rtl' => '',
186
+ 'upgrade_notice' => '',
187
+ 'requires' => '',
188
+ 'requires_php' => '',
189
+ 'tested' => '',
190
+ 'compatibility' => '',
191
+ 'contributors' => '',
192
+ 'ratings' => '',
193
+ 'num_ratings' => '',
194
+ 'last_updated' => '',
195
+ 'homepage' => '',
196
+ 'author_block_count' => '',
197
+ 'author_block_rating' => '',
198
+ ];*/
199
+ // phpcs:enable
200
+ if ( isset( $response['success'] ) && $response['success'] ) {
201
  $data = $response['data']['package'];
202
  $response = $this->license->get_information();
203
+ if ( isset( $response['success'] ) && $response['success'] ) {
204
  $data = array_merge( $data, $response['data']['info'] );
205
  }
206
+ if ( isset( $data['product_id'] ) ) {
207
+ unset( $data['product_id'] );
208
+ }
209
  /**
210
  * Filter API Response Data
211
  * @param array $data
219
  /**
220
  * Updates information on the "View version x.x details" page with custom data.
221
  *
222
+ * @param mixed $data Plugin info Data.
223
+ * @param string $action Request Action.
224
+ * @param object $args API Args.
225
  *
226
  * @return object $data
227
  */
228
  public function plugins_api_filter( $data, $action = '', $args = null ) {
229
+ if ( 'plugin_information' != $action ) {
230
+ return $data;
231
+ }
232
  if ( ! isset( $args->slug ) || ( $args->slug != $this->client->getSlug() ) ) return $data;
233
  $project_info = $this->get_cached_version_info();
234
  if ( false === $project_info ) {
240
 
241
  /**
242
  * Check theme update
243
+ * @param object $transient_data Theme update transient data.
244
  * @return object
245
  */
246
  public function check_theme_update( $transient_data ) {
247
  global $pagenow;
248
+ if ( ! is_object( $transient_data ) ) {
249
+ $transient_data = new stdClass();
250
+ }
251
  if ( 'themes.php' == $pagenow && is_multisite() ) return $transient_data;
252
  if ( ! empty( $transient_data->response ) && ! empty( $transient_data->response[ $this->client->getSlug() ] ) ) {
253
  return $transient_data;
270
  /**
271
  * Typecast child element to array or object
272
  * Utility method
273
+ * @param array|object $object the array or object to convert/typecast.
274
+ * @param array $children children array.
275
+ * @param string $castTo optional array or object.
276
  *
277
  * @return mixed|array|object
278
  */
279
  private function __children_to_array( $object, $children = [], $castTo = 'array' ) {
280
+ if ( ! empty( $children ) && is_array( $children ) && ( is_object( $object ) || is_array( $object ) ) ) {
281
  $isObject = is_object( $object );
282
  $castTo = strtolower( $castTo ) == 'array' ? 'A' : 'O';
283
+ foreach ( $children as $child ) {
284
+ if ( $isObject && property_exists( $object, $child ) ) {
285
+ $object->{$child} = 'A' === $castTo ? (array) $object->{$child} : (object) $object->{$child};
286
+ } elseif ( array_key_exists( $child, $object ) ) {
287
+ $object[ $child ] = 'A' === $castTo ? (array) $object[ $child ] : (object) $object[ $child ];
288
  }
289
  }
290
  }
291
  return $object;
292
  }
293
  }
294
+ // End of file Updater.php.
libs/WebAppick/phpcs.xml ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <ruleset name="WordPress Coding Standards">
3
+ <description>WebAppick dev PHP_CodeSniffer ruleset.</description>
4
+
5
+ <file>.</file>
6
+
7
+ <!-- Exclude paths -->
8
+ <exclude-pattern>tests/cli/</exclude-pattern>
9
+ <exclude-pattern>*/node_modules/*</exclude-pattern>
10
+ <exclude-pattern>*/vendor/*</exclude-pattern>
11
+
12
+ <!-- Show progress, show the error codes for each message (source). -->
13
+ <arg value="ps" />
14
+
15
+ <!-- Strip the file paths in reports down to the relevant bit. -->
16
+ <arg name="basepath" value="./" />
17
+
18
+ <!-- Check up to 8 files simultaneously. -->
19
+ <!-- <arg name="parallel" value="8" />-->
20
+
21
+ <!-- Configs -->
22
+ <!-- <config name="minimum_supported_wp_version" value="5.0" />-->
23
+ <!-- <config name="testVersion" value="5.6-" />-->
24
+
25
+ <!-- Rules -->
26
+ <rule ref="WordPress">
27
+ <exclude name="WordPress.Files.FileName.InvalidClassFileName"/>
28
+ </rule>
29
+ <rule ref="WordPress-Core" />
30
+ <rule ref="WordPress-Extra" />
31
+ <rule ref="WordPress-VIP-Go" />
32
+
33
+ <rule ref="WordPress.WP.I18n">
34
+ <properties>
35
+ <property name="text_domain" type="array" value="webappick" />
36
+ </properties>
37
+ </rule>
38
+
39
+ <rule ref="PHPCompatibility">
40
+ <exclude-pattern>tests/</exclude-pattern>
41
+ </rule>
42
+
43
+ <rule ref="WordPress.Files.FileName.InvalidClassFileName">
44
+ <exclude-pattern>includes/**/abstract-*.php</exclude-pattern>
45
+ <exclude-pattern>tests/*</exclude-pattern>
46
+ <exclude-pattern>src/*</exclude-pattern>
47
+ </rule>
48
+
49
+ <rule ref="Generic.Commenting">
50
+ <exclude-pattern>tests/</exclude-pattern>
51
+ </rule>
52
+
53
+ <rule ref="PEAR.Functions.FunctionCallSignature.EmptyLine">
54
+ <exclude-pattern>tests/e2e-tests/</exclude-pattern>
55
+ </rule>
56
+
57
+ <rule ref="WordPress.Files.FileName.NotHyphenatedLowercase">
58
+ <exclude-pattern>i18n/</exclude-pattern>
59
+ <exclude-pattern>src/</exclude-pattern>
60
+ </rule>
61
+
62
+ <rule ref="Generic">
63
+ <exclude-pattern>.</exclude-pattern>
64
+ <exclude name="Generic.Commenting.DocComment.SpacingBeforeTags"/>
65
+ <exclude name="Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed" />
66
+ <exclude name="Generic.WhiteSpace.DisallowTabIndent.NonIndentTabsUsed" />
67
+ <exclude name="Generic.WhiteSpace.DisallowTabIndent.TabsUsed" />
68
+ <exclude name="Generic.PHP.ClosingPHPTag.NotFound" />
69
+ <exclude name="Generic.Files.LineLength.TooLong" />
70
+ </rule>
71
+ </ruleset>
uninstall.php CHANGED
@@ -7,7 +7,7 @@
7
  */
8
 
9
  // If uninstall not called from WordPress, then exit.
10
- if (!defined('WP_UNINSTALL_PLUGIN')) {
11
  exit;
12
  }
13
 
7
  */
8
 
9
  // If uninstall not called from WordPress, then exit.
10
+ if ( ! defined('WP_UNINSTALL_PLUGIN') ) {
11
  exit;
12
  }
13
 
woo-feed.php CHANGED
@@ -2,11 +2,6 @@
2
  /**
3
  * The plugin bootstrap file
4
  *
5
- * This file is read by WordPress to generate the plugin information in the plugin
6
- * admin area. This file also includes all of the dependencies used by the plugin,
7
- * registers the activation and deactivation functions, and defines a function
8
- * that starts the plugin.
9
- *
10
  * @link https://webappick.com
11
  * @since 1.0.0
12
  * @package Woo_Feed
@@ -14,8 +9,10 @@
14
  * @wordpress-plugin
15
  * Plugin Name: WooCommerce Product Feed
16
  * Plugin URI: https://webappick.com/
17
- * Description: This plugin generate WooCommerce product feed for Shopping Engines like Google Shopping,Facebook Product Feed,eBay,Amazon,Idealo and many more..
18
- * Version: 3.2.17
 
 
19
  * Author: WebAppick
20
  * Author URI: https://webappick.com/
21
  * License: GPL v2
@@ -31,18 +28,21 @@
31
  * WC Requirement & Test
32
  * WC requires at least: 3.2
33
  * WC tested up to: 3.9.1
34
- *
35
  */
36
- // Exit if accessed directly
37
- if (!defined('ABSPATH')) die();
38
- // Constants
 
 
39
  if ( ! defined( 'WOO_FEED_FREE_VERSION' ) ) {
40
  /**
41
  * Plugin Version
42
  * @var string
 
43
  */
44
- define( 'WOO_FEED_FREE_VERSION', '3.2.17' );
45
  }
 
46
  if ( ! defined( 'WOO_FEED_FREE_FILE') ) {
47
  /**
48
  * Plugin Base File
@@ -55,14 +55,16 @@ if ( ! defined( 'WOO_FEED_FREE_PATH' ) ) {
55
  /**
56
  * Plugin Path with trailing slash
57
  * @var string dirname( __FILE__ )
 
58
  */
59
- /** @define "WOO_FEED_FREE_PATH" "./" */
60
- define( 'WOO_FEED_FREE_PATH', plugin_dir_path( __FILE__ ) );
61
  }
62
  if ( ! defined( 'WOO_FEED_FREE_ADMIN_PATH' ) ) {
63
  /**
64
  * Admin File Path with trailing slash
65
  * @var string
 
66
  */
67
  define( 'WOO_FEED_FREE_ADMIN_PATH', WOO_FEED_FREE_PATH . 'admin/' );
68
  }
@@ -80,7 +82,7 @@ if ( ! defined( 'WOO_FEED_PLUGIN_URL' ) ) {
80
  * @var string
81
  * @since 3.1.37
82
  */
83
- define( 'WOO_FEED_PLUGIN_URL', trailingslashit( plugin_dir_url(__FILE__) ) );
84
  }
85
  if ( ! defined( 'WOO_FEED_MIN_PHP_VERSION' ) ) {
86
  /**
@@ -104,7 +106,7 @@ if ( ! defined( 'WOO_FEED_PLUGIN_BASE_NAME' ) ) {
104
  * @var string
105
  * @since 3.1.41
106
  */
107
- define( 'WOO_FEED_PLUGIN_BASE_NAME', plugin_basename(__FILE__) );
108
  }
109
 
110
  if ( ! defined( 'WOO_FEED_LOG_DIR' ) ) {
@@ -114,10 +116,14 @@ if ( ! defined( 'WOO_FEED_LOG_DIR' ) ) {
114
  * @var string
115
  * @since 3.2.1
116
  */
117
- /** @define "WOO_FEED_LOG_DIR" "./../../uploads/woo-feed/logs" */
118
  define( 'WOO_FEED_LOG_DIR', $upload_dir['basedir'] . '/woo-feed/logs/' );
119
  }
120
 
 
 
 
 
121
  /**
122
  * Load Helper functions
123
  */
@@ -126,10 +132,6 @@ require_once WOO_FEED_FREE_PATH . 'includes/helper.php';
126
  * Installer
127
  */
128
  require_once WOO_FEED_FREE_PATH . 'includes/class-woo-feed-installer.php';
129
- /**
130
- * Load Uses Tracker
131
- */
132
- require_once WOO_FEED_FREE_PATH . 'includes/classes/class-woo-feed-webappick-api.php';
133
 
134
  if ( ! class_exists( 'Woo_Feed' ) ) {
135
  /**
@@ -152,6 +154,7 @@ if ( ! function_exists( 'run_woo_feed' ) ) {
152
  function run_woo_feed() {
153
  $plugin = new Woo_Feed();
154
  register_activation_hook( WOO_FEED_FREE_FILE, [ 'Woo_Feed_installer', 'install' ] );
 
155
  /**
156
  * Ensure Feed Plugin runs only if WooCommerce loaded (installed and activated)
157
  * @since 3.1.41
@@ -160,8 +163,28 @@ if ( ! function_exists( 'run_woo_feed' ) ) {
160
  add_action( 'admin_notices', 'wooFeed_Admin_Notices' );
161
  WooFeedWebAppickAPI::getInstance();
162
  }
 
163
  run_woo_feed();
164
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
 
166
  #======================================================================================================================*
167
  #
@@ -173,74 +196,93 @@ if ( ! function_exists( 'woo_feed_get_product_information' ) ) {
173
  /**
174
  * Count Total Products
175
  */
176
- function woo_feed_get_product_information(){
177
- check_ajax_referer('wpf_feed_nonce');
178
- if( ! current_user_can( 'manage_woocommerce' ) ) {
 
 
 
179
  // woo_feed_log_debug_message( 'User doesnt have enough permission.' );
180
- wp_send_json_error( esc_html__( 'Unauthorized Action.' ) );
181
  die();
182
  }
183
- if(woo_feed_wc_version_check(3.2)){
184
-
185
- $feed = sanitize_text_field( $_REQUEST['feed'] );
186
- $limit = absint( $_REQUEST['limit'] );
187
-
188
- $getConfig=maybe_unserialize(get_option($feed));
189
-
190
- $products=new Woo_Feed_Products_v3($getConfig);
191
- $ids=$products->query_products();
192
-
193
- if(is_array($ids) && !empty($ids)){
194
-
195
- if(count($ids)>2e3){
196
- $ids=array_slice($ids,0,2e3,true);
197
- }
198
-
199
- if(count($ids)>$limit){
200
- $batches=array_chunk($ids,$limit);
201
- }else{
202
- $batches = array( $ids );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203
  }
204
-
205
- $data = array( 'product' => $batches,'total'=>count($ids));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
  $data['success'] = true;
207
- wp_send_json_success( $data );
208
- }else{
209
- $data['success'] = false;
210
- $data['message'] = 'Failed to fetch products.';
211
- wp_send_json_error( $data );
 
 
 
 
 
 
 
 
 
 
212
  }
213
-
214
- wp_die();
215
- // $query=new WC_Product_Query(array(
216
- // 'limit' => -1,
217
- // 'status' => 'publish',
218
- // 'orderby' => 'date',
219
- // 'order' => 'DESC',
220
- // 'type' => array('variable','variation','simple','grouped','external'),
221
- // 'return' => 'ids',
222
- // ));
223
- // $products=$query->get_products();
224
- // $totalProducts=count($products);
225
- }else{
226
- $products=wp_count_posts('product');
227
- $variations=wp_count_posts('product_variation');
228
- $totalProducts=$products->publish + $variations->publish;
229
  }
230
-
231
-
232
- $data=array('product'=>$totalProducts);
233
-
234
- if($totalProducts>0){
235
- $data['success']=true;
236
- wp_send_json_success($data);
237
- }else{
238
- $data['success']=false;
239
- $data['message']='No products found. Add product before generating the feed.';
240
- wp_send_json_error($data);
241
- }
242
-
243
- wp_die();
244
  }
245
  }
246
  if ( ! function_exists( 'woo_feed_make_batch_feed' ) ) {
@@ -251,9 +293,9 @@ if ( ! function_exists( 'woo_feed_make_batch_feed' ) ) {
251
  */
252
  function woo_feed_make_batch_feed(){
253
  check_ajax_referer('wpf_feed_nonce');
254
- if( ! current_user_can( 'manage_woocommerce' ) ) {
255
  // woo_feed_log_debug_message( 'User doesnt have enough permission.' );
256
- wp_send_json_error( esc_html__( 'Unauthorized Action.' ) );
257
  die();
258
  }
259
  //$limit=sanitize_text_field($_POST['limit']);
@@ -261,9 +303,9 @@ if ( ! function_exists( 'woo_feed_make_batch_feed' ) ) {
261
  $feedName = str_replace( "wf_feed_", "", sanitize_text_field( $_POST['feed'] ) );
262
  $feedInfo = get_option( $feedName );
263
 
264
- if(!$feedInfo){
265
- $getFeedConfig=unserialize(get_option($feedName));
266
- $feedInfo=$getFeedConfig['feedrules'];
267
  }
268
 
269
  $products = array_map( 'absint', $_REQUEST['products'] );
@@ -271,21 +313,21 @@ if ( ! function_exists( 'woo_feed_make_batch_feed' ) ) {
271
  $feedInfo['productIds'] = $products;
272
 
273
 
274
- if( $offset == 0 ){
275
  $fileName = str_replace(" ", "",$feedInfo['filename']);
276
  $type = $feedInfo['feedType'];
277
  $feedService = $feedInfo['provider'];
278
- if ($type == "csv") {
279
- $type="json";
280
  }
281
 
282
  $upload_dir = wp_upload_dir();
283
  $base = $upload_dir['basedir'];
284
  $path = $base . "/woo-feed/" . $feedService . "/" . $type;
285
 
286
- $tempFiles['headerFile'] =$path . "/" . "wf_store_feed_header_info_".$fileName . "." . $type;
287
- $tempFiles['bodyFile'] =$path . "/" . "wf_store_feed_body_info_".$fileName . "." . $type;
288
- $tempFiles['footerFile'] =$path . "/" . "wf_store_feed_footer_info_".$fileName . "." . $type;
289
 
290
  woo_feed_unlink_tempFiles($tempFiles);
291
  }
@@ -294,18 +336,18 @@ if ( ! function_exists( 'woo_feed_make_batch_feed' ) ) {
294
  // $feedInfo['Limit']=$limit;
295
  // $feedInfo['Offset']=$offset;
296
 
297
- $feed_data=woo_feed_generate_feed_data($feedInfo);
298
- if($feed_data){
299
- $data=array(
300
- "success"=>true,
301
- "products"=>"yes",
302
  );
303
  wp_send_json_success($data);
304
  die();
305
- }else{
306
- $data=array(
307
- "success"=>true,
308
- "products"=>"no",
309
  );
310
  wp_send_json_success($data);
311
  die();
@@ -317,14 +359,14 @@ if ( ! function_exists( 'woo_feed_save_feed_file' ) ) {
317
  function woo_feed_save_feed_file(){
318
 
319
  check_ajax_referer('wpf_feed_nonce');
320
- if( ! current_user_can( 'manage_woocommerce' ) ) {
321
  // woo_feed_log_debug_message( 'User doesnt have enough permission.' );
322
- wp_send_json_error( esc_html__( 'Unauthorized Action.' ) );
323
  die();
324
  }
325
  $feed = str_replace("wf_feed_", "", sanitize_text_field( $_REQUEST['feed'] ) );
326
  $info = get_option($feed);
327
- if(!$info){
328
  $getInfo = unserialize(get_option( sanitize_text_field( $_REQUEST['feed'] ) ));
329
  $info = $getInfo['feedrules'];
330
  }
@@ -333,19 +375,19 @@ if ( ! function_exists( 'woo_feed_save_feed_file' ) ) {
333
  $fileName = str_replace(" ", "",$info['filename']);
334
  $type = $info['feedType'];
335
 
336
- $feedHeader=woo_feed_get_batch_feed_info($feedService,$type,"wf_store_feed_header_info_".$fileName);
337
- $feedBody=woo_feed_get_batch_feed_info($feedService,$type,"wf_store_feed_body_info_".$fileName);
338
- $feedFooter=woo_feed_get_batch_feed_info($feedService,$type,"wf_store_feed_footer_info_".$fileName);
339
 
340
- if($type=='csv'){
341
- $csvHead[0]=$feedHeader;
342
- if(!empty($csvHead) && !empty($feedBody)){
343
- $string=array_merge($csvHead,$feedBody);
344
- }else{
345
- $string=array();
346
  }
347
- }else{
348
- $string=$feedHeader.$feedBody.$feedFooter;
349
  }
350
 
351
  $upload_dir = wp_upload_dir();
@@ -353,17 +395,20 @@ if ( ! function_exists( 'woo_feed_save_feed_file' ) ) {
353
  $path = $base . "/woo-feed/" . $feedService . "/" . $type;
354
  $saveFile = false;
355
  # Check If any products founds
356
- if ($string && !empty($string)) {
357
  # Save File
358
  $file = $path . "/" . $fileName . "." . $type;
359
  $save = new Woo_Feed_Savefile();
360
- if ($type == "csv") {
361
  $saveFile = $save->saveCSVFile($path, $file, $string, $info);
362
  } else {
363
  $saveFile = $save->saveFile($path, $file, $string);
364
  }
365
- }else{
366
- $data=array("success"=>false,"message"=>"No Product Found with your feed configuration. Please configure the feed properly.");
 
 
 
367
  wp_send_json_error($data);
368
  wp_die();
369
  }
@@ -372,19 +417,19 @@ if ( ! function_exists( 'woo_feed_save_feed_file' ) ) {
372
  # Save Info into database
373
  $url = $upload_dir['baseurl'] . "/woo-feed/" . $feedService . "/" . $type . "/" . $fileName . "." . $type;
374
  $feedInfo = array(
375
- 'feedrules' => $info,
376
- 'url' => $url,
377
- 'last_updated' => date("Y-m-d H:i:s"),
378
  );
379
 
380
  $feedOldInfo = unserialize( get_option( "wf_feed_".$fileName ) );
381
- if( isset( $feedOldInfo['status'] ) ) {
382
  $feedInfo['status'] = $feedOldInfo['status'];
383
- }else{
384
- $feedInfo['status']=1;
385
  }
386
 
387
- if (!empty($name) && $name != "wf_feed_" . $fileName) {
388
  delete_option($name);
389
  }
390
 
@@ -393,16 +438,16 @@ if ( ! function_exists( 'woo_feed_save_feed_file' ) ) {
393
  delete_option("wf_store_feed_body_info_".$fileName);
394
  delete_option("wf_store_feed_footer_info_".$fileName);
395
 
396
- if ($type == "csv") $type="json";
397
 
398
  # Remove Temp feed files
399
- $tempFiles['headerFile'] =$path . "/" . "wf_store_feed_header_info_".$fileName . "." . $type;
400
- $tempFiles['bodyFile'] =$path . "/" . "wf_store_feed_body_info_".$fileName . "." . $type;
401
- $tempFiles['footerFile'] =$path . "/" . "wf_store_feed_footer_info_".$fileName . "." . $type;
402
 
403
  woo_feed_unlink_tempFiles($tempFiles);
404
  update_option('wf_feed_' . $fileName, serialize($feedInfo));
405
- if ($saveFile) {
406
 
407
  # FTP File Upload Info
408
  $ftpHost = $info['ftphost'];
@@ -410,38 +455,41 @@ if ( ! function_exists( 'woo_feed_save_feed_file' ) ) {
410
  $ftpPassword = $info['ftppassword'];
411
  $ftpPath = $info['ftppath'];
412
  $ftpEnabled = $info['ftpenabled'];
413
- $ftporsftp = isset($info['ftporsftp'])?$info['ftporsftp']:"ftp";
414
- $ftpPort = isset($info['ftpport']) && !empty($info['ftpport'])?$info['ftpport']:21;
415
- try{
416
- if ($type == "json") $type="csv";
417
  # Upload file to ftp server
418
- if ($ftpEnabled) {
419
- if($ftporsftp == "ftp") {
420
  $ftp = new FTPClient();
421
- if ($ftp->connect($ftpHost, $ftpUser, $ftpPassword,false,$ftpPort)){
422
  $ftp->uploadFile($file, $fileName . "." . $type);
423
  }
424
- } elseif ($ftporsftp == "sftp" && extension_loaded ( 'ssh2' )) {
425
  $sftp = new SFTPConnection($ftpHost, $ftpPort);
426
  $sftp->login($ftpUser, $ftpPassword);
427
  $sftp->uploadFile($file, "/".$fileName . "." . $type);
428
  }
429
  }
430
- }catch (Exception $e){}
431
  $getInfo = unserialize(get_option('wf_feed_' . $fileName));
432
  $url = $getInfo['url'];
433
 
434
- $cat=woo_feed_check_google_category($feedInfo);
435
 
436
- $data=array(
437
- "info"=>$feedInfo,
438
- "url"=>$url,
439
- "cat"=>$cat,
440
- "message"=>"Feed Making Complete",
441
  );
442
  wp_send_json_success($data);
443
  } else {
444
- $data=array("success"=>false,"message"=>"Failed to save feed file. Please confirm that your WordPress directory have Read and Write permission.");
 
 
 
445
  wp_send_json_error($data);
446
  }
447
 
@@ -450,20 +498,20 @@ if ( ! function_exists( 'woo_feed_save_feed_file' ) ) {
450
  }
451
  // Ajax Helper
452
  if ( ! function_exists( 'woo_feed_generate_feed_data' ) ) {
453
- function woo_feed_generate_feed_data($info){
454
 
455
- try{
456
- if (count($info) && isset($info['provider'])) {
457
  # GEt Post data
458
- if ($info['provider'] == 'google' || $info['provider'] == 'adroll' || $info['provider'] == 'smartly.io') {
459
  $merchant = "Woo_Feed_Google";
460
- } elseif ($info['provider'] == 'pinterest') {
461
  $merchant = "Woo_Feed_Pinterest";
462
- } elseif ($info['provider'] == 'facebook') {
463
  $merchant = "Woo_Feed_Facebook";
464
- }elseif (strpos($info['provider'],'amazon') !==FALSE) {
465
  $merchant = "Woo_Feed_Amazon";
466
- }elseif ($info['provider'] == 'custom2') {
467
  $merchant = "Woo_Feed_Custom2";
468
  } else {
469
  $merchant = "Woo_Feed_Custom";
@@ -478,33 +526,32 @@ if ( ! function_exists( 'woo_feed_generate_feed_data' ) ) {
478
  # Get Feed info
479
  $products = new Woo_Generate_Feed($merchant, $feedRules);
480
  $feed = $products->getProducts();
481
- if(isset($feed['body']) && !empty($feed['body'])){
482
- $feedHeader="wf_store_feed_header_info_".$fileName;
483
- $feedBody="wf_store_feed_body_info_".$fileName;
484
- $feedFooter="wf_store_feed_footer_info_".$fileName;
485
- $prevFeed= woo_feed_get_batch_feed_info( $feedService, $type, $feedBody );
486
- if($prevFeed){
487
- if($type=='csv'){
488
- if(!empty($prevFeed)){
489
  $newFeed = array_merge( $prevFeed, $feed['body'] );
490
  woo_feed_save_batch_feed_info( $feedService, $type, $newFeed, $feedBody, $info );
491
  }
492
- }else{
493
- $newFeed=$prevFeed.$feed['body'];
494
  woo_feed_save_batch_feed_info( $feedService, $type, $newFeed, $feedBody, $info );
495
- }
496
-
497
- }else{
498
  woo_feed_save_batch_feed_info( $feedService, $type, $feed['body'], $feedBody, $info );
499
  }
500
  woo_feed_save_batch_feed_info( $feedService, $type, $feed['header'], $feedHeader, $info );
501
  woo_feed_save_batch_feed_info( $feedService, $type,$feed['footer'], $feedFooter, $info );
502
  return true;
503
- }else{
504
  return false;
505
  }
506
  }
507
- }catch (Exception $e){
508
  return false;
509
  }
510
  return false;
@@ -522,7 +569,7 @@ if ( ! function_exists( 'woo_feed_cron_update_feed' ) ) {
522
  $result = $wpdb->get_results( $query, 'ARRAY_A' );
523
  foreach ( $result as $key => $value ) {
524
  $feedInfo = maybe_unserialize( get_option( $value['option_name'] ) );
525
- if( ! isset( $feedInfo['feedrules'] ) || isset( $feedInfo['status'] ) && $feedInfo['status'] == "0" ) continue;
526
  woo_feed_add_update( $feedInfo['feedrules'] );
527
  }
528
  }
@@ -539,10 +586,10 @@ if ( ! function_exists( 'woo_feed_cron_update_single_feed' ) ) {
539
  global $wpdb;
540
  $feedName = "wf_feed_".$feedName[0];
541
  $result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->options WHERE option_name = %s", $feedName ),'ARRAY_A');
542
- if( ! empty( $result ) ) {
543
  foreach ( $result as $key => $value ) {
544
  $feedInfo = maybe_unserialize( get_option( $value['option_name'] ) );
545
- if( ! isset( $feedInfo['feedrules'] ) || isset( $feedInfo['status'] ) && $feedInfo['status'] == "0" ) continue;
546
  woo_feed_add_update( $feedInfo['feedrules'] );
547
  }
548
  }
@@ -557,16 +604,16 @@ if ( ! function_exists( 'woo_feed_add_update' ) ) {
557
  * @param string $name
558
  * @return string|bool
559
  */
560
- function woo_feed_add_update($info = array(), $name = "") {
561
- if (count($info) && isset($info['provider'])) {
562
  # GEt Post data
563
- if ($info['provider'] == 'google' || $info['provider'] == 'adroll' || $info['provider'] == 'smartly.io') {
564
  $merchant = "Woo_Feed_Google";
565
- } elseif ($info['provider'] == 'pinterest') {
566
  $merchant = "Woo_Feed_Pinterest";
567
- } elseif ($info['provider'] == 'facebook') {
568
  $merchant = "Woo_Feed_Facebook";
569
- }elseif (strpos($info['provider'],'amazon') !==FALSE) {
570
  $merchant = "Woo_Feed_Amazon";
571
  } else {
572
  $merchant = "Woo_Feed_Custom";
@@ -583,19 +630,19 @@ if ( ! function_exists( 'woo_feed_add_update' ) ) {
583
  $products = new Woo_Generate_Feed($merchant, $feedRules);
584
  $getString = $products->getProducts();
585
 
586
- if($type=='csv'){
587
- $csvHead[0]=$getString['header'];
588
- if(!empty($csvHead) && !empty($getString['body'])){
589
- $string=array_merge($csvHead,$getString['body']);
590
- }else{
591
- $string=array();
592
  }
593
- }else{
594
- $string=$getString['header'].$getString['body'].$getString['footer'];
595
  }
596
 
597
  # Check If any products founds
598
- if ($string && !empty($string)) {
599
 
600
  $upload_dir = wp_upload_dir();
601
  $base = $upload_dir['basedir'];
@@ -604,7 +651,7 @@ if ( ! function_exists( 'woo_feed_add_update' ) ) {
604
  $path = $base . "/woo-feed/" . $feedService . "/" . $type;
605
  $file = $path . "/" . $fileName . "." . $type;
606
  $save = new Woo_Feed_Savefile();
607
- if ($type == "csv") {
608
  $saveFile = $save->saveCSVFile($path, $file, $string, $info);
609
  } else {
610
  $saveFile = $save->saveFile($path, $file, $string);
@@ -615,49 +662,49 @@ if ( ! function_exists( 'woo_feed_add_update' ) ) {
615
  $ftpUser = sanitize_text_field($info['ftpuser']);
616
  $ftpPassword = sanitize_text_field($info['ftppassword']);
617
  $ftpPath = sanitize_text_field($info['ftppath']);
618
- $ftpPort = isset($info['ftpport']) && !empty($info['ftpport'])?sanitize_text_field($info['ftpport']):21;
619
  $ftpEnabled = sanitize_text_field($info['ftpenabled']);
620
 
621
- $ftporsftp = isset($info['ftporsftp'])?sanitize_text_field($info['ftporsftp']):"ftp";
622
 
623
 
624
- try{
625
- if ($type == "json") {
626
- $type="csv";
627
  }
628
  # Upload file to ftp server
629
- if ($ftpEnabled) {
630
- if($ftporsftp == "ftp") {
631
  $ftp = new FTPClient();
632
- if ($ftp->connect($ftpHost, $ftpUser, $ftpPassword,false,$ftpPort)){
633
  $ftp->uploadFile($file, $fileName . "." . $type);
634
  }
635
- } elseif ($ftporsftp == "sftp" && extension_loaded ( 'ssh2' )) {
636
  $sftp = new SFTPConnection($ftpHost, $ftpPort);
637
  $sftp->login($ftpUser, $ftpPassword);
638
  $sftp->uploadFile($file, "/".$fileName . "." . $type);
639
  }
640
  }
641
- }catch (Exception $e){
642
 
643
  }
644
 
645
  # Save Info into database
646
  $url = $upload_dir['baseurl'] . "/woo-feed/" . $feedService . "/" . $type . "/" . $fileName . "." . $type;
647
  $feedInfo = array(
648
- 'feedrules' => $feedRules,
649
- 'url' => $url,
650
- 'last_updated' => date("Y-m-d H:i:s"),
651
- 'status'=>1
652
  );
653
 
654
 
655
- if (!empty($name) && $name != "wf_feed_" . $fileName) {
656
  delete_option($name);
657
  }
658
 
659
  $update = update_option('wf_feed_' . $fileName, serialize($feedInfo));
660
- if ($saveFile) {
661
  $getInfo = unserialize(get_option('wf_feed_' . $fileName));
662
  $url = $getInfo['url'];
663
  return $url;
@@ -691,16 +738,14 @@ if ( ! function_exists( 'woo_feed_generate_feed' ) ) {
691
 
692
  wp_schedule_event(time(), 'woo_feed_corn', 'woo_feed_update_single_feed', $arg );
693
 
694
- wp_redirect( add_query_arg( [
695
- 'feed_created' => (int) false !== $fileName,
696
- 'feed_regenerate' => 1,
697
- 'feed_name' => $fileName ? $fileName : '',
698
  ], admin_url( 'admin.php?page=webappick-manage-feeds' ) ) );
699
  die();
700
-
701
  } else {
702
- echo "<div class='notice notice-warning is-dismissible'><p>" . __("You are awesome for using <b>WooCommerce Product Feed</b>. Free version works great for up to <b>2000 products including variations.</b>", 'woo-feed') . "</p></div>";
703
- require WOO_FEED_FREE_ADMIN_PATH . "partials/woo-feed-admin-display.php";
704
  }
705
  }
706
  }
@@ -710,9 +755,9 @@ if ( ! function_exists( 'woo_feed_manage_feed' ) ) {
710
  */
711
  function woo_feed_manage_feed() {
712
  // Manage action for category mapping
713
- if( isset( $_GET['action'] ) && $_GET['action'] == 'edit-feed' ) {
714
- if( ! defined( 'WOO_FEED_EDIT_CONFIG' ) ) define( 'WOO_FEED_EDIT_CONFIG', true );
715
- if( count( $_POST ) && isset( $_POST['provider'], $_POST['feed_id'], $_POST['filename'], $_POST['feedType'] ) ) {
716
  # Verify Nonce
717
  if ( ! wp_verify_nonce( sanitize_text_field( $_POST['_wpnonce'] ), 'wf_edit_feed' ) ) {
718
  wp_die( 'Failed security check' );
@@ -733,10 +778,10 @@ if ( ! function_exists( 'woo_feed_manage_feed' ) ) {
733
  $fileName = woo_feed_save_feed_config_data( $_POST, $fileName, isset( $_POST['edit-feed'] ) );
734
  // redirect to the feed list with status
735
  // @TODO this should be handled in admin_init action for proper redirection to work...
736
- wp_redirect( add_query_arg( [
737
- 'feed_updated' => (int) false !== $fileName,
738
- 'feed_regenerate' => (int) isset( $_POST['edit-feed'] ),
739
- 'feed_name' => $fileName ? $fileName : '',
740
  ], admin_url( 'admin.php?page=webappick-manage-feeds' ) ) );
741
  die();
742
  }
@@ -747,7 +792,7 @@ if ( ! function_exists( 'woo_feed_manage_feed' ) ) {
747
  $fname = sanitize_text_field( $_GET['feed'] );
748
  $feedInfo = unserialize( get_option( $fname ) );
749
  $feedId = $wpdb->get_row( $wpdb->prepare( "SELECT option_id FROM $wpdb->options WHERE option_name = %s LIMIT 1", $fname ) );
750
- if( $feedId ) $feedId = $feedId->option_id;
751
  $provider = strtolower( $feedInfo['feedrules']['provider'] );
752
  $feedRules = $feedInfo['feedrules'];
753
 
@@ -756,9 +801,9 @@ if ( ! function_exists( 'woo_feed_manage_feed' ) ) {
756
  } else {
757
  # Update Interval
758
  if ( isset( $_POST['wf_schedule'] ) ) {
759
- if( isset( $_POST['wf_schedule_nonce'] ) && wp_verify_nonce( sanitize_text_field( $_POST['wf_schedule_nonce'] ),'wf_schedule' ) ) {
760
  $interval = absint( $_POST['wf_schedule'] );
761
- if( $interval >= woo_feed_get_minimum_interval_option() ) {
762
  if ( update_option('wf_schedule', sanitize_text_field( $_POST['wf_schedule'] ) ) ) {
763
  wp_clear_scheduled_hook('woo_feed_update');
764
  add_filter( 'cron_schedules', 'Woo_Feed_installer::cron_schedules' );
@@ -767,8 +812,8 @@ if ( ! function_exists( 'woo_feed_manage_feed' ) ) {
767
  } else $update = 2; // db fail
768
  } else $update = 3; // invalid value
769
  } else $update = 4; // invalid nonce
770
- wp_redirect( add_query_arg( [ 'schedule_updated' => $update ], admin_url( 'admin.php?page=webappick-manage-feeds' ) ) );
771
- wp_die();
772
  }
773
  require WOO_FEED_FREE_ADMIN_PATH . "partials/woo-feed-manage-list.php";
774
  }
@@ -780,13 +825,13 @@ if ( ! function_exists( 'feed_merchant_view' ) ) {
780
  add_action('wp_ajax_get_feed_merchant', 'feed_merchant_view');
781
  function feed_merchant_view() {
782
  check_ajax_referer('wpf_feed_nonce');
783
- if( ! current_user_can( 'manage_woocommerce' ) ) {
784
  // woo_feed_log_debug_message( 'User doesnt have enough permission.' );
785
- wp_send_json_error( esc_html__( 'Unauthorized Action.' ) );
786
  die();
787
  }
788
  $merchant = $provider = isset( $_REQUEST['merchant'] ) && ! empty( $_REQUEST['merchant'] ) ? sanitize_text_field( $_REQUEST['merchant'] ) : '';
789
- if( empty( $merchant ) ) wp_die();
790
  ob_start();
791
  /** @noinspection PhpUnusedLocalVariableInspection */
792
  $dropDown = new Woo_Feed_Dropdown();
@@ -795,9 +840,9 @@ if ( ! function_exists( 'feed_merchant_view' ) ) {
795
  /** @noinspection PhpUnusedLocalVariableInspection */
796
  $attributes = new Woo_Feed_Default_Attributes();
797
 
798
- if ($merchant == 'smartly.io') {
799
  include WOO_FEED_FREE_ADMIN_PATH . "partials/templates/google_add-feed.php";
800
- } else if (file_exists(WOO_FEED_FREE_ADMIN_PATH . "partials/templates/" . $merchant . "_add-feed.php")) {
801
  include WOO_FEED_FREE_ADMIN_PATH . "partials/templates/" . $merchant . "_add-feed.php";
802
  } else {
803
  include WOO_FEED_FREE_ADMIN_PATH . "partials/templates/common_add-feed.php";
@@ -811,9 +856,9 @@ if ( ! function_exists( 'woo_feed_get_google_categories' ) ) {
811
  add_action( 'wp_ajax_get_google_categories', 'woo_feed_get_google_categories' );
812
  function woo_feed_get_google_categories() {
813
  check_ajax_referer('wpf_feed_nonce');
814
- if( ! current_user_can( 'manage_woocommerce' ) ) {
815
  // woo_feed_log_debug_message( 'User doesnt have enough permission.' );
816
- wp_send_json_error( esc_html__( 'Unauthorized Action.' ) );
817
  die();
818
  }
819
  $wooFeedDropDown = new Woo_Feed_Dropdown();
@@ -826,13 +871,13 @@ if ( ! function_exists( 'woo_feed_get_ssh2_status' ) ) {
826
  add_action('wp_ajax_get_ssh2_status', 'woo_feed_get_ssh2_status');
827
  function woo_feed_get_ssh2_status() {
828
  check_ajax_referer( 'wpf_feed_nonce' );
829
- if( ! current_user_can( 'manage_woocommerce' ) ) {
830
  // woo_feed_log_debug_message( 'User doesnt have enough permission.' );
831
- wp_send_json_error( esc_html__( 'Unauthorized Action.' ) );
832
  die();
833
  }
834
  $php_extension = get_loaded_extensions();
835
- if(extension_loaded ( 'ssh2' )) {
836
  wp_send_json_success('exists');
837
  } else {
838
  wp_send_json_success('not exists');
@@ -846,19 +891,19 @@ if ( ! function_exists( 'woo_feed_update_feed_status' ) ) {
846
  */
847
  add_action('wp_ajax_update_feed_status', 'woo_feed_update_feed_status');
848
  function woo_feed_update_feed_status(){
849
- if( ! current_user_can( 'manage_woocommerce' ) ) {
850
  // woo_feed_log_debug_message( 'User doesnt have enough permission.' );
851
- wp_send_json_error( esc_html__( 'Unauthorized Action.' ) );
852
  die();
853
  }
854
- if(!empty($_POST['feedName'])){
855
  $feedInfo = unserialize(get_option( sanitize_text_field( $_POST['feedName'] ) ));
856
  $feedInfo['status'] = sanitize_text_field( $_POST['status'] );
857
- $data = array('status' => true);
858
  update_option( sanitize_text_field( $_POST['feedName'] ),serialize($feedInfo));
859
  wp_send_json_success($data);
860
- }else{
861
- $data = array('status' => false);
862
  wp_send_json_error($data);
863
  }
864
  wp_die();
@@ -870,22 +915,22 @@ if ( ! function_exists( 'woo_feed_config_feed' ) ) {
870
  * Feed config
871
  */
872
  function woo_feed_config_feed(){
873
- if( isset( $_POST['wa_woo_feed_config'], $_POST['_wpnonce'] ) ) {
874
  check_admin_referer( 'woo-feed-config' );
875
  $batch_limit = absint( $_POST['batch_limit'] );
876
- if( $batch_limit <= 0 ) $batch_limit = 200;
877
  update_option( "woo_feed_per_batch", $batch_limit, false );
878
  $queryType = strtolower( sanitize_text_field( $_POST['woo_feed_product_query_type'] ) );
879
  if ( ! $queryType || ! in_array( $queryType, [ 'wc', 'wp', 'both' ] ) ) {
880
  $queryType = 'wc';
881
  }
882
  update_option( "woo_feed_product_query_type", $queryType,false );
883
- if( isset( $_POST['enable_error_debugging'] ) && $_POST['enable_error_debugging'] === 'on' ) {
884
  update_option( "woo_feed_enable_error_debugging", 'on', false );
885
  } else {
886
  delete_option( 'woo_feed_enable_error_debugging' );
887
  }
888
- if( isset( $_POST['opt_in'] ) ) {
889
  WooFeedWebAppickAPI::getInstance()->trackerOptIn();
890
  } else {
891
  WooFeedWebAppickAPI::getInstance()->trackerOptOut();
@@ -895,126 +940,5 @@ if ( ! function_exists( 'woo_feed_config_feed' ) ) {
895
  require WOO_FEED_FREE_ADMIN_PATH . "partials/woo-feed-config.php";
896
  }
897
  }
898
- // Pages
899
- if ( ! function_exists( 'woo_feed_pro_vs_free' ) ) {
900
- /**
901
- * Difference between free and premium plugin
902
- */
903
- function woo_feed_pro_vs_free(){
904
- require WOO_FEED_FREE_ADMIN_PATH . "partials/woo-feed-pro-vs-free.php";
905
- }
906
- }
907
- if ( ! function_exists( 'woo_feed_pro_features_page_remove_admin_notices' ) ) {
908
- add_action( 'admin_head', 'woo_feed_pro_features_page_remove_admin_notices', 9999 );
909
- /**
910
- * Remove Admin Notice in pro features page.
911
- * @global string $pagenow
912
- * @global string $plugin_page
913
- * @return void
914
- */
915
- function woo_feed_pro_features_page_remove_admin_notices() {
916
- global $pagenow, $plugin_page;
917
- if( 'admin.php' == $pagenow && 'webappick-feed-pro-vs-free' == $plugin_page ) {
918
- remove_all_actions( 'admin_notices' );
919
- }
920
- }
921
- }
922
 
923
- // Notices
924
- if ( ! function_exists( 'woo_feed_review_notice' ) ) {
925
- function woo_feed_review_notice() {
926
- $options = get_option( 'woo_feed_review_notice' );
927
- $installDate = get_option( 'woo-feed-free-activation-time' );
928
- $installDate = strtotime( '-16 days', $installDate );
929
- $pluginName = sprintf( '<i>%s</i>', esc_html__( 'WooCommerce Product Feed', 'woo-feed' ) );
930
- ob_start();
931
- ?>
932
- <div class="woo-feed-notice notice notice-info is-dismissible">
933
- <p><strong><?php printf(
934
- esc_html__( ':) We have spent countless hours developing this free plugin for you, and we would really appreciate it if you dropped us a quick rating. Your opinion matters a lot to us. It helps us to get better. Thanks for using %s.', 'woo-feed' ),
935
- $pluginName
936
- ); ?></strong></p>
937
- <ul>
938
- <li><a data-response="later" href="#"><?php esc_html_e( 'Remind me later', 'woo-feed' ); ?></a></li>
939
- <li><a data-response="never" href="#"><?php esc_html_e( 'I would not', 'woo-feed' ); ?></a></li>
940
- <li><a data-response="given" href="#" target="_blank"><?php esc_html_e( 'Review Here', 'woo-feed' ); ?></a></li>
941
- </ul>
942
- </div>
943
- <?php
944
- $notice = ob_get_clean();
945
- if ( ! $options && time() >= $installDate + ( DAY_IN_SECONDS * 15 ) ) {
946
- echo $notice;
947
- } elseif ( is_array( $options ) ) {
948
- if ( ( ! array_key_exists( 'review_notice', $options ) ) || ( $options['review_notice'] == 'later' && time() >= ( $options['updated_at'] + ( DAY_IN_SECONDS * 30 ) ) ) ) {
949
- echo $notice;
950
- }
951
- }
952
- }
953
- add_action( 'admin_notices', 'woo_feed_review_notice' );
954
- }
955
- if ( ! function_exists( 'woo_feed_save_review_notice' ) ) {
956
- /**
957
- * Show Review request admin notice
958
- */
959
- function woo_feed_save_review_notice() {
960
- check_ajax_referer( 'wpf_feed_nonce' );
961
- if( isset( $_POST['notice'] ) && ! empty( $_POST['notice'] ) && in_array( $_POST['notice'], [ 'later', 'never', 'given' ] ) ) {
962
- $value = [
963
- 'review_notice' => sanitize_text_field( $_POST['notice'] ),
964
- 'updated_at' => time(),
965
- ];
966
- update_option( 'woo_feed_review_notice', $value );
967
- wp_send_json_success( $value );
968
- wp_die();
969
- }
970
- wp_send_json_error( esc_html__( 'Invalid Request.', 'woo-feed' ) );
971
- wp_die();
972
- }
973
- add_action('wp_ajax_woo_feed_save_review_notice', 'woo_feed_save_review_notice');
974
- }
975
- if ( ! function_exists( 'woo_feed_admin_notices' ) ) {
976
- /**
977
- * Show notice if WPML installed
978
- */
979
- function woo_feed_admin_notices() {
980
- $pluginName = sprintf( '<b>%s</b>', esc_html__( 'WooCommerce Product Feed', 'woo-feed' ) );
981
- $proLink = sprintf( '<b><a href="http://bit.ly/2KIwvTt" target="_blank">%s</a></b>', esc_html__( 'Premium', 'woo-feed' ) );
982
- if ( class_exists( 'SitePress' ) && get_option( 'woo_feed_wpml_notice' ) === false ) { ?>
983
- <div class="woo-feed-notice notice notice-success is-dismissible" data-which="wpml">
984
- <button type="button" class="notice-dismiss">
985
- <span class="screen-reader-text"><?php esc_html_e( 'Dismiss this notice.', 'woo-feed' ); ?></span>
986
- </button>
987
- <p><?php printf( esc_html__( 'You are awesome for using %s. Using the %s version you can make multilingual feed for your WPML languages.', 'woo-feed' ), $pluginName, $proLink ); ?></p>
988
- </div>
989
- <?php }
990
- if ( class_exists( 'RP_WCDPD', false ) && get_option( 'woo_feed_rp-wcdpd_notice' ) === false ) {
991
- $rp_dpd = sprintf( '<b>%s</b>', esc_html__( 'WooCommerce Dynamic Pricing & Discounts', 'rp_wcdpd' ) );
992
- ?>
993
- <div class="woo-feed-notice notice notice-success is-dismissible" data-which="rp-wcdpd">
994
- <button type="button" class="notice-dismiss">
995
- <span class="screen-reader-text"><?php esc_html_e( 'Dismiss this notice.', 'woo-feed' ); ?></span>
996
- </button>
997
- <p><?php printf( esc_html__( '%s isn\'t fully compatible with %s. Get the %s version for full support.', 'woo-feed' ), $pluginName, $rp_dpd, $proLink ); ?></p>
998
- </div>
999
- <?php }
1000
- }
1001
- add_action( 'admin_notices', 'woo_feed_admin_notices' );
1002
- }
1003
- if ( ! function_exists( 'woo_feed_hide_notice' ) ) {
1004
- add_action('wp_ajax_woo_feed_hide_notice', 'woo_feed_hide_notice');
1005
- function woo_feed_hide_notice() {
1006
- check_ajax_referer( 'wpf_feed_nonce' );
1007
- if( isset( $_REQUEST['which'] ) && ! empty( $_REQUEST['which'] ) ) {
1008
- $which = sanitize_text_field( $_REQUEST['which'] );
1009
- $notices = [ 'rp-wcdpd', 'wpml' ];
1010
- if( in_array( $which, $notices ) ) {
1011
- update_option( sprintf( 'woo_feed_%s_notice', $which ), '1', false );
1012
- wp_send_json_success( esc_html__( 'Request Successful.', 'woo-feed' ) );
1013
- wp_die();
1014
- }
1015
- }
1016
- wp_send_json_error( esc_html__( 'Invalid Request.', 'woo-feed' ) );
1017
- wp_die();
1018
- }
1019
- }
1020
  // End of file woo-feed.php
2
  /**
3
  * The plugin bootstrap file
4
  *
 
 
 
 
 
5
  * @link https://webappick.com
6
  * @since 1.0.0
7
  * @package Woo_Feed
9
  * @wordpress-plugin
10
  * Plugin Name: WooCommerce Product Feed
11
  * Plugin URI: https://webappick.com/
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.2.18
16
  * Author: WebAppick
17
  * Author URI: https://webappick.com/
18
  * License: GPL v2
28
  * WC Requirement & Test
29
  * WC requires at least: 3.2
30
  * WC tested up to: 3.9.1
 
31
  */
32
+
33
+ if ( ! defined( 'ABSPATH' ) ) {
34
+ die(); // If this file is called directly, abort.
35
+ }
36
+
37
  if ( ! defined( 'WOO_FEED_FREE_VERSION' ) ) {
38
  /**
39
  * Plugin Version
40
  * @var string
41
+ * @since 3.1.6
42
  */
43
+ define( 'WOO_FEED_FREE_VERSION', '3.2.18' );
44
  }
45
+
46
  if ( ! defined( 'WOO_FEED_FREE_FILE') ) {
47
  /**
48
  * Plugin Base File
55
  /**
56
  * Plugin Path with trailing slash
57
  * @var string dirname( __FILE__ )
58
+ * * @since 3.1.6
59
  */
60
+ /** @define "WOO_FEED_FREE_PATH" "./" */ // phpcs:ignore
61
+ define( 'WOO_FEED_FREE_PATH', plugin_dir_path( WOO_FEED_FREE_FILE ) );
62
  }
63
  if ( ! defined( 'WOO_FEED_FREE_ADMIN_PATH' ) ) {
64
  /**
65
  * Admin File Path with trailing slash
66
  * @var string
67
+ * @since 3.1.6
68
  */
69
  define( 'WOO_FEED_FREE_ADMIN_PATH', WOO_FEED_FREE_PATH . 'admin/' );
70
  }
82
  * @var string
83
  * @since 3.1.37
84
  */
85
+ define( 'WOO_FEED_PLUGIN_URL', trailingslashit( plugin_dir_url(WOO_FEED_FREE_FILE ) ) );
86
  }
87
  if ( ! defined( 'WOO_FEED_MIN_PHP_VERSION' ) ) {
88
  /**
106
  * @var string
107
  * @since 3.1.41
108
  */
109
+ define( 'WOO_FEED_PLUGIN_BASE_NAME', plugin_basename(WOO_FEED_FREE_FILE ) );
110
  }
111
 
112
  if ( ! defined( 'WOO_FEED_LOG_DIR' ) ) {
116
  * @var string
117
  * @since 3.2.1
118
  */
119
+ /** @define "WOO_FEED_LOG_DIR" "./../../uploads/woo-feed/logs" */ // phpcs:ignore
120
  define( 'WOO_FEED_LOG_DIR', $upload_dir['basedir'] . '/woo-feed/logs/' );
121
  }
122
 
123
+ /**
124
+ * Load Uses Tracker
125
+ */
126
+ require_once WOO_FEED_FREE_PATH . 'includes/classes/class-woo-feed-webappick-api.php';
127
  /**
128
  * Load Helper functions
129
  */
132
  * Installer
133
  */
134
  require_once WOO_FEED_FREE_PATH . 'includes/class-woo-feed-installer.php';
 
 
 
 
135
 
136
  if ( ! class_exists( 'Woo_Feed' ) ) {
137
  /**
154
  function run_woo_feed() {
155
  $plugin = new Woo_Feed();
156
  register_activation_hook( WOO_FEED_FREE_FILE, [ 'Woo_Feed_installer', 'install' ] );
157
+ //register_shutdown_function( 'woo_feed_log_errors_at_shutdown' );
158
  /**
159
  * Ensure Feed Plugin runs only if WooCommerce loaded (installed and activated)
160
  * @since 3.1.41
163
  add_action( 'admin_notices', 'wooFeed_Admin_Notices' );
164
  WooFeedWebAppickAPI::getInstance();
165
  }
166
+
167
  run_woo_feed();
168
  }
169
+ // Log cleaner.
170
+ if ( ! function_exists( 'woo_feed_cleanup_logs' ) ) {
171
+ /**
172
+ * Trigger logging cleanup using the logging class.
173
+ *
174
+ * @since 3.4.0
175
+ */
176
+ function woo_feed_cleanup_logs() {
177
+ $logger = woo_feed_get_logger();
178
+ // @TODO dont' clear all logs.
179
+ // @TODO clear only the error log.
180
+ // @TODO change shutdown function and send the main error log to wc-logs directory.
181
+ if ( is_callable( array( $logger, 'clear_expired_logs' ) ) ) {
182
+ $logger->clear_expired_logs();
183
+ }
184
+ }
185
+
186
+ add_action( 'woo_feed_cleanup_logs', 'woo_feed_cleanup_logs' );
187
+ }
188
 
189
  #======================================================================================================================*
190
  #
196
  /**
197
  * Count Total Products
198
  */
199
+ /**
200
+ * Count Total Products
201
+ */
202
+ function woo_feed_get_product_information() {
203
+ check_ajax_referer( 'wpf_feed_nonce' );
204
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
205
  // woo_feed_log_debug_message( 'User doesnt have enough permission.' );
206
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ) );
207
  die();
208
  }
209
+ // @TODO use only WC_Product_Query it's available from WC 3.2, we don't support earlier versions of wc.
210
+ if ( woo_feed_wc_version_check( 3.2 ) && isset( $_REQUEST['feed'] ) ) {
211
+ $feed = sanitize_text_field( $_REQUEST['feed'] );
212
+ $limit = isset( $_REQUEST['limit'] ) ? absint( $_REQUEST['limit'] ) : 200;
213
+ $getConfig = maybe_unserialize( get_option( $feed ) );
214
+ // if ( woo_feed_is_debugging_enabled() ) {
215
+ // clear log, set the pointer to the beginning of the file.
216
+ // woo_feed_delete_log( $getConfig['filename'] );
217
+ // woo_feed_log_feed_process( $getConfig['filename'], sprintf( 'Getting Data for %s feed.', $feed ) );
218
+ // woo_feed_log_feed_process( $getConfig['filename'], 'Generating Feed VIA Ajax...' );
219
+ // woo_feed_log_feed_process( $getConfig['filename'], sprintf( 'Getting Data for %s feed.', $feed ) );
220
+ // woo_feed_log_feed_process( $getConfig['filename'], sprintf( 'Current Limit is %d.', $limit ) );
221
+ // woo_feed_log( $getConfig['filename'], 'Feed Config::' . PHP_EOL . print_r( $getConfig, true ), 'info' );
222
+ // }
223
+ try {
224
+ $products = new Woo_Feed_Products_v3( $getConfig );
225
+ $ids = $products->query_products();
226
+ // woo_feed_log_feed_process( $getConfig['filename'], sprintf( 'Total %d product found', is_array( $ids ) && ! empty( $ids ) ? count( $ids ) : 0 ) );
227
+ if ( is_array( $ids ) && ! empty( $ids ) ) {
228
+ if ( count( $ids ) > $limit ) {
229
+ $batches = array_chunk( $ids, $limit );
230
+ } else {
231
+ $batches = array( $ids );
232
+ }
233
+ // woo_feed_log_feed_process( $getConfig['filename'], sprintf( 'Total %d batches', count( $batches ) ) );
234
+ wp_send_json_success(
235
+ [
236
+ 'product' => $batches,
237
+ 'total' => count( $ids ),
238
+ 'success' => true,
239
+ ]
240
+ );
241
+ wp_die();
242
+ } else {
243
+ wp_send_json_error(
244
+ [
245
+ 'message' => esc_html__( 'No products found. Add product or change feed config before generate the feed.', 'woo-feed' ),
246
+ 'success' => false,
247
+ ]
248
+ );
249
+ wp_die();
250
  }
251
+ } catch ( Exception $e ) {
252
+ // if ( woo_feed_is_debugging_enabled() ) {
253
+ // $message = 'Error getting Product Ids.' . PHP_EOL . 'Caught Exception :: ' . $e->getMessage();
254
+ // woo_feed_log( $getConfig['filename'], $message, 'critical', $e, true );
255
+ // woo_feed_log_fatal_error( $message, $e );
256
+ // }
257
+ wp_send_json_error(
258
+ [
259
+ 'message' => esc_html__( 'Failed to fetch products.', 'woo-feed' ),
260
+ 'success' => false,
261
+ ]
262
+ );
263
+ wp_die();
264
+ }
265
+ } else {
266
+ $products = wp_count_posts( 'product' );
267
+ if ( $products->publish > 0 ) {
268
  $data['success'] = true;
269
+ wp_send_json_success(
270
+ [
271
+ 'product' => $products->publish,
272
+ 'success' => false,
273
+ ]
274
+ );
275
+ wp_die();
276
+ } else {
277
+ wp_send_json_error(
278
+ [
279
+ 'message' => esc_html__( 'No products found. Add product or change feed config before generate the feed.', 'woo-feed' ),
280
+ 'success' => false,
281
+ ]
282
+ );
283
+ wp_die();
284
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
285
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
286
  }
287
  }
288
  if ( ! function_exists( 'woo_feed_make_batch_feed' ) ) {
293
  */
294
  function woo_feed_make_batch_feed(){
295
  check_ajax_referer('wpf_feed_nonce');
296
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
297
  // woo_feed_log_debug_message( 'User doesnt have enough permission.' );
298
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ) );
299
  die();
300
  }
301
  //$limit=sanitize_text_field($_POST['limit']);
303
  $feedName = str_replace( "wf_feed_", "", sanitize_text_field( $_POST['feed'] ) );
304
  $feedInfo = get_option( $feedName );
305
 
306
+ if ( ! $feedInfo ) {
307
+ $getFeedConfig = unserialize(get_option($feedName));
308
+ $feedInfo = $getFeedConfig['feedrules'];
309
  }
310
 
311
  $products = array_map( 'absint', $_REQUEST['products'] );
313
  $feedInfo['productIds'] = $products;
314
 
315
 
316
+ if ( $offset == 0 ) {
317
  $fileName = str_replace(" ", "",$feedInfo['filename']);
318
  $type = $feedInfo['feedType'];
319
  $feedService = $feedInfo['provider'];
320
+ if ( $type == "csv" ) {
321
+ $type = "json";
322
  }
323
 
324
  $upload_dir = wp_upload_dir();
325
  $base = $upload_dir['basedir'];
326
  $path = $base . "/woo-feed/" . $feedService . "/" . $type;
327
 
328
+ $tempFiles['headerFile'] = $path . "/" . "wf_store_feed_header_info_".$fileName . "." . $type;
329
+ $tempFiles['bodyFile'] = $path . "/" . "wf_store_feed_body_info_".$fileName . "." . $type;
330
+ $tempFiles['footerFile'] = $path . "/" . "wf_store_feed_footer_info_".$fileName . "." . $type;
331
 
332
  woo_feed_unlink_tempFiles($tempFiles);
333
  }
336
  // $feedInfo['Limit']=$limit;
337
  // $feedInfo['Offset']=$offset;
338
 
339
+ $feed_data = woo_feed_generate_feed_data($feedInfo);
340
+ if ( $feed_data ) {
341
+ $data = array(
342
+ "success" => true,
343
+ "products" => "yes",
344
  );
345
  wp_send_json_success($data);
346
  die();
347
+ }else {
348
+ $data = array(
349
+ "success" => true,
350
+ "products" => "no",
351
  );
352
  wp_send_json_success($data);
353
  die();
359
  function woo_feed_save_feed_file(){
360
 
361
  check_ajax_referer('wpf_feed_nonce');
362
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
363
  // woo_feed_log_debug_message( 'User doesnt have enough permission.' );
364
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ) );
365
  die();
366
  }
367
  $feed = str_replace("wf_feed_", "", sanitize_text_field( $_REQUEST['feed'] ) );
368
  $info = get_option($feed);
369
+ if ( ! $info ) {
370
  $getInfo = unserialize(get_option( sanitize_text_field( $_REQUEST['feed'] ) ));
371
  $info = $getInfo['feedrules'];
372
  }
375
  $fileName = str_replace(" ", "",$info['filename']);
376
  $type = $info['feedType'];
377
 
378
+ $feedHeader = woo_feed_get_batch_feed_info($feedService,$type,"wf_store_feed_header_info_".$fileName);
379
+ $feedBody = woo_feed_get_batch_feed_info($feedService,$type,"wf_store_feed_body_info_".$fileName);
380
+ $feedFooter = woo_feed_get_batch_feed_info($feedService,$type,"wf_store_feed_footer_info_".$fileName);
381
 
382
+ if ( $type == 'csv' ) {
383
+ $csvHead[0] = $feedHeader;
384
+ if ( ! empty($csvHead) && ! empty($feedBody) ) {
385
+ $string = array_merge($csvHead,$feedBody);
386
+ }else {
387
+ $string = array();
388
  }
389
+ }else {
390
+ $string = $feedHeader.$feedBody.$feedFooter;
391
  }
392
 
393
  $upload_dir = wp_upload_dir();
395
  $path = $base . "/woo-feed/" . $feedService . "/" . $type;
396
  $saveFile = false;
397
  # Check If any products founds
398
+ if ( $string && ! empty($string) ) {
399
  # Save File
400
  $file = $path . "/" . $fileName . "." . $type;
401
  $save = new Woo_Feed_Savefile();
402
+ if ( $type == "csv" ) {
403
  $saveFile = $save->saveCSVFile($path, $file, $string, $info);
404
  } else {
405
  $saveFile = $save->saveFile($path, $file, $string);
406
  }
407
+ }else {
408
+ $data = array(
409
+ "success" => false,
410
+ "message" => "No Product Found with your feed configuration. Please configure the feed properly.",
411
+ );
412
  wp_send_json_error($data);
413
  wp_die();
414
  }
417
  # Save Info into database
418
  $url = $upload_dir['baseurl'] . "/woo-feed/" . $feedService . "/" . $type . "/" . $fileName . "." . $type;
419
  $feedInfo = array(
420
+ 'feedrules' => $info,
421
+ 'url' => $url,
422
+ 'last_updated' => gmdate("Y-m-d H:i:s"),
423
  );
424
 
425
  $feedOldInfo = unserialize( get_option( "wf_feed_".$fileName ) );
426
+ if ( isset( $feedOldInfo['status'] ) ) {
427
  $feedInfo['status'] = $feedOldInfo['status'];
428
+ }else {
429
+ $feedInfo['status'] = 1;
430
  }
431
 
432
+ if ( ! empty($name) && $name != "wf_feed_" . $fileName ) {
433
  delete_option($name);
434
  }
435
 
438
  delete_option("wf_store_feed_body_info_".$fileName);
439
  delete_option("wf_store_feed_footer_info_".$fileName);
440
 
441
+ if ($type == "csv") $type = "json";
442
 
443
  # Remove Temp feed files
444
+ $tempFiles['headerFile'] = $path . "/" . "wf_store_feed_header_info_".$fileName . "." . $type;
445
+ $tempFiles['bodyFile'] = $path . "/" . "wf_store_feed_body_info_".$fileName . "." . $type;
446
+ $tempFiles['footerFile'] = $path . "/" . "wf_store_feed_footer_info_".$fileName . "." . $type;
447
 
448
  woo_feed_unlink_tempFiles($tempFiles);
449
  update_option('wf_feed_' . $fileName, serialize($feedInfo));
450
+ if ( $saveFile ) {
451
 
452
  # FTP File Upload Info
453
  $ftpHost = $info['ftphost'];
455
  $ftpPassword = $info['ftppassword'];
456
  $ftpPath = $info['ftppath'];
457
  $ftpEnabled = $info['ftpenabled'];
458
+ $ftporsftp = isset($info['ftporsftp']) ? $info['ftporsftp'] : "ftp";
459
+ $ftpPort = isset($info['ftpport']) && ! empty($info['ftpport']) ? $info['ftpport'] : 21;
460
+ try {
461
+ if ($type == "json") $type = "csv";
462
  # Upload file to ftp server
463
+ if ( $ftpEnabled ) {
464
+ if ( $ftporsftp == "ftp" ) {
465
  $ftp = new FTPClient();
466
+ if ( $ftp->connect($ftpHost, $ftpUser, $ftpPassword,false,$ftpPort) ) {
467
  $ftp->uploadFile($file, $fileName . "." . $type);
468
  }
469
+ } elseif ( $ftporsftp == "sftp" && extension_loaded ( 'ssh2' ) ) {
470
  $sftp = new SFTPConnection($ftpHost, $ftpPort);
471
  $sftp->login($ftpUser, $ftpPassword);
472
  $sftp->uploadFile($file, "/".$fileName . "." . $type);
473
  }
474
  }
475
+ }catch ( Exception $e ) {}
476
  $getInfo = unserialize(get_option('wf_feed_' . $fileName));
477
  $url = $getInfo['url'];
478
 
479
+ $cat = woo_feed_check_google_category($feedInfo);
480
 
481
+ $data = array(
482
+ "info" => $feedInfo,
483
+ "url" => $url,
484
+ "cat" => $cat,
485
+ "message" => "Feed Making Complete",
486
  );
487
  wp_send_json_success($data);
488
  } else {
489
+ $data = array(
490
+ "success" => false,
491
+ "message" => esc_html__( 'Failed to save feed file. Please confirm that your WordPress directory have Read and Write permission.', 'woo-feed' ),
492
+ );
493
  wp_send_json_error($data);
494
  }
495
 
498
  }
499
  // Ajax Helper
500
  if ( ! function_exists( 'woo_feed_generate_feed_data' ) ) {
501
+ function woo_feed_generate_feed_data( $info ) {
502
 
503
+ try {
504
+ if ( count($info) && isset($info['provider']) ) {
505
  # GEt Post data
506
+ if ( $info['provider'] == 'google' || $info['provider'] == 'adroll' || $info['provider'] == 'smartly.io' ) {
507
  $merchant = "Woo_Feed_Google";
508
+ } elseif ( $info['provider'] == 'pinterest' ) {
509
  $merchant = "Woo_Feed_Pinterest";
510
+ } elseif ( $info['provider'] == 'facebook' ) {
511
  $merchant = "Woo_Feed_Facebook";
512
+ }elseif ( strpos($info['provider'],'amazon') !== FALSE ) {
513
  $merchant = "Woo_Feed_Amazon";
514
+ }elseif ( $info['provider'] == 'custom2' ) {
515
  $merchant = "Woo_Feed_Custom2";
516
  } else {
517
  $merchant = "Woo_Feed_Custom";
526
  # Get Feed info
527
  $products = new Woo_Generate_Feed($merchant, $feedRules);
528
  $feed = $products->getProducts();
529
+ if ( isset($feed['body']) && ! empty($feed['body']) ) {
530
+ $feedHeader = "wf_store_feed_header_info_".$fileName;
531
+ $feedBody = "wf_store_feed_body_info_".$fileName;
532
+ $feedFooter = "wf_store_feed_footer_info_".$fileName;
533
+ $prevFeed = woo_feed_get_batch_feed_info( $feedService, $type, $feedBody );
534
+ if ( $prevFeed ) {
535
+ if ( $type == 'csv' ) {
536
+ if ( ! empty($prevFeed) ) {
537
  $newFeed = array_merge( $prevFeed, $feed['body'] );
538
  woo_feed_save_batch_feed_info( $feedService, $type, $newFeed, $feedBody, $info );
539
  }
540
+ }else {
541
+ $newFeed = $prevFeed.$feed['body'];
542
  woo_feed_save_batch_feed_info( $feedService, $type, $newFeed, $feedBody, $info );
543
+ }
544
+ }else {
 
545
  woo_feed_save_batch_feed_info( $feedService, $type, $feed['body'], $feedBody, $info );
546
  }
547
  woo_feed_save_batch_feed_info( $feedService, $type, $feed['header'], $feedHeader, $info );
548
  woo_feed_save_batch_feed_info( $feedService, $type,$feed['footer'], $feedFooter, $info );
549
  return true;
550
+ }else {
551
  return false;
552
  }
553
  }
554
+ }catch ( Exception $e ) {
555
  return false;
556
  }
557
  return false;
569
  $result = $wpdb->get_results( $query, 'ARRAY_A' );
570
  foreach ( $result as $key => $value ) {
571
  $feedInfo = maybe_unserialize( get_option( $value['option_name'] ) );
572
+ if ( ! isset( $feedInfo['feedrules'] ) || isset( $feedInfo['status'] ) && $feedInfo['status'] == "0" ) continue;
573
  woo_feed_add_update( $feedInfo['feedrules'] );
574
  }
575
  }
586
  global $wpdb;
587
  $feedName = "wf_feed_".$feedName[0];
588
  $result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->options WHERE option_name = %s", $feedName ),'ARRAY_A');
589
+ if ( ! empty( $result ) ) {
590
  foreach ( $result as $key => $value ) {
591
  $feedInfo = maybe_unserialize( get_option( $value['option_name'] ) );
592
+ if ( ! isset( $feedInfo['feedrules'] ) || isset( $feedInfo['status'] ) && $feedInfo['status'] == "0" ) continue;
593
  woo_feed_add_update( $feedInfo['feedrules'] );
594
  }
595
  }
604
  * @param string $name
605
  * @return string|bool
606
  */
607
+ function woo_feed_add_update( $info = array(), $name = "" ) {
608
+ if ( count($info) && isset($info['provider']) ) {
609
  # GEt Post data
610
+ if ( $info['provider'] == 'google' || $info['provider'] == 'adroll' || $info['provider'] == 'smartly.io' ) {
611
  $merchant = "Woo_Feed_Google";
612
+ } elseif ( $info['provider'] == 'pinterest' ) {
613
  $merchant = "Woo_Feed_Pinterest";
614
+ } elseif ( $info['provider'] == 'facebook' ) {
615
  $merchant = "Woo_Feed_Facebook";
616
+ }elseif ( strpos($info['provider'],'amazon') !== FALSE ) {
617
  $merchant = "Woo_Feed_Amazon";
618
  } else {
619
  $merchant = "Woo_Feed_Custom";
630
  $products = new Woo_Generate_Feed($merchant, $feedRules);
631
  $getString = $products->getProducts();
632
 
633
+ if ( $type == 'csv' ) {
634
+ $csvHead[0] = $getString['header'];
635
+ if ( ! empty($csvHead) && ! empty($getString['body']) ) {
636
+ $string = array_merge($csvHead,$getString['body']);
637
+ }else {
638
+ $string = array();
639
  }
640
+ }else {
641
+ $string = $getString['header'].$getString['body'].$getString['footer'];
642
  }
643
 
644
  # Check If any products founds
645
+ if ( $string && ! empty($string) ) {
646
 
647
  $upload_dir = wp_upload_dir();
648
  $base = $upload_dir['basedir'];
651
  $path = $base . "/woo-feed/" . $feedService . "/" . $type;
652
  $file = $path . "/" . $fileName . "." . $type;
653
  $save = new Woo_Feed_Savefile();
654
+ if ( $type == "csv" ) {
655
  $saveFile = $save->saveCSVFile($path, $file, $string, $info);
656
  } else {
657
  $saveFile = $save->saveFile($path, $file, $string);
662
  $ftpUser = sanitize_text_field($info['ftpuser']);
663
  $ftpPassword = sanitize_text_field($info['ftppassword']);
664
  $ftpPath = sanitize_text_field($info['ftppath']);
665
+ $ftpPort = isset($info['ftpport']) && ! empty($info['ftpport']) ? sanitize_text_field($info['ftpport']) : 21;
666
  $ftpEnabled = sanitize_text_field($info['ftpenabled']);
667
 
668
+ $ftporsftp = isset($info['ftporsftp']) ? sanitize_text_field($info['ftporsftp']) : "ftp";
669
 
670
 
671
+ try {
672
+ if ( $type == "json" ) {
673
+ $type = "csv";
674
  }
675
  # Upload file to ftp server
676
+ if ( $ftpEnabled ) {
677
+ if ( $ftporsftp == "ftp" ) {
678
  $ftp = new FTPClient();
679
+ if ( $ftp->connect($ftpHost, $ftpUser, $ftpPassword,false,$ftpPort) ) {
680
  $ftp->uploadFile($file, $fileName . "." . $type);
681
  }
682
+ } elseif ( $ftporsftp == "sftp" && extension_loaded ( 'ssh2' ) ) {
683
  $sftp = new SFTPConnection($ftpHost, $ftpPort);
684
  $sftp->login($ftpUser, $ftpPassword);
685
  $sftp->uploadFile($file, "/".$fileName . "." . $type);
686
  }
687
  }
688
+ }catch ( Exception $e ) {
689
 
690
  }
691
 
692
  # Save Info into database
693
  $url = $upload_dir['baseurl'] . "/woo-feed/" . $feedService . "/" . $type . "/" . $fileName . "." . $type;
694
  $feedInfo = array(
695
+ 'feedrules' => $feedRules,
696
+ 'url' => $url,
697
+ 'last_updated' => gmdate("Y-m-d H:i:s"),
698
+ 'status' => 1,
699
  );
700
 
701
 
702
+ if ( ! empty($name) && $name != "wf_feed_" . $fileName ) {
703
  delete_option($name);
704
  }
705
 
706
  $update = update_option('wf_feed_' . $fileName, serialize($feedInfo));
707
+ if ( $saveFile ) {
708
  $getInfo = unserialize(get_option('wf_feed_' . $fileName));
709
  $url = $getInfo['url'];
710
  return $url;
738
 
739
  wp_schedule_event(time(), 'woo_feed_corn', 'woo_feed_update_single_feed', $arg );
740
 
741
+ wp_safe_redirect( add_query_arg( [
742
+ 'feed_created' => (int) false !== $fileName,
743
+ 'feed_regenerate' => 1,
744
+ 'feed_name' => $fileName ? $fileName : '',
745
  ], admin_url( 'admin.php?page=webappick-manage-feeds' ) ) );
746
  die();
 
747
  } else {
748
+ require WOO_FEED_FREE_ADMIN_PATH . 'partials/woo-feed-admin-display.php';
 
749
  }
750
  }
751
  }
755
  */
756
  function woo_feed_manage_feed() {
757
  // Manage action for category mapping
758
+ if ( isset( $_GET['action'] ) && $_GET['action'] == 'edit-feed' ) {
759
+ if ( ! defined( 'WOO_FEED_EDIT_CONFIG' ) ) define( 'WOO_FEED_EDIT_CONFIG', true );
760
+ if ( count( $_POST ) && isset( $_POST['provider'], $_POST['feed_id'], $_POST['filename'], $_POST['feedType'] ) ) {
761
  # Verify Nonce
762
  if ( ! wp_verify_nonce( sanitize_text_field( $_POST['_wpnonce'] ), 'wf_edit_feed' ) ) {
763
  wp_die( 'Failed security check' );
778
  $fileName = woo_feed_save_feed_config_data( $_POST, $fileName, isset( $_POST['edit-feed'] ) );
779
  // redirect to the feed list with status
780
  // @TODO this should be handled in admin_init action for proper redirection to work...
781
+ wp_safe_redirect( add_query_arg( [
782
+ 'feed_updated' => (int) false !== $fileName,
783
+ 'feed_regenerate' => (int) isset( $_POST['edit-feed'] ),
784
+ 'feed_name' => $fileName ? $fileName : '',
785
  ], admin_url( 'admin.php?page=webappick-manage-feeds' ) ) );
786
  die();
787
  }
792
  $fname = sanitize_text_field( $_GET['feed'] );
793
  $feedInfo = unserialize( get_option( $fname ) );
794
  $feedId = $wpdb->get_row( $wpdb->prepare( "SELECT option_id FROM $wpdb->options WHERE option_name = %s LIMIT 1", $fname ) );
795
+ if ( $feedId ) $feedId = $feedId->option_id;
796
  $provider = strtolower( $feedInfo['feedrules']['provider'] );
797
  $feedRules = $feedInfo['feedrules'];
798
 
801
  } else {
802
  # Update Interval
803
  if ( isset( $_POST['wf_schedule'] ) ) {
804
+ if ( isset( $_POST['wf_schedule_nonce'] ) && wp_verify_nonce( sanitize_text_field( $_POST['wf_schedule_nonce'] ),'wf_schedule' ) ) {
805
  $interval = absint( $_POST['wf_schedule'] );
806
+ if ( $interval >= woo_feed_get_minimum_interval_option() ) {
807
  if ( update_option('wf_schedule', sanitize_text_field( $_POST['wf_schedule'] ) ) ) {
808
  wp_clear_scheduled_hook('woo_feed_update');
809
  add_filter( 'cron_schedules', 'Woo_Feed_installer::cron_schedules' );
812
  } else $update = 2; // db fail
813
  } else $update = 3; // invalid value
814
  } else $update = 4; // invalid nonce
815
+ wp_safe_redirect( add_query_arg( [ 'schedule_updated' => $update ], admin_url( 'admin.php?page=webappick-manage-feeds' ) ) );
816
+ die();
817
  }
818
  require WOO_FEED_FREE_ADMIN_PATH . "partials/woo-feed-manage-list.php";
819
  }
825
  add_action('wp_ajax_get_feed_merchant', 'feed_merchant_view');
826
  function feed_merchant_view() {
827
  check_ajax_referer('wpf_feed_nonce');
828
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
829
  // woo_feed_log_debug_message( 'User doesnt have enough permission.' );
830
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ) );
831
  die();
832
  }
833
  $merchant = $provider = isset( $_REQUEST['merchant'] ) && ! empty( $_REQUEST['merchant'] ) ? sanitize_text_field( $_REQUEST['merchant'] ) : '';
834
+ if ( empty( $merchant ) ) wp_die();
835
  ob_start();
836
  /** @noinspection PhpUnusedLocalVariableInspection */
837
  $dropDown = new Woo_Feed_Dropdown();
840
  /** @noinspection PhpUnusedLocalVariableInspection */
841
  $attributes = new Woo_Feed_Default_Attributes();
842
 
843
+ if ( $merchant == 'smartly.io' ) {
844
  include WOO_FEED_FREE_ADMIN_PATH . "partials/templates/google_add-feed.php";
845
+ } elseif ( file_exists(WOO_FEED_FREE_ADMIN_PATH . "partials/templates/" . $merchant . "_add-feed.php") ) {
846
  include WOO_FEED_FREE_ADMIN_PATH . "partials/templates/" . $merchant . "_add-feed.php";
847
  } else {
848
  include WOO_FEED_FREE_ADMIN_PATH . "partials/templates/common_add-feed.php";
856
  add_action( 'wp_ajax_get_google_categories', 'woo_feed_get_google_categories' );
857
  function woo_feed_get_google_categories() {
858
  check_ajax_referer('wpf_feed_nonce');
859
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
860
  // woo_feed_log_debug_message( 'User doesnt have enough permission.' );
861
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ) );
862
  die();
863
  }
864
  $wooFeedDropDown = new Woo_Feed_Dropdown();
871
  add_action('wp_ajax_get_ssh2_status', 'woo_feed_get_ssh2_status');
872
  function woo_feed_get_ssh2_status() {
873
  check_ajax_referer( 'wpf_feed_nonce' );
874
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
875
  // woo_feed_log_debug_message( 'User doesnt have enough permission.' );
876
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ) );
877
  die();
878
  }
879
  $php_extension = get_loaded_extensions();
880
+ if ( extension_loaded ( 'ssh2' ) ) {
881
  wp_send_json_success('exists');
882
  } else {
883
  wp_send_json_success('not exists');
891
  */
892
  add_action('wp_ajax_update_feed_status', 'woo_feed_update_feed_status');
893
  function woo_feed_update_feed_status(){
894
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
895
  // woo_feed_log_debug_message( 'User doesnt have enough permission.' );
896
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ) );
897
  die();
898
  }
899
+ if ( ! empty($_POST['feedName']) ) {
900
  $feedInfo = unserialize(get_option( sanitize_text_field( $_POST['feedName'] ) ));
901
  $feedInfo['status'] = sanitize_text_field( $_POST['status'] );
902
+ $data = array( 'status' => true );
903
  update_option( sanitize_text_field( $_POST['feedName'] ),serialize($feedInfo));
904
  wp_send_json_success($data);
905
+ }else {
906
+ $data = array( 'status' => false );
907
  wp_send_json_error($data);
908
  }
909
  wp_die();
915
  * Feed config
916
  */
917
  function woo_feed_config_feed(){
918
+ if ( isset( $_POST['wa_woo_feed_config'], $_POST['_wpnonce'] ) ) {
919
  check_admin_referer( 'woo-feed-config' );
920
  $batch_limit = absint( $_POST['batch_limit'] );
921
+ if ( $batch_limit <= 0 ) $batch_limit = 200;
922
  update_option( "woo_feed_per_batch", $batch_limit, false );
923
  $queryType = strtolower( sanitize_text_field( $_POST['woo_feed_product_query_type'] ) );
924
  if ( ! $queryType || ! in_array( $queryType, [ 'wc', 'wp', 'both' ] ) ) {
925
  $queryType = 'wc';
926
  }
927
  update_option( "woo_feed_product_query_type", $queryType,false );
928
+ if ( isset( $_POST['enable_error_debugging'] ) && $_POST['enable_error_debugging'] === 'on' ) {
929
  update_option( "woo_feed_enable_error_debugging", 'on', false );
930
  } else {
931
  delete_option( 'woo_feed_enable_error_debugging' );
932
  }
933
+ if ( isset( $_POST['opt_in'] ) ) {
934
  WooFeedWebAppickAPI::getInstance()->trackerOptIn();
935
  } else {
936
  WooFeedWebAppickAPI::getInstance()->trackerOptOut();
940
  require WOO_FEED_FREE_ADMIN_PATH . "partials/woo-feed-config.php";
941
  }
942
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
943
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
944
  // End of file woo-feed.php