CTX Feed – WooCommerce Product Feed Manager Plugin - Version 4.5.8

Version Description

(2022-11-07) = * Fixed: Undefined array key page Warning fixed.

Download this release

Release Info

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

Code changes from version 4.5.7 to 4.5.8

README.txt CHANGED
@@ -5,7 +5,7 @@ Tags: WooCommerce Product Feed, WooCommerce, Google Shopping, Google Merchant, F
5
  Requires at least: 4.4
6
  Tested Up To: 6.1
7
  Requires PHP: 5.6
8
- Stable tag: 4.5.7
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -590,6 +590,9 @@ Using pro version:
590
 
591
  == Changelog ==
592
 
 
 
 
593
  = 4.5.7 (2022-10-28) =
594
  * Added: Featured Status attribute added.
595
  * Tweak: WordPress 6.1 compatibility checked.
5
  Requires at least: 4.4
6
  Tested Up To: 6.1
7
  Requires PHP: 5.6
8
+ Stable tag: 4.5.8
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
590
 
591
  == Changelog ==
592
 
593
+ = 4.5.8 (2022-11-07) =
594
+ * Fixed: Undefined array key “page” Warning fixed.
595
+
596
  = 4.5.7 (2022-10-28) =
597
  * Added: Featured Status attribute added.
598
  * Tweak: WordPress 6.1 compatibility checked.
