PluginProbe
Datafeedr API / 1.1.2
Datafeedr API v1.1.2
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 1.0.33 All 181 releases
datafeedr-api / functions / admin-functions.php

admin-functions.php in Datafeedr API 1.1.2, at functions/admin-functions.php

235 lines 9.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Load AJAX related functions.
5 */
6 require_once( DFRAPI_PATH . 'functions/ajax.php' );
7
8 /**
9 * These are the Admin pages associated with the Datafeedr API plugin.
10 *
11 * These are called from their respecitive classes.
12 */
13 function dfrapi_setting_pages( $key=false ) {
14
15 $pages = array (
16 'dfrapi-configuration' => __( 'Configuration', DFRAPI_DOMAIN ),
17 'dfrapi-networks' => __( 'Networks', DFRAPI_DOMAIN ),
18 'dfrapi-merchants' => __( 'Merchants', DFRAPI_DOMAIN ),
19 'dfrapi-tools' => __( 'Tools', DFRAPI_DOMAIN ),
20 'dfrapi-export' => __( 'Export', DFRAPI_DOMAIN ),
21 'dfrapi-import' => __( 'Import', DFRAPI_DOMAIN ),
22 'dfrapi-account' => __( 'Account', DFRAPI_DOMAIN ),
23 );
24
25 if ( isset( $pages[$key] ) ) {
26 return $pages[$key];
27 }
28
29 }
30
31 /**
32 * This stores messages to be displayed using the 'admin_notices' action.
33 */
34 function dfrapi_admin_messages( $key = false, $msg = '' ) {
35
36 $messages = array(
37
38 // User is missing 1 or more of their API Keys.
39 'missing_api_keys' => array(
40 'class' => 'notice notice-warning',
41 'message' => __( 'Your Datafeedr API Keys are missing. ', DFRAPI_DOMAIN ),
42 'url' => 'admin.php?page=dfrapi',
43 'button_text' => __( 'Add API Keys', DFRAPI_DOMAIN )
44 ),
45
46 // User is missing a network
47 'missing_network_ids' => array(
48 'class' => 'notice notice-warning',
49 'message' => __( 'You haven\'t selected any affiliate networks yet.', DFRAPI_DOMAIN ),
50 'url' => 'admin.php?page=dfrapi_networks',
51 'button_text' => __( 'Select Networks', DFRAPI_DOMAIN )
52 ),
53
54 // User is missing a merchant
55 'missing_merchant_ids' => array(
56 'class' => 'notice notice-warning',
57 'message' => __( 'You haven\'t selected any merchants yet.', DFRAPI_DOMAIN ),
58 'url' => 'admin.php?page=dfrapi_merchants',
59 'button_text' => __( 'Select Merchants', DFRAPI_DOMAIN )
60 ),
61
62 // Display message that user has used 90%+ of API requests.
63 'usage_over_90_percent' => array(
64 'class' => 'notice notice-warning',
65 'message' => __( 'You have used ', DFRAPI_DOMAIN ) . dfrapi_get_api_usage_percentage() . __( '% of your total Datafeedr API requests this month. ', DFRAPI_DOMAIN ),
66 'url' => 'admin.php?page=dfrapi_account',
67 'button_text' => __( 'View Account', DFRAPI_DOMAIN )
68 ),
69
70 // Missing affiliate IDs message.
71 'missing_affiliate_ids' => array(
72 'class' => 'notice notice-warning',
73 'message' => __( 'You are missing affiliate IDs. ', DFRAPI_DOMAIN ),
74 'url' => 'admin.php?page=dfrapi_networks',
75 'button_text' => __( 'Enter your Affiliate IDs', DFRAPI_DOMAIN )
76 ),
77
78 // Unapproved Zanox merchant(s) message.
79 'unapproved_zanox_merchants' => array(
80 'class' => 'notice notice-error',
81 'message' => '<strong>' . __( 'Unapproved Zanox Merchant(s):', DFRAPI_DOMAIN ) . '</strong> ' .
82 __( 'You have selected one or more Zanox merchants who have not approved your Adspace ID(s):<br />', DFRAPI_DOMAIN ) .
83 $msg . '<br /><br />' .
84 __( 'Please remove unapproved Zanox merchants from your ', DFRAPI_DOMAIN ) .
85 '<a href="' . admin_url( 'admin.php?page=dfrapi_merchants' ) . '" target="_blank">' .
86 __( 'Zanox merchant selection', DFRAPI_DOMAIN ) .
87 '</a>' .
88 __( ' then delete your cached API data ', DFRAPI_DOMAIN ) .
89 '<a href="' . admin_url( 'admin.php?page=dfrapi_tools' ) . '" target="_blank">' .
90 __( 'here', DFRAPI_DOMAIN ) .
91 '</a>.',
92 'url' => '',
93 'button_text' => __( '', DFRAPI_DOMAIN )
94 ),
95
96 // Unapproved Partnerize merchant(s) message.
97 'unapproved_ph_merchants' => array(
98 'class' => 'notice notice-error',
99 'message' => '<strong>' . __( 'Unapproved Partnerize Merchant(s):', DFRAPI_DOMAIN ) . '</strong> ' .
100 __( 'You have selected one or more Partnerize merchants who have not approved your publisher account:<br />',
101 DFRAPI_DOMAIN ) .
102 $msg . '<br /><br />' .
103 __( 'Please remove unapproved Partnerize merchants from your ', DFRAPI_DOMAIN ) .
104 '<a href="' . admin_url( 'admin.php?page=dfrapi_merchants' ) . '" target="_blank">' .
105 __( 'Partnerize merchant selection', DFRAPI_DOMAIN ) .
106 '</a>' .
107 __( ' then delete your cached API data ', DFRAPI_DOMAIN ) .
108 '<a href="' . admin_url( 'admin.php?page=dfrapi_tools' ) . '" target="_blank">' .
109 __( 'here', DFRAPI_DOMAIN ) .
110 '</a>.',
111 'url' => '',
112 'button_text' => __( '', DFRAPI_DOMAIN )
113 ),
114
115 // Unapproved Effiliation merchant(s) message.
116 'unapproved_effiliation_merchants' => array(
117 'class' => 'notice notice-error',
118 'message' => '<strong>' . __( 'Unapproved Effiliation Merchant(s):', DFRAPI_DOMAIN ) . '</strong> ' .
119 __( 'You have selected one or more Effiliation merchants who have not approved your publisher account:<br />',
120 DFRAPI_DOMAIN ) .
121 $msg . '<br /><br />' .
122 __( 'Please remove unapproved Effiliation merchants from your ', DFRAPI_DOMAIN ) .
123 '<a href="' . admin_url( 'admin.php?page=dfrapi_merchants' ) . '" target="_blank">' .
124 __( 'Effiliation merchant selection', DFRAPI_DOMAIN ) .
125 '</a>' .
126 __( ' then delete your cached API data ', DFRAPI_DOMAIN ) .
127 '<a href="' . admin_url( 'admin.php?page=dfrapi_tools' ) . '" target="_blank">' .
128 __( 'here', DFRAPI_DOMAIN ) .
129 '</a>.',
130 'url' => '',
131 'button_text' => __( '', DFRAPI_DOMAIN )
132 ),
133
134 );
135
136 if ( isset( $messages[$key] ) ) {
137 dfrapi_admin_notices( $key, $messages );
138 }
139
140 }
141
142 /**
143 * This gets any notices set by the plugin.
144 */
145 function dfrapi_admin_notices( $key, $messages ) {
146 $notices = get_option( 'dfrapi_admin_notices', array() );
147 $notices[$key] = $messages[$key];
148 update_option( 'dfrapi_admin_notices', $notices );
149 }
150
151 /**
152 * Button text for admin notices.
153 */
154 function dfrapi_fix_button( $url, $button_text=false ) {
155 if ( !$button_text ) {
156 $button_text = __( 'Fix This Now', DFRAPI_DOMAIN );
157 }
158 if ( substr( $url, 0, 4 ) === "http" ) {
159 return ' <a target="blank" href="' . $url . '">' .$button_text . '</a>';
160 } else {
161 return ' <a href="' . admin_url( $url ) . '">' .$button_text . '</a>';
162 }
163 }
164
165 /**
166 * Return plan IDs & names.
167 */
168 function dfrapi_get_membership_plans() {
169 return array(
170 10300 => 'Private',
171 10200 => 'Free',
172 101000 => 'Starter',
173 1025000 => 'Basic',
174 1125000 => 'Beta Tester',
175 10100000 => 'Professional',
176 10250000 => 'Enterprise',
177 30001 => 'Combo 1',
178 30002 => 'Combo 2',
179 30003 => 'Combo 3',
180 );
181 }
182
183 /**
184 * Convert network group names to a css class name.
185 */
186 function dfrapi_group_name_to_css( $group ) {
187 if ( is_string( $group ) ) {
188 return strtolower(
189 str_replace(
190 array( " ", "-", "." ),
191 "",
192 $group
193 )
194 );
195 } elseif ( is_array( $group ) ) {
196 $name = str_replace( array( " ", "-", "." ), "", $group['group'] );
197 $type = ( $group['type'] == 'coupons' ) ? '_coupons' : '';
198 return strtolower( $name . $type );
199 }
200 }
201
202 /**
203 * Adds global "support" content to "Help" tabs for all Datafeedr plugins.
204 */
205 function dfrapi_help_tab( $screen ) {
206
207 $screen->add_help_tab( array(
208 'id' => 'dfrapi_support_tab',
209 'title' => __( 'Support', DFRAPI_DOMAIN ),
210 'content' =>
211 '<h2>' . __( "Datafeedr Support", DFRAPI_DOMAIN ) . '</h2>' .
212 '<p>' . sprintf(__( 'Find answers to common questions and problems in the <a href="%s?utm_source=plugin&utm_medium=link&utm_campaign=helptab" target="_blank">documentation</a> and in the <a href="%s?utm_source=plugin&utm_medium=link&utm_campaign=helptab" target="_blank">support forum</a>', DFRAPI_DOMAIN ), DFRAPI_DOCS_URL, DFRAPI_QNA_URL ) . '. ' . __( 'For additional help, feel free to contact us using the links below.', DFRAPI_DOMAIN ) . '</p>' .
213 '<p><a href="' . DFRAPI_ASK_QUESTION_URL . '?utm_source=plugin&utm_medium=link&utm_campaign=helptab" class="button button-primary" target="_blank">' . __( 'Post a Question', DFRAPI_DOMAIN ) . '</a> (' . __( 'recommended', DFRAPI_DOMAIN ) . ')</p>' .
214 '<p><a href="' . DFRAPI_EMAIL_US_URL . '?utm_source=plugin&utm_medium=link&utm_campaign=helptab" class="button" target="_blank">' . __( 'Email Us', DFRAPI_DOMAIN ) . '</a></p>'
215
216 ) );
217
218 $screen->add_help_tab( array(
219 'id' => 'dfrapi_bug_tab',
220 'title' => __( 'Found a bug?', DFRAPI_DOMAIN ),
221 'content' =>
222 '<h2>' . __( "Found a bug?", DFRAPI_DOMAIN ) . '</h2>' .
223 '<p>' . sprintf( __( 'If you find a bug within Datafeedr, check the <a href="%s?utm_source=plugin&utm_medium=link&utm_campaign=helptab" target="_blank">Bug Reports</a> to see if it’s already been reported. Report a new bug with as much description as possible (context, screenshots, error log, etc.) Thank you!', DFRAPI_DOMAIN ), DFRAPI_BUG_REPORTS_URL ) . '</p>' .
224 '<p><a href="' . DFRAPI_REPORT_BUG_URL . '?utm_source=plugin&utm_medium=link&utm_campaign=helptab" class="button button-primary" target="_blank">' . __( 'Report a bug', DFRAPI_DOMAIN ) . '</a></p>'
225
226 ) );
227
228 $screen->set_help_sidebar(
229 '<p><strong>' . __( 'For more information:', DFRAPI_DOMAIN ) . '</strong></p>' .
230 '<p><a href="' . DFRAPI_HOME_URL . '?utm_source=plugin&utm_medium=link&utm_campaign=helptab" target="_blank">' . __( 'About Datafeedr', DFRAPI_DOMAIN ) . '</a></p>' .
231 '<p><a href="' . DFRAPI_KEYS_URL . '?utm_source=plugin&utm_medium=link&utm_campaign=helptab" target="_blank">' . __( 'Datafeedr API Keys', DFRAPI_DOMAIN ) . '</a></p>'
232 );
233
234 return $screen;
235 }