PluginProbe
WPGet API – Connect to any external REST API / 1.4.6
WPGet API – Connect to any external REST API v1.4.6
1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.3 2.1.4 2.1.5 2.2.0 2.2.1 2.2.10 2.2.2 2.2.3 All 97 releases
← All changes | includes/class-admin-options.php +99 -248 1.9.91.4.6 View file →
@@ -45,14 +45,8 @@
45 45 */
46 46 public $options_pages = array();
47 47
48 48 /**
49 - * Is pro plugin installed
50 - * @var array
51 - */
52 - public $pro_plugin = false;
53 -
54 - /**
55 49 * Holds an instance of the object
56 50 *
57 51 * @var Myprefix_Admin
58 52 **/
@@ -65,9 +59,8 @@
65 59 private function __construct() {
66 60 // Set our title
67 61 $this->menu_title = __( 'WPGetAPI', 'wpgetapi' );
68 62 $this->title = __( 'WPGetAPI', 'wpgetapi' );
69 -
70 63 }
71 64
72 65 /**
73 66 * Returns the running object
@@ -91,17 +84,11 @@
91 84 add_action( 'admin_menu', array( $this, 'add_options_pages' ) );
92 85
93 86 add_action( 'cmb2_admin_init', array( $this, 'init_custom_fields' ) );
94 87
95 - add_action( "cmb2_save_options-page_fields", array( $this, 'redirect' ), 1, 2 );
96 -
97 - add_action( 'admin_footer', array( $this, 'load_testing_javascript' ) );
98 -
99 - add_action( 'wp_ajax_wpgetapi_test_endpoint', array( $this, 'test_the_endpoint' ) );
100 -
88 + add_action( "cmb2_save_options-page_fields", array( $this, 'redirect' ), 98, 2 );
101 89 }
102 90
103 -
104 91 /**
105 92 * Setup our custom fields
106 93 * @since 0.1.0
107 94 */
@@ -114,9 +101,8 @@
114 101 * Register our setting to WP
115 102 * @since 0.1.0
116 103 */
117 104 public function init() {
118 - $this->pro_plugin = is_plugin_active( 'wpgetapi-extras/wpgetapi-extras.php' ) ? true : false;
119 105 $option_tabs = self::option_fields();
120 106 foreach ($option_tabs as $index => $option_tab) {
121 107 register_setting( $option_tab['id'], $option_tab['id'] );
122 108 }
@@ -150,9 +136,9 @@
150 136 $option_metabox[] = array(
151 137 'title' => __( 'Setup', 'wpgetapi' ),
152 138 'menu_title' => __( 'Setup', 'wpgetapi' ),
153 139 'id' => 'wpgetapi_setup',
154 - 'desc' => __( 'Add the details of the API(s) you are using. Endpoints will be setup in the next step after hitting save.', 'wpgetapi' ),
140 + 'desc' => __( 'Add the details of each API you are using.', 'wpgetapi' ),
155 141 'show_on' => array( 'key' => 'options-page', 'value' => array( 'wpgetapi_setup' ), ),
156 142 'show_names' => true,
157 143 'fields' => $this->setup_fields(),
158 144 );
@@ -175,9 +161,9 @@
175 161 'id' => $metabox_id,
176 162 'desc' => '',
177 163 'show_on' => array( 'key' => 'options-page', 'value' => array( $metabox_id ), ),
178 164 'show_names' => true,
179 - 'fields' => $this->endpoint_fields( $type, $api_id, $base_url ),
165 + 'fields' => $this->api_fields( $type, $api_id, $base_url ),
180 166 );
181 167
182 168 }
183 169
@@ -203,9 +189,9 @@
203 189 'sortable' => true, // beta
204 190 ),
205 191 'fields' => array(
206 192 array(
207 - 'name' => __( 'API Name', 'wpgetapi' ) . '<span class="dashicons dashicons-editor-help" data-tip="' . __( 'The name of this API. Call it whatever you like.', 'wpgetapi' ) . '"></span>',
193 + 'name' => __( 'API Name', 'wpgetapi' ),
208 194 'id' => 'name',
209 195 'type' => 'text',
210 196 'attributes' => array(
211 197 'required' => true,
@@ -210,12 +196,12 @@
210 196 'attributes' => array(
211 197 'required' => true,
212 198 'placeholder' => 'Google Maps',
213 199 ),
214 - 'desc' => '',
200 + 'desc' => __( 'The name of the API you are connecting to.', 'wpgetapi' ),
215 201 ),
216 202 array(
217 - 'name' => __( 'Unique ID', 'wpgetapi' ) . '<span class="dashicons dashicons-editor-help" data-tip="' . __( 'Choose your own unique ID for this API. Use lowercase letters and underscores only!', 'wpgetapi' ) . '"></span>',
203 + 'name' => __( 'Unique ID', 'wpgetapi' ),
218 204 'id' => 'id',
219 205 'type' => 'text',
220 206 'attributes' => array(
221 207 'required' => true,
@@ -220,19 +206,19 @@
220 206 'attributes' => array(
221 207 'required' => true,
222 208 'placeholder' => 'google_maps',
223 209 ),
224 - 'desc' => '',
210 + 'desc' => __( 'A unique ID for your API.', 'wpgetapi' ),
225 211 ),
226 212 array(
227 - 'name' => __( 'Base URL', 'wpgetapi' ) . '<span class="dashicons dashicons-editor-help" data-tip="' . __( 'The base URL of the API you are connecting to.', 'wpgetapi' ) . '"></span>',
213 + 'name' => __( 'Base URL', 'wpgetapi' ),
228 214 'id' => 'base_url',
229 215 'type' => 'text',
230 216 'attributes' => array(
231 217 'required' => true,
232 - 'placeholder' => 'https://maps.googleapis.com/maps/api',
218 + 'placeholder' => 'http://maps.googleapis.com/maps/api',
233 219 ),
234 - 'desc' => '',
220 + 'desc' => __( 'The base URL of the API you are connecting to.', 'wpgetapi' ),
235 221 ),
236 222
237 223 )
238 224 );
@@ -242,22 +228,19 @@
242 228 }
243 229
244 230
245 231 /**
246 - * Endpoint settings.
232 + * Site wide info on the current sale.
247 233 * @return sale info array
248 234 *
249 235 */
250 - public function endpoint_fields( $type = '', $api_id = '', $base_url = '' ) {
236 + public function api_fields( $type = '', $api_id = '', $base_url = '' ) {
251 237
252 238 $fields = array();
253 239
254 - $cache_disabled = $this->pro_plugin ? '' : 'disabled';
255 - $cache_url = $this->pro_plugin ? '<a target="_blank" href="https://wpgetapi.com/docs/caching-api-calls/">Caching Help</a>' : '<a target="_blank" href="https://wpgetapi.com/downloads/pro-plugin/?utm_campaign=Cache Pro Plugin&utm_medium=Admin&utm_source=User">PRO Feature<span class="dashicons dashicons-external"></span></a>';
256 -
257 240 $endpoint_fields = apply_filters( 'wpgetapi_fields_endpoints', array(
258 241 array(
259 - 'name' => __( 'Unique ID', 'wpgetapi' ) . '<span class="dashicons dashicons-editor-help" data-tip="' . __( 'Choose your own unique ID for this endpoint. Use lowercase letters and underscores only!', 'wpgetapi' ) . '"></span>',
242 + 'name' => __( 'Unique ID', 'wpgetapi' ),
260 243 'id' => 'id',
261 244 'type' => 'text',
262 245 'classes' => 'field-id',
263 246 'attributes' => array(
@@ -263,15 +246,18 @@
263 246 'attributes' => array(
264 247 'required' => true,
265 248 'placeholder' => 'new_endpoint',
266 249 ),
267 - 'desc' => '',
268 - 'before_row' => "wpgetapi_output_top_of_endpoint",
269 - 'api_id' => $api_id,
270 -
250 + 'desc' => __( 'A unique ID for this endpoint.', 'wpgetapi' ),
251 + 'before_row' => "
252 + <pre class='functions'>
253 + Template Tag: </span><span>wpgetapi_endpoint( '" . $api_id . "', '<span class='endpoint_id'></span>', array('debug' => false) );</span><br>
254 + Shortcode: <span>[wpgetapi_endpoint api_id='" . $api_id . "' endpoint_id='<span class='endpoint_id'></span>' debug='false']</span>
255 + </pre>
256 + ",
271 257 ),
272 258 array(
273 - 'name' => __( 'Endpoint', 'wpgetapi' ) . '<span class="dashicons dashicons-editor-help" data-tip="' . __( 'This Endpoint will be appended to the Base URL to create the full URL that will be called.', 'wpgetapi' ) . '"></span>',
259 + 'name' => __( 'Endpoint', 'wpgetapi' ),
274 260 'id' => 'endpoint',
275 261 'type' => 'text',
276 262 'classes' => 'field-endpoint',
277 263 'attributes' => array(
@@ -277,12 +263,12 @@
277 263 'attributes' => array(
278 264 'required' => true,
279 265 'placeholder' => '/newendpoint',
280 266 ),
281 - 'desc' => '',
267 + 'desc' => __( 'The endpoint that will be appended to the base URL.', 'wpgetapi' ),
282 268 ),
283 269 array(
284 - 'name' => __( 'Method', 'wpgetapi' ) . '<span class="dashicons dashicons-editor-help" data-tip="' . __( 'The Request Method for this endpoint. If you are displaying data from the API, it will usually be GET. If you are sending to the API, it will usually be POST.', 'wpgetapi' ) . '"></span>',
270 + 'name' => __( 'Method', 'wpgetapi' ),
285 271 'id' => 'method',
286 272 'type' => 'select',
287 273 'classes' => 'field-method',
288 274 'attributes' => array(
@@ -290,23 +276,13 @@
290 276 ),
291 277 'options' => array(
292 278 'GET' => 'GET',
293 279 'POST' => 'POST',
294 - 'PUT' => 'PUT',
295 - 'PATCH' => 'PATCH',
296 - 'DELETE' => 'DELETE',
297 280 ),
298 - 'desc' => '',
281 + 'desc' => __( 'The request method for this endpoint.', 'wpgetapi' ),
299 282 ),
300 -
301 283 array(
302 - 'name' => __( 'Results Format', 'wpgetapi' ) .
303 - '<span class="dashicons dashicons-editor-help" data-tip="' .
304 - sprintf(
305 - __( 'The format that the API data will be returned in. To format the data as HTML, click the link below to learn how. %1s', 'wpgetapi' ),
306 - htmlentities( '<br><a target="_blank" href="https://wpgetapi.com/docs/formatting-json-data/?utm_campaign=Shortcode JSON&utm_medium=Admin&utm_source=User">Format as HTML</a>' )
307 - ) .
308 - '"></span>',
284 + 'name' => __( 'Results Format', 'wpgetapi' ),
309 285 'id' => 'results_format',
310 286 'type' => 'select',
311 287 'classes' => 'field-results-format',
312 288 'attributes' => array(
@@ -312,85 +288,54 @@
312 288 'attributes' => array(
313 289 'required' => true,
314 290 ),
315 291 'options_cb' => 'wpgetapi_results_format_options',
316 - 'desc' => ''
292 + 'desc' => __( 'The format of the results.', 'wpgetapi' ),
317 293 ),
318 -
319 294 array(
320 - 'name' => __( 'Cache Time', 'wpgetapi' ) .
321 - '<span class="dashicons dashicons-editor-help" data-tip="' .
322 - sprintf(
323 - __( 'The time in seconds to cache this request for. %1s', 'wpgetapi' ),
324 - htmlentities( '<br>' . $cache_url )
325 - ) .
326 - '"></span>',
327 - 'id' => 'cache_time',
328 - 'type' => 'text',
329 - 'classes' => 'field-cache-time',
330 - 'attributes' => array(
331 - 'placeholder' => '3600',
332 - $cache_disabled => $cache_disabled,
333 - ),
334 - 'desc' => ''
335 - ),
336 -
337 - array(
338 - 'name' => __( 'Query String', 'wpgetapi' ) .
339 - '<span class="dashicons dashicons-editor-help" data-tip="' .
340 - sprintf(
341 - __( 'Parameters as name/value pairs that will be appended to the URL. The query string is the part of the URL after the question mark, like so: https://yoururl.com<b>?key=value&key3=value3</b> %1s', 'wpgetapi' ),
342 - htmlentities( '<br><a target="_blank" href="https://wpgetapi.com/docs/adding-query-string-parameters/?utm_campaign=Query String&utm_medium=Admin&utm_source=User">More Info</a>' )
343 - ) .
344 - '"></span>',
295 + 'name' => __( 'Query String', 'wpgetapi' ),
345 296 'id' => 'query_parameters',
346 297 'type' => 'parameter',
347 298 'classes' => 'field-query-parameters',
348 299 'repeatable' => true,
349 - 'desc' => ''
300 + 'desc' => sprintf(
301 + __( 'Parameters as name/value pairs that will be appended to the URL. %1s', 'wpgetapi' ),
302 + '<a target="_blank" href="https://wpgetapi.com/docs/adding-query-string-parameters/?utm_campaign=Query String&utm_medium=Admin&utm_source=User">Help <span class="dashicons dashicons-external"></span></a>'
303 + )
350 304 ),
351 305 array(
352 - 'name' => __( 'Headers', 'wpgetapi' ) .
353 - '<span class="dashicons dashicons-editor-help" data-tip="' .
354 - sprintf(
355 - __( 'Parameters as name/value pairs, sent in the Headers. %1s', 'wpgetapi' ),
356 - htmlentities( '<br><a target="_blank" href="https://wpgetapi.com/docs/sending-headers-in-request/?utm_campaign=Headers&utm_medium=Admin&utm_source=User">More Info</a>' )
357 - ) .
358 - '"></span>',
306 + 'name' => __( 'Headers', 'wpgetapi' ),
359 307 'id' => 'header_parameters',
360 308 'type' => 'parameter',
361 309 'classes' => 'field-header-parameters',
362 310 'repeatable' => true,
363 - 'desc' => ''
311 + 'desc' => sprintf(
312 + __( 'Parameters as name/value pairs, sent in the headers. %1s', 'wpgetapi' ),
313 + '<a target="_blank" href="https://wpgetapi.com/docs/sending-headers-in-request/?utm_campaign=Headers&utm_medium=Admin&utm_source=User">Help <span class="dashicons dashicons-external"></span></a>'
314 + )
364 315 ),
365 316 array(
366 - 'name' => __( 'Body POST Fields', 'wpgetapi' ) .
367 - '<span class="dashicons dashicons-editor-help" data-tip="' .
368 - sprintf(
369 - __( 'Parameters as name/value pairs, sent in the Body as POST fields. %1s', 'wpgetapi' ),
370 - htmlentities( '<br><a target="_blank" href="https://wpgetapi.com/docs/sending-post-fields-in-request/?utm_campaign=Body&utm_medium=Admin&utm_source=User">More Info</a>' )
371 - ) .
372 - '"></span>',
317 + 'name' => __( 'Body POST Fields', 'wpgetapi' ),
373 318 'id' => 'body_parameters',
374 319 'type' => 'parameter',
375 320 'classes' => 'field-body-parameters',
376 321 'repeatable' => true,
377 - 'desc' => ''
322 + 'desc' => sprintf(
323 + __( 'Parameters as name/value pairs, sent in the body as POST fields. %1s', 'wpgetapi' ),
324 + '<a target="_blank" href="https://wpgetapi.com/docs/sending-headers-in-request/?utm_campaign=Body&utm_medium=Admin&utm_source=User">Help <span class="dashicons dashicons-external"></span></a>'
325 + )
378 326 ),
379 327 array(
380 - 'name' => __( 'Encode Body', 'wpgetapi' ) . '<span class="dashicons dashicons-editor-help" data-tip="' . __( 'Encoding of the above Body parameters.', 'wpgetapi' ) . '"></span>',
328 + 'name' => __( 'Encode Body', 'wpgetapi' ),
381 329 'id' => 'body_json_encode',
382 330 'type' => 'select',
383 331 'classes' => 'field-body-json-encode',
384 - 'options' => array(
385 - 'false' => __( 'No encoding (raw)', 'wpgetapi' ),
386 - 'true' => __( 'JSON encode', 'wpgetapi' ),
387 - 'url' => __( 'URL encode (x-www-form-urlencoded)', 'wpgetapi' ),
388 - 'base64' => __( 'Base64 encode', 'wpgetapi' ),
389 - 'xml' => __( 'XML format (available in PRO)', 'wpgetapi' ),
390 -
332 + 'options' => array(
333 + 'false' => __( 'No encoding', 'wpgetapi' ),
334 + 'true' => __( 'JSON encode', 'wpgetapi' ),
335 + 'url' => __( 'URL encode', 'wpgetapi' ),
391 336 ),
392 - 'desc' => '',
337 + 'desc' => __( 'Should Body parameters be encoded (if set). ', 'wpgetapi' ),
393 338 ),
394 339 ) );
395 340
396 341
@@ -420,9 +365,9 @@
420 365
421 366 foreach ($option_tabs as $index => $option_tab) {
422 367 if ( $index == 0) {
423 368
424 - $this->options_pages[] = add_menu_page( $this->title, $this->menu_title, 'manage_options', $option_tab['id'], array( $this, 'admin_page_display' ), 'none'
369 + $this->options_pages[] = add_menu_page( $this->title, $this->menu_title, 'manage_options', $option_tab['id'], array( $this, 'admin_page_display' ), 'dashicons-editor-code'
425 370 ); //Link admin menu to first tab
426 371
427 372 add_submenu_page( $option_tabs[0]['id'], $this->menu_title, $option_tab['menu_title'], 'manage_options', $option_tab['id'], array( $this, 'admin_page_display' ) ); //Duplicate menu link for first submenu page
428 373 } else {
@@ -450,15 +395,12 @@
450 395 <div class="wrap wpgetapi">
451 396
452 397 <div class="main_content_cell">
453 398
454 - <h1 class="wp-heading-inline">
455 - <img width="24" height="22" src="<?php echo esc_url( WPGETAPIURL . 'assets/img/wpgetapi-icon.png' ); ?>" /> <?php esc_html_e( $this->title, 'wpgetapi' ) ?> <span class="vnum"><?php echo WPGETAPIVERSION; ?></span>
456 - </h1>
399 + <h1 class="wp-heading-inline"><?php esc_html_e( $this->title, 'wpgetapi' ) ?></h1>
457 400 <!-- Options Page Nav Tabs -->
458 401 <h2 class="nav-tab-wrapper">
459 402 <?php foreach ($option_tabs as $option_tab) :
460 -
461 403 $tab_slug = $option_tab['id'];
462 404 $nav_class = 'nav-tab';
463 405 if ( $tab_slug == $_GET['page'] ) {
464 406 $nav_class .= ' nav-tab-active'; //add active class to current tab
@@ -463,20 +405,17 @@
463 405 if ( $tab_slug == $_GET['page'] ) {
464 406 $nav_class .= ' nav-tab-active'; //add active class to current tab
465 407 $tab_forms[] = $option_tab; //add current tab to forms to be rendered
466 408 }
467 -
468 - ?>
469 -
470 - <a class="<?php esc_attr_e( $nav_class ); ?>" href="<?php esc_url( menu_page_url( $tab_slug ) ); ?>"><?php esc_attr_e( $option_tab['menu_title'], 'wpgetapi' ); ?></a>
471 -
409 + ?>
410 + <a class="<?php esc_attr_e( $nav_class ); ?>" href="<?php esc_url( menu_page_url( $tab_slug ) ); ?>"><?php esc_attr_e( $option_tab['menu_title'], 'wpgetapi' ); ?></a>
472 411 <?php endforeach; ?>
473 412 </h2>
474 413 <!-- End of Nav Tabs -->
475 414
476 - <?php
477 - //render all tab forms (normaly just 1 form)
478 - foreach ($tab_forms as $tab_form) : ?>
415 + <?php foreach ($tab_forms as $tab_form) : //render all tab forms (normaly just 1 form)
416 +
417 + ?>
479 418
480 419 <div id="<?php esc_attr_e($tab_form['id']); ?>" class="cmb-form group">
481 420 <div class="metabox-holder">
482 421 <div class="pmpbox pad">
@@ -481,9 +420,9 @@
481 420 <div class="metabox-holder">
482 421 <div class="pmpbox pad">
483 422 <h3 class="title"><?php esc_html_e($tab_form['title'], 'wpgetapi'); ?></h3>
484 423 <div class="desc"><?php echo wp_kses_post( $tab_form['desc'] ); ?></div>
485 - <?php cmb2_metabox_form( $tab_form, $tab_form['id'], $tab_form ); ?>
424 + <?php cmb2_metabox_form( $tab_form, $tab_form['id'] ); ?>
486 425 </div>
487 426 </div>
488 427 </div>
489 428
@@ -506,74 +445,8 @@
506 445
507 446 }
508 447
509 448
510 - public function test_the_endpoint() {
511 -
512 - $api_id = sanitize_text_field( $_POST['api_id'] );
513 - $endpoint_id = sanitize_text_field( $_POST['endpoint_id'] );
514 - $data = wpgetapi_endpoint( $api_id, $endpoint_id, array( 'test_endpoint' => true ) );
515 -
516 - $output = array(
517 - 'data' => $data,
518 - 'endpoint_id' => $endpoint_id
519 - );
520 - echo json_encode( $output );
521 -
522 - wp_die(); // this is required to terminate immediately and return a proper response
523 -
524 - }
525 -
526 -
527 - public function load_testing_javascript() { ?>
528 -
529 - <script type="text/javascript" >
530 -
531 - jQuery(document).ready(function($) {
532 -
533 - $('body').on( 'click', '.wpgetapi-test-area .test-button', function(){//delegated
534 -
535 - var $this = $(this);
536 - var area = $this.parents( '.wpgetapi-test-area' );
537 - var api_id = $( area ).data( 'api' );
538 - var endpoint_id = $( area ).data( 'endpoint' );
539 -
540 - // disable button
541 - $this.attr( 'disabled', true );
542 -
543 - var data = {
544 - 'action': 'wpgetapi_test_endpoint',
545 - 'api_id': api_id,
546 - 'endpoint_id': endpoint_id
547 - };
548 -
549 - // send and get response
550 - jQuery.post(ajaxurl, data, function( response ) {
551 -
552 - var output = JSON.parse( response );
553 -
554 - jQuery( '.wpgetapi-test-area[data-endpoint="' + output.endpoint_id + '"] .handle' ).show();
555 -
556 - jQuery( '.wpgetapi-test-area[data-endpoint="' + output.endpoint_id + '"] .wpgetapi-result' ).html( output.data);
557 -
558 - // enable button
559 - $( '.wpgetapi-test-area[data-endpoint="' + output.endpoint_id + '"] .test-button' ).attr( 'disabled', false );
560 -
561 - });
562 -
563 - });
564 -
565 - $( '.wpgetapi-test-area .handle' ).on('click', function() {
566 - $('.wpgetapi-result').toggle();
567 - });
568 -
569 - });
570 -
571 - </script> <?php
572 -
573 - }
574 -
575 -
576 449 /**
577 450 * Sidebar markup.
578 451 * @since 1.4.1
579 452 */
@@ -587,43 +460,41 @@
587 460
588 461 ?>
589 462
590 463 <div class="box">
591 - <strong><?php esc_html_e( 'Endpoint Instructions', 'wpgetapi' ); ?></strong>
464 + <h3><?php esc_html_e( 'Endpoint Instructions', 'wpgetapi' ); ?></h3>
592 465 <ol>
593 - <li><?php _e( 'Give your endpoint a <b>Unique ID</b>', 'wpgetapi' ); ?></li>
594 - <li><?php _e( 'Add the <b>Endpoint</b> which can be found in your API docs', 'wpgetapi' ); ?></li>
595 - <li><?php _e( 'Set the <b>Method</b> - GET for getting data & POST for sending data to the API', 'wpgetapi' ); ?></li>
596 - <li><?php _e( 'Set the desired <b>Results Format</b>', 'wpgetapi' ); ?></li>
597 - <li><?php _e( 'Other fields are optional & will depend on your API', 'wpgetapi' ); ?></li>
598 - <li><?php _e( 'Hit the Save button', 'wpgetapi' ); ?></li>
599 - <li><?php _e( 'Copy the Template Tag or Shortcode & paste into page, post or theme file', 'wpgetapi' ); ?></li>
466 + <li><?php esc_html_e( 'Fill in the Unique ID and Endpoint.', 'wpgetapi' ); ?></li>
467 + <li><?php esc_html_e( 'Set the Method.', 'wpgetapi' ); ?></li>
468 + <li><?php esc_html_e( 'Set the desired Results Format.', 'wpgetapi' ); ?></li>
469 + <li><?php esc_html_e( 'The rest of the fields are optional and will depend on the API you using.', 'wpgetapi' ); ?></li>
470 + <li><?php esc_html_e( 'Hit the Save button.', 'wpgetapi' ); ?></li>
471 + <li><?php esc_html_e( 'After saving, copy the Template Tag or the Shortcode and paste into appropriate place.', 'wpgetapi' ); ?></li>
600 472 </ol>
601 473 </div>
602 -
603 - <hr>
474 +
475 + <hr>
476 +
477 + <div class="box">
478 + <strong><?php esc_html_e( 'Notes', 'wpgetapi' ); ?></strong>
479 + <ul>
480 + <li><?php esc_html_e( 'The Unique ID can be whatever you like. This is used to identify each endpoint within the plugin.', 'wpgetapi' ); ?></li>
481 + <li><?php esc_html_e( 'The Endpoint can be found in the documentation of your API.', 'wpgetapi' ); ?></li>
482 + </ul>
483 + </div>
604 484
485 + <hr>
486 +
605 487 <div class="box">
606 488 <strong><?php esc_html_e( 'Getting Help', 'wpgetapi' ); ?></strong>
607 489 <ul>
608 - <li><?php
490 + <li><?php
609 491 printf(
610 - esc_html__( 'View the %1$s', 'cmb2' ),
611 - '<a target="_blank" href="https://wpgetapi.com/docs/quick-start-guide/?utm_campaign=Docs&utm_medium=Admin&utm_source=User">Quick Start Guide</a>'
492 + esc_html__( 'Visit our website for guides on %1$s or %2$s.', 'cmb2' ),
493 + '<a target="_blank" href="https://wpgetapi.com/docs/using-the-shortcode/?utm_campaign=Shortcode&utm_medium=Admin&utm_source=User">Using the Shortcode</a>',
494 + '<a target="_blank" href="https://wpgetapi.com/docs/using-the-template-function/?utm_campaign=Template Tag&utm_medium=Admin&utm_source=User">Template Tag</a>'
612 495 );
613 496 ?></li>
614 - <li><?php
615 - printf(
616 - esc_html__( 'View the %1$s', 'cmb2' ),
617 - '<a target="_blank" href="https://wpgetapi.com/docs/frequently-asked-questions/?utm_campaign=Docs&utm_medium=Admin&utm_source=User">FAQs</a>'
618 - );
619 - ?></li>
620 - <li><?php
621 - printf(
622 - esc_html__( 'Do more with the %1$s', 'cmb2' ),
623 - '<a target="_blank" href="https://wpgetapi.com/downloads/pro-plugin/?utm_campaign=Pro&utm_medium=Admin&utm_source=User">PRO Plugin</a>'
624 - );
625 - ?></li>
626 497 </ul>
627 498 </div>
628 499
629 500 <?php
@@ -643,41 +514,38 @@
643 514 ob_start();
644 515 ?>
645 516
646 517 <div class="box">
647 - <strong><?php esc_html_e( 'Setup Instructions', 'wpgetapi' ); ?></strong>
518 + <h3><?php esc_html_e( 'Setup Instructions', 'wpgetapi' ); ?></h3>
648 519 <ol>
649 - <li><?php _e( 'Name your API in the <b>API Name</b> field', 'wpgetapi' ); ?></li>
650 - <li><?php _e( 'Give your API a <b>Unique ID</b>', 'wpgetapi' ); ?></li>
651 - <li><?php _e( 'Add the <b>Base URL</b> of your API. This can be found in the docs of your API', 'wpgetapi' ); ?></li>
652 - <li><?php _e( 'Hit the Save button', 'wpgetapi' ); ?></li>
653 - <li><?php _e( 'Visit the new tab that will be created', 'wpgetapi' ); ?></li>
520 + <li><?php esc_html_e( 'Fill in the API Name, Unique ID and Base URL of your API.', 'wpgetapi' ); ?></li>
521 + <li><?php esc_html_e( 'Hit the Save button.', 'wpgetapi' ); ?></li>
522 + <li><?php esc_html_e( 'After saving, visit the new tab that will be created.', 'wpgetapi' ); ?></li>
654 523 </ol>
655 524 </div>
656 525
657 526 <hr>
527 +
528 + <div class="box">
529 + <strong><?php esc_html_e( 'Notes', 'wpgetapi' ); ?></strong>
530 + <ul>
531 + <li><?php esc_html_e( 'The API Name and Unique ID can be whatever you like. These are used to identify each API within the plugin.', 'wpgetapi' ); ?></li>
532 + <li><?php esc_html_e( 'The Base URL can be found in the documentation of your API.', 'wpgetapi' ); ?></li>
533 + </ul>
534 + </div>
658 535
536 + <hr>
537 +
659 538 <div class="box">
660 539 <strong><?php esc_html_e( 'Getting Help', 'wpgetapi' ); ?></strong>
661 540 <ul>
662 - <li><?php
541 + <li><?php
663 542 printf(
664 - esc_html__( 'View the %1$s', 'cmb2' ),
665 - '<a target="_blank" href="https://wpgetapi.com/docs/quick-start-guide/?utm_campaign=Docs&utm_medium=Admin&utm_source=User">Quick Start Guide</a>'
543 + esc_html__( 'Visit our website to view %1$s or %2$s.', 'cmb2' ),
544 + '<a target="_blank" href="https://wpgetapi.com/docs/quick-start-guide/?utm_campaign=Quick Start&utm_medium=Admin&utm_source=User">Quick Start Guide</a>',
545 + '<a target="_blank" href="https://wpgetapi.com/docs/step-by-step-example/?utm_campaign=Step by Step&utm_medium=Admin&utm_source=User">Step by Step Example</a>'
666 546 );
667 547 ?></li>
668 - <li><?php
669 - printf(
670 - esc_html__( 'View the %1$s', 'cmb2' ),
671 - '<a target="_blank" href="https://wpgetapi.com/docs/frequently-asked-questions/?utm_campaign=Docs&utm_medium=Admin&utm_source=User">FAQs</a>'
672 - );
673 - ?></li>
674 - <li><?php
675 - printf(
676 - esc_html__( 'Do more with the %1$s', 'cmb2' ),
677 - '<a target="_blank" href="https://wpgetapi.com/downloads/pro-plugin/?utm_campaign=Pro&utm_medium=Admin&utm_source=User">PRO Plugin</a>'
678 - );
679 - ?></li>
680 548 </ul>
681 549 </div>
682 550
683 551 <?php
@@ -686,36 +554,19 @@
686 554 return $content;
687 555
688 556 }
689 557
690 -
691 558 /**
692 559 * Tabs don't immmediately appear on save, so this hack!
693 560 * @since 0.1.0
694 561 */
695 562 public function redirect( $object_id, $updated ) {
696 -
697 563 if( $object_id == 'wpgetapi_setup' ) {
698 -
699 - add_settings_error( 'wpgetapi-notices', '', 'Saved, reloading page...', 'updated' );
564 + add_settings_error( 'wpgetapi-notices', '', 'Settings saved.', 'updated' );
700 565 settings_errors( 'wpgetapi-notices' );
701 - ?>
702 -
703 - <script>
704 - setTimeout(function() {
705 - location.reload();
706 - }, 1000);
707 - </script>
708 - <?php
709 -
710 - } else if ( strpos( $object_id, 'wpgetapi_' ) !== false ) {
711 -
712 - $text = apply_filters( 'wpgetapi_admin_notice_text', __( 'Saved.', 'wpgetapi' ), $object_id );
713 - add_settings_error( 'wpgetapi-notices', '', $text, 'updated' );
714 - settings_errors( 'wpgetapi-notices' );
715 -
566 + wp_redirect( admin_url( 'admin.php?page=' . $object_id ) );
567 + exit;
716 568 }
717 -
718 569 }
719 570
720 571
721 572 /**