V5/API/RestController.php ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace CTXFeed\V5\API;
4
+
5
+
6
+
7
+ use CTXFeed\V5\API\V1\DropDownOptionsApi;
8
+ use CTXFeed\V5\API\V1\FeedLists;
9
+ use CTXFeed\V5\API\V1\MerchantConfig;
10
+ use CTXFeed\V5\API\V1\MerchantInfo;
11
+ use CTXFeed\V5\API\V1\ProductCategories;
12
+ use CTXFeed\V5\API\V1\ProductTaxonomy;
13
+ use CTXFeed\V5\API\V1\ProductTitles;
14
+ use WP_REST_Controller;
15
+
16
+ class RestController extends WP_REST_Controller {
17
+
18
+
19
+ /**
20
+ * @var array $response ;
21
+ */
22
+ public $response = [
23
+ 'status' => true,
24
+ 'data' => null,
25
+ 'extra' => null
26
+ ];
27
+ /**
28
+ * The single instance of the class
29
+ *
30
+ * @var RestController
31
+ *
32
+ */
33
+ protected static $_instance = null;
34
+
35
+ public function __construct() {
36
+ add_action( 'rest_api_init', [ $this, 'register_api' ] );
37
+ }
38
+
39
+ public function register_api() {
40
+ $classes = [
41
+ DropDownOptionsApi::instance(),
42
+ ProductTaxonomy::instance(),
43
+ ProductTitles::instance(),
44
+ ProductCategories::instance(),
45
+ MerchantInfo::instance(),
46
+ MerchantConfig::instance(),
47
+ FeedLists::instance(),
48
+ ];
49
+ foreach ( $classes as $class ) {
50
+ $class->register_routes();
51
+ }
52
+ }
53
+
54
+ /**
55
+ * Main RestController Instance.
56
+ *
57
+ * Ensures only one instance of RestController is loaded or can be loaded.
58
+ *
59
+ * @return RestController Main instance
60
+ */
61
+ public static function instance() {
62
+ if ( is_null( self::$_instance ) ) {
63
+ self::$_instance = new self();
64
+ }
65
+
66
+ return self::$_instance;
67
+ }
68
+
69
+ /**
70
+ * Cloning is forbidden.
71
+ */
72
+ final public function __clone() {
73
+ _doing_it_wrong( __FUNCTION__, __( 'Cloning is forbidden.', 'woo-feed' ), WOO_FEED_FREE_VERSION );
74
+ }
75
+
76
+ /**
77
+ * Unserializing instances of this class is forbidden.
78
+ */
79
+ final public function __wakeup() {
80
+ _doing_it_wrong( __FUNCTION__, __( 'Unserializing instances of this class is forbidden.', 'woo-feed' ), WOO_FEED_FREE_VERSION );
81
+ }
82
+
83
+ /**
84
+ * Get single item permission to perform current action.
85
+ *
86
+ * @param $request
87
+ *
88
+ * @return bool
89
+ */
90
+ public function get_item_permissions_check( $request ) {
91
+ if ( current_user_can( 'manage_options' ) ) {
92
+ return true;
93
+ }
94
+
95
+ return true;
96
+ }
97
+
98
+ /**
99
+ * Get items permission to perform current action.
100
+ *
101
+ * @param $request
102
+ *
103
+ * @return bool
104
+ */
105
+ public function get_items_permissions_check( $request ) {
106
+ if ( current_user_can( 'manage_options' ) ) {
107
+ return true;
108
+ }
109
+
110
+ return false;
111
+ }
112
+
113
+ /**
114
+ * @param $data
115
+ *
116
+ * @return void
117
+ */
118
+ public function success( $data ) {
119
+ $this->response['status'] = true;
120
+ $this->response['data'] = $data;
121
+ }
122
+
123
+ /**
124
+ * @param $data
125
+ *
126
+ * @return void
127
+ */
128
+ public function error( $data ) {
129
+ $this->response['status'] = false;
130
+ $this->response['data'] = $data;
131
+ }
132
+
133
+ }
V5/API/V1/DropDownOptionsApi.php ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace CTXFeed\V5\API\V1;
4
+
5
+ use CTXFeed\V5\API\RestController;
6
+ use WP_REST_Server;
7
+ use CTXFeed\V5\Common\DropDownOptions;
8
+
9
+ class DropDownOptionsApi extends RestController {
10
+
11
+ /**
12
+ * @var $namespace ;
13
+ */
14
+ public $namespace;
15
+ /**
16
+ * @var $version ;
17
+ */
18
+ public $version = 'v1';
19
+ /**
20
+ * @var $rest_base
21
+ */
22
+
23
+ protected $rest_base;
24
+
25
+ /**
26
+ * @var $dropdown
27
+ */
28
+ protected $dropdown;
29
+ /**
30
+ * The single instance of the class
31
+ *
32
+ * @var DropDownOptionsApi
33
+ *
34
+ */
35
+ protected static $_instance = null;
36
+
37
+ public function __construct() {
38
+ parent::__construct();
39
+ $this->namespace = 'ctxfeed/' . $this->version;
40
+ $this->rest_base = 'dropdown';
41
+ $this->dropdown = DropDownOptions::instance();
42
+
43
+ }
44
+
45
+ /**
46
+ * Main DropDownOptionsApi Instance.
47
+ *
48
+ * Ensures only one instance of DropDownOptionsApi is loaded or can be loaded.
49
+ *
50
+ * @return DropDownOptionsApi Main instance
51
+ */
52
+ public static function instance() {
53
+ if ( is_null( self::$_instance ) ) {
54
+ self::$_instance = new self();
55
+ }
56
+
57
+ return self::$_instance;
58
+ }
59
+
60
+ public function register_routes() {
61
+ register_rest_route(
62
+ $this->namespace,
63
+ '/' . $this->rest_base,
64
+ [
65
+ /**
66
+ * @endpoint: wp-json/ctxfeed/v1/dropdown/?type=feed_country
67
+ * @param $type String will be DropDownOptions class\'s method name
68
+ */
69
+ [
70
+ 'methods' => WP_REST_Server::READABLE,
71
+ 'callback' => [ $this, 'get_item' ],
72
+ 'permission_callback' => [ $this, 'get_item_permissions_check' ],
73
+ 'args' => [
74
+ 'type' => [
75
+ 'description' => __( 'Dropdown type name. $type will be DropDownOptions class\'s method name. Example: wp-json/ctxfeed/v1/dropdown/?type=feed_country. Here fee_country is DropDownOptions method name.' ),
76
+ 'type' => 'string',
77
+ 'required' => true
78
+ ],
79
+ ],
80
+ ],
81
+ ]
82
+ );
83
+ }
84
+
85
+
86
+ /**
87
+ * Get dropdown based on type params. If parameter 'type' is not passed then it will give error.
88
+ * $type will be DropDownOptions class's method name.
89
+ *
90
+ * @param $request
91
+ *
92
+ * @return void|\WP_Error|\WP_REST_Response
93
+ */
94
+ public function get_item( $request ) {
95
+ $param = $request->get_param( 'type' );
96
+
97
+ if ( method_exists( $this->dropdown, $param ) ) {
98
+ $this->response['data'] = $this->dropdown::$param( '', false );
99
+ } else {
100
+ $this->error( __( 'Method Does not exist !', 'woo-feed' ) );
101
+
102
+ return rest_ensure_response( $this->response );
103
+ }
104
+
105
+ return rest_ensure_response( $this->response );
106
+ }
107
+ }
V5/API/V1/FeedLists.php ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace CTXFeed\V5\API\V1;
4
+
5
+ use CTXFeed\V5\API\RestController;
6
+ use \WP_REST_Server;
7
+
8
+ class FeedLists extends RestController {
9
+ /**
10
+ * @var $namespace ;
11
+ */
12
+ public $namespace;
13
+ /**
14
+ * @var $version ;
15
+ */
16
+ public $version = 'v1';
17
+ /**
18
+ * @var $rest_base
19
+ */
20
+
21
+ protected $rest_base = 'feed_lists';
22
+
23
+ /**
24
+ * The single instance of the class
25
+ *
26
+ * @var FeedLists
27
+ *
28
+ */
29
+ protected static $_instance = null;
30
+
31
+ public function __construct() {
32
+ parent::__construct();
33
+ $this->namespace = 'ctxfeed/' . $this->version;
34
+ }
35
+
36
+ /**
37
+ * Main FeedLists Instance.
38
+ *
39
+ * Ensures only one instance of FeedLists is loaded or can be loaded.
40
+ *
41
+ * @return FeedLists Main instance
42
+ */
43
+ public static function instance() {
44
+ if ( is_null( self::$_instance ) ) {
45
+ self::$_instance = new self();
46
+ }
47
+
48
+ return self::$_instance;
49
+ }
50
+
51
+ /**
52
+ * Register routes.
53
+ * @return void
54
+ */
55
+ public function register_routes() {
56
+ register_rest_route(
57
+ $this->namespace,
58
+ '/' . $this->rest_base,
59
+ [
60
+ /**
61
+ * @endpoint: wp-json/ctxfeed/v1/feed_lists
62
+ * @description Will get all feed lists
63
+ *
64
+ * @endpoint http://localhost/azizulhasan/challan/wp-json/ctxfeed/v1/feed_lists/?status=inactive
65
+ * @description Only inactive feed lists will be returned.
66
+ * @param $status String
67
+ *
68
+ * @endpoint wp-json/ctxfeed/v1/feed_lists/?status=active
69
+ * @description Only active feed lists will be returned.
70
+ * @param $status String
71
+ */
72
+ [
73
+ 'methods' => WP_REST_Server::READABLE,
74
+ 'callback' => [ $this, 'get_feed_lists' ],
75
+ 'permission_callback' => [ $this, 'get_item_permissions_check' ],
76
+ 'args' => [
77
+ 'status' => [
78
+ 'description' => __( 'Is active or inactive', 'woo-feed' ),
79
+ 'type' => 'string',
80
+ 'required' => false
81
+ ],
82
+ ],
83
+ ],
84
+ ]
85
+ );
86
+ }
87
+
88
+ /**
89
+ *
90
+ * @param $request
91
+ *
92
+ * @return \WP_Error|\WP_HTTP_Response|\WP_REST_Response
93
+ */
94
+ public function get_feed_lists( $request ) {
95
+ $status = $request->get_param( 'status' );
96
+ global $wpdb;
97
+ $feed_lists = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->options WHERE option_name LIKE %s ORDER BY option_id DESC;", 'wf_feed_%' ), 'ARRAY_A' );
98
+
99
+ if ( $status ) {
100
+ /**
101
+ * True if status is active/inactive
102
+ */
103
+ if ( 'active' === $status || 'inactive' === $status ) {
104
+ $this->response['data'] = $this->get_lists( $feed_lists, $status );
105
+ } else {
106
+ $this->error( __( 'Status should be active/inactive !', 'woo-feed' ) );
107
+ }
108
+ } else {
109
+ $this->response['data'] = $this->get_lists( $feed_lists );
110
+ }
111
+
112
+ return rest_ensure_response( $this->response );
113
+ }
114
+
115
+ public function get_lists( $feed_lists, $status = '' ) {
116
+ $lists = [];
117
+ if ( $status ) {
118
+ foreach ( $feed_lists as $feed_list ) {
119
+ $feed_list['option_value'] = maybe_unserialize( get_option( $feed_list['option_name'] ) );
120
+ if ( 'active' === $status && 1 === $feed_list['option_value']['status'] ) {
121
+ $lists[] = $feed_list;
122
+ }
123
+ if ( 'inactive' === $status && 0 === $feed_list['option_value']['status'] ) {
124
+ $lists[] = $feed_list;
125
+ }
126
+ }
127
+ } else {
128
+ foreach ( $feed_lists as $feed_list ) {
129
+ $feed_list['option_value'] = maybe_unserialize( get_option( $feed_list['option_name'] ) );
130
+ $lists[] = $feed_list;
131
+ }
132
+ }
133
+
134
+ return $lists;
135
+ }
136
+
137
+ }
V5/API/V1/MerchantConfig.php ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace CTXFeed\V5\API\V1;
4
+
5
+ namespace CTXFeed\V5\API\V1;
6
+
7
+ use CTXFeed\V5\API\RestController;
8
+ use CTXFeed\V5\Helper\CommonHelper;
9
+ use CTXFeed\V5\Merchant\TemplateConfig;
10
+ use CTXFeed\V5\Utility\Config;
11
+ use WP_REST_Server;
12
+
13
+ //TODO: Custom Template 2 React/Js Output Rendering test.
14
+
15
+ class MerchantConfig extends RestController {
16
+ /**
17
+ * @var $namespace ;
18
+ */
19
+ public $namespace;
20
+ /**
21
+ * @var $version ;
22
+ */
23
+ public $version = 'v1';
24
+ /**
25
+ * @var $rest_base
26
+ */
27
+
28
+ protected $rest_base = 'merchant_config';
29
+
30
+ /**
31
+ * The single instance of the class
32
+ *
33
+ * @var MerchantConfig
34
+ *
35
+ */
36
+ protected static $_instance = null;
37
+
38
+ public function __construct() {
39
+ parent::__construct();
40
+ $this->namespace = 'ctxfeed/' . $this->version;
41
+ }
42
+
43
+ /**
44
+ * Main MerchantConfig Instance.
45
+ *
46
+ * Ensures only one instance of MerchantConfig is loaded or can be loaded.
47
+ *
48
+ * @return MerchantConfig Main instance
49
+ */
50
+ public static function instance() {
51
+ if ( is_null( self::$_instance ) ) {
52
+ self::$_instance = new self();
53
+ }
54
+
55
+ return self::$_instance;
56
+ }
57
+
58
+ /**
59
+ * Register routes.
60
+ *
61
+ * @return void
62
+ */
63
+ public function register_routes() {
64
+ register_rest_route(
65
+ $this->namespace,
66
+ '/' . $this->rest_base,
67
+ [
68
+ /**
69
+ * @endpoint: wp-json/ctxfeed/v1/merchant_config/?feed=wf_feed_google_shopping_33&type=edit
70
+ * @description It used for editing. Will get feed configuration based $type and $feed file name.
71
+ * @param $feed String feed file name
72
+ * @param $type String feed type edit/add
73
+ *
74
+ *
75
+ * @endpoint wp-json/ctxfeed/v1/merchant_config/?merchant=google&type=add
76
+ * @description It used for adding. Will get feed d configuration based $merchant name and $type.
77
+ * @param $type String feed type edit/add
78
+ * @param $merchant String merchant name
79
+ *
80
+ */
81
+ [
82
+ 'methods' => WP_REST_Server::READABLE,
83
+ 'callback' => [ $this, 'get_merchant_config' ],
84
+ 'permission_callback' => [ $this, 'get_item_permissions_check' ],
85
+ 'args' => [
86
+ 'merchant' => [
87
+ 'description' => __( 'Merchant name', 'woo-feed' ),
88
+ 'type' => 'string',
89
+ 'required' => false
90
+ ],
91
+ 'type' => [
92
+ 'description' => __( 'Edit or Add', 'woo-feed' ),
93
+ 'type' => 'string',
94
+ 'required' => true
95
+ ],
96
+ 'feed' => [
97
+ 'description' => __( 'feed file name', 'woo-feed' ),
98
+ 'type' => 'string',
99
+ 'required' => false
100
+ ]
101
+ ],
102
+ ],
103
+ ]
104
+ );
105
+ }
106
+
107
+ /**
108
+ *
109
+ * @param $request
110
+ *
111
+ * @return \WP_Error|\WP_HTTP_Response|\WP_REST_Response
112
+ */
113
+ public function get_merchant_config( $request ) {
114
+ $merchant = $request->get_param( 'merchant' );
115
+ /**
116
+ * Configuration type Example: add/edit
117
+ * if add : default merchant config will be return.
118
+ * else : current feed files config will be returned.
119
+ */
120
+ $type = $request->get_param( 'type' );
121
+ if ( 'add' === $type ) {
122
+ /**
123
+ * Get Feed merchant configuration like : itemWrapper, itemsWrapper, delimiter, extraHeader etc.
124
+ */
125
+ $defaultMerchantConfig = TemplateConfig::get( $merchant );
126
+ $defaultMerchantConfig['provider'] = $merchant;
127
+ $merchant = new Config( $defaultMerchantConfig );
128
+ $merchant_config = $merchant->get_config();
129
+
130
+ $this->success( $merchant_config );
131
+
132
+ } elseif ( 'edit' === $type ) {
133
+ $feedName = $request->get_param( 'feed' );
134
+ /**
135
+ * True if feed name is missing
136
+ */
137
+ if ( ! $feedName ) {
138
+ $this->error( __( 'Feed file name missing!', 'woo-feed' ) );
139
+
140
+ return rest_ensure_response( $this->response );
141
+ }
142
+
143
+ $feedName = CommonHelper::get_feed_option_name( $feedName );
144
+ $feedInfo = get_option( 'wf_config' . $feedName, false );
145
+
146
+ if ( $feedInfo ) {
147
+ $this->success( $feedInfo );
148
+ } else {
149
+ $this->error( sprintf( __( 'No configuration found with this feed name: %s', 'woo-feed' ), $feedName ) );
150
+ }
151
+ }
152
+
153
+
154
+ return rest_ensure_response( $this->response );
155
+ }
156
+ }
V5/API/V1/MerchantInfo.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace CTXFeed\V5\API\V1;
4
+
5
+ namespace CTXFeed\V5\API\V1;
6
+
7
+ use CTXFeed\V5\API\RestController;
8
+ use CTXFeed\V5\Merchant\TemplateInfo;
9
+ use WP_REST_Server;
10
+
11
+ class MerchantInfo extends RestController {
12
+ /**
13
+ * @var $namespace ;
14
+ */
15
+ public $namespace;
16
+ /**
17
+ * @var $version ;
18
+ */
19
+ public $version = 'v1';
20
+ /**
21
+ * @var $rest_base
22
+ */
23
+
24
+ protected $rest_base = 'merchant_info';
25
+
26
+ /**
27
+ * The single instance of the class
28
+ *
29
+ * @var MerchantInfo
30
+ *
31
+ */
32
+ protected static $_instance = null;
33
+
34
+ public function __construct() {
35
+ parent::__construct();
36
+ $this->namespace = 'ctxfeed/' . $this->version;
37
+ }
38
+
39
+ /**
40
+ * Main MerchantInfo Instance.
41
+ *
42
+ * Ensures only one instance of MerchantInfo is loaded or can be loaded.
43
+ *
44
+ * @return MerchantInfo Main instance
45
+ */
46
+ public static function instance() {
47
+ if ( is_null( self::$_instance ) ) {
48
+ self::$_instance = new self();
49
+ }
50
+
51
+ return self::$_instance;
52
+ }
53
+
54
+ /**
55
+ * Register routes.
56
+ *
57
+ * @return void
58
+ */
59
+ public function register_routes() {
60
+ register_rest_route(
61
+ $this->namespace,
62
+ '/' . $this->rest_base,
63
+ [
64
+ /**
65
+ * @endpoint wp-json/ctxfeed/v1/merchant_info/?merchant=google
66
+ * @description Get Feed merchant information like : Docs, Supported file types etc.
67
+ * @param $merchant String merchant name
68
+ *
69
+ */
70
+ [
71
+ 'methods' => WP_REST_Server::READABLE,
72
+ 'callback' => [ $this, 'get_merchant_info' ],
73
+ 'permission_callback' => [ $this, 'get_item_permissions_check' ],
74
+ 'args' => [
75
+ 'merchant' => [
76
+ 'description' => __( 'Merchant name' ),
77
+ 'type' => 'string',
78
+ 'required' => true
79
+ ],
80
+ ],
81
+ ],
82
+ ]
83
+ );
84
+ }
85
+
86
+ /**
87
+ *
88
+ * @param $request
89
+ *
90
+ * @return \WP_Error|\WP_HTTP_Response|\WP_REST_Response
91
+ */
92
+ public function get_merchant_info( $request ) {
93
+ $merchant = $request->get_param( 'merchant' );
94
+ /**
95
+ * Get Feed merchant information like : Docs, Supported file types etc.
96
+ */
97
+ $merchantInfo = TemplateInfo::get( $merchant );
98
+
99
+ $this->success( $merchantInfo );
100
+
101
+ return rest_ensure_response( $this->response );
102
+ }
103
+ }
V5/API/V1/ProductCategories.php ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace CTXFeed\V5\API\V1;
4
+
5
+ use CTXFeed\V5\API\RestController;
6
+ use \WP_REST_Server;
7
+
8
+ class ProductCategories extends RestController {
9
+ /**
10
+ * @var $namespace ;
11
+ */
12
+ public $namespace;
13
+ /**
14
+ * @var $version ;
15
+ */
16
+ public $version = 'v1';
17
+ /**
18
+ * @var $rest_base
19
+ */
20
+
21
+ protected $rest_base = 'categories';
22
+
23
+ /**
24
+ * The single instance of the class
25
+ *
26
+ * @var ProductCategories
27
+ *
28
+ */
29
+ protected static $_instance = null;
30
+
31
+ public function __construct() {
32
+ parent::__construct();
33
+ $this->namespace = 'ctxfeed/' . $this->version;
34
+ }
35
+
36
+ /**
37
+ * Main ProductCategories Instance.
38
+ *
39
+ * Ensures only one instance of ProductCategories is loaded or can be loaded.
40
+ *
41
+ * @return ProductCategories Main instance
42
+ */
43
+ public static function instance() {
44
+ if ( is_null( self::$_instance ) ) {
45
+ self::$_instance = new self();
46
+ }
47
+
48
+ return self::$_instance;
49
+ }
50
+
51
+ /**
52
+ * Register routes.
53
+ * @return void
54
+ */
55
+ public function register_routes() {
56
+ register_rest_route(
57
+ $this->namespace,
58
+ '/' . $this->rest_base,
59
+ [
60
+ /**
61
+ * @endpoint wp-json/ctxfeed/v1/categories/?search=hoo
62
+ * @description will return all categories based on search string.
63
+ * @param $search String
64
+ *
65
+ */
66
+ [
67
+ 'methods' => WP_REST_Server::READABLE,
68
+ 'callback' => [ $this, 'search_categories' ],
69
+ 'permission_callback' => [ $this, 'get_item_permissions_check' ],
70
+ 'args' => [
71
+ 'search' => [
72
+ 'description' => __( 'Search string.', 'woo-feed' ),
73
+ 'type' => 'string',
74
+ 'required' => false
75
+ ],
76
+ ],
77
+ ],
78
+ ]
79
+ );
80
+ }
81
+
82
+ /**
83
+ *
84
+ * @param $request
85
+ *
86
+ * @return \WP_Error|\WP_HTTP_Response|\WP_REST_Response
87
+ */
88
+ public function search_categories( $request ) {
89
+ $search_string = $request->get_param( 'search' );
90
+
91
+ $args = array(
92
+ 'taxonomy' => array( 'product_cat' ),
93
+ 'orderby' => 'id',
94
+ 'order' => 'DESC',
95
+ 'hide_empty' => true,
96
+ 'fields' => 'all',
97
+ 'name__like' => $search_string,
98
+ );
99
+
100
+ $terms = get_terms( $args );
101
+
102
+ $this->success( $terms );
103
+
104
+ return rest_ensure_response( $this->response );
105
+ }
106
+
107
+ }
V5/API/V1/ProductTaxonomy.php ADDED
@@ -0,0 +1,408 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace CTXFeed\V5\API\V1;
4
+
5
+ use CTXFeed\V5\API\RestController;
6
+ use phpDocumentor\Reflection\Types\Boolean;
7
+ use PhpParser\Node\Scalar\String_;
8
+ use WP_REST_Server;
9
+
10
+ class ProductTaxonomy extends RestController {
11
+ /**
12
+ * @var $namespace ;
13
+ */
14
+ public $namespace;
15
+ /**
16
+ * @var $version ;
17
+ */
18
+ public $version = 'v1';
19
+ /**
20
+ * @var $rest_base
21
+ */
22
+
23
+ protected $rest_base = 'taxonomies';
24
+
25
+ /**
26
+ * Default country code
27
+ * @var string
28
+ */
29
+ protected $country_code = 'en-US';
30
+ /**
31
+ * Default merchang
32
+ * @var string
33
+ */
34
+ protected $merchant = 'google';
35
+ /**
36
+ * Default file name will be with id Example: taxonomy-with-ids.en-US.txt. If $with_id is false file name Example: taxonomy.en-US.txt for google merchant.
37
+ * this role will not applicable with facebook catalog.
38
+ * @var bool
39
+ */
40
+ protected $with_id = true;
41
+ protected $ext = 'txt';
42
+
43
+ /**
44
+ * The single instance of the class
45
+ *
46
+ * @var ProductTaxonomy
47
+ *
48
+ */
49
+ protected static $_instance = null;
50
+
51
+ public function __construct() {
52
+ parent::__construct();
53
+ $this->namespace = 'ctxfeed/' . $this->version;
54
+ }
55
+
56
+ /**
57
+ * Main ProductTaxonomy Instance.
58
+ *
59
+ * Ensures only one instance of ProductTaxonomy is loaded or can be loaded.
60
+ *
61
+ * @return ProductTaxonomy Main instance
62
+ */
63
+ public static function instance() {
64
+ if ( is_null( self::$_instance ) ) {
65
+ self::$_instance = new self();
66
+ }
67
+
68
+ return self::$_instance;
69
+ }
70
+
71
+ public function register_routes() {
72
+ register_rest_route(
73
+ $this->namespace,
74
+ '/' . $this->rest_base,
75
+ [
76
+ /**
77
+ * @endpoint wp-json/ctxfeed/v1/taxonomies/?country_code=en-US&merchant=google
78
+ * @description will return stored merchant data.
79
+ * @param $country_code
80
+ * @param $merchant
81
+ *
82
+ * @endpoint wp-json/ctxfeed/v1/taxonomies/?country_code=en-US&merchant=google&update=true
83
+ * @description Download merchant taxonomy file.
84
+ * @param $country_code String
85
+ * @param $merchant Stirng
86
+ * @param $update Boolean if true the taxonomy file will be downloaded based on merchant and country code.
87
+ */
88
+ [
89
+ 'methods' => WP_REST_Server::READABLE,
90
+ 'callback' => [ $this, 'manage_taxonomy' ],
91
+ 'permission_callback' => [ $this, 'get_item_permissions_check' ],
92
+ 'args' => [
93
+ 'country_code' => [
94
+ 'description' => __( 'Country code.' ),
95
+ 'type' => 'string',
96
+ 'required' => true
97
+ ],
98
+ 'merchant' => [
99
+ 'description' => __( 'Merchant name' ),
100
+ 'type' => 'string',
101
+ 'required' => true
102
+ ],
103
+ 'with_id' => [
104
+ 'description' => __( 'If true then taxonomy will be downloaded with id' ),
105
+ 'type' => 'boolean',
106
+ 'required' => false,
107
+ 'default' => true
108
+ ],
109
+ 'ext' => [
110
+ 'description' => __( 'File extension default is txt' ),
111
+ 'type' => 'string',
112
+ 'required' => false,
113
+ 'default' => 'txt'
114
+ ],
115
+ 'update' => [
116
+ 'description' => __( 'Should update if value is true' ),
117
+ 'type' => 'boolean',
118
+ 'required' => false,
119
+ 'default' => false
120
+ ],
121
+ ],
122
+ ],
123
+ ]
124
+ );
125
+ }
126
+
127
+ /**
128
+ * Base on parameter taxonomy file either updated or try to get file from specific folder( WOO_FEED_FREE_ADMIN_URL . 'partials/templates/taxonomies/')
129
+ * if parameter 'update' is passed, and it's value is true then file will be updated.
130
+ * else file will be, get.
131
+ *
132
+ * @param $request
133
+ *
134
+ * @return void
135
+ */
136
+ public function manage_taxonomy( $request ) {
137
+ $this->country_code = $request->get_param( 'country_code' );
138
+ $this->merchant = $request->get_param( 'merchant' );
139
+ $this->with_id = $request->get_param( 'with_id' );
140
+ $this->ext = $request->get_param( 'ext' );
141
+ $is_update = $request->get_param( 'update' );
142
+
143
+ if ( true == $is_update ) {
144
+ $this->update_taxonomy();
145
+ } else {
146
+ $this->get_taxonomy();
147
+ }
148
+
149
+ return rest_ensure_response( $this->response );
150
+ }
151
+
152
+ /**
153
+ *
154
+ * @return bool
155
+ */
156
+ public function get_taxonomy() {
157
+ $url = WOO_FEED_FREE_ADMIN_URL . 'partials/templates/taxonomies/';
158
+ if ( 'google' == $this->merchant ) {
159
+ $url .= 'google_taxonomy.txt';
160
+ } elseif ( 'facebook' == $this->merchant ) {
161
+ $url .= 'fb_taxonomy.txt';
162
+ } else {
163
+ $url .= 'google_taxonomy.txt';
164
+ }
165
+ $response = file_get_contents( $url );
166
+ if ( $response ) {
167
+ $this->success( $response );
168
+ } else {
169
+ $this->error( sprintf( __( 'No data found with this url: %s', 'woo-feed' ), $url ) );
170
+ }
171
+
172
+ return true;
173
+ }
174
+
175
+ /**
176
+ * @param $request
177
+ *
178
+ * @return void|\WP_Error|\WP_REST_Response
179
+ */
180
+ public function update_taxonomy() {
181
+ /**
182
+ * Depending on parameter like merchant and file extension file will be downloaded.
183
+ * if url doesn't has any resource response will be false.
184
+ */
185
+ $url = $this->get_url();
186
+ $response = wp_safe_remote_get( $url );
187
+ if ( '200' == wp_remote_retrieve_response_code( $response ) ) {
188
+ $response_body = wp_remote_retrieve_body( $response );
189
+ $path = WOO_FEED_FREE_ADMIN_PATH . 'partials/templates/taxonomies/';
190
+ $filepath = $path . '/' . $this->get_filename_for_save();
191
+ /**
192
+ * data will be put on targeted folder.
193
+ */
194
+ $fp = fopen( $filepath, 'w' );//phpcs:ignore
195
+ fwrite( $fp, $response_body );//phpcs:ignore
196
+ fclose( $fp );//phpcs:ignore
197
+ $this->success( $url );
198
+ } else {
199
+ $this->error( sprintf( __( 'No data found with this url: %s', 'woo-feed' ), $url ) );
200
+ }
201
+
202
+ return true;
203
+ }
204
+
205
+ /**
206
+ * @return string
207
+ */
208
+ public function get_url() {
209
+ return $this->get_merchant_url() . $this->get_filename_for_download();
210
+ }
211
+
212
+ /**
213
+ * @return string|void
214
+ */
215
+ private function get_filename_for_save() {
216
+ $filename = 'google_taxonomy_US.txt';
217
+ if ( 'google' === $this->merchant ) {
218
+ $filename = 'google_taxonomy_' . $this->country_code . '.' . $this->ext;
219
+ } elseif ( 'facebook' === $this->merchant ) {
220
+ $filename = 'facebook_taxonomy_' . $this->country_code . '.' . $this->ext;
221
+ }
222
+
223
+ return $filename;
224
+ }
225
+
226
+ /**
227
+ * @return string|void
228
+ */
229
+ private function get_filename_for_download() {
230
+ $filename = 'taxonomy.en-US.txt';
231
+ $country_code = $this->country_code;
232
+ $codes = $this->get_country_codes();
233
+ foreach ( $codes as $code ) {
234
+ if ( false !== strpos( $code, $this->country_code ) ) {
235
+ $country_code = $code;
236
+ break;
237
+ }
238
+ }
239
+ if ( 'google' === $this->merchant ) {
240
+ $filename = ( true == $this->with_id ) ? 'taxonomy-with-ids.' . $country_code . '.' . $this->ext : 'taxonomy.' . $country_code . '.' . $this->ext;
241
+ } elseif ( 'facebook' === $this->merchant ) {
242
+ $country_code = str_replace( '-', '_', $country_code );
243
+ $filename = $country_code . '.' . $this->ext;
244
+ }
245
+
246
+ return $filename;
247
+ }
248
+
249
+ /**
250
+ * taxonomy with ids example: https://www.google.com/basepages/producttype/taxonomy-with-ids.en-US.txt
251
+ * taxonomy without id example: https://www.google.com/basepages/producttype/taxonomy.en-US.txt
252
+ * @return mixed
253
+ */
254
+ private function get_merchant_url() {
255
+ $urls = apply_filters( 'ctxfeed_mechant_ur', [
256
+ 'google' => 'https://www.google.com/basepages/producttype/',
257
+ 'facebook' => 'https://www.facebook.com/products/categories/'
258
+ ] );
259
+
260
+ return $urls[ $this->merchant ];
261
+ }
262
+
263
+ private function get_country_codes() {
264
+ return apply_filters( 'ctxfeed_country_codes', [
265
+ "af",
266
+ "ak",
267
+ "sq",
268
+ "am",
269
+ "ar",
270
+ "hy",
271
+ "rup-MK",
272
+ "as",
273
+ "az",
274
+ "az-TR",
275
+ "ba",
276
+ "eu",
277
+ "bel",
278
+ "bn-BD",
279
+ "bs-BA",
280
+ "bg-BG",
281
+ "my-MM",
282
+ "ca",
283
+ "bal",
284
+ "zh-CN",
285
+ "zh-HK",
286
+ "zh-TW",
287
+ "co",
288
+ "hr",
289
+ "cs-CZ",
290
+ "da-DK",
291
+ "dv",
292
+ "nl-NL",
293
+ "nl-BE",
294
+ "en-US",
295
+ "en-AU",
296
+ "en-CA",
297
+ "en-GB",
298
+ "eo",
299
+ "et",
300
+ "fo",
301
+ "fi",
302
+ "fr-BE",
303
+ "fr-FR",
304
+ "fy",
305
+ "fuc",
306
+ "gl-ES",
307
+ "ka-GE",
308
+ "de-DE",
309
+ "de-CH",
310
+ "el",
311
+ "gn",
312
+ "gu-IN",
313
+ "haw-US",
314
+ "haz",
315
+ "he-IL",
316
+ "hi-IN",
317
+ "hu-HU",
318
+ "is-IS",
319
+ "ido",
320
+ "id-ID",
321
+ "ga",
322
+ "it-IT",
323
+ "ja",
324
+ "jv-ID",
325
+ "kn",
326
+ "kk",
327
+ "km",
328
+ "kin",
329
+ "ky-KY",
330
+ "ko-KR",
331
+ "ckb",
332
+ "lo",
333
+ "lv",
334
+ "li",
335
+ "lin",
336
+ "lt-LT",
337
+ "lb-LU",
338
+ "mk-MK",
339
+ "mg-MG",
340
+ "ms-MY",
341
+ "ml-IN",
342
+ "mr",
343
+ "xmf",
344
+ "mn",
345
+ "me-ME",
346
+ "ne-NP",
347
+ "nb-NO",
348
+ "nn-NO",
349
+ "ory",
350
+ "os",
351
+ "ps",
352
+ "fa-IR",
353
+ "fa-AF",
354
+ "pl-PL",
355
+ "pt-BR",
356
+ "pt-PT",
357
+ "pa-IN",
358
+ "rhg",
359
+ "ro-RO",
360
+ "ru-RU",
361
+ "ru-UA",
362
+ "rue",
363
+ "sah",
364
+ "sa-IN",
365
+ "srd",
366
+ "gd",
367
+ "sr-RS",
368
+ "sd-PK",
369
+ "si-LK",
370
+ "sk-SK",
371
+ "sl-SI",
372
+ "so-SO",
373
+ "azb",
374
+ "es-AR",
375
+ "es-CL",
376
+ "es-CO",
377
+ "es-MX",
378
+ "es-PE",
379
+ "es-PR",
380
+ "es-ES",
381
+ "es-VE",
382
+ "su-ID",
383
+ "sw",
384
+ "sv-SE",
385
+ "gsw",
386
+ "tl",
387
+ "tg",
388
+ "tzm",
389
+ "ta-IN",
390
+ "ta-LK",
391
+ "tt-RU",
392
+ "te",
393
+ "th",
394
+ "bo",
395
+ "tir",
396
+ "tr-TR",
397
+ "tuk",
398
+ "ug-CN",
399
+ "uk",
400
+ "ur",
401
+ "uz-UZ",
402
+ "vi",
403
+ "wa",
404
+ "cy",
405
+ "yor"
406
+ ] );
407
+ }
408
+ }
V5/API/V1/ProductTitles.php ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace CTXFeed\V5\API\V1;
4
+
5
+ use CTXFeed\V5\API\RestController;
6
+ use \WP_REST_Server;
7
+
8
+ class ProductTitles extends RestController {
9
+ /**
10
+ * @var $namespace ;
11
+ */
12
+ public $namespace;
13
+ /**
14
+ * @var $version ;
15
+ */
16
+ public $version = 'v1';
17
+ /**
18
+ * @var $rest_base
19
+ */
20
+
21
+ protected $rest_base = 'product_titles';
22
+
23
+ /**
24
+ * The single instance of the class
25
+ *
26
+ * @var ProductTitles
27
+ *
28
+ */
29
+ protected static $_instance = null;
30
+
31
+ public function __construct() {
32
+ parent::__construct();
33
+ $this->namespace = 'ctxfeed/' . $this->version;
34
+ }
35
+
36
+ /**
37
+ * Main ProductTitles Instance.
38
+ *
39
+ * Ensures only one instance of ProductTitles is loaded or can be loaded.
40
+ *
41
+ * @return ProductTitles Main instance
42
+ */
43
+ public static function instance() {
44
+ if ( is_null( self::$_instance ) ) {
45
+ self::$_instance = new self();
46
+ }
47
+
48
+ return self::$_instance;
49
+ }
50
+
51
+ /**
52
+ * Register routes.
53
+ * @return void
54
+ */
55
+ public function register_routes() {
56
+ register_rest_route(
57
+ $this->namespace,
58
+ '/' . $this->rest_base,
59
+ [
60
+ /**
61
+ * @endpoint wp-json/ctxfeed/v1/product_titles/?search=hoo
62
+ * @description will return all product titles based on search string.
63
+ * @param $search String
64
+ *
65
+ */
66
+ [
67
+ 'methods' => WP_REST_Server::READABLE,
68
+ 'callback' => [ $this, 'get_product_titles' ],
69
+ 'permission_callback' => [ $this, 'get_item_permissions_check' ],
70
+ 'args' => [
71
+ 'search' => [
72
+ 'description' => __( 'Search string.', 'woo-feed' ),
73
+ 'type' => 'string',
74
+ 'required' => true
75
+ ],
76
+ ],
77
+ ],
78
+ ]
79
+ );
80
+ }
81
+
82
+ /**
83
+ *
84
+ * @param $request
85
+ *
86
+ * @return \WP_Error|\WP_HTTP_Response|\WP_REST_Response
87
+ */
88
+ public function get_product_titles( $request ) {
89
+ $search_string = $request->get_param( 'search' );
90
+
91
+ $data_store = \WC_Data_Store::load( 'product' );
92
+ $ids = $data_store->search_products( $search_string, 'product', true, false, 200, [], [] );
93
+ $search_results = [];
94
+ foreach ( $ids as $id ) {
95
+ if ( $id < 1 ) {
96
+ continue;
97
+ }
98
+ $handle = wc_get_product( $id );
99
+ $search_results[ $id ] = strip_tags( $handle->get_formatted_name() );
100
+ }
101
+ $this->success( [ $search_results ] );
102
+
103
+ return rest_ensure_response( $this->response );
104
+ }
105
+
106
+ }
V5/Common/DropDownOptions.php CHANGED
@@ -2,6 +2,7 @@
2
 
