PluginProbe
Datafeedr API / 1.4.3
Datafeedr API v1.4.3
1.4.3 1.4.2 1.0.125 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.2 1.0.20 1.0.21 1.0.22 1.0.23 1.0.24 1.0.25 1.0.26 1.0.27 1.0.28 1.0.29 1.0.3 1.0.30 1.0.31 1.0.32 All 182 releases
← All changes | classes/class-dfrapi-networks.php +121 -130 1.0.125 → 1.4.3 View file →
@@ -1,7 +1,10 @@
1 1 <?php
2 2
3 -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3 +// Exit if accessed directly
4 +if ( ! defined( 'ABSPATH' ) ) {
5 + exit;
6 +}
4 7
5 8 if ( ! class_exists( 'Dfrapi_Networks' ) ) {
6 9
7 10 /**
@@ -11,12 +14,13 @@
11 14
12 15 private $page = 'dfrapi-networks';
13 16 private $key;
14 17 private $all_networks;
18 + public $options;
15 19
16 20 public function __construct() {
17 21
18 - $this->key = 'dfrapi_networks';
22 + $this->key = 'dfrapi_networks';
19 23 $this->all_networks = dfrapi_api_get_all_networks();
20 24 add_action( 'init', array( $this, 'load_settings' ) );
21 25 add_action( 'admin_init', array( $this, 'register_settings' ) );
22 26 add_action( 'admin_notices', array( $this, 'admin_notice' ) );
@@ -24,23 +28,17 @@
24 28 }
25 29
26 30 function api_errors() {
27 31 if ( array_key_exists( 'dfrapi_api_error', $this->all_networks ) ) {
28 - $html = '';
29 - $html .= '<div class="notice notice-error">';
30 - $html .= '<p>';
31 - $html .= $this->all_networks;
32 - $html .= '</p>';
33 - $html .= '</div>';
34 - echo $html;
32 + echo '<div class="notice notice-error">';
33 + dfrapi_output_api_error( $this->all_networks );
34 + echo '</div>';
35 35 }
36 36 }
37 37
38 38 function admin_notice() {
39 39 if ( isset( $_GET['settings-updated'] ) && $_GET['settings-updated'] == true && isset( $_GET['page'] ) && $this->key == $_GET['page'] ) {
40 - echo '<div class="updated"><p>';
41 - _e( 'Networks successfully updated!', DFRAPI_DOMAIN );
42 - echo '</p></div>';
40 + dfrapi_admin_notice( __( 'Networks successfully updated!', 'datafeedr-api' ), 'success' );
43 41 }
44 42 }
45 43
46 44 function load_settings() {
@@ -51,14 +49,20 @@
51 49 }
52 50
53 51 function register_settings() {
54 52 register_setting( $this->page, $this->key, array( $this, 'validate' ) );
55 - add_settings_section( 'networks', __( 'Select Networks', DFRAPI_DOMAIN ), array( &$this, 'section_networks_desc' ), $this->page );
56 - add_settings_field( 'ids', __( 'Networks', DFRAPI_DOMAIN ), array( &$this, 'field_network_ids' ), $this->page, 'networks', array( 'label_for' => 'DFRAPI_HIDE_LABEL' ) );
53 + add_settings_section( 'networks', __( 'Select Networks', 'datafeedr-api' ), array(
54 + &$this,
55 + 'section_networks_desc'
56 + ), $this->page );
57 + add_settings_field( 'ids', __( 'Networks', 'datafeedr-api' ), array(
58 + &$this,
59 + 'field_network_ids'
60 + ), $this->page, 'networks', array( 'label_for' => 'DFRAPI_HIDE_LABEL' ) );
57 61 }
58 62
59 63 function section_networks_desc() {
60 - echo __( 'Select the affiliate networks you belong to, enter your affiliate ID for each then click <strong>[Save Changes]</strong>.', DFRAPI_DOMAIN );
64 + echo __( 'Select the affiliate networks you belong to, enter your affiliate ID for each then click <strong>[Save Changes]</strong>.', 'datafeedr-api' );
61 65 }
62 66
63 67 function field_network_ids() {
64 68 $groups = $this->get_network_group_names();
@@ -63,14 +67,14 @@
63 67 function field_network_ids() {
64 68 $groups = $this->get_network_group_names();
65 69 foreach ( $groups as $group ) {
66 70 $num_networks_checked_in_group = $this->num_networks_checked_in_group( $group );
67 - $active = ( $num_networks_checked_in_group != '' ) ? 'active' : '';
68 - $group_name = ( 'AffiliateWindow' == $group ) ? 'Awin' : $group;
71 + $active = ( $num_networks_checked_in_group != '' ) ? 'active' : '';
72 + $group_name = ( 'AffiliateWindow' == $group ) ? 'Awin' : $group;
69 73 echo '
70 - <div class="group network_logo_30x30_' . dfrapi_group_name_to_css( $group ) . ' ' . $active . '" id="group_' . dfrapi_group_name_to_css( $group ) . '">
74 + <div class="group network_logo_30x30_' . esc_attr( dfrapi_group_name_to_css( $group ) ) . ' ' . $active . '" id="group_' . esc_attr( dfrapi_group_name_to_css( $group ) ) . '">
71 75 <div class="meta">
72 - <span class="name">' . $group_name . '</span>
76 + <span class="name">' . esc_html( $group_name ) . '</span>
73 77 <span class="status">
74 78 ' . $this->num_missing_affiliate_ids_in_group( $group ) . '
75 79 ' . $num_networks_checked_in_group . '
76 80 ' . $this->num_networks_in_group( $group ) . '
@@ -89,50 +93,81 @@
89 93 <table class="wp-list-table widefat fixed networks_table" cellspacing="0">
90 94 <thead>
91 95 <tr>
92 96 <th class="checkbox_head"> &nbsp; </th>
93 - <th class="networks_head">' . __( 'Network', DFRAPI_DOMAIN ) . '</th>
94 - <th class="type_head">' . __( 'Type', DFRAPI_DOMAIN ) . '</th>
95 - <th class="aid_head">' . __( 'Affiliate ID', DFRAPI_DOMAIN ) . ' <a href="' .$this->map_link( $group_name ) .'" target="_blank" title="' . __( 'Learn how to find your affiliate ID from ', DFRAPI_DOMAIN ) . $group_name . __( ' (opens in new window).', DFRAPI_DOMAIN ) . '"><img src="' . DFRAPI_URL . 'images/icons/help.png" alt="' . __( 'more info', DFRAPI_DOMAIN ) . '" style="vertical-align: middle" /></a> <small style="font-weight:normal;color:#a00;">(' . __( 'required', DFRAPI_DOMAIN ) . ')</small></th>
96 - <th class="tid_head">' . __( 'Tracking ID', DFRAPI_DOMAIN ) . ' <a href="https://datafeedrapi.helpscoutdocs.com/article/212-tracking-ids" target="_blank" title="' . __( 'Learn more about this field (opens in new window).', DFRAPI_DOMAIN ) . '"><img src="' . DFRAPI_URL . 'images/icons/help.png" alt="' . __( 'more info', DFRAPI_DOMAIN ) . '" style="vertical-align: middle" /></a> <small style="font-weight:normal;color:#999;">(' . __( 'optional', DFRAPI_DOMAIN ) . ')</small></th>
97 + <th class="networks_head">' . __( 'Network', 'datafeedr-api' ) . '</th>
98 + <th class="type_head">' . __( 'Type', 'datafeedr-api' ) . '</th>
99 + <th class="aid_head">' . __( 'Affiliate ID', 'datafeedr-api' ) . ' <a href="' . esc_url( $this->map_link( $group_name ) ) . '" target="_blank" title="' . esc_attr( __( 'Learn how to find your affiliate ID from ', 'datafeedr-api' ) . $group_name . __( ' (opens in new window).', 'datafeedr-api' ) ) . '"><img src="' . DFRAPI_URL . 'images/icons/help.png" alt="' . __( 'more info', 'datafeedr-api' ) . '" style="vertical-align: middle" /></a> <small style="font-weight:normal;color:#a00;">(' . __( 'required', 'datafeedr-api' ) . ')</small></th>
100 + <th class="tid_head">' . __( 'Tracking ID', 'datafeedr-api' ) . ' <a href="https://datafeedrapi.helpscoutdocs.com/article/212-tracking-ids" target="_blank" title="' . __( 'Learn more about this field (opens in new window).', 'datafeedr-api' ) . '"><img src="' . DFRAPI_URL . 'images/icons/help.png" alt="' . __( 'more info', 'datafeedr-api' ) . '" style="vertical-align: middle" /></a> <small style="font-weight:normal;color:#999;">(' . __( 'optional', 'datafeedr-api' ) . ')</small></th>
97 101 </tr>
98 102 </thead>
99 103 <tbody>
100 104 ';
101 105
102 - $i=0;
106 + $i = 0;
103 107
104 108 foreach ( $this->all_networks as $network ) {
105 109
106 - $i++;
107 - $checked = ( array_key_exists( $network['_id'], (array) $this->options['ids'] ) ) ? ' checked="checked"' : '';
108 - $type = ( $network['type'] == 'products' ) ? __( 'products', DFRAPI_DOMAIN ) : __( 'coupons', DFRAPI_DOMAIN );
109 - $type_class = ( $network['type'] == 'products' ) ? ' dfrapi_label-info"' : ' dfrapi_label-success';
110 + $i ++;
111 + $checked = ( array_key_exists( $network['_id'], (array) $this->options['ids'] ) ) ? ' checked="checked"' : '';
112 + $type = ( $network['type'] === 'products' ) ? __( 'products', 'datafeedr-api' ) : __( 'coupons', 'datafeedr-api' );
113 + $type_class = ( $network['type'] === 'products' ) ? ' dfrapi_label-info"' : ' dfrapi_label-success';
110 114 $no_products = ( $network['product_count'] < 1 ) ? 'no_products' : '';
111 - $alternate = ( $i % 2 ) ? '' : ' alternate';
115 + $alternate = ( $i % 2 ) ? '' : ' alternate';
112 116
117 + if ( $network['group'] == $group_name && (int) $network['group_id'] === dfrapi_get_partnerize_group_id() && ! dfrapi_get_ph_keys() ) {
118 + $html .= sprintf(
119 + __( '<tr><td colspan="4"><strong>%1$s</strong><br />Please go to <a href="%2$s">Datafeedr API > Configuration</a> and enter your Partnerize API keys before selecting this network.</td></tr>', 'datafeedr-api' ),
120 + esc_html( $network['name'] ),
121 + esc_url( dfrapi_configuration_page_url() )
122 + );
123 +
124 + continue;
125 + }
126 +
127 + if ( $network['group'] == $group_name && (int) $network['group_id'] === dfrapi_get_effiliation_group_id() && ! dfrapi_get_effiliation_keys() ) {
128 + $html .= sprintf(
129 + __( '<tr><td colspan="4"><strong>%1$s</strong><br />Please go to <a href="%2$s">Datafeedr API > Configuration</a> and enter your Effiliation Key before selecting this network.</td></tr>', 'datafeedr-api' ),
130 + esc_html( $network['name'] ),
131 + esc_url( dfrapi_configuration_page_url() )
132 + );
133 +
134 + continue;
135 + }
136 +
137 + if ( $network['group'] == $group_name && (int) $network['group_id'] === dfrapi_get_belboon_group_id() && is_wp_error( dfrapi_get_belboon_adspace_id() ) ) {
138 + $html .= sprintf(
139 + __( '<tr><td colspan="4"><strong>%1$s</strong><br />Please go to <a href="%2$s">Datafeedr API > Configuration</a> and enter your Belboon Adspace ID before selecting this network.</td></tr>', 'datafeedr-api' ),
140 + esc_html( $network['name'] ),
141 + esc_url( dfrapi_configuration_page_url() )
142 + );
143 +
144 + continue;
145 + }
146 +
113 147 if ( $network['group'] == $group_name ) {
114 148
115 - $aid = ( isset( $this->options['ids'][ $network['_id'] ]['aid'] ) ) ? $this->options['ids'][ $network['_id'] ]['aid'] : '';
116 - $tid = ( isset( $this->options['ids'][ $network['_id'] ]['tid'] ) ) ? $this->options['ids'][ $network['_id'] ]['tid'] : '';
149 + $aid = ( isset( $this->options['ids'][ $network['_id'] ]['aid'] ) ) ? esc_attr( $this->options['ids'][ $network['_id'] ]['aid'] ) : '';
150 + $tid = ( isset( $this->options['ids'][ $network['_id'] ]['tid'] ) ) ? esc_attr( $this->options['ids'][ $network['_id'] ]['tid'] ) : '';
151 + $nid = absint( $network['_id'] );
117 152
118 153 $html .= '
119 - <tr
120 - class="network ' . $no_products . $alternate . '"
121 - id="network_id_' . $network['_id'] . '"
122 - nid="' . $network['_id'] . '"
123 - key="' . $this->key . '"
124 - aid="' . $aid . '"
154 + <tr
155 + class="network ' . $no_products . $alternate . '"
156 + id="network_id_' . $nid . '"
157 + nid="' . $nid . '"
158 + key="' . $this->key . '"
159 + aid="' . $aid . '"
125 160 tid="' . $tid . '"
126 161 >
127 162 <td class="network_checkbox">
128 - <input type="checkbox" id="nid_' . $network['_id'] . '" class="check_network" name="' . $this->key . '[ids][' . $network['_id'] . '][nid]" value="' . $network['_id'] . '"' . $checked . ' />
163 + <input type="checkbox" id="nid_' . $nid . '" class="check_network" name="' . $this->key . '[ids][' . $nid . '][nid]" value="' . $nid . '"' . $checked . ' />
129 164 </td>
130 165 <td class="network_name">
131 - <label for="nid_' . $network['_id'] . '">
132 - ' . $network['name'] . '
166 + <label for="nid_' . $nid . '">
167 + ' . esc_html( $network['name'] ) . '
133 168 <div class="network_info">
134 - <span class="num_merchants">' . number_format( $network['merchant_count'] ) . ' ' . __( 'merchants', DFRAPI_DOMAIN ) . ' <span class="sep">/</span>
169 + <span class="num_merchants">' . number_format( $network['merchant_count'] ) . ' ' . __( 'merchants', 'datafeedr-api' ) . ' <span class="sep">/</span>
135 170 <span class="num_products">' . number_format( $network['product_count'] ) . ' ' . $type . '</span>
136 171 </div>
137 172 </label>
138 173 </td>
@@ -140,27 +175,31 @@
140 175 <span class="dfrapi_label' . $type_class . '">' . ucfirst( $type ) . '</span>
141 176 </td>
142 177 ';
143 178
144 - if ( $network['group_id'] == 10037 ) {
145 - $html .= '<td class="aid_input">' . $this->zanox_adspace( $network['_id'], $aid ) . '</td>';
146 - } elseif ( $network['group_id'] == 10027 ) {
179 + if ( $network['group_id'] == dfrapi_get_partnerize_group_id() ) {
147 180 $url = admin_url( 'admin.php?page=dfrapi' );
148 - $html .= '<td class="aid_input"><a href="' . $url . '" target="_blank">Add/Edit Partnerize Keys</a></td>';
149 - } elseif ( $network['group_id'] == 10017 ) {
181 + $html .= '<td class="aid_input"><a href="' . $url . '" target="_blank">Edit Partnerize Keys</a></td>';
182 + } elseif ( $network['group_id'] == dfrapi_get_effiliation_group_id() ) {
150 183 $url = admin_url( 'admin.php?page=dfrapi' );
151 - $html .= '<td class="aid_input"><a href="' . $url . '" target="_blank">Add/Edit Effiliation Key</a></td>';
152 - } elseif ( $network['group_id'] == 10007 && is_wp_error( dfrapi_get_belboon_adspace_id() ) ) {
184 + $html .= '<td class="aid_input"><a href="' . $url . '" target="_blank">Edit Effiliation Key</a></td>';
185 + } elseif ( $network['group_id'] == dfrapi_get_belboon_group_id() && is_wp_error( dfrapi_get_belboon_adspace_id() ) ) {
153 186 $url = admin_url( 'admin.php?page=dfrapi' );
154 187 $html .= '<td class="aid_input"><a href="' . $url . '" target="_blank">Your Belboon Adspace ID is required before you can enter your affiliate ID. Enter Adspace ID.</a></td>';
188 + } elseif ( $network['group_id'] == 10033 && is_wp_error( dfrapi_get_affiliate_gateway_sid() ) ) {
189 + $url = admin_url( 'admin.php?page=dfrapi' );
190 + $html .= '<td class="aid_input"><a href="' . $url . '" target="_blank">Your Affiliate Gateway SID is required before you can enter your affiliate ID. Enter SID.</a></td>';
191 + } elseif ( $network['group_id'] == 10045 && is_wp_error( dfrapi_get_adservice_mid() ) ) {
192 + $url = admin_url( 'admin.php?page=dfrapi' );
193 + $html .= '<td class="aid_input"><a href="' . $url . '" target="_blank">Your Adservice Media ID is required before you can enter your affiliate ID. Enter Media ID.</a></td>';
155 194 } else {
156 - $html .= '<td class="aid_input"><input type="text" name="dfrapi_networks[ids][' . $network['_id'] . '][aid]" value="' . $aid . '" class="aid_input_field" /></td>';
195 + $html .= '<td class="aid_input"><input type="text" name="dfrapi_networks[ids][' . $nid . '][aid]" value="' . $aid . '" class="aid_input_field" /></td>';
157 196 }
158 197
159 - if ( $group_name == 'NoTrackingIDOption' ) {
198 + if ( apply_filters( 'dfrapi_network_supports_tracking_id', true, $network ) ) {
199 + $html .= '<td class="tid_input"><input type="text" name="dfrapi_networks[ids][' . $nid . '][tid]" value="' . $tid . '" class="tid_input_field" /></td>';
200 + } else {
160 201 $html .= '<td class="tid_input"><small>n/a</small></td>';
161 - } else {
162 - $html .= '<td class="tid_input"><input type="text" name="dfrapi_networks[ids][' . $network['_id'] . '][tid]" value="' . $tid . '" class="tid_input_field" /></td>';
163 202 }
164 203
165 204 $html .= '</tr>';
166 205 }
@@ -170,87 +209,37 @@
170 209 </tbody>
171 210 </table>
172 211 </div>
173 212 ';
213 +
174 214 return $html;
175 215 }
176 216
177 217 function get_network_group_names() {
178 218 $networks = $this->all_networks;
179 - $groups = array();
219 + $groups = array();
180 220 foreach ( $networks as $network ) {
181 221 $groups[] = $network['group'];
182 222 }
223 +
183 224 return array_unique( $groups );
184 225 }
185 226
186 - /**
187 - * This returns <select> menu for adspaces.
188 - */
189 - function zanox_adspace( $nid, $selected_adspace ) {
190 - $html = '';
191 - $adspaces = $this->get_zanox_adspaces();
192 - if ( isset( $adspaces['zanox_error'] ) ) {
193 - if ( $adspaces['zanox_error'] == 'missing_keys' ) {
194 - $html .= '<span><a href="' . admin_url( 'admin.php?page=dfrapi' ) . '" class="dfrapi_warning">' . __( 'Please add your Zanox Connection &amp; Secret Key', DFRAPI_DOMAIN ) . '</a>.</span>';
195 - } else {
196 - $html .= '<pre>' . print_r( $adspaces['zanox_error'], TRUE ) . '</pre>';
197 - }
198 - } else {
199 - $html .= '<select name="dfrapi_networks[ids][' . $nid . '][aid]">';
200 - $html .= '<option value="">' . __( 'Select an adspace', DFRAPI_DOMAIN ) . '</option>';
201 - foreach( $adspaces as $adspace ) {
202 - $selected = selected( $selected_adspace, $adspace['id'], false );
203 - $html .= '<option value="' . $adspace['id'] . '" ' . $selected . '>' . $adspace['name'] . '</option>';
204 - }
205 - $html .= '</select>';
206 - }
207 - return $html;
208 - }
209 -
210 - /**
211 - * This returns adspaces for a Zanox user.
212 - */
213 - function get_zanox_adspaces() {
214 - $option_name = 'dfrapi_zanox_adspaces';
215 - $use_cache = wp_using_ext_object_cache( false );
216 - $adspaces = get_transient( $option_name );
217 - wp_using_ext_object_cache( $use_cache );
218 - if ( false === $adspaces || empty ( $adspaces ) ) {
219 - $zanox_keys = dfrapi_get_zanox_keys();
220 - if ( !$zanox_keys ) {
221 - return array( 'zanox_error' => 'missing_keys' );
222 - } else {
223 - $client = new Dfr_ZanoxAPIClient( $zanox_keys['connection_key'], $zanox_keys['secret_key'] );
224 - $adspaces = $client->adspaces();
225 - if ( $client->error() ) {
226 - return array( 'zanox_error' => $client->error() );
227 - } else {
228 - $use_cache = wp_using_ext_object_cache( false );
229 - set_transient( $option_name, $adspaces, HOUR_IN_SECONDS );
230 - wp_using_ext_object_cache( $use_cache );
231 - }
232 - }
233 - }
234 - dfrapi_update_transient_whitelist( $option_name );
235 - return $adspaces;
236 - }
237 -
238 227 function num_missing_affiliate_ids_in_group( $group_name ) {
239 228 $count = 0;
240 229 foreach ( $this->all_networks as $network ) {
241 230
242 - if ( $network['group_id'] == 10027 ) {
231 + if ( $network['group_id'] == dfrapi_get_partnerize_group_id() ) {
243 232 continue;
244 233 }
245 234
246 - if ( $network['group_id'] == 10017 ) {
235 + if ( $network['group_id'] == dfrapi_get_effiliation_group_id() ) {
247 236 continue;
248 237 }
249 238
250 239 if ( $network['group'] == $group_name ) {
251 240 if ( array_key_exists( $network['_id'], (array) $this->options['ids'] ) ) {
252 - if ( trim( $this->options['ids'][ $network['_id'] ]['aid'] ) == '' ) {
241 + if ( dfrapi_get_affiliate_id_by_network_id( (int) $network['_id'] ) === false ) {
253 242 $count ++;
254 243 }
255 244 }
256 245 }
@@ -259,9 +248,9 @@
259 248 if ( $count > 0 ) {
260 249 $messages = $this->messages();
261 250
262 251 return '<span class="num_missing">' . sprintf( translate_nooped_plural( $messages['num_missing'],
263 - $count, DFRAPI_DOMAIN ), number_format( $count ) ) . '</span> <span class="sep">/</span> ';
252 + $count, 'datafeedr-api' ), number_format( $count ) ) . '</span> <span class="sep">/</span> ';
264 253 }
265 254
266 255 return '';
267 256 }
@@ -270,9 +259,9 @@
270 259 $count = 0;
271 260 foreach ( $this->all_networks as $network ) {
272 261 if ( $network['group'] == $group_name ) {
273 262 if ( array_key_exists( $network['_id'], (array) $this->options['ids'] ) ) {
274 - $count++;
263 + $count ++;
275 264 }
276 265 }
277 266 }
278 267
@@ -277,9 +266,10 @@
277 266 }
278 267
279 268 if ( $count > 0 ) {
280 269 $messages = $this->messages();
281 - return '<span class="num_checked">' . sprintf( translate_nooped_plural( $messages['num_checked'], $count, DFRAPI_DOMAIN ), number_format( $count ) ) . '</span> <span class="sep">/</span> ';
270 +
271 + return '<span class="num_checked">' . sprintf( translate_nooped_plural( $messages['num_checked'], $count, 'datafeedr-api' ), number_format( $count ) ) . '</span> <span class="sep">/</span> ';
282 272 }
283 273 }
284 274
285 275 function num_networks_in_group( $group_name ) {
@@ -285,15 +275,16 @@
285 275 function num_networks_in_group( $group_name ) {
286 276 $count = 0;
287 277 foreach ( $this->all_networks as $network ) {
288 278 if ( $network['group'] == $group_name ) {
289 - $count++;
279 + $count ++;
290 280 }
291 281 }
292 282
293 283 if ( $count > 0 ) {
294 284 $messages = $this->messages();
295 - return '<span class="num_networks">' . sprintf( translate_nooped_plural( $messages['num_networks'], $count, DFRAPI_DOMAIN ), number_format( $count ) ) . '</span> <span class="sep">/</span> ';
285 +
286 + return '<span class="num_networks">' . sprintf( translate_nooped_plural( $messages['num_networks'], $count, 'datafeedr-api' ), number_format( $count ) ) . '</span> <span class="sep">/</span> ';
296 287 }
297 288 }
298 289
299 290 function num_merchants_in_group( $group_name ) {
@@ -305,9 +296,10 @@
305 296 }
306 297
307 298 if ( $count > 0 ) {
308 299 $messages = $this->messages();
309 - return '<span class="num_merchants">' . sprintf( translate_nooped_plural( $messages['num_merchants'], $count, DFRAPI_DOMAIN ), number_format( $count ) ) . '</span> <span class="sep">/</span> ';
300 +
301 + return '<span class="num_merchants">' . sprintf( translate_nooped_plural( $messages['num_merchants'], $count, 'datafeedr-api' ), number_format( $count ) ) . '</span> <span class="sep">/</span> ';
310 302 }
311 303 }
312 304
313 305 function num_products_in_group( $group_name ) {
@@ -319,9 +311,10 @@
319 311 }
320 312
321 313 if ( $count > 0 ) {
322 314 $messages = $this->messages();
323 - return '<span class="num_products">' . sprintf( translate_nooped_plural( $messages['num_products'], $count, DFRAPI_DOMAIN ), number_format( $count ) ) . '</span>';
315 +
316 + return '<span class="num_products">' . sprintf( translate_nooped_plural( $messages['num_products'], $count, 'datafeedr-api' ), number_format( $count ) ) . '</span>';
324 317 }
325 318
326 319 }
327 320
@@ -326,10 +319,10 @@
326 319 }
327 320
328 321 function messages() {
329 322 return array(
330 - 'num_missing' => _n_noop( '%s missing affiliate ID', '%s missing affiliate IDs' ),
331 - 'num_checked' => _n_noop( '%s network selected', '%s networks selected' ),
323 + 'num_missing' => _n_noop( '%s missing affiliate ID', '%s missing affiliate IDs' ),
324 + 'num_checked' => _n_noop( '%s network selected', '%s networks selected' ),
332 325 'num_networks' => _n_noop( '%s network', '%s networks' ),
333 326 'num_merchants' => _n_noop( '%s merchant', '%s merchants' ),
334 327 'num_products' => _n_noop( '%s product', '%s products' ),
335 328 );
@@ -334,14 +327,16 @@
334 327 'num_products' => _n_noop( '%s product', '%s products' ),
335 328 );
336 329 }
337 330
338 - function map_link( $name ) {
339 - $links = array(
331 + function map_link( $name ): string {
332 + $links = [
340 333 '2Performant' => 'https://datafeedrapi.helpscoutdocs.com/article/240-how-to-find-your-2performant-affiliate-id',
341 334 'Admitad' => 'https://datafeedrapi.helpscoutdocs.com/article/241-how-to-find-your-admitad-affiliate-id',
342 335 'ADCELL' => 'https://datafeedrapi.helpscoutdocs.com/article/235-how-to-find-your-adcell-affiliate-id',
336 + 'Addrevenue' => 'https://datafeedrapi.helpscoutdocs.com/article/259-how-to-find-your-addrevenue-affiliate-id',
343 337 'Adrecord' => 'https://datafeedrapi.helpscoutdocs.com/article/115-how-to-find-your-adrecord-affiliate-id',
338 + 'Adservice' => 'https://datafeedrapi.helpscoutdocs.com/article/251-how-to-find-your-adservice-affiliate-id-and-media-id',
344 339 'Adtraction' => 'https://datafeedrapi.helpscoutdocs.com/article/116-how-to-find-your-adtraction-affiliate-id',
345 340 'Affiliate4You' => 'http://www.datafeedr.com/docs/item/265',
346 341 'Awin' => 'https://datafeedrapi.helpscoutdocs.com/article/120-how-to-find-your-affiliate-window-affiliate-id',
347 342 'Affiliator' => 'http://www.datafeedr.com/docs/item/270',
@@ -360,13 +355,15 @@
360 355 'Commission Monster' => 'http://www.datafeedr.com/docs/item/109',
361 356 'Connexity' => 'https://datafeedrapi.helpscoutdocs.com/article/178-how-to-find-your-connexity-affiliate-id',
362 357 'Daisycon' => 'https://datafeedrapi.helpscoutdocs.com/article/135-how-to-find-your-daisycon-affiliate-id',
363 358 'DGM' => 'http://www.datafeedr.com/docs/item/263',
359 + 'Digital Advisor' => 'https://datafeedrapi.helpscoutdocs.com/article/250-how-to-find-your-digital-advisor-affiliate-id',
364 360 'Double.net' => 'https://datafeedrapi.helpscoutdocs.com/article/136-how-to-find-your-double-net-affiliate-id',
365 361 'Effiliation' => 'https://datafeedrapi.helpscoutdocs.com/article/211-how-to-find-your-effiliation-api-key',
366 362 'FamilyBlend' => 'https://datafeedrapi.helpscoutdocs.com/article/117-how-to-find-your-familyblend-affiliate-id',
367 363 'FlexOffers' => 'https://datafeedrapi.helpscoutdocs.com/article/209-how-to-find-your-flexoffers-affiliate-id',
368 364 'FlipKart' => 'https://datafeedrapi.helpscoutdocs.com/article/137-how-to-find-your-flipkart-affiliate-id',
365 + 'GoAffPro' => 'https://datafeedrapi.helpscoutdocs.com/article/249-how-to-find-your-goaffpro-affiliate-id',
369 366 'Impact' => 'https://datafeedrapi.helpscoutdocs.com/article/134-how-to-find-your-impact-radius-affiliate-id',
370 367 'LinkConnector' => 'https://datafeedrapi.helpscoutdocs.com/article/138-how-to-find-your-linkconnector-affiliate-id',
371 368 'Rakuten' => 'https://datafeedrapi.helpscoutdocs.com/article/139-how-to-find-your-rakuten-affiliate-id',
372 369 'M4N' => 'http://www.datafeedr.com/docs/item/198',
@@ -377,8 +374,9 @@
377 374 'Partner-ads' => 'https://datafeedrapi.helpscoutdocs.com/article/143-how-to-find-your-partner-ads-affiliate-id',
378 375 'Partnerize' => 'https://datafeedrapi.helpscoutdocs.com/article/195-how-to-find-your-partnerize-publisher-id-and-api-keys',
379 376 'PepperJam' => 'https://datafeedrapi.helpscoutdocs.com/article/127-how-to-find-your-ebay-enterprise-affiliate-network-affiliate-id',
380 377 'PerformanceHorizon' => 'https://datafeedrapi.helpscoutdocs.com/article/195-how-to-find-your-performance-horizon-publisher-id-and-api-keys',
378 + 'Profitshare' => 'https://datafeedrapi.helpscoutdocs.com/article/242-how-to-find-your-profitshare-affiliate-id',
381 379 'RegNow' => 'http://www.datafeedr.com/docs/item/111',
382 380 'RevResponse' => 'https://datafeedrapi.helpscoutdocs.com/article/144-how-to-find-your-revresponse-affiliate-id',
383 381 'ShareASale' => 'https://datafeedrapi.helpscoutdocs.com/article/126-how-to-find-your-shareasale-affiliate-id',
384 382 'Shopello' => 'https://datafeedrapi.helpscoutdocs.com/article/171-how-to-find-your-shopello-affiliate-id',
@@ -384,27 +382,20 @@
384 382 'Shopello' => 'https://datafeedrapi.helpscoutdocs.com/article/171-how-to-find-your-shopello-affiliate-id',
385 383 'Snapdeal' => 'https://datafeedrapi.helpscoutdocs.com/article/172-how-to-find-your-snapdeal-affiliate-id',
386 384 'SuperClix' => 'https://datafeedrapi.helpscoutdocs.com/article/145-how-to-find-your-superclix-affiliate-id',
387 385 'The Affiliate Gateway' => 'https://datafeedrapi.helpscoutdocs.com/article/225-how-to-find-your-affiliate-gateway-affiliate-id',
386 + 'TimeOne' => 'https://datafeedrapi.helpscoutdocs.com/article/262-how-to-find-your-timeone-affiliate-id',
388 387 'TradeDoubler' => 'https://datafeedrapi.helpscoutdocs.com/article/146-how-to-find-your-tradedoubler-affiliate-id',
389 388 'TradeTracker' => 'https://datafeedrapi.helpscoutdocs.com/article/148-how-to-find-your-tradetracker-affiliate-id',
390 389 'Webgains' => 'https://datafeedrapi.helpscoutdocs.com/article/147-how-to-find-your-webgains-affiliate-id',
391 390 'Zanox' => 'https://datafeedrapi.helpscoutdocs.com/article/149-how-to-find-your-zanox-api-keys',
392 - );
391 + ];
393 392
394 - return isset( $links[ $name ] ) ? $links[ $name ] : DFRAPI_DOCS_URL;
393 + return $links[ $name ] ?? ( DFRAPI_DOCS_SEARCH_URL . sanitize_title( $name ) );
395 394 }
396 395
397 396 function validate( $input ) {
398 - $new_input['ids'] = array();
399 - if ( isset( $input['ids'] ) ) {
400 - foreach ( $input['ids'] as $k => $v ) {
401 - if ( isset( $v['nid'] ) ) {
402 - $new_input['ids'][$k] = $v;
403 - }
404 - }
405 - }
406 - return $new_input;
397 + return dfrapi_sanitize_networks_option( $input );
407 398 }
408 399
409 400 } // class Dfrapi_Networks
410 401