@@ -86,8 +86,46 @@ public function get_usage_data( $data ) {
86
86
$ categories = count ( $ terms );
87
87
}
88
88
// imports.
89
- $ imports = array ();
90
89
$ license = 'free ' ;
90
+
91
+ $ imports = array (
92
+ // how many active imports are created.
93
+ 'publish ' => count (
94
+ get_posts (
95
+ array (
96
+ 'post_type ' => 'feedzy_imports ' ,
97
+ 'post_status ' => 'publish ' ,
98
+ 'numberposts ' => 99 ,
99
+ 'fields ' => 'ids ' ,
100
+ )
101
+ )
102
+ ),
103
+ // how many draft imports are created.
104
+ 'draft ' => count (
105
+ get_posts (
106
+ array (
107
+ 'post_type ' => 'feedzy_imports ' ,
108
+ 'post_status ' => 'draft ' ,
109
+ 'numberposts ' => 99 ,
110
+ 'fields ' => 'ids ' ,
111
+ )
112
+ )
113
+ ),
114
+ // how many posts were imported by the imports.
115
+ 'imported ' => count (
116
+ get_posts (
117
+ array (
118
+ 'post_type ' => 'post ' ,
119
+ 'post_status ' => array ( 'publish ' , 'private ' , 'draft ' , 'trash ' ),
120
+ 'numberposts ' => 2999 , //phpcs:ignore WordPress.WP.PostsPerPage.posts_per_page_numberposts
121
+ 'fields ' => 'ids ' ,
122
+ 'meta_key ' => 'feedzy ' , //phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key
123
+ 'meta_value ' => 1 , //phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_value
124
+ )
125
+ )
126
+ ),
127
+ );
128
+
91
129
if ( feedzy_is_pro () ) {
92
130
$ license = 'pro ' ;
93
131
if ( apply_filters ( 'feedzy_is_license_of_type ' , false , 'agency ' ) ) {
@@ -107,70 +145,57 @@ public function get_usage_data( $data ) {
107
145
}
108
146
}
109
147
110
- $ imports = apply_filters (
111
- 'feedzy_usage_data ' ,
112
- array (
113
- // how many active imports are created.
114
- 'publish ' => count (
115
- get_posts (
116
- array (
117
- 'post_type ' => 'feedzy_imports ' ,
118
- 'post_status ' => 'publish ' ,
119
- 'numberposts ' => 99 ,
120
- 'fields ' => 'ids ' ,
121
- )
122
- )
123
- ),
124
- // how many draft imports are created
125
- 'draft ' => count (
126
- get_posts (
127
- array (
128
- 'post_type ' => 'feedzy_imports ' ,
129
- 'post_status ' => 'draft ' ,
130
- 'numberposts ' => 99 ,
131
- 'fields ' => 'ids ' ,
132
- )
133
- )
134
- ),
135
- // how many posts were imported by the imports
136
- 'imported ' => count (
137
- get_posts (
138
- array (
139
- 'post_type ' => 'post ' ,
140
- 'post_status ' => array ( 'publish ' , 'private ' , 'draft ' , 'trash ' ),
141
- 'numberposts ' => 2999 , //phpcs:ignore WordPress.WP.PostsPerPage.posts_per_page_numberposts
142
- 'fields ' => 'ids ' ,
143
- 'meta_key ' => 'feedzy ' , //phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key
144
- 'meta_value ' => 1 , //phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_value
145
- )
146
- )
147
- ),
148
- // integrations
149
- 'integrations ' => $ integrations ,
150
- )
151
- );
148
+ $ imports ['integrations ' ] = $ integrations ;
152
149
}
153
150
154
- $ settings = apply_filters ( 'feedzy_get_settings ' , null );
155
- $ config = array ();
156
- if ( $ settings ) {
157
- $ proxy = isset ( $ settings ['proxy ' ] ) && is_array ( $ settings ['proxy ' ] ) && ! empty ( $ settings ['proxy ' ] ) ? array_filter ( $ settings ['proxy ' ] ) : array ();
158
- if ( ! empty ( $ proxy ) ) {
159
- $ config [] = 'proxy ' ;
160
- }
161
- }
151
+ $ imports = wp_parse_args ( Feedzy_Rss_Feeds_Usage::get_instance ()->get_usage_stats (), $ imports );
152
+ $ imports = apply_filters ( 'feedzy_usage_data ' , $ imports );
162
153
163
154
// how many posts contain the shortcode
164
155
global $ wpdb ;
165
156
$ shortcodes = $ wpdb ->get_var ( "SELECT count(*) FROM {$ wpdb ->prefix }posts WHERE post_status IN ('publish', 'private') AND post_content LIKE '%[feedzy-rss %' " ); //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching
157
+
166
158
$ data = array (
167
- 'categories ' => $ categories ,
168
- 'imports ' => $ imports ,
169
- 'shortcodes ' => $ shortcodes ,
170
- 'license ' => $ license ,
171
- 'config ' => $ config ,
159
+ 'categories ' => $ categories ,
160
+ 'imports ' => $ imports ,
161
+ 'shortcodes ' => $ shortcodes ,
162
+ 'license ' => $ license ,
172
163
);
173
164
165
+ $ settings = apply_filters ( 'feedzy_get_settings ' , null );
166
+
167
+ if ( ! is_array ( $ settings ) || empty ( $ settings ) ) {
168
+ return $ data ;
169
+ }
170
+
171
+ $ general_settings = array ();
172
+ $ config = array ();
173
+
174
+ $ proxy = isset ( $ settings ['proxy ' ] ) && is_array ( $ settings ['proxy ' ] ) && ! empty ( $ settings ['proxy ' ] ) ? array_filter ( $ settings ['proxy ' ] ) : array ();
175
+ if ( ! empty ( $ proxy ) ) {
176
+ $ config [] = 'proxy ' ;
177
+ }
178
+
179
+ if ( isset ( $ settings ['header ' ], $ settings ['header ' ]['user-agent ' ] ) && ! empty ( $ settings ['header ' ]['user-agent ' ] ) ) {
180
+ $ config [] = 'custom-user-agent ' ;
181
+ }
182
+
183
+ if ( ! empty ( $ config ) ) {
184
+ $ data ['config ' ] = $ config ;
185
+ }
186
+
187
+ if ( is_array ( $ settings ['general ' ] ) && ! empty ( $ settings ['general ' ] ) ) {
188
+ foreach ( $ settings ['general ' ] as $ key => $ value ) {
189
+ if ( ! empty ( $ value ) ) {
190
+ $ general_settings [ $ key ] = $ value ;
191
+ }
192
+ }
193
+
194
+ if ( ! empty ( $ general_settings ) ) {
195
+ $ data ['general ' ] = $ general_settings ;
196
+ }
197
+ }
198
+
174
199
return $ data ;
175
200
}
176
201
0 commit comments