3
  namespace CTXFeed\V5\Common;
4
 
 
5
  use CTXFeed\V5\Product\ProductAttributeFactory;
6
  use CTXFeed\V5\Utility\DropDown;
7
 
@@ -10,12 +11,35 @@ use CTXFeed\V5\Utility\DropDown;
10
  * @subpackage CTXFeed\V5\Common\DropDownOptions
11
  */
12
  class DropDownOptions {
13
-
14
  /**
15
  * Product Category
16
  */
17
  private static $cats;
18
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  /**
20
  * Country List
21
  *
@@ -28,7 +52,7 @@ class DropDownOptions {
28
  * @updated 15-07-2022
29
  */
30
  public static function feed_country( $selected = '', $dropdown = true ) {
31
- $countries = array(
32
  'AF' => 'Afghanistan',
33
  'AX' => 'Aland Islands',
34
  'AL' => 'Albania',
@@ -276,10 +300,10 @@ class DropDownOptions {
276
  'ZM' => 'Zambia',
277
  'ZW' => 'Zimbabwe',
278
  );
279
-
280
  return self::Create_DropDown_IF_Needed( $countries, $dropdown, $selected );
281
  }
282
-
283
  /**
284
  * Feed Template List.
285
  *
@@ -424,10 +448,10 @@ class DropDownOptions {
424
  ]
425
  ],
426
  ];
427
-
428
  return self::Create_DropDown_IF_Needed( $merchant, $dropdown, $selected );
429
  }
430
-
431
  /**
432
  * Feed File Type List.
433
  *
@@ -445,10 +469,10 @@ class DropDownOptions {
445
  'txt' => 'TXT',
446
  'json' => 'JSON',
447
  );
448
-
449
  return self::Create_DropDown_IF_Needed( $types, $dropdown, $selected );
450
  }
451
-
452
  /**
453
  * Variation Options.
454
  *
@@ -467,10 +491,10 @@ class DropDownOptions {
467
  'last' => esc_html__( 'Last Variation', 'woo-feed' ),
468
  'both' => esc_html__( 'Variable + Variations', 'woo-feed' ),
469
  );
470
-
471
  return self::Create_DropDown_IF_Needed( $variation_options, $dropdown, $selected );
472
  }
473
-
474
  /**
475
  * Variation Price Options.
476
  *
@@ -485,10 +509,10 @@ class DropDownOptions {
485
  'max' => esc_html__( 'Max Variation Price', 'woo-feed' ),
486
  'min' => esc_html__( 'Min Variation Price', 'woo-feed' ),
487
  );
488
-
489
  return self::Create_DropDown_IF_Needed( $variation_price, $dropdown, $selected );
490
  }
491
-
492
  /**
493
  * Variation Quantity Options.
494
  *
@@ -503,10 +527,10 @@ class DropDownOptions {
503
  'max' => esc_html__( 'Max Variation Price', 'woo-feed' ),
504
  'min' => esc_html__( 'Min Variation Price', 'woo-feed' ),
505
  );
506
-
507
  return self::Create_DropDown_IF_Needed( $variation_quantity, $dropdown, $selected );
508
  }
509
-
510
  /**
511
  * CSV Feed Delimiters.
512
  *
@@ -524,10 +548,10 @@ class DropDownOptions {
524
  ';' => 'Semi Colon',
525
  "\t" => 'TAB',
526
  ];
527
-
528
  return self::Create_DropDown_IF_Needed( $delimiters, $dropdown, $selected );
529
  }
530
-
531
  /**
532
  * CSV Feed Enclosure.
533
  *
@@ -542,10 +566,10 @@ class DropDownOptions {
542
  'single' => '\'',
543
  ' ' => 'None',
544
  ];
545
-
546
  return self::Create_DropDown_IF_Needed( $enclosure, $dropdown, $selected );
547
  }
548
-
549
  /**
550
  * Get Merchant attribute dropdown.
551
  *
@@ -557,10 +581,10 @@ class DropDownOptions {
557
  */
558
  public static function merchant_attributes( $attributes, $selected = '', $dropdown = true ) {
559
  $cache_key = 'ctx_merchant_attribute_dropdown_' . $selected;
560
-
561
  return self::Create_DropDown_IF_Needed( $attributes, $dropdown, $selected, $cache_key, true );
562
  }
563
-
564
  /**
565
  * Product Attributes.
566
  *
@@ -572,10 +596,10 @@ class DropDownOptions {
572
  public static function product_attributes( $selected = '', $dropdown = true ) {
573
  $attributes = ProductAttributeFactory::getAttributes();
574
  $cache_key = 'woo_feed_product_attribute_dropdown';
575
-
576
  return self::Create_DropDown_IF_Needed( $attributes, $dropdown, $selected, $cache_key, true );
577
  }
578
-
579
  /**
580
  * Comparing Condition. Used on Dynamic Attributes and
581
  *
@@ -597,10 +621,10 @@ class DropDownOptions {
597
  'nContains' => __( 'does not contain', 'woo-feed' ),
598
  'between' => __( 'between', 'woo-feed' ),
599
  );
600
-
601
  return self::Create_DropDown_IF_Needed( $conditions, $dropdown, $selected );
602
  }
603
-
604
  /**
605
  * Variation Query Type at Settings.
606
  *
@@ -614,10 +638,10 @@ class DropDownOptions {
614
  'individual' => __( 'Individual', 'woo-feed' ),
615
  'variable' => __( 'Variable Dependable', 'woo-feed' ),
616
  ];
617
-
618
  return self::Create_DropDown_IF_Needed( $variation_query_type, $dropdown, $selected );
619
  }
620
-
621
  /**
622
  * Product Query Type at Settings.
623
  *
@@ -632,10 +656,10 @@ class DropDownOptions {
632
  'wp' => __( 'WP_Query', 'woo-feed' ),
633
  'both' => __( 'Both', 'woo-feed' ),
634
  ];
635
-
636
  return self::Create_DropDown_IF_Needed( $product_query_type, $dropdown, $selected );
637
  }
638
-
639
  /**
640
  * Get all WP Options list.
641
  *
@@ -647,17 +671,17 @@ class DropDownOptions {
647
  public static function get_options( $selected = '', $dropdown = false ) {
648
  $options = [];
649
  $getOptions = wp_load_alloptions();
650
-
651
  if ( ! empty( $getOptions ) ) {
652
  $options[''] = "Select an Option";
653
  foreach ( $getOptions as $key => $option ) {
654
  $options[ $key ] = $key;
655
  }
656
  }
657
-
658
  return self::Create_DropDown_IF_Needed( $options, $dropdown, $selected );
659
  }
660
-
661
  /**
662
  * Get Product Categories
663
  *
@@ -676,7 +700,7 @@ class DropDownOptions {
676
  * @return array
677
  */
678
  public static function get_categories( $parent = 0, $dropdown = true, $selected = [] ) {
679
-
680
  $args = [
681
  'taxonomy' => 'product_cat',
682
  'parent' => $parent,
@@ -687,7 +711,7 @@ class DropDownOptions {
687
  'title_li' => '',
688
  'hide_empty' => 0,
689
  ];
690
-
691
  $categories = get_categories( $args );
692
  if ( ! empty( $categories ) ) {
693
  foreach ( $categories as $cat ) {
@@ -699,8 +723,8 @@ class DropDownOptions {
699
  // return self::$cats;
700
  return self::Create_DropDown_IF_Needed( self::$cats, $dropdown, $selected );
701
  }
702
-
703
-
704
  /**
705
  * Make DropDown Option from array if needed else return the array.
706
  *
@@ -713,12 +737,12 @@ class DropDownOptions {
713
  * @return array|false|mixed|string|string[]
714
  */
715
  public static function Create_DropDown_IF_Needed( $array, $DropDownStatus, $selected, $cache_key = '', $cache = false ) {
716
-
717
  if ( $DropDownStatus ) {
718
  return Dropdown::Create( $array, $selected, $cache_key, $cache );
719
  }
720
-
721
  return $array;
722
  }
723
-
724
- }
2
 
3
  namespace CTXFeed\V5\Common;
4
 
5
+ use CTXFeed\V5\API\RestController;
6
  use CTXFeed\V5\Product\ProductAttributeFactory;
7
  use CTXFeed\V5\Utility\DropDown;
8
 
11
  * @subpackage CTXFeed\V5\Common\DropDownOptions
12
  */
13
  class DropDownOptions {
14
+
15
  /**
16
  * Product Category
17
  */
18
  private static $cats;
19
+
20
+ /**
21
+ * The single instance of the class
22
+ *
23
+ * @var DropDownOptions
24
+ *
25
+ */
26
+ protected static $_instance = null;
27
+
28
+ /**
29
+ * Main DropDownOptions Instance.
30
+ *
31
+ * Ensures only one instance of DropDownOptions is loaded or can be loaded.
32
+ *
33
+ * @return DropDownOptions Main instance
34
+ */
35
+ public static function instance() {
36
+ if ( is_null( self::$_instance ) ) {
37
+ self::$_instance = new self();
38
+ }
39
+
40
+ return self::$_instance;
41
+ }
42
+
43
  /**
44
  * Country List
45
  *
52
  * @updated 15-07-2022
53
  */
54
  public static function feed_country( $selected = '', $dropdown = true ) {
55
+ return array(
56
  'AF' => 'Afghanistan',
57
  'AX' => 'Aland Islands',
58
  'AL' => 'Albania',
300
  'ZM' => 'Zambia',
301
  'ZW' => 'Zimbabwe',
302
  );
303
+
304
  return self::Create_DropDown_IF_Needed( $countries, $dropdown, $selected );
305
  }
306
+
307
  /**
308
  * Feed Template List.
309
  *
448
  ]
449
  ],
450
  ];
451
+
452
  return self::Create_DropDown_IF_Needed( $merchant, $dropdown, $selected );
453
  }
454
+
455
  /**
456
  * Feed File Type List.
457
  *
469
  'txt' => 'TXT',
470
  'json' => 'JSON',
471
  );
472
+
473
  return self::Create_DropDown_IF_Needed( $types, $dropdown, $selected );
474
  }
475
+
476
  /**
477
  * Variation Options.
478
  *
491
  'last' => esc_html__( 'Last Variation', 'woo-feed' ),
492
  'both' => esc_html__( 'Variable + Variations', 'woo-feed' ),
493
  );
494
+
495
  return self::Create_DropDown_IF_Needed( $variation_options, $dropdown, $selected );
496
  }
497
+
498
  /**
499
  * Variation Price Options.
500
  *
509
  'max' => esc_html__( 'Max Variation Price', 'woo-feed' ),
510
  'min' => esc_html__( 'Min Variation Price', 'woo-feed' ),
511
  );
512
+
513
  return self::Create_DropDown_IF_Needed( $variation_price, $dropdown, $selected );
514
  }
515
+
516
  /**
517
  * Variation Quantity Options.
518
  *
527
  'max' => esc_html__( 'Max Variation Price', 'woo-feed' ),
528
  'min' => esc_html__( 'Min Variation Price', 'woo-feed' ),
529
  );
530
+
531
  return self::Create_DropDown_IF_Needed( $variation_quantity, $dropdown, $selected );
532
  }
533
+
534
  /**
535
  * CSV Feed Delimiters.
536
  *
548
  ';' => 'Semi Colon',
549
  "\t" => 'TAB',
550
  ];
551
+
552
  return self::Create_DropDown_IF_Needed( $delimiters, $dropdown, $selected );
553
  }
554
+
555
  /**
556
  * CSV Feed Enclosure.
557
  *
566
  'single' => '\'',
567
  ' ' => 'None',
568
  ];
569
+
570
  return self::Create_DropDown_IF_Needed( $enclosure, $dropdown, $selected );
571
  }
572
+
573
  /**
574
  * Get Merchant attribute dropdown.
575
  *
581
  */
582
  public static function merchant_attributes( $attributes, $selected = '', $dropdown = true ) {
583
  $cache_key = 'ctx_merchant_attribute_dropdown_' . $selected;
584
+
585
  return self::Create_DropDown_IF_Needed( $attributes, $dropdown, $selected, $cache_key, true );
586
  }
587
+
588
  /**
589
  * Product Attributes.
590
  *
596
  public static function product_attributes( $selected = '', $dropdown = true ) {
597
  $attributes = ProductAttributeFactory::getAttributes();
598
  $cache_key = 'woo_feed_product_attribute_dropdown';
599
+
600
  return self::Create_DropDown_IF_Needed( $attributes, $dropdown, $selected, $cache_key, true );
601
  }
602
+
603
  /**
604
  * Comparing Condition. Used on Dynamic Attributes and
605
  *
621
  'nContains' => __( 'does not contain', 'woo-feed' ),
622
  'between' => __( 'between', 'woo-feed' ),
623
  );
624
+
625
  return self::Create_DropDown_IF_Needed( $conditions, $dropdown, $selected );
626
  }
627
+
628
  /**
629
  * Variation Query Type at Settings.
630
  *
638
  'individual' => __( 'Individual', 'woo-feed' ),
639
  'variable' => __( 'Variable Dependable', 'woo-feed' ),
640
  ];
641
+
642
  return self::Create_DropDown_IF_Needed( $variation_query_type, $dropdown, $selected );
643
  }
644
+
645
  /**
646
  * Product Query Type at Settings.
647
  *
656
  'wp' => __( 'WP_Query', 'woo-feed' ),
657
  'both' => __( 'Both', 'woo-feed' ),
658
  ];
659
+
660
  return self::Create_DropDown_IF_Needed( $product_query_type, $dropdown, $selected );
661
  }
662
+
663
  /**
664
  * Get all WP Options list.
665
  *
671
  public static function get_options( $selected = '', $dropdown = false ) {
672
  $options = [];
673
  $getOptions = wp_load_alloptions();
674
+
675
  if ( ! empty( $getOptions ) ) {
676
  $options[''] = "Select an Option";
677
  foreach ( $getOptions as $key => $option ) {
678
  $options[ $key ] = $key;
679
  }
680
  }
681
+
682
  return self::Create_DropDown_IF_Needed( $options, $dropdown, $selected );
683
  }
684
+
685
  /**
686
  * Get Product Categories
687
  *
700
  * @return array
701
  */
702
  public static function get_categories( $parent = 0, $dropdown = true, $selected = [] ) {
703
+
704
  $args = [
705
  'taxonomy' => 'product_cat',
706
  'parent' => $parent,
711
  'title_li' => '',
712
  'hide_empty' => 0,
713
  ];
714
+
715
  $categories = get_categories( $args );
716
  if ( ! empty( $categories ) ) {
717
  foreach ( $categories as $cat ) {
723
  // return self::$cats;
724
  return self::Create_DropDown_IF_Needed( self::$cats, $dropdown, $selected );
725
  }
726
+
727
+
728
  /**
729
  * Make DropDown Option from array if needed else return the array.
730
  *
737
  * @return array|false|mixed|string|string[]
738
  */
739
  public static function Create_DropDown_IF_Needed( $array, $DropDownStatus, $selected, $cache_key = '', $cache = false ) {
740
+
741
  if ( $DropDownStatus ) {
742
  return Dropdown::Create( $array, $selected, $cache_key, $cache );
743
  }
744
+
745
  return $array;
746
  }
747
+
748
+ }
V5/Filter/Filter.php CHANGED
@@ -5,8 +5,7 @@ namespace CTXFeed\V5\Filter;
5
  use CTXFeed\V5\Utility\Config;
6
  use WC_Product;
7
 
8
- class Filter
9
- {
10
  /**
11
  * @var WC_Product $product
12
  */
@@ -16,17 +15,15 @@ class Filter
16
  */
17
  private $config;
18
 
19
- public function __construct($product, $config)
20
- {
21
  $this->product = $product;
22
- $this->config = $config;
23
  }
24
 
25
  /**
26
  * @return bool
27
  */
28
- public function exclude()
29
- {
30
  $exclude = false;
31
 
32
  // Remove Out Of Stock Product.
@@ -51,12 +48,12 @@ class Filter
51
  $exclude = $this->exclude_empty_price_products();
52
 
53
  // Exclude for variation
54
- if ($this->product->is_type('variation')) {
55
- $exclude = $this->exclude_variation($exclude);
56
  }
57
 
58
 
59
- return apply_filters('ctx_feed_filter_product', $exclude, $this->product, $this->config);
60
  }
61
 
62
  /**
@@ -64,8 +61,7 @@ class Filter
64
  *
65
  * @return bool
66
  */
67
- public function exclude_out_of_stock_products()
68
- {
69
  if ( ! $this->config->remove_outofstock_product() || $this->product->get_stock_status() !== 'outofstock' && $this->product->get_stock_quantity() !== 0 ) {
70
  return false;
71
  }
@@ -80,11 +76,11 @@ class Filter
80
  *
81
  * @return bool
82
  */
83
- public function exclude_back_order_products()
84
- {
85
- if ($this->config->remove_backorder_product() && $this->product->get_stock_status() === 'onbackorder') {
86
  return true;
87
  }
 
88
  return false;
89
  }
90
 
@@ -93,11 +89,11 @@ class Filter
93
  *
94
  * @return bool
95
  */
96
- public function exclude_empty_title_products()
97
- {
98
- if ($this->config->remove_empty_title() && empty($this->product->get_name())) {
99
  return true;
100
  }
 
101
  return false;
102
  }
103
 
@@ -106,11 +102,11 @@ class Filter
106
  *
107
  * @return bool
108
  */
109
- public function exclude_hidden_products()
110
- {
111
- if ($this->config->remove_hidden_products() && $this->product->get_catalog_visibility() === 'hidden') {
112
  return true;
113
  }
 
114
  return false;
115
  }
116
 
@@ -119,11 +115,11 @@ class Filter
119
  *
120
  * @return bool
121
  */
122
- public function exclude_empty_description_products()
123
- {
124
- if ($this->config->remove_empty_description() && empty($this->product->get_description())) {
125
  return true;
126
  }
 
127
  return false;
128
  }
129
 
@@ -132,11 +128,11 @@ class Filter
132
  *
133
  * @return bool
134
  */
135
- public function exclude_empty_image_products()
136
- {
137
- if ($this->config->remove_empty_image() && empty($this->product->get_image('woocommerce_thumbnail', [], false))) {
138
  return true;
139
  }
 
140
  return false;
141
  }
142
 
@@ -145,11 +141,11 @@ class Filter
145
  *
146
  * @return bool
147
  */
148
- public function exclude_empty_price_products()
149
- {
150
- if ($this->config->remove_empty_price() && empty($this->product->get_price())) {
151
  return true;
152
  }
 
153
  return false;
154
  }
155
 
@@ -157,63 +153,79 @@ class Filter
157
  * Exclude Variations.
158
  *
159
  * @param $exclude
 
160
  * @return bool|mixed
161
  */
162
- public function exclude_variation($exclude)
163
- {
164
  $id = $this->product->get_id();
165
- if ($this->product->is_type('variation')) {
166
  $id = $this->product->get_parent_id();
167
  }
168
 
169
  // Remove products which are set to exclude.
170
- $exclude_products = $this->config->get_products_to_exclude();
171
- if ($exclude_products && in_array($this->product->get_id(), $exclude_products, true)) {
172
- $exclude = true;
173
- }
174
 
175
  // Only add products which are set to include.
176
- $include_products = $this->config->get_products_to_include();
177
- if ($include_products && !in_array($this->product->get_id(), $include_products, true)) {
178
- $exclude = true;
179
- }
180
 
181
  // Remove categories which are set to exclude.
182
- $exclude_categories = $this->config->get_categories_to_exclude();
183
- if ($exclude_categories && has_term($exclude_categories, 'product_cat', $id)) {
184
- $exclude = true;
185
- }
186
 
187
  // Only add categories which are set to include.
188
- $include_categories = $this->config->get_categories_to_include();
189
- if ($include_categories && !has_term($include_categories, 'product_cat', $id)) {
190
- $exclude = true;
191
- }
192
 
193
  return $exclude;
194
  }
195
 
196
- public function exclude_variation_products( ) {
 
 
 
 
197
 
 
198
  }
199
 
200
- public function include_variation_products( ) {
 
 
 
 
201
 
 
202
  }
203
 
204
- public function exclude_variation_category( ) {
 
 
 
 
205
 
 
206
  }
207
 
208
- public function include_variation_category( ) {
 
 
 
 
209
 
 
210
  }
211
 
212
- public function exclude_variation_status( ) {
 
 
 
 
213
 
 
214
  }
215
 
216
- public function include_variation_status( ) {
217
-
218
- }
219
  }
5
  use CTXFeed\V5\Utility\Config;
6
  use WC_Product;
7
 
8
+ class Filter {
 
9
  /**
10
  * @var WC_Product $product
11
  */
15
  */
16
  private $config;
17
 
18
+ public function __construct( $product, $config ) {
 
19
  $this->product = $product;
20
+ $this->config = $config;
21
  }
22
 
23
  /**
24
  * @return bool
25
  */
26
+ public function exclude() {
 
27
  $exclude = false;
28
 
29
  // Remove Out Of Stock Product.
48
  $exclude = $this->exclude_empty_price_products();
49
 
50
  // Exclude for variation
51
+ if ( $this->product->is_type( 'variation' ) ) {
52
+ $exclude = $this->exclude_variation( $exclude );
53
  }
54
 
55
 
56
+ return apply_filters( 'ctx_feed_filter_product', $exclude, $this->product, $this->config );
57
  }
58
 
59
  /**
61
  *
62
  * @return bool
63
  */
64
+ public function exclude_out_of_stock_products() {
 
65
  if ( ! $this->config->remove_outofstock_product() || $this->product->get_stock_status() !== 'outofstock' && $this->product->get_stock_quantity() !== 0 ) {
66
  return false;
67
  }
76
  *
77
  * @return bool
78
  */
79
+ public function exclude_back_order_products() {
80
+ if ( $this->config->remove_backorder_product() && $this->product->get_stock_status() === 'onbackorder' ) {
 
81
  return true;
82
  }
83
+
84
  return false;
85
  }
86
 
89
  *
90
  * @return bool
91
  */
92
+ public function exclude_empty_title_products() {
93
+ if ( $this->config->remove_empty_title() && empty( $this->product->get_name() ) ) {
 
94
  return true;
95
  }
96
+
97
  return false;
98
  }
99
 
102
  *
103
  * @return bool
104
  */
105
+ public function exclude_hidden_products() {
106
+ if ( $this->config->remove_hidden_products() && $this->product->get_catalog_visibility() === 'hidden' ) {
 
107
  return true;
108
  }
109
+
110
  return false;
111
  }
112
 
115
  *
116
  * @return bool
117
  */
118
+ public function exclude_empty_description_products() {
119
+ if ( $this->config->remove_empty_description() && empty( $this->product->get_description() ) ) {
 
120
  return true;
121
  }
122
+
123
  return false;
124
  }
125
 
128
  *
129
  * @return bool
130
  */
131
+ public function exclude_empty_image_products() {
132
+ if ( $this->config->remove_empty_image() && empty( $this->product->get_image( 'woocommerce_thumbnail', [], false ) ) ) {
 
133
  return true;
134
  }
135
+
136
  return false;
137
  }
138
 
141
  *
142
  * @return bool
143
  */
144
+ public function exclude_empty_price_products() {
145
+ if ( $this->config->remove_empty_price() && empty( $this->product->get_price() ) ) {
 
146
  return true;
147
  }
148
+
149
  return false;
150
  }
151
 
153
  * Exclude Variations.
154
  *
155
  * @param $exclude
156
+ *
157
  * @return bool|mixed
158
  */
159
+ public function exclude_variation( $exclude ) {
 
160
  $id = $this->product->get_id();
161
+ if ( $this->product->is_type( 'variation' ) ) {
162
  $id = $this->product->get_parent_id();
163
  }
164
 
165
  // Remove products which are set to exclude.
166
+ $exclude = $this->exclude_variation_products();
 
 
 
167
 
168
  // Only add products which are set to include.
169
+ $exclude = $this->include_variation_products();
 
 
 
170
 
171
  // Remove categories which are set to exclude.
172
+ $exclude = $this->exclude_variation_category( $id );
 
 
 
173
 
174
  // Only add categories which are set to include.
175
+ $exclude = $this->include_variation_category( $id );
176
+
177
+ // Only add product status which are set to include.
178
+ $exclude = $this->include_variation_status();
179
 
180
  return $exclude;
181
  }
182
 
183
+ public function exclude_variation_products() {
184
+ $exclude_products = $this->config->get_products_to_exclude();
185
+ if ( $exclude_products && in_array( $this->product->get_id(), $exclude_products, false ) ) {
186
+ return true;
187
+ }
188
 
189
+ return false;
190
  }
191
 
192
+ public function include_variation_products() {
193
+ $include_products = $this->config->get_products_to_include();
194
+ if ( $include_products && ! in_array( $this->product->get_id(), $include_products, true ) ) {
195
+ return true;
196
+ }
197
 
198
+ return false;
199
  }
200
 
201
+ public function exclude_variation_category( $id ) {
202
+ $exclude_categories = $this->config->get_categories_to_exclude();
203
+ if ( $exclude_categories && has_term( $exclude_categories, 'product_cat', $id ) ) {
204
+ return true;
205
+ }
206
 
207
+ return false;
208
  }
209
 
210
+ public function include_variation_category( $id ) {
211
+ $include_categories = $this->config->get_categories_to_include();
212
+ if ( $include_categories && ! has_term( $include_categories, 'product_cat', $id ) ) {
213
+ return true;
214
+ }
215
 
216
+ return false;
217
  }
218
 
219
+ public function include_variation_status() {
220
+ $variation_status = $this->config->get_post_status_to_include();
221
+ if ( in_array( $this->product->get_status(), $variation_status ) ) {
222
+ return true;
223
+ }
224
 
225
+ return false;
226
  }
227
 
228
+ // TODO String Replace
229
+ // TODO Number Format
230
+ // TODO UTM Parameter
231
  }
V5/Filter/FilterInfo.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace CTXFeed\V5\Filter;
4
+
5
+ class FilterInfo {
6
+
7
+ }
V5/Helper/CommonHelper.php CHANGED
@@ -91,4 +91,51 @@ class CommonHelper {
91
  return false;
92
  }
93
 
94
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  return false;
92
  }
93
 
94
+ /**
95
+ * @param $slug
96
+ * @param $prefix
97
+ * @param $option_id
98
+ *
99
+ * @return mixed|string
100
+ */
101
+ public static function unique_option_name( $slug, $prefix = '', $option_id = null ) {
102
+ global $wpdb;
103
+ /** @noinspection SpellCheckingInspection */
104
+ $disallowed = array( 'siteurl', 'home', 'blogname', 'blogdescription', 'users_can_register', 'admin_email' );
105
+ if ( $option_id && $option_id > 0 ) {
106
+ $checkSql = "SELECT option_name FROM $wpdb->options WHERE option_name = %s AND option_id != %d LIMIT 1";
107
+ $nameCheck = $wpdb->get_var( $wpdb->prepare( $checkSql, $prefix . $slug, $option_id ) ); // phpcs:ignore
108
+ } else {
109
+ $checkSql = "SELECT option_name FROM $wpdb->options WHERE option_name = %s LIMIT 1";
110
+ $nameCheck = $wpdb->get_var( $wpdb->prepare( $checkSql, $prefix . $slug ) ); // phpcs:ignore
111
+ }
112
+ // slug found or slug in disallowed list
113
+ if ( $nameCheck || in_array( $slug, $disallowed, true ) ) {
114
+ $suffix = 2;
115
+ do {
116
+ $altName = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
117
+ if ( $option_id && $option_id > 0 ) {
118
+ $nameCheck = $wpdb->get_var( $wpdb->prepare( $checkSql, $prefix . $altName, $option_id ) ); // phpcs:ignore
119
+ } else {
120
+ $nameCheck = $wpdb->get_var( $wpdb->prepare( $checkSql, $prefix . $altName ) ); // phpcs:ignore
121
+ }
122
+ $suffix ++;
123
+ } while ( $nameCheck );
124
+ $slug = $altName;
125
+ }
126
+
127
+ return $slug;
128
+ }
129
+
130
+ public static function get_options( $prefix ) {
131
+
132
+ global $wpdb;
133
+ /** @noinspection SpellCheckingInspection */
134
+ $sql = "SELECT option_name FROM $wpdb->options WHERE option_name LIKE %s";
135
+
136
+ // phpcs:ignore
137
+
138
+ return $wpdb->get_results( $wpdb->prepare( $sql, $prefix.'%') );
139
+ }
140
+
141
+ }
V5/Merchant/TemplateConfig.php CHANGED
@@ -1,13 +1,12 @@
1
  <?php
 
2
  namespace CTXFeed\V5\Merchant;
3
  class TemplateConfig {
4
 
5
- private static $template;
6
  private static $brand;
7
  private static $currency;
8
 
9
- public function __construct( $merchant = null, $currency = null, $brand = null ) {
10
- self::$template = ! empty( $merchant ) ? $merchant : 'default';
11
  self::$brand = ! empty( $brand ) ? $brand : self::default_brand();
12
  self::$currency = ! empty( $currency ) ? $currency : get_woocommerce_currency();
13
  }
@@ -42,7 +41,7 @@ class TemplateConfig {
42
  return apply_filters( 'woo_feed_get_default_brand_name', $brand );
43
  }
44
 
45
- public static function get() {
46
  $config = array(
47
  'default' => array(
48
  'mattributes' => array(
@@ -10374,6 +10373,11 @@ class TemplateConfig {
10374
  ),
10375
  );
10376
 
10377
- return $config[ self::$template ];
 
 
 
 
 
10378
  }
10379
- }
1
  <?php
2
+
3
  namespace CTXFeed\V5\Merchant;
4
  class TemplateConfig {
5
 
 
6
  private static $brand;
7
  private static $currency;
8
 
9
+ public function __construct( $currency = null, $brand = null ) {
 
10
  self::$brand = ! empty( $brand ) ? $brand : self::default_brand();
11
  self::$currency = ! empty( $currency ) ? $currency : get_woocommerce_currency();
12
  }
41
  return apply_filters( 'woo_feed_get_default_brand_name', $brand );
42
  }
43
 
44
+ public static function get( $merchant = 'custom' ) {
45
  $config = array(
46
  'default' => array(
47
  'mattributes' => array(
10373
  ),
10374
  );
10375
 
10376
+ if ( array_key_exists( $merchant, $config ) ) {
10377
+ return $config[ $merchant ];
10378
+ }
10379
+
10380
+ return $config['custom'];
10381
+
10382
  }
10383
+ }
V5/Merchant/TemplateInfo.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  namespace CTXFeed\V5\Merchant;
3
  class TemplateInfo {
4
  public static function get( $template = 'custom' ) {
@@ -12,7 +13,7 @@ class TemplateInfo {
12
  'google' => array(
13
  'link' => 'https://support.google.com/merchants/answer/7052112?hl=en',
14
  'video' => 'https://youtu.be/PTUYgF7DwEo',
15
- 'feed_file_type' => array( 'XML', 'CSV','TSV', 'TXT' ),
16
  'doc' => array(
17
  esc_html__( 'How to make google merchant feed?', 'woo-feed' ) => 'https://youtu.be/PTUYgF7DwEo',
18
  esc_html__( 'How to configure shipping info?', 'woo-feed' ) => 'https://webappick.com/docs/woo-feed/merchants/how-to-configure-google-merchant-shipping-attribute/',
@@ -51,7 +52,7 @@ class TemplateInfo {
51
  ), // Facebook.
52
  'pinterest' => array(
53
  'link' => 'https://help.pinterest.com/en/business/article/before-you-get-started-with-catalogs',
54
- 'feed_file_type' => array( 'XML', 'CSV', 'TSV','TXT' ),
55
  'doc' => array(
56
  esc_html__( 'How to configure google product categories?', 'woo-feed' ) => 'https://webappick.com/docs/woo-feed/feed-configuration/how-to-map-store-category-with-merchant-category/',
57
  ),
@@ -432,6 +433,10 @@ class TemplateInfo {
432
  ),
433
  );
434
 
435
- return $info[ $template ];
 
 
 
 
436
  }
437
- }
1
  <?php
2
+
3
  namespace CTXFeed\V5\Merchant;
4
  class TemplateInfo {
5
  public static function get( $template = 'custom' ) {
13
  'google' => array(
14
  'link' => 'https://support.google.com/merchants/answer/7052112?hl=en',
15
  'video' => 'https://youtu.be/PTUYgF7DwEo',
16
+ 'feed_file_type' => array( 'XML', 'CSV', 'TSV', 'TXT' ),
17
  'doc' => array(
18
  esc_html__( 'How to make google merchant feed?', 'woo-feed' ) => 'https://youtu.be/PTUYgF7DwEo',
19
  esc_html__( 'How to configure shipping info?', 'woo-feed' ) => 'https://webappick.com/docs/woo-feed/merchants/how-to-configure-google-merchant-shipping-attribute/',
52
  ), // Facebook.
53
  'pinterest' => array(
54
  'link' => 'https://help.pinterest.com/en/business/article/before-you-get-started-with-catalogs',
55
+ 'feed_file_type' => array( 'XML', 'CSV', 'TSV', 'TXT' ),
56
  'doc' => array(
57
  esc_html__( 'How to configure google product categories?', 'woo-feed' ) => 'https://webappick.com/docs/woo-feed/feed-configuration/how-to-map-store-category-with-merchant-category/',
58
  ),
433
  ),
434
  );
435
 
436
+ if ( array_key_exists( $template, $info ) ) {
437
+ return $info[ $template ];
438
+ }
439
+
440
+ return $info['custom'];
441
  }
442
+ }
V5/Output/AttributeMapping.php ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace CTXFeed\V5\Output;
4
+
5
+
6
+ use CTXFeed\V5\Helper\CommonHelper;
7
+ use CTXFeed\V5\Product\AttributeValueByType;
8
+ use CTXFeed\V5\Utility\Config;
9
+ use WC_Product;
10
+
11
+ /**
12
+ * Class AttributeMapping
13
+ *
14
+ * @package CTXFeed
15
+ * @subpackage CTXFeed\V5\Output
16
+ * @author Ohidul Islam <wahid0003@gmail.com>
17
+ * @link https://webappick.com
18
+ * @license https://opensource.org/licenses/gpl-license.php GNU Public License
19
+ * @category Output
20
+ */
21
+ class AttributeMapping {
22
+
23
+ /**
24
+ * @param $attribute
25
+ * @param $merchant_attribute
26
+ * @param WC_Product $product
27
+ * @param Config $config
28
+ *
29
+ * @return string
30
+ */
31
+ public function getMappingValue( $attribute, $merchant_attribute, $product, $config ) {
32
+ $getAttributeValueByType = new AttributeValueByType( $attribute, $product, $config, $merchant_attribute );
33
+ $attributes = get_option( $attribute );
34
+ $glue = ! empty( $attributes['glue'] ) ? $attributes['glue'] : " ";
35
+ $output = '';
36
+
37
+ if ( isset( $attributes['mapping'] ) ) {
38
+ foreach ( $attributes['mapping'] as $map ) {
39
+ $get_value = $getAttributeValueByType->get_value( $map );
40
+ if ( ! empty( $get_value ) ) {
41
+ $output .= $glue . $get_value;
42
+ }
43
+ }
44
+ }
45
+
46
+ //trim extra glue
47
+ $output = trim( $output, $glue );
48
+
49
+ // remove extra whitespace
50
+ $output = preg_replace( '!\s\s+!', ' ', $output );
51
+
52
+ return apply_filters( 'woo_feed_filter_attribute_mapping', $output, $attribute, $product, $config );
53
+ }
54
+
55
+ /**
56
+ * Get Attribute Mapping.
57
+ *
58
+ * @param $attribute
59
+ *
60
+ * @return false|mixed|null
61
+ */
62
+ public function getMapping( $attribute ) {
63
+ if ( strpos( $attribute, AttributeValueByType::PRODUCT_ATTRIBUTE_MAPPING_PREFIX ) === false ) {
64
+ $attribute = AttributeValueByType::PRODUCT_ATTRIBUTE_MAPPING_PREFIX . $attribute;
65
+ }
66
+
67
+ return get_option( $attribute );
68
+ }
69
+
70
+
71
+ public function getMappings() {
72
+
73
+ $mappings = CommonHelper::get_options( AttributeValueByType::PRODUCT_ATTRIBUTE_MAPPING_PREFIX );
74
+ $data = [];
75
+ if ( ! empty( $mappings ) ) {
76
+ foreach ( $mappings as $mapping ) {
77
+ $data[ $mapping->option_name ] = get_option( $mapping->option_name );
78
+ }
79
+
80
+ return $data;
81
+ }
82
+
83
+ return false;
84
+ }
85
+
86
+ /**
87
+ * Save Attribute mapping.
88
+ *
89
+ * @param array $mappingConfig
90
+ *
91
+ * @return bool
92
+ */
93
+ public function saveMapping( $mappingConfig ) {
94
+
95
+ $data = array();
96
+
97
+ $data['name'] = '';
98
+ if ( isset( $mappingConfig['mapping_name'] ) ) {
99
+ $data['name'] = sanitize_text_field( $mappingConfig['mapping_name'] );
100
+ }
101
+
102
+ // Set Multiple Attributes or texts.
103
+ if ( isset( $mappingConfig['value'] ) ) {
104
+ foreach ( $mappingConfig['value'] as $item ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
105
+ if ( ' ' === $item ) {
106
+ $data['mapping'][] = $item;
107
+ } elseif ( '' !== $item ) {
108
+ $data['mapping'][] = sanitize_text_field( $item );
109
+ }
110
+ }
111
+ $data['mapping'] = array_filter( $data['mapping'] );
112
+ }
113
+
114
+ // Set Glue.
115
+ if ( isset( $mappingConfig['mapping_glue'] ) ) {
116
+ $data['glue'] = $mappingConfig['mapping_glue'];
117
+ } else {
118
+ $data['glue'] = '';
119
+ }
120
+
121
+ // Set Option Name.
122
+ if ( isset( $mappingConfig['option_name'] ) &&
123
+ ! empty( $mappingConfig['option_name'] ) &&
124
+ false !== strpos( $mappingConfig['option_name'], AttributeValueByType::PRODUCT_ATTRIBUTE_MAPPING_PREFIX ) // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
125
+ ) {
126
+ $option = sanitize_text_field( $mappingConfig['option_name'] );
127
+ } else {
128
+ // generate unique one.
129
+ $option = CommonHelper::unique_option_name( AttributeValueByType::PRODUCT_ATTRIBUTE_MAPPING_PREFIX . $data['name'] );
130
+ }
131
+
132
+ return update_option( $option, $data );
133
+ }
134
+
135
+ /**
136
+ * Delete Attribute Mapping.
137
+ *
138
+ * @param $attribute
139
+ *
140
+ * @return bool
141
+ */
142
+ public function deleteMapping( $attribute ) {
143
+ if ( strpos( $attribute, AttributeValueByType::PRODUCT_ATTRIBUTE_MAPPING_PREFIX ) === false ) {
144
+ $attribute = AttributeValueByType::PRODUCT_ATTRIBUTE_MAPPING_PREFIX . $attribute;
145
+ }
146
+
147
+ return delete_option( $attribute );
148
+ }
149
+
150
+
151
+ }
V5/Output/CategoryMapping.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace CTXFeed\V5\Output;
4
+
5
+
6
+ /**
7
+ * Class CategoryMapping
8
+ *
9
+ * @package CTXFeed
10
+ * @subpackage CTXFeed\V5\Output
11
+ * @author Ohidul Islam <wahid0003@gmail.com>
12
+ * @link https://webappick.com
13
+ * @license https://opensource.org/licenses/gpl-license.php GNU Public License
14
+ * @category MyCategory
15
+ */
16
+ class CategoryMapping {
17
+
18
+ }
V5/Output/DynamicAttributes.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace CTXFeed\V5\Output;
4
+
5
+
6
+ /**
7
+ * Class DynamicAttributes
8
+ *
9
+ * @package CTXFeed
10
+ * @subpackage CTXFeed\V5\Output
11
+ * @author Ohidul Islam <wahid0003@gmail.com>
12
+ * @link https://webappick.com
13
+ * @license https://opensource.org/licenses/gpl-license.php GNU Public License
14
+ * @category MyCategory
15
+ */
16
+ class DynamicAttributes {
17
+
18
+ }
V5/Output/OutputCommands.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace CTXFeed\V5\Output;
4
+
5
+
6
+ /**
7
+ * Class OutputCommands
8
+ *
9
+ * @package CTXFeed
10
+ * @subpackage CTXFeed\V5\Output
11
+ * @author Ohidul Islam <wahid0003@gmail.com>
12
+ * @link https://webappick.com
13
+ * @license https://opensource.org/licenses/gpl-license.php GNU Public License
14
+ * @category MyCategory
15
+ */
16
+ class OutputCommands {
17
+
18
+ }
V5/Product/AttributeValueByType.php CHANGED
@@ -12,7 +12,7 @@ use WC_Product_Variable;
12
  use WC_Product_Variation;
13
 
14
  class AttributeValueByType {
15
-
16
  /**
17
  * Advance Custom Field (ACF) Prefix
18
  *
@@ -81,13 +81,13 @@ class AttributeValueByType {
81
  * @var string
82
  */
83
  const PRODUCT_CUSTOM_IDENTIFIER = 'woo_feed_';
84
-
85
  private $attribute;
86
  private $merchant_attribute;
87
  private $product;
88
  private $productInfo;
89
  private $config;
90
-
91
  /**
92
  * @param $attribute
93
  * @param $merchant_attribute
@@ -100,11 +100,11 @@ class AttributeValueByType {
100
  $this->product = $product;
101
  $this->config = $config;
102
  $this->productInfo = new ProductInfo( $this->product, $this->config );
103
-
104
  // Load Merchant Template Override File.
105
- OverrideFactory::init( $config );
106
  }
107
-
108
  /**
109
  * Get product attribute value by attribute type.
110
  *
@@ -114,13 +114,13 @@ class AttributeValueByType {
114
  if ( ! empty( $attr ) ) {
115
  $this->attribute = $attr;
116
  }
117
-
118
  if ( method_exists( $this->productInfo, $this->attribute ) ) {
119
  $attribute = $this->attribute;
120
  $output = $this->productInfo->$attribute();
121
  } elseif ( false !== strpos( $this->attribute, self::PRODUCT_EXTRA_ATTRIBUTE_PREFIX ) ) {
122
  $attribute = str_replace( self::PRODUCT_EXTRA_ATTRIBUTE_PREFIX, '', $this->attribute );
123
-
124
  /**
125
  * Filter output for extra attribute, which can be added via 3rd party plugins.
126
  *
@@ -175,15 +175,15 @@ class AttributeValueByType {
175
  // return the attribute so multiple attribute can be used with separator to make custom attribute.
176
  $output = $this->attribute;
177
  }
178
-
179
  // Json encode if value is an array
180
  if ( is_array( $output ) ) {
181
  $output = wp_json_encode( $output );
182
  }
183
-
184
  return $this->apply_filters_to_attribute_value( $output, $this->merchant_attribute );
185
  }
186
-
187
  /**
188
  * Apply Filter to Attribute value
189
  *
@@ -205,7 +205,7 @@ class AttributeValueByType {
205
  *
206
  */
207
  $output = apply_filters( 'woo_feed_get_attribute', $output, $this->product, $this->config, $product_attribute, $merchant_attribute );
208
-
209
  /**
210
  * Filter attribute value before return based on product attribute name
211
  *
@@ -216,9 +216,9 @@ class AttributeValueByType {
216
  * @since 3.3.5
217
  *
218
  */
219
-
220
  $output = apply_filters( "woo_feed_get_{$product_attribute}_attribute", $output, $this->product, $this->config, $product_attribute, $merchant_attribute );
221
-
222
  /**
223
  * Filter attribute value before return based on merchant name
224
  *
@@ -229,9 +229,9 @@ class AttributeValueByType {
229
  * @since 3.3.5
230
  *
231
  */
232
-
233
  $output = apply_filters( "woo_feed_get_{$this->config->provider}_attribute", $output, $this->product, $this->config, $product_attribute, $merchant_attribute );
234
-
235
  /**
236
  * Filter attribute value before return based on merchant and merchant attribute name
237
  *
@@ -243,10 +243,10 @@ class AttributeValueByType {
243
  *
244
  */
245
  $merchant_attribute = str_replace( [ ' ', 'g:' ], '', $merchant_attribute );
246
-
247
  //$output = "woo_feed_get_{$this->config->provider}_{$merchant_attribute}_attribute";
248
  return apply_filters( "woo_feed_get_{$this->config->provider}_{$merchant_attribute}_attribute", $output, $this->product, $this->config, $product_attribute, $merchant_attribute );
249
  }
250
-
251
-
252
- }
12
  use WC_Product_Variation;
13
 
14
  class AttributeValueByType {
15
+
16
  /**
17
  * Advance Custom Field (ACF) Prefix
18
  *
81
  * @var string
82
  */
83
  const PRODUCT_CUSTOM_IDENTIFIER = 'woo_feed_';
84
+
85
  private $attribute;
86
  private $merchant_attribute;
87
  private $product;
88
  private $productInfo;
89
  private $config;
90
+
91
  /**
92
  * @param $attribute
93
  * @param $merchant_attribute
100
  $this->product = $product;
101
  $this->config = $config;
102
  $this->productInfo = new ProductInfo( $this->product, $this->config );
103
+
104
  // Load Merchant Template Override File.
105
+ // OverrideFactory::init( $config );
106
  }
107
+
108
  /**
109
  * Get product attribute value by attribute type.
110
  *
114
  if ( ! empty( $attr ) ) {
115
  $this->attribute = $attr;
116
  }
117
+
118
  if ( method_exists( $this->productInfo, $this->attribute ) ) {
119
  $attribute = $this->attribute;
120
  $output = $this->productInfo->$attribute();
121
  } elseif ( false !== strpos( $this->attribute, self::PRODUCT_EXTRA_ATTRIBUTE_PREFIX ) ) {
122
  $attribute = str_replace( self::PRODUCT_EXTRA_ATTRIBUTE_PREFIX, '', $this->attribute );
123
+
124
  /**
125
  * Filter output for extra attribute, which can be added via 3rd party plugins.
126
  *
175
  // return the attribute so multiple attribute can be used with separator to make custom attribute.
176
  $output = $this->attribute;
177
  }
178
+
179
  // Json encode if value is an array
180
  if ( is_array( $output ) ) {
181
  $output = wp_json_encode( $output );
182
  }
183
+
184
  return $this->apply_filters_to_attribute_value( $output, $this->merchant_attribute );
185
  }
186
+
187
  /**
188
  * Apply Filter to Attribute value
189
  *
205
  *
206
  */
207
  $output = apply_filters( 'woo_feed_get_attribute', $output, $this->product, $this->config, $product_attribute, $merchant_attribute );
208
+
209
  /**
210
  * Filter attribute value before return based on product attribute name
211
  *
216
  * @since 3.3.5
217
  *
218
  */
219
+
220
  $output = apply_filters( "woo_feed_get_{$product_attribute}_attribute", $output, $this->product, $this->config, $product_attribute, $merchant_attribute );
221
+
222
  /**
223
  * Filter attribute value before return based on merchant name
224
  *
229
  * @since 3.3.5
230
  *
231
  */
232
+
233
  $output = apply_filters( "woo_feed_get_{$this->config->provider}_attribute", $output, $this->product, $this->config, $product_attribute, $merchant_attribute );
234
+
235
  /**
236
  * Filter attribute value before return based on merchant and merchant attribute name
237
  *
243
  *
244
  */
245
  $merchant_attribute = str_replace( [ ' ', 'g:' ], '', $merchant_attribute );
246
+
247
  //$output = "woo_feed_get_{$this->config->provider}_{$merchant_attribute}_attribute";
248
  return apply_filters( "woo_feed_get_{$this->config->provider}_{$merchant_attribute}_attribute", $output, $this->product, $this->config, $product_attribute, $merchant_attribute );
249
  }
250
+
251
+
252
+ }
V5/Product/ProductInfo.php CHANGED
@@ -83,7 +83,7 @@ class ProductInfo {
83
  $title .= " - " . $variation_attributes;
84
  }
85
  }
86
-
87
  return apply_filters( 'woo_feed_filter_product_title', $title, $this->product, $this->config );
88
  }
89
 
83
  $title .= " - " . $variation_attributes;
84
  }
85
  }
86
+ return $title;
87
  return apply_filters( 'woo_feed_filter_product_title', $title, $this->product, $this->config );
88
  }
89
 
V5/Utility/Config.php CHANGED
@@ -460,7 +460,6 @@ class Config
460
  */
461
  public function get_products_to_exclude()
462
  {
463
-
464
  if (isset($this->config['filter_mode'])) {
465
  $mode = $this->config['filter_mode'];
466
  if ('exclude' === $mode['product_ids'] && !empty($this->config['product_ids'])) {
460
  */
461
  public function get_products_to_exclude()
462
  {
 
463
  if (isset($this->config['filter_mode'])) {
464
  $mode = $this->config['filter_mode'];
465
  if ('exclude' === $mode['product_ids'] && !empty($this->config['product_ids'])) {
admin/class-woo-feed-admin.php CHANGED
@@ -34,7 +34,7 @@ class Woo_Feed_Admin {
34
  * Initialize the class and set its properties.
35
  *
36
  * @param string $woo_feed The name of this plugin.
37
- * @param string $version The version of this plugin.
38
  *
39
  * @since 1.0.0
40
  *
@@ -66,9 +66,9 @@ class Woo_Feed_Admin {
66
  * class.
67
  */
68
  $mainDeps = array();
69
- $ext = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '.css' : '.min.css';
70
  if ( false !== strpos( $hook, 'webappick' ) && false !== strpos( $hook, 'feed' ) ) {
71
- wp_enqueue_style('thickbox');
72
  wp_register_style( 'selectize', plugin_dir_url( __FILE__ ) . 'css/selectize' . $ext, array(), $this->version );
73
  wp_enqueue_style( 'fancy-select', plugin_dir_url( __FILE__ ) . 'css/fancy-select' . $ext, array(), $this->version );
74
  wp_register_style( 'slick', plugin_dir_url( __FILE__ ) . 'css/slick' . $ext, array(), $this->version );
@@ -104,33 +104,33 @@ class Woo_Feed_Admin {
104
  * class.
105
  */
106
 
107
- //dequeue unnecessary scripts from loading
108
- $js_dequeue_handles = woo_feed_get_js_dequeue_handles_list();
109
 
110
- $page = apply_filters('CTXFEED_filter_securing_input', "GET", @$_GET['page'], "text");
 
 
111
 
112
- if ( isset($page) ) {
113
- $woo_feed_plugin_pages = woo_feed_get_plugin_pages_slugs();
114
-
115
- if ( in_array($page, $woo_feed_plugin_pages) ) {
116
- if ( isset($js_dequeue_handles) && ! empty($js_dequeue_handles) ) {
117
- foreach ( $js_dequeue_handles as $script_handle ) {
118
- wp_dequeue_script($script_handle);
119
- }
120
- }
121
- }
122
- }
123
 
124
  $ext = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '.js' : '.min.js';
125
  if ( false !== strpos( $hook, 'webappick' ) && false !== strpos( $hook, 'feed' ) ) {
126
- wp_enqueue_script('thickbox');
127
  if ( is_network_admin() ) {
128
  add_action( 'admin_head', '_thickbox_path_admin_subfolder' );
129
  }
130
  wp_register_script( 'jquery-selectize', plugin_dir_url( __FILE__ ) . 'js/selectize.min.js', array( 'jquery' ), $this->version, false );
131
  wp_register_script( 'fancy-select', plugin_dir_url( __FILE__ ) . 'js/fancy-select' . $ext, array( 'jquery' ), $this->version, false );
132
  wp_register_script( 'jquery-validate', plugin_dir_url( __FILE__ ) . 'js/jquery.validate.min.js', array( 'jquery' ), $this->version, false );
133
- wp_register_script( 'jquery-validate-additional-methods', plugin_dir_url( __FILE__ ) . 'js/additional-methods.min.js', array( 'jquery', 'jquery-validate' ), $this->version, false );
 
 
 
134
  wp_register_script( 'jquery-sortable', plugin_dir_url( __FILE__ ) . 'js/jquery-sortable' . $ext, array( 'jquery' ), $this->version, false );
135
 
136
  $feedScriptDependency = [
@@ -152,32 +152,34 @@ class Woo_Feed_Admin {
152
 
153
  wp_register_script( $this->woo_feed, plugin_dir_url( __FILE__ ) . 'js/woo-feed-admin' . $ext, $feedScriptDependency, $this->version, false );
154
 
155
- //get feed options with which feed is previously generated
156
- $feed_rules = "";
157
 
158
- $feed = apply_filters('CTXFEED_filter_securing_input', "GET", @$_GET['feed'], "text");
159
- if ( $feed ) {
160
- $filename = str_replace('wf_feed_', '', wp_unslash($feed));
161
- $feed_options = maybe_unserialize(get_option('wf_feed_' . $filename));
162
- if ( isset($feed_options['feedrules']) ) {
163
- $feed_rules = $feed_options['feedrules'];
164
- }
165
- }
166
 
167
- $page = apply_filters('CTXFEED_filter_securing_input', "GET", @$_GET['page'], "text");
168
- $action = apply_filters('CTXFEED_filter_securing_input', "GET", @$_GET['action'], "text");
169
  $js_opts = array(
170
  'wpf_ajax_url' => admin_url( 'admin-ajax.php' ),
171
  'wpf_debug' => woo_feed_is_debugging_enabled(),
172
- "feed_rules" => $feed_rules,
173
  'pages' => [
174
  'list' => [
175
  'feed' => esc_url( admin_url( 'admin.php?page=webappick-manage-feeds' ) ),
176
  ],
177
  ],
178
  'nonce' => wp_create_nonce( 'wpf_feed_nonce' ),
179
- 'is_feed_edit' => $page && $action && 'webappick-manage-feeds' === $page && 'edit-feed' === $page, // phpcs:ignore WordPress.Security.NonceVerification.Recommended
180
- 'is_feed_add' => $page && 'webappick-new-feed' === $page, // phpcs:ignore WordPress.Security.NonceVerification.Recommended
 
 
181
  'na' => esc_html__( 'N/A', 'woo-feed' ),
182
  'regenerate' => esc_html__( 'Generating...', 'woo-feed' ),
183
  'learn_more' => esc_html__( 'Learn More..', 'woo-feed' ),
@@ -205,26 +207,26 @@ class Woo_Feed_Admin {
205
  'nonce' => wp_create_nonce( 'wpf_feed_nonce' ),
206
  'error' => esc_html__( 'There was an error processing ajax request.', 'woo-feed' ),
207
  ],
208
- 'woocommerce' => [
209
- 'currency' => get_option( 'woocommerce_currency' ),
210
- 'weight' => get_option('woocommerce_weight_unit'),
211
- 'dimension' => get_option('woocommerce_dimension_unit'),
212
- ],
213
  );
214
 
215
- $feed_created = apply_filters('CTXFEED_filter_securing_input', "GET", @$_GET['feed_created'], "text");
216
- $feed_updated = apply_filters('CTXFEED_filter_securing_input', "GET", @$_GET['feed_updated'], "text");
217
- $feed_imported = apply_filters('CTXFEED_filter_securing_input', "GET", @$_GET['feed_imported'], "text");
218
- $feed_regenerate = apply_filters('CTXFEED_filter_securing_input', "GET", @$_GET['feed_regenerate'], "text");
219
- $feed_name = apply_filters('CTXFEED_filter_securing_input', "GET", @$_GET['feed_name'], "file_name");
220
 
221
  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
222
  if ( ( $feed_created || $feed_updated || $feed_imported ) && $feed_regenerate && 1 === (int) $feed_regenerate ) {
223
  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
224
- $fileName = ! empty( $feed_name ) ? wp_unslash($feed_name) : ''; // trigger feed regenerate...
225
  if ( ! empty( $fileName ) ) {
226
  // filename must be wf_config+XXX format for js to work.
227
- $js_opts['generator']['feed'] = 'wf_config' . woo_feed_extract_feed_option_name( $fileName );
228
  $js_opts['generator']['regenerate'] = true;
229
  }
230
  }
@@ -233,7 +235,10 @@ class Woo_Feed_Admin {
233
 
234
  if ( 'woo-feed_page_webappick-feed-pro-vs-free' === $hook ) {
235
  wp_register_script( 'jquery-slick', plugin_dir_url( __FILE__ ) . 'js/slick' . $ext, array( 'jquery' ), $this->version, false );
236
- wp_register_script( $this->woo_feed . '-pro', plugin_dir_url( __FILE__ ) . 'js/woo-feed-admin-pro' . $ext, [ $this->woo_feed, 'jquery-slick' ], $this->version, false );
 
 
 
237
  wp_enqueue_script( $this->woo_feed . '-pro' );
238
  }
239
  }
@@ -241,7 +246,9 @@ class Woo_Feed_Admin {
241
 
242
  /**
243
  * Add Go to Pro and Documentation link
 
244
  * @param array $links
 
245
  * @return array
246
  */
247
  public function woo_feed_plugin_action_links( $links ) {
@@ -251,6 +258,7 @@ class Woo_Feed_Admin {
251
  $links[] = sprintf( '<a style="color:#ce7304; font-weight: bold;" href="%s">%s</a>', esc_url( admin_url( 'admin.php?page=webappick-feed-docs' ) ), __( 'Docs', 'woo-feed' ) );
252
  /** @noinspection HtmlUnknownTarget */
253
  $links[] = sprintf( '<a href="%s">%s</a>', esc_url( admin_url( 'admin.php?page=webappick-feed-settings' ) ), __( 'Settings', 'woo-feed' ) );
 
254
  return $links;
255
  }
256
 
@@ -275,16 +283,20 @@ class Woo_Feed_Admin {
275
  add_menu_page( __( 'CTX Feed', 'woo-feed' ), __( 'CTX Feed', 'woo-feed' ), 'manage_woocommerce', 'webappick-manage-feeds', 'woo_feed_manage_feed', 'dashicons-rss' );
276
  add_submenu_page( 'webappick-manage-feeds', __( 'Manage Feeds', 'woo-feed' ), __( 'Manage Feeds', 'woo-feed' ), 'manage_woocommerce', 'webappick-manage-feeds', 'woo_feed_manage_feed' );
277
  add_submenu_page( 'webappick-manage-feeds', __( 'Make Feed', 'woo-feed' ), __( 'Make Feed', 'woo-feed' ), 'manage_woocommerce', 'webappick-new-feed', 'woo_feed_generate_new_feed' );
278
- add_submenu_page( 'webappick-manage-feeds', __( 'Category Mapping', 'woo-feed' ), __( 'Category Mapping', 'woo-feed' ), 'manage_woocommerce', 'webappick-feed-category-mapping', 'woo_feed_category_mapping' );
279
- add_submenu_page( 'webappick-manage-feeds', __( 'WP Options', 'woo-feed' ), __( 'WP Options', 'woo-feed' ), 'manage_woocommerce', 'webappick-wp-options', 'woo_feed_wp_options' );
280
- add_submenu_page( 'webappick-manage-feeds', __( 'Settings', 'woo-feed' ), __( 'Settings', 'woo-feed' ), 'manage_woocommerce', 'webappick-feed-settings', 'woo_feed_config_feed' );
281
  add_submenu_page( 'webappick-manage-feeds', __( 'Status', 'woo-feed' ), __( 'Status', 'woo-feed' ), 'manage_woocommerce', 'webappick-wp-status', 'woo_feed_system_status' );
282
- 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' ) );
 
 
 
283
  }
284
  }
285
 
286
  /**
287
  * Redirect user to with new menu slug (if user browser any bookmarked url)
 
288
  * @return void
289
  * @since 3.1.7
290
  */
@@ -293,10 +305,10 @@ class Woo_Feed_Admin {
293
  // redirect user to new old slug => new slug
294
  $redirect_to = array(
295
  'webappick-product-feed-for-woocommerce/admin/class-woo-feed-admin.php' => 'webappick-new-feed',
296
- 'woo_feed_manage_feed' => 'webappick-manage-feeds',
297
- 'woo_feed_config_feed' => 'webappick-feed-settings',
298
- 'woo_feed_pro_vs_free' => 'webappick-feed-pro-vs-free',
299
- 'woo_feed_wp_options' => 'webappick-wp-options',
300
  );
301
  if ( 'admin.php' === $pagenow && isset( $plugin_page ) && ! empty( $plugin_page ) ) {
302
  foreach ( $redirect_to as $from => $to ) {
34
  * Initialize the class and set its properties.
35
  *
36
  * @param string $woo_feed The name of this plugin.
37
+ * @param string $version The version of this plugin.
38
  *
39
  * @since 1.0.0
40
  *
66
  * class.
67
  */
68
  $mainDeps = array();
69
+ $ext = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '.css' : '.min.css';
70
  if ( false !== strpos( $hook, 'webappick' ) && false !== strpos( $hook, 'feed' ) ) {
71
+ wp_enqueue_style( 'thickbox' );
72
  wp_register_style( 'selectize', plugin_dir_url( __FILE__ ) . 'css/selectize' . $ext, array(), $this->version );
73
  wp_enqueue_style( 'fancy-select', plugin_dir_url( __FILE__ ) . 'css/fancy-select' . $ext, array(), $this->version );
74
  wp_register_style( 'slick', plugin_dir_url( __FILE__ ) . 'css/slick' . $ext, array(), $this->version );
104
  * class.
105
  */
106
 
107
+ //dequeue unnecessary scripts from loading
108
+ $js_dequeue_handles = woo_feed_get_js_dequeue_handles_list();
109
 
110
+ if ( isset( $_GET['page'] ) ) {
111
+ $page = apply_filters( 'CTXFEED_filter_securing_input', "GET", @$_GET['page'], "text" );
112
+ $woo_feed_plugin_pages = woo_feed_get_plugin_pages_slugs();
113
 
114
+ if ( isset( $js_dequeue_handles ) && ! empty( $js_dequeue_handles ) && in_array( $page, $woo_feed_plugin_pages, true ) ) {
115
+ foreach ( $js_dequeue_handles as $script_handle ) {
116
+ wp_dequeue_script( $script_handle );
117
+ }
118
+ }
119
+ }
 
 
 
 
 
120
 
121
  $ext = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '.js' : '.min.js';
122
  if ( false !== strpos( $hook, 'webappick' ) && false !== strpos( $hook, 'feed' ) ) {
123
+ wp_enqueue_script( 'thickbox' );
124
  if ( is_network_admin() ) {
125
  add_action( 'admin_head', '_thickbox_path_admin_subfolder' );
126
  }
127
  wp_register_script( 'jquery-selectize', plugin_dir_url( __FILE__ ) . 'js/selectize.min.js', array( 'jquery' ), $this->version, false );
128
  wp_register_script( 'fancy-select', plugin_dir_url( __FILE__ ) . 'js/fancy-select' . $ext, array( 'jquery' ), $this->version, false );
129
  wp_register_script( 'jquery-validate', plugin_dir_url( __FILE__ ) . 'js/jquery.validate.min.js', array( 'jquery' ), $this->version, false );
130
+ wp_register_script( 'jquery-validate-additional-methods', plugin_dir_url( __FILE__ ) . 'js/additional-methods.min.js', array(
131
+ 'jquery',
132
+ 'jquery-validate'
133
+ ), $this->version, false );
134
  wp_register_script( 'jquery-sortable', plugin_dir_url( __FILE__ ) . 'js/jquery-sortable' . $ext, array( 'jquery' ), $this->version, false );
135
 
136
  $feedScriptDependency = [
152
 
153
  wp_register_script( $this->woo_feed, plugin_dir_url( __FILE__ ) . 'js/woo-feed-admin' . $ext, $feedScriptDependency, $this->version, false );
154
 
155
+ //get feed options with which feed is previously generated
156
+ $feed_rules = "";
157
 
158
+ if ( isset( $_GET['feed'] ) ) {
159
+ $feed = apply_filters( 'CTXFEED_filter_securing_input', "GET", @$_GET['feed'], "text" );
160
+ $filename = str_replace( 'wf_feed_', '', wp_unslash( $feed ) );
161
+ $feed_options = maybe_unserialize( get_option( 'wf_feed_' . $filename ) );
162
+ if ( isset( $feed_options['feedrules'] ) ) {
163
+ $feed_rules = $feed_options['feedrules'];
164
+ }
165
+ }
166
 
167
+ $page = isset( $_GET['page'] ) ? apply_filters( 'CTXFEED_filter_securing_input', "GET", @$_GET['page'], "text" ) : false;
168
+ $action = isset( $_GET['action'] ) && apply_filters( 'CTXFEED_filter_securing_input', "GET", @$_GET['action'], "text" );
169
  $js_opts = array(
170
  'wpf_ajax_url' => admin_url( 'admin-ajax.php' ),
171
  'wpf_debug' => woo_feed_is_debugging_enabled(),
172
+ "feed_rules" => $feed_rules,
173
  'pages' => [
174
  'list' => [
175
  'feed' => esc_url( admin_url( 'admin.php?page=webappick-manage-feeds' ) ),
176
  ],
177
  ],
178
  'nonce' => wp_create_nonce( 'wpf_feed_nonce' ),
179
+ 'is_feed_edit' => $action && 'webappick-manage-feeds' === $page && 'edit-feed' === $page,
180
+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended
181
+ 'is_feed_add' => 'webappick-new-feed' === $page,
182
+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended
183
  'na' => esc_html__( 'N/A', 'woo-feed' ),
184
  'regenerate' => esc_html__( 'Generating...', 'woo-feed' ),
185
  'learn_more' => esc_html__( 'Learn More..', 'woo-feed' ),
207
  'nonce' => wp_create_nonce( 'wpf_feed_nonce' ),
208
  'error' => esc_html__( 'There was an error processing ajax request.', 'woo-feed' ),
209
  ],
210
+ 'woocommerce' => [
211
+ 'currency' => get_option( 'woocommerce_currency' ),
212
+ 'weight' => get_option( 'woocommerce_weight_unit' ),
213
+ 'dimension' => get_option( 'woocommerce_dimension_unit' ),
214
+ ],
215
  );
216
 
217
+ $feed_created = apply_filters( 'CTXFEED_filter_securing_input', "GET", @$_GET['feed_created'], "text" );
218
+ $feed_updated = apply_filters( 'CTXFEED_filter_securing_input', "GET", @$_GET['feed_updated'], "text" );
219
+ $feed_imported = apply_filters( 'CTXFEED_filter_securing_input', "GET", @$_GET['feed_imported'], "text" );
220
+ $feed_regenerate = apply_filters( 'CTXFEED_filter_securing_input', "GET", @$_GET['feed_regenerate'], "text" );
221
+ $feed_name = apply_filters( 'CTXFEED_filter_securing_input', "GET", @$_GET['feed_name'], "file_name" );
222
 
223
  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
224
  if ( ( $feed_created || $feed_updated || $feed_imported ) && $feed_regenerate && 1 === (int) $feed_regenerate ) {
225
  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
226
+ $fileName = ! empty( $feed_name ) ? wp_unslash( $feed_name ) : ''; // trigger feed regenerate...
227
  if ( ! empty( $fileName ) ) {
228
  // filename must be wf_config+XXX format for js to work.
229
+ $js_opts['generator']['feed'] = 'wf_config' . woo_feed_extract_feed_option_name( $fileName );
230
  $js_opts['generator']['regenerate'] = true;
231
  }
232
  }
235
 
236
  if ( 'woo-feed_page_webappick-feed-pro-vs-free' === $hook ) {
237
  wp_register_script( 'jquery-slick', plugin_dir_url( __FILE__ ) . 'js/slick' . $ext, array( 'jquery' ), $this->version, false );
238
+ wp_register_script( $this->woo_feed . '-pro', plugin_dir_url( __FILE__ ) . 'js/woo-feed-admin-pro' . $ext, [
239
+ $this->woo_feed,
240
+ 'jquery-slick'
241
+ ], $this->version, false );
242
  wp_enqueue_script( $this->woo_feed . '-pro' );
243
  }
244
  }
246
 
247
  /**
248
  * Add Go to Pro and Documentation link
249
+ *
250
  * @param array $links
251
+ *
252
  * @return array
253
  */
254
  public function woo_feed_plugin_action_links( $links ) {
258
  $links[] = sprintf( '<a style="color:#ce7304; font-weight: bold;" href="%s">%s</a>', esc_url( admin_url( 'admin.php?page=webappick-feed-docs' ) ), __( 'Docs', 'woo-feed' ) );
259
  /** @noinspection HtmlUnknownTarget */
260
  $links[] = sprintf( '<a href="%s">%s</a>', esc_url( admin_url( 'admin.php?page=webappick-feed-settings' ) ), __( 'Settings', 'woo-feed' ) );
261
+
262
  return $links;
263
  }
264
 
283
  add_menu_page( __( 'CTX Feed', 'woo-feed' ), __( 'CTX Feed', 'woo-feed' ), 'manage_woocommerce', 'webappick-manage-feeds', 'woo_feed_manage_feed', 'dashicons-rss' );
284
  add_submenu_page( 'webappick-manage-feeds', __( 'Manage Feeds', 'woo-feed' ), __( 'Manage Feeds', 'woo-feed' ), 'manage_woocommerce', 'webappick-manage-feeds', 'woo_feed_manage_feed' );
285
  add_submenu_page( 'webappick-manage-feeds', __( 'Make Feed', 'woo-feed' ), __( 'Make Feed', 'woo-feed' ), 'manage_woocommerce', 'webappick-new-feed', 'woo_feed_generate_new_feed' );
286
+ add_submenu_page( 'webappick-manage-feeds', __( 'Category Mapping', 'woo-feed' ), __( 'Category Mapping', 'woo-feed' ), 'manage_woocommerce', 'webappick-feed-category-mapping', 'woo_feed_category_mapping' );
287
+ add_submenu_page( 'webappick-manage-feeds', __( 'WP Options', 'woo-feed' ), __( 'WP Options', 'woo-feed' ), 'manage_woocommerce', 'webappick-wp-options', 'woo_feed_wp_options' );
288
+ add_submenu_page( 'webappick-manage-feeds', __( 'Settings', 'woo-feed' ), __( 'Settings', 'woo-feed' ), 'manage_woocommerce', 'webappick-feed-settings', 'woo_feed_config_feed' );
289
  add_submenu_page( 'webappick-manage-feeds', __( 'Status', 'woo-feed' ), __( 'Status', 'woo-feed' ), 'manage_woocommerce', 'webappick-wp-status', 'woo_feed_system_status' );
290
+ add_submenu_page( 'webappick-manage-feeds', __( 'Documentation', 'woo-feed' ), '<span class="woo-feed-docs">' . __( 'Docs', 'woo-feed' ) . '</span>', 'manage_woocommerce', 'webappick-feed-docs', array(
291
+ WooFeedDocs::getInstance(),
292
+ 'woo_feed_docs'
293
+ ) );
294
  }
295
  }
296
 
297
  /**
298
  * Redirect user to with new menu slug (if user browser any bookmarked url)
299
+ *
300
  * @return void
301
  * @since 3.1.7
302
  */
305
  // redirect user to new old slug => new slug
306
  $redirect_to = array(
307
  'webappick-product-feed-for-woocommerce/admin/class-woo-feed-admin.php' => 'webappick-new-feed',
308
+ 'woo_feed_manage_feed' => 'webappick-manage-feeds',
309
+ 'woo_feed_config_feed' => 'webappick-feed-settings',
310
+ 'woo_feed_pro_vs_free' => 'webappick-feed-pro-vs-free',
311
+ 'woo_feed_wp_options' => 'webappick-wp-options',
312
  );
313
  if ( 'admin.php' === $pagenow && isset( $plugin_page ) && ! empty( $plugin_page ) ) {
314
  foreach ( $redirect_to as $from => $to ) {
includes/class-woo-feed.php CHANGED
@@ -29,7 +29,7 @@
29
  * @author Wahid <wahid0003@gmail.com.com>
30
  */
31
  class Woo_Feed {
32
-
33
  /**
34
  * The loader that's responsible for maintaining and registering all hooks that power
35
  * the plugin.
@@ -39,7 +39,7 @@ class Woo_Feed {
39
  * @var Woo_Feed_Loader $loader Maintains and registers all hooks for the plugin.
40
  */
41
  protected $loader;
42
-
43
  /**
44
  * The unique identifier of this plugin.
45
  *
@@ -48,7 +48,7 @@ class Woo_Feed {
48
  * @var string $woo_feed The string used to uniquely identify this plugin.
49
  */
50
  protected $woo_feed;
51
-
52
  /**
53
  * The current version of the plugin.
54
  *
@@ -57,7 +57,7 @@ class Woo_Feed {
57
  * @var string $version The current version of the plugin.
58
  */
59
  protected $version;
60
-
61
  /**
62
  * Define the core functionality of the plugin.
63
  *
@@ -71,8 +71,8 @@ class Woo_Feed {
71
  $this->woo_feed = 'woo-feed';
72
  $this->version = WOO_FEED_FREE_VERSION;
73
  }
74
-
75
-
76
  /**
77
  * Load the required dependencies for this plugin.
78
  *
@@ -90,8 +90,8 @@ class Woo_Feed {
90
  * @access private
91
  */
92
  private function load_dependencies() {
93
-
94
-
95
  /**
96
  * Load Error Logger File Handler
97
  */
@@ -105,13 +105,13 @@ class Woo_Feed {
105
  * core plugin.
106
  */
107
  require_once WOO_FEED_FREE_PATH . 'includes/class-woo-feed-loader.php';
108
-
109
  /**
110
  * The class responsible for defining internationalization functionality
111
  * of the plugin.
112
  */
113
  require_once WOO_FEED_FREE_PATH . 'includes/class-woo-feed-i18n.php';
114
-
115
  /**
116
  * The class responsible for getting all product information
117
  * of the plugin.
@@ -119,17 +119,17 @@ class Woo_Feed {
119
  require_once WOO_FEED_FREE_PATH . 'includes/classes/class-woo-feed-products.php';
120
  require_once WOO_FEED_FREE_PATH . 'includes/classes/class-woo-feed-products-v3.php';
121
  require_once WOO_FEED_FREE_PATH . 'includes/classes/class-woo-feed-merchant.php';
122
-
123
  /**
124
  * The class responsible for processing feed
125
  */
126
  require_once WOO_FEED_FREE_PATH . 'includes/classes/class-woo-feed-engine.php';
127
-
128
  /**
129
  * The class contain all merchants attribute dropdown
130
  */
131
  require_once WOO_FEED_FREE_PATH . 'includes/classes/class-woo-feed-dropdown.php';
132
-
133
  /**
134
  * The class contain merchant attributes
135
  */
@@ -138,7 +138,7 @@ class Woo_Feed {
138
  * The class contain product attributes
139
  */
140
  require_once WOO_FEED_FREE_PATH . 'includes/classes/class-woo-feed-product-attributes.php';
141
-
142
  /**
143
  * The class responsible for generating feed
144
  */
@@ -153,7 +153,7 @@ class Woo_Feed {
153
  * The class is a shipping calculation library
154
  */
155
  require_once WOO_FEED_FREE_PATH . 'includes/class-woo-feed-status.php';
156
-
157
  /**
158
  * The class responsible for save feed
159
  */
@@ -175,7 +175,7 @@ class Woo_Feed {
175
  * The class responsible for defining all actions that occur in the admin area.
176
  */
177
  require_once WOO_FEED_FREE_PATH . 'admin/class-woo-feed-admin.php';
178
-
179
  /**
180
  * The class responsible for making list table
181
  */
@@ -195,12 +195,13 @@ class Woo_Feed {
195
  * The class responsible for making category list
196
  */
197
  require_once WOO_FEED_FREE_PATH . 'admin/class-woo-feed-category-list.php';
198
-
199
  require_once WOO_FEED_FREE_PATH . 'includes/widget.php';
200
 
201
  $this->loader = new Woo_Feed_Loader();
 
202
  }
203
-
204
  /**
205
  * Define the locale for this plugin for internationalization.
206
  *
@@ -215,7 +216,7 @@ class Woo_Feed {
215
  $plugin_i18n->set_domain( $this->get_woo_feed() );
216
  $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
217
  }
218
-
219
  /**
220
  * Register all of the hooks related to the admin area functionality
221
  * of the plugin.
@@ -224,16 +225,16 @@ class Woo_Feed {
224
  * @access private
225
  */
226
  private function define_admin_hooks() {
227
-
228
  $plugin_admin = new Woo_Feed_Admin( $this->get_woo_feed(), $this->get_version() );
229
-
230
  $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
231
  $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
232
  $this->loader->add_action( 'admin_menu', $plugin_admin, 'load_admin_pages' );
233
  $this->loader->add_action( 'admin_page_access_denied', $plugin_admin, 'handle_old_menu_slugs' );
234
  $this->loader->add_filter( 'plugin_action_links_' . WOO_FEED_PLUGIN_BASE_NAME, $plugin_admin, 'woo_feed_plugin_action_links' );
235
  }
236
-
237
  /**
238
  * Run the loader to execute all of the hooks with WordPress.
239
  *
@@ -247,7 +248,7 @@ class Woo_Feed {
247
  $this->loader->run();
248
  }
249
  }
250
-
251
  /**
252
  * The name of the plugin used to uniquely identify it within the context of
253
  * WordPress and to define internationalization functionality.
@@ -258,7 +259,7 @@ class Woo_Feed {
258
  public function get_woo_feed() {
259
  return $this->woo_feed;
260
  }
261
-
262
  /**
263
  * The reference to the class that orchestrates the hooks with the plugin.
264
  *
@@ -268,7 +269,7 @@ class Woo_Feed {
268
  public function get_loader() {
269
  return $this->loader;
270
  }
271
-
272
  /**
273
  * Retrieve the version number of the plugin.
274
  *
@@ -278,4 +279,4 @@ class Woo_Feed {
278
  public function get_version() {
279
  return $this->version;
280
  }
281
- }
29
  * @author Wahid <wahid0003@gmail.com.com>
30
  */
31
  class Woo_Feed {
32
+
33
  /**
34
  * The loader that's responsible for maintaining and registering all hooks that power
35
  * the plugin.
39
  * @var Woo_Feed_Loader $loader Maintains and registers all hooks for the plugin.
40
  */
41
  protected $loader;
42
+
43
  /**
44
  * The unique identifier of this plugin.
45
  *
48
  * @var string $woo_feed The string used to uniquely identify this plugin.
49
  */
50
  protected $woo_feed;
51
+
52
  /**
53
  * The current version of the plugin.
54
  *
57
  * @var string $version The current version of the plugin.
58
  */
59
  protected $version;
60
+
61
  /**
62
  * Define the core functionality of the plugin.
63
  *
71
  $this->woo_feed = 'woo-feed';
72
  $this->version = WOO_FEED_FREE_VERSION;
73
  }
74
+
75
+
76
  /**
77
  * Load the required dependencies for this plugin.
78
  *
90
  * @access private
91
  */
92
  private function load_dependencies() {
93
+
94
+
95
  /**
96
  * Load Error Logger File Handler
97
  */
105
  * core plugin.
106
  */
107
  require_once WOO_FEED_FREE_PATH . 'includes/class-woo-feed-loader.php';
108
+
109
  /**
110
  * The class responsible for defining internationalization functionality
111
  * of the plugin.
112
  */
113
  require_once WOO_FEED_FREE_PATH . 'includes/class-woo-feed-i18n.php';
114
+
115
  /**
116
  * The class responsible for getting all product information
117
  * of the plugin.
119
  require_once WOO_FEED_FREE_PATH . 'includes/classes/class-woo-feed-products.php';
120
  require_once WOO_FEED_FREE_PATH . 'includes/classes/class-woo-feed-products-v3.php';
121
  require_once WOO_FEED_FREE_PATH . 'includes/classes/class-woo-feed-merchant.php';
122
+
123
  /**
124
  * The class responsible for processing feed
125
  */
126
  require_once WOO_FEED_FREE_PATH . 'includes/classes/class-woo-feed-engine.php';
127
+
128
  /**
129
  * The class contain all merchants attribute dropdown
130
  */
131
  require_once WOO_FEED_FREE_PATH . 'includes/classes/class-woo-feed-dropdown.php';
132
+
133
  /**
134
  * The class contain merchant attributes
135
  */
138
  * The class contain product attributes
139
  */
140
  require_once WOO_FEED_FREE_PATH . 'includes/classes/class-woo-feed-product-attributes.php';
141
+
142
  /**
143
  * The class responsible for generating feed
144
  */
153
  * The class is a shipping calculation library
154
  */
155
  require_once WOO_FEED_FREE_PATH . 'includes/class-woo-feed-status.php';
156
+
157
  /**
158
  * The class responsible for save feed
159
  */
175
  * The class responsible for defining all actions that occur in the admin area.
176
  */
177
  require_once WOO_FEED_FREE_PATH . 'admin/class-woo-feed-admin.php';
178
+
179
  /**
180
  * The class responsible for making list table
181
  */
195
  * The class responsible for making category list
196
  */
197
  require_once WOO_FEED_FREE_PATH . 'admin/class-woo-feed-category-list.php';
198
+
199
  require_once WOO_FEED_FREE_PATH . 'includes/widget.php';
200
 
201
  $this->loader = new Woo_Feed_Loader();
202
+
203
  }
204
+
205
  /**
206
  * Define the locale for this plugin for internationalization.
207
  *
216
  $plugin_i18n->set_domain( $this->get_woo_feed() );
217
  $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
218
  }
219
+
220
  /**
221
  * Register all of the hooks related to the admin area functionality
222
  * of the plugin.
225
  * @access private
226
  */
227
  private function define_admin_hooks() {
228
+
229
  $plugin_admin = new Woo_Feed_Admin( $this->get_woo_feed(), $this->get_version() );
230
+
231
  $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
232
  $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
233
  $this->loader->add_action( 'admin_menu', $plugin_admin, 'load_admin_pages' );
234
  $this->loader->add_action( 'admin_page_access_denied', $plugin_admin, 'handle_old_menu_slugs' );
235
  $this->loader->add_filter( 'plugin_action_links_' . WOO_FEED_PLUGIN_BASE_NAME, $plugin_admin, 'woo_feed_plugin_action_links' );
236
  }
237
+
238
  /**
239
  * Run the loader to execute all of the hooks with WordPress.
240
  *
248
  $this->loader->run();
249
  }
250
  }
251
+
252
  /**
253
  * The name of the plugin used to uniquely identify it within the context of
254
  * WordPress and to define internationalization functionality.
259
  public function get_woo_feed() {
260
  return $this->woo_feed;
261
  }
262
+
263
  /**
264
  * The reference to the class that orchestrates the hooks with the plugin.
265
  *
269
  public function get_loader() {
270
  return $this->loader;
271
  }
272
+
273
  /**
274
  * Retrieve the version number of the plugin.
275
  *
279
  public function get_version() {
280
  return $this->version;
281
  }
282
+ }
includes/classes/class-woo-feed-constants.php CHANGED
@@ -23,7 +23,7 @@ if( ! class_exists("Woo_Feed_Constants") ) {
23
  * @var string
24
  * @since 3.1.6
25
  */
26
- define( 'WOO_FEED_FREE_VERSION', '4.5.7' );
27
  }
28
 
29
  if ( ! defined( 'WOO_FEED_FREE_PATH' ) ) {
23
  * @var string
24
  * @since 3.1.6
25
  */
26
+ define( 'WOO_FEED_FREE_VERSION', '4.5.8' );
27
  }
28
 
29
  if ( ! defined( 'WOO_FEED_FREE_PATH' ) ) {
woo-feed.php CHANGED
@@ -10,7 +10,7 @@
10
  * Plugin Name: CTX Feed
11
  * Plugin URI: https://webappick.com/
12
  * Description: Easily generate woocommerce product feed for any marketing channel like Google Shopping(Merchant), Facebook Remarketing, Bing, eBay & more. Support 100+ Merchants.
13
- * Version: 4.5.7
14
  * Author: WebAppick
15
  * Author URI: https://webappick.com/
16
  * License: GPL v2
@@ -28,6 +28,8 @@
28
  * WC tested up to: 6.9.1
29
  */
30
 
 
 
31
  if ( ! defined( 'ABSPATH' ) ) {
32
  die(); // If this file is called directly, abort.
33
  }
@@ -132,9 +134,7 @@ if ( ! function_exists( 'run_woo_feed' ) ) {
132
  add_action( 'plugins_loaded', array( $plugin, 'run' ), PHP_INT_MAX );
133
  add_action( 'admin_notices', 'wooFeed_Admin_Notices' );
134
  //add_action( 'admin_notices', 'woo_feed_black_friday_notice' );
135
- if( isset($_GET['page'] ) && preg_match( '/^webappick\W+/', $_GET['page'] ) ) {
136
- add_action( 'admin_notices', 'woo_feed_halloween_notice' );
137
- }
138
  WooFeedWebAppickAPI::getInstance();
139
 
140
  }
@@ -892,5 +892,15 @@ if ( ! function_exists( 'woo_feed_deactivate' ) ) {
892
  }
893
  }
894
 
 
 
 
 
 
 
 
 
 
895
 
 
896
  // End of file woo-feed.php
10
  * Plugin Name: CTX Feed
11
  * Plugin URI: https://webappick.com/
12
  * Description: Easily generate woocommerce product feed for any marketing channel like Google Shopping(Merchant), Facebook Remarketing, Bing, eBay & more. Support 100+ Merchants.
13
+ * Version: 4.5.8
14
  * Author: WebAppick
15
  * Author URI: https://webappick.com/
16
  * License: GPL v2
28
  * WC tested up to: 6.9.1
29
  */
30
 
31
+ //use CTXFeed\V5\API\RestController;
32
+
33
  if ( ! defined( 'ABSPATH' ) ) {
34
  die(); // If this file is called directly, abort.
35
  }
134
  add_action( 'plugins_loaded', array( $plugin, 'run' ), PHP_INT_MAX );
135
  add_action( 'admin_notices', 'wooFeed_Admin_Notices' );
136
  //add_action( 'admin_notices', 'woo_feed_black_friday_notice' );
137
+
 
 
138
  WooFeedWebAppickAPI::getInstance();
139
 
140
  }
892
  }
893
  }
894
 
895
+ /**
896
+ * rest api init
897
+ * @return void
898
+ */
899
+ //if( ! function_exists( 'init_rest_api' ) ) {
900
+ // function init_rest_api() {
901
+ // RestController::instance();
902
+ // }
903
+ //}
904
 
905
+ //add_action('init', 'init_rest_api' );
906
  // End of file woo-feed.php