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 +21 -33 1.4.2 → 1.4.3 View file →
@@ -28,15 +28,11 @@
28 28 }
29 29
30 30 function api_errors() {
31 31 if ( array_key_exists( 'dfrapi_api_error', $this->all_networks ) ) {
32 - $html = '';
33 - $html .= '<div class="notice notice-error">';
34 - $html .= '<p>';
35 - $html .= $this->all_networks;
36 - $html .= '</p>';
37 - $html .= '</div>';
38 - echo $html;
32 + echo '<div class="notice notice-error">';
33 + dfrapi_output_api_error( $this->all_networks );
34 + echo '</div>';
39 35 }
40 36 }
41 37
42 38 function admin_notice() {
@@ -74,11 +70,11 @@
74 70 $num_networks_checked_in_group = $this->num_networks_checked_in_group( $group );
75 71 $active = ( $num_networks_checked_in_group != '' ) ? 'active' : '';
76 72 $group_name = ( 'AffiliateWindow' == $group ) ? 'Awin' : $group;
77 73 echo '
78 - <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 ) ) . '">
79 75 <div class="meta">
80 - <span class="name">' . $group_name . '</span>
76 + <span class="name">' . esc_html( $group_name ) . '</span>
81 77 <span class="status">
82 78 ' . $this->num_missing_affiliate_ids_in_group( $group ) . '
83 79 ' . $num_networks_checked_in_group . '
84 80 ' . $this->num_networks_in_group( $group ) . '
@@ -99,9 +95,9 @@
99 95 <tr>
100 96 <th class="checkbox_head"> &nbsp; </th>
101 97 <th class="networks_head">' . __( 'Network', 'datafeedr-api' ) . '</th>
102 98 <th class="type_head">' . __( 'Type', 'datafeedr-api' ) . '</th>
103 - <th class="aid_head">' . __( 'Affiliate ID', 'datafeedr-api' ) . ' <a href="' . $this->map_link( $group_name ) . '" target="_blank" title="' . __( '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>
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>
104 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>
105 101 </tr>
106 102 </thead>
107 103 <tbody>
@@ -149,26 +145,27 @@
149 145 }
150 146
151 147 if ( $network['group'] == $group_name ) {
152 148
153 - $aid = ( isset( $this->options['ids'][ $network['_id'] ]['aid'] ) ) ? $this->options['ids'][ $network['_id'] ]['aid'] : '';
154 - $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'] );
155 152
156 153 $html .= '
157 - <tr
158 - class="network ' . $no_products . $alternate . '"
159 - id="network_id_' . $network['_id'] . '"
160 - nid="' . $network['_id'] . '"
161 - key="' . $this->key . '"
162 - 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 . '"
163 160 tid="' . $tid . '"
164 161 >
165 162 <td class="network_checkbox">
166 - <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 . ' />
167 164 </td>
168 165 <td class="network_name">
169 - <label for="nid_' . $network['_id'] . '">
170 - ' . $network['name'] . '
166 + <label for="nid_' . $nid . '">
167 + ' . esc_html( $network['name'] ) . '
171 168 <div class="network_info">
172 169 <span class="num_merchants">' . number_format( $network['merchant_count'] ) . ' ' . __( 'merchants', 'datafeedr-api' ) . ' <span class="sep">/</span>
173 170 <span class="num_products">' . number_format( $network['product_count'] ) . ' ' . $type . '</span>
174 171 </div>
@@ -194,13 +191,13 @@
194 191 } elseif ( $network['group_id'] == 10045 && is_wp_error( dfrapi_get_adservice_mid() ) ) {
195 192 $url = admin_url( 'admin.php?page=dfrapi' );
196 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>';
197 194 } else {
198 - $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>';
199 196 }
200 197
201 198 if ( apply_filters( 'dfrapi_network_supports_tracking_id', true, $network ) ) {
202 - $html .= '<td class="tid_input"><input type="text" name="dfrapi_networks[ids][' . $network['_id'] . '][tid]" value="' . $tid . '" class="tid_input_field" /></td>';
199 + $html .= '<td class="tid_input"><input type="text" name="dfrapi_networks[ids][' . $nid . '][tid]" value="' . $tid . '" class="tid_input_field" /></td>';
203 200 } else {
204 201 $html .= '<td class="tid_input"><small>n/a</small></td>';
205 202 }
206 203
@@ -396,18 +393,9 @@
396 393 return $links[ $name ] ?? ( DFRAPI_DOCS_SEARCH_URL . sanitize_title( $name ) );
397 394 }
398 395
399 396 function validate( $input ) {
400 - $new_input['ids'] = array();
401 - if ( isset( $input['ids'] ) ) {
402 - foreach ( $input['ids'] as $k => $v ) {
403 - if ( isset( $v['nid'] ) ) {
404 - $new_input['ids'][ $k ] = $v;
405 - }
406 - }
407 - }
408 -
409 - return $new_input;
397 + return dfrapi_sanitize_networks_option( $input );
410 398 }
411 399
412 400 } // class Dfrapi_Networks
413 401