PluginProbe
Datafeedr API / 1.0.14
Datafeedr API v1.0.14
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
datafeedr-api / functions / admin-functions.php

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

178 lines 6.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * These are the Admin pages associated with the Datafeedr API plugin.
5 *
6 * These are called from their respecitive classes.
7 */
8 function dfrapi_setting_pages( $key=false ) {
9
10 $pages = array (
11 'dfrapi-configuration' => __( 'Configuration', DFRAPI_DOMAIN ),
12 'dfrapi-networks' => __( 'Networks', DFRAPI_DOMAIN ),
13 'dfrapi-merchants' => __( 'Merchants', DFRAPI_DOMAIN ),
14 'dfrapi-tools' => __( 'Tools', DFRAPI_DOMAIN ),
15 'dfrapi-export' => __( 'Export', DFRAPI_DOMAIN ),
16 'dfrapi-import' => __( 'Import', DFRAPI_DOMAIN ),
17 'dfrapi-account' => __( 'Account', DFRAPI_DOMAIN ),
18 );
19
20 if ( isset( $pages[$key] ) ) {
21 return $pages[$key];
22 }
23
24 }
25
26 /**
27 * This stores messages to be displayed using the
28 * 'admin_notices' action.
29 */
30 function dfrapi_admin_messages( $key=false ) {
31
32 $messages = array(
33
34 // User is missing 1 or more of their API Keys.
35 'missing_api_keys' => array(
36 'class' => 'update-nag',
37 'message' => __( 'Your Datafeedr API Keys are missing.', DFRAPI_DOMAIN ),
38 'url' => 'admin.php?page=dfrapi',
39 'button_text' => __( 'Add Your API Keys', DFRAPI_DOMAIN )
40 ),
41
42 // User is missing a network
43 'missing_network_ids' => array(
44 'class' => 'update-nag',
45 'message' => __( 'You haven\'t selected any affiliate networks yet.', DFRAPI_DOMAIN ),
46 'url' => 'admin.php?page=dfrapi_networks',
47 'button_text' => __( 'Select Networks', DFRAPI_DOMAIN )
48 ),
49
50 // User is missing a merchant
51 'missing_merchant_ids' => array(
52 'class' => 'update-nag',
53 'message' => __( 'You haven\'t selected any merchants yet.', DFRAPI_DOMAIN ),
54 'url' => 'admin.php?page=dfrapi_merchants',
55 'button_text' => __( 'Select Merchants', DFRAPI_DOMAIN )
56 ),
57
58 // Display message that user has used 90%+ of API requests.
59 'usage_over_90_percent' => array(
60 'class' => 'update-nag',
61 'message' => __( 'You have used ', DFRAPI_DOMAIN ) . dfrapi_get_api_usage_percentage() . __( '% of your total Datafeedr API requests this month. ', DFRAPI_DOMAIN ),
62 'url' => 'admin.php?page=dfrapi_account',
63 'button_text' => __( 'View Account', DFRAPI_DOMAIN )
64 ),
65
66 // Missing affiliate IDs message.
67 'missing_affiliate_ids' => array(
68 'class' => 'update-nag',
69 'message' => __( 'You are missing affiliate IDs. ', DFRAPI_DOMAIN ),
70 'url' => 'admin.php?page=dfrapi_networks',
71 'button_text' => __( 'Enter your Affiliate IDs', DFRAPI_DOMAIN )
72 ),
73
74 // Missing affiliate IDs message.
75 'database_rotation' => array(
76 'class' => 'update-nag',
77 'message' => __( '<strong>Datafeedr API Message:</strong> We are currently refreshing our database of 280 million products. This process starts daily at 8:00am GMT and runs for about 20 minutes. During this time you may be unable to query our database.', DFRAPI_DOMAIN ),
78 'url' => '',
79 'button_text' => __( '', DFRAPI_DOMAIN )
80 ),
81 );
82
83 if ( isset( $messages[$key] ) ) {
84 dfrapi_admin_notices( $key, $messages );
85 }
86
87 }
88
89 /**
90 * This gets any notices set by the plugin.
91 */
92 function dfrapi_admin_notices( $key, $messages ) {
93 $notices = get_option( 'dfrapi_admin_notices', array() );
94 $notices[$key] = $messages[$key];
95 update_option( 'dfrapi_admin_notices', $notices );
96 }
97
98 /**
99 * Button text for admin notices.
100 */
101 function dfrapi_fix_button( $url, $button_text=false ) {
102 if ( !$button_text ) {
103 $button_text = __( 'Fix This Now', DFRAPI_DOMAIN );
104 }
105 if ( substr( $url, 0, 4 ) === "http" ) {
106 return ' <a target="blank" href="' . $url . '">' .$button_text . '</a>';
107 } else {
108 return ' <a href="' . admin_url( $url ) . '">' .$button_text . '</a>';
109 }
110 }
111
112 /**
113 * Return plan IDs & names.
114 */
115 function dfrapi_get_membership_plans() {
116 return array(
117 10200 => 'Free',
118 101000 => 'Starter',
119 1025000 => 'Basic',
120 1125000 => 'Beta Tester',
121 10100000 => 'Professional',
122 10250000 => 'Enterprise',
123 );
124 }
125
126 /**
127 * Convert network group names to a css class name.
128 */
129 function dfrapi_group_name_to_css( $group ) {
130 if ( is_string( $group ) ) {
131 return strtolower(
132 str_replace(
133 array( " ", "-", "." ),
134 "",
135 $group
136 )
137 );
138 } elseif ( is_array( $group ) ) {
139 $name = str_replace( array( " ", "-", "." ), "", $group['group'] );
140 $type = ( $group['type'] == 'coupons' ) ? '_coupons' : '';
141 return strtolower( $name . $type );
142 }
143 }
144
145 /**
146 * Adds global "support" content to "Help" tabs for all Datafeedr plugins.
147 */
148 function dfrapi_help_tab( $screen ) {
149
150 $screen->add_help_tab( array(
151 'id' => 'dfrapi_support_tab',
152 'title' => __( 'Support', DFRAPI_DOMAIN ),
153 'content' =>
154 '<h2>' . __( "Datafeedr Support", DFRAPI_DOMAIN ) . '</h2>' .
155 '<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>' .
156 '<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>' .
157 '<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>'
158
159 ) );
160
161 $screen->add_help_tab( array(
162 'id' => 'dfrapi_bug_tab',
163 'title' => __( 'Found a bug?', DFRAPI_DOMAIN ),
164 'content' =>
165 '<h2>' . __( "Found a bug?", DFRAPI_DOMAIN ) . '</h2>' .
166 '<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>' .
167 '<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>'
168
169 ) );
170
171 $screen->set_help_sidebar(
172 '<p><strong>' . __( 'For more information:', DFRAPI_DOMAIN ) . '</strong></p>' .
173 '<p><a href="' . DFRAPI_HOME_URL . '?utm_source=plugin&utm_medium=link&utm_campaign=helptab" target="_blank">' . __( 'About Datafeedr', DFRAPI_DOMAIN ) . '</a></p>' .
174 '<p><a href="' . DFRAPI_HOME_URL . '/keys?utm_source=plugin&utm_medium=link&utm_campaign=helptab" target="_blank">' . __( 'Datafeedr API Keys', DFRAPI_DOMAIN ) . '</a></p>'
175 );
176
177 return $screen;
178 }