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 +98 -244 1.9.41.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,22 +276,13 @@
290 276 ),
291 277 'options' => array(
292 278 'GET' => 'GET',
293 279 'POST' => 'POST',
294 - 'PUT' => 'PUT',
295 - 'DELETE' => 'DELETE',
296 280 ),
297 - 'desc' => '',
281 + 'desc' => __( 'The request method for this endpoint.', 'wpgetapi' ),
298 282 ),
299 -
300 283 array(
301 - 'name' => __( 'Results Format', 'wpgetapi' ) .
302 - '<span class="dashicons dashicons-editor-help" data-tip="' .
303 - sprintf(
304 - __( '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' ),
305 - 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>' )
306 - ) .
307 - '"></span>',
284 + 'name' => __( 'Results Format', 'wpgetapi' ),
308 285 'id' => 'results_format',
309 286 'type' => 'select',
310 287 'classes' => 'field-results-format',
311 288 'attributes' => array(
@@ -311,83 +288,54 @@
311 288 'attributes' => array(
312 289 'required' => true,
313 290 ),
314 291 'options_cb' => 'wpgetapi_results_format_options',
315 - 'desc' => ''
292 + 'desc' => __( 'The format of the results.', 'wpgetapi' ),
316 293 ),
317 -
318 294 array(
319 - 'name' => __( 'Cache Time', 'wpgetapi' ) .
320 - '<span class="dashicons dashicons-editor-help" data-tip="' .
321 - sprintf(
322 - __( 'The time in seconds to cache this request for. %1s', 'wpgetapi' ),
323 - htmlentities( '<br>' . $cache_url )
324 - ) .
325 - '"></span>',
326 - 'id' => 'cache_time',
327 - 'type' => 'text',
328 - 'classes' => 'field-cache-time',
329 - 'attributes' => array(
330 - 'placeholder' => '3600',
331 - $cache_disabled => $cache_disabled,
332 - ),
333 - 'desc' => ''
334 - ),
335 -
336 - array(
337 - 'name' => __( 'Query String', 'wpgetapi' ) .
338 - '<span class="dashicons dashicons-editor-help" data-tip="' .
339 - sprintf(
340 - __( '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' ),
341 - 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>' )
342 - ) .
343 - '"></span>',
295 + 'name' => __( 'Query String', 'wpgetapi' ),
344 296 'id' => 'query_parameters',
345 297 'type' => 'parameter',
346 298 'classes' => 'field-query-parameters',
347 299 'repeatable' => true,
348 - '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 + )
349 304 ),
350 305 array(
351 - 'name' => __( 'Headers', 'wpgetapi' ) .
352 - '<span class="dashicons dashicons-editor-help" data-tip="' .
353 - sprintf(
354 - __( 'Parameters as name/value pairs, sent in the Headers. %1s', 'wpgetapi' ),
355 - 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>' )
356 - ) .
357 - '"></span>',
306 + 'name' => __( 'Headers', 'wpgetapi' ),
358 307 'id' => 'header_parameters',
359 308 'type' => 'parameter',
360 309 'classes' => 'field-header-parameters',
361 310 'repeatable' => true,
362 - '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 + )
363 315 ),
364 316 array(
365 - 'name' => __( 'Body POST Fields', 'wpgetapi' ) .
366 - '<span class="dashicons dashicons-editor-help" data-tip="' .
367 - sprintf(
368 - __( 'Parameters as name/value pairs, sent in the Body as POST fields. %1s', 'wpgetapi' ),
369 - 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>' )
370 - ) .
371 - '"></span>',
317 + 'name' => __( 'Body POST Fields', 'wpgetapi' ),
372 318 'id' => 'body_parameters',
373 319 'type' => 'parameter',
374 320 'classes' => 'field-body-parameters',
375 321 'repeatable' => true,
376 - '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 + )
377 326 ),
378 327 array(
379 - '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' ),
380 329 'id' => 'body_json_encode',
381 330 'type' => 'select',
382 331 'classes' => 'field-body-json-encode',
383 - 'options' => array(
384 - 'false' => __( 'No encoding (raw)', 'wpgetapi' ),
332 + 'options' => array(
333 + 'false' => __( 'No encoding', 'wpgetapi' ),
385 334 'true' => __( 'JSON encode', 'wpgetapi' ),
386 - 'url' => __( 'URL encode (x-www-form-urlencoded)', 'wpgetapi' ),
387 - 'xml' => __( 'XML format (available in PRO only)', 'wpgetapi' ),
335 + 'url' => __( 'URL encode', 'wpgetapi' ),
388 336 ),
389 - 'desc' => '',
337 + 'desc' => __( 'Should Body parameters be encoded (if set). ', 'wpgetapi' ),
390 338 ),
391 339 ) );
392 340
393 341
@@ -417,9 +365,9 @@
417 365
418 366 foreach ($option_tabs as $index => $option_tab) {
419 367 if ( $index == 0) {
420 368
421 - $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'
422 370 ); //Link admin menu to first tab
423 371
424 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
425 373 } else {
@@ -447,15 +395,12 @@
447 395 <div class="wrap wpgetapi">
448 396
449 397 <div class="main_content_cell">
450 398
451 - <h1 class="wp-heading-inline">
452 - <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>
453 - </h1>
399 + <h1 class="wp-heading-inline"><?php esc_html_e( $this->title, 'wpgetapi' ) ?></h1>
454 400 <!-- Options Page Nav Tabs -->
455 401 <h2 class="nav-tab-wrapper">
456 402 <?php foreach ($option_tabs as $option_tab) :
457 -
458 403 $tab_slug = $option_tab['id'];
459 404 $nav_class = 'nav-tab';
460 405 if ( $tab_slug == $_GET['page'] ) {
461 406 $nav_class .= ' nav-tab-active'; //add active class to current tab
@@ -460,20 +405,17 @@
460 405 if ( $tab_slug == $_GET['page'] ) {
461 406 $nav_class .= ' nav-tab-active'; //add active class to current tab
462 407 $tab_forms[] = $option_tab; //add current tab to forms to be rendered
463 408 }
464 -
465 - ?>
466 -
467 - <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>
468 -
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>
469 411 <?php endforeach; ?>
470 412 </h2>
471 413 <!-- End of Nav Tabs -->
472 414
473 - <?php
474 - //render all tab forms (normaly just 1 form)
475 - foreach ($tab_forms as $tab_form) : ?>
415 + <?php foreach ($tab_forms as $tab_form) : //render all tab forms (normaly just 1 form)
416 +
417 + ?>
476 418
477 419 <div id="<?php esc_attr_e($tab_form['id']); ?>" class="cmb-form group">
478 420 <div class="metabox-holder">
479 421 <div class="pmpbox pad">
@@ -478,9 +420,9 @@
478 420 <div class="metabox-holder">
479 421 <div class="pmpbox pad">
480 422 <h3 class="title"><?php esc_html_e($tab_form['title'], 'wpgetapi'); ?></h3>
481 423 <div class="desc"><?php echo wp_kses_post( $tab_form['desc'] ); ?></div>
482 - <?php cmb2_metabox_form( $tab_form, $tab_form['id'], $tab_form ); ?>
424 + <?php cmb2_metabox_form( $tab_form, $tab_form['id'] ); ?>
483 425 </div>
484 426 </div>
485 427 </div>
486 428
@@ -503,74 +445,8 @@
503 445
504 446 }
505 447
506 448
507 - public function test_the_endpoint() {
508 -
509 - $api_id = sanitize_text_field( $_POST['api_id'] );
510 - $endpoint_id = sanitize_text_field( $_POST['endpoint_id'] );
511 - $data = wpgetapi_endpoint( $api_id, $endpoint_id, array( 'test_endpoint' => true ) );
512 -
513 - $output = array(
514 - 'data' => $data,
515 - 'endpoint_id' => $endpoint_id
516 - );
517 - echo json_encode( $output );
518 -
519 - wp_die(); // this is required to terminate immediately and return a proper response
520 -
521 - }
522 -
523 -
524 - public function load_testing_javascript() { ?>
525 -
526 - <script type="text/javascript" >
527 -
528 - jQuery(document).ready(function($) {
529 -
530 - $('body').on( 'click', '.wpgetapi-test-area .test-button', function(){//delegated
531 -
532 - var $this = $(this);
533 - var area = $this.parents( '.wpgetapi-test-area' );
534 - var api_id = $( area ).data( 'api' );
535 - var endpoint_id = $( area ).data( 'endpoint' );
536 -
537 - // disable button
538 - $this.attr( 'disabled', true );
539 -
540 - var data = {
541 - 'action': 'wpgetapi_test_endpoint',
542 - 'api_id': api_id,
543 - 'endpoint_id': endpoint_id
544 - };
545 -
546 - // send and get response
547 - jQuery.post(ajaxurl, data, function( response ) {
548 -
549 - var output = JSON.parse( response );
550 -
551 - jQuery( '.wpgetapi-test-area[data-endpoint="' + output.endpoint_id + '"] .handle' ).show();
552 -
553 - jQuery( '.wpgetapi-test-area[data-endpoint="' + output.endpoint_id + '"] .wpgetapi-result' ).html( output.data);
554 -
555 - // enable button
556 - $( '.wpgetapi-test-area[data-endpoint="' + output.endpoint_id + '"] .test-button' ).attr( 'disabled', false );
557 -
558 - });
559 -
560 - });
561 -
562 - $( '.wpgetapi-test-area .handle' ).on('click', function() {
563 - $('.wpgetapi-result').toggle();
564 - });
565 -
566 - });
567 -
568 - </script> <?php
569 -
570 - }
571 -
572 -
573 449 /**
574 450 * Sidebar markup.
575 451 * @since 1.4.1
576 452 */
@@ -584,43 +460,41 @@
584 460
585 461 ?>
586 462
587 463 <div class="box">
588 - <strong><?php esc_html_e( 'Endpoint Instructions', 'wpgetapi' ); ?></strong>
464 + <h3><?php esc_html_e( 'Endpoint Instructions', 'wpgetapi' ); ?></h3>
589 465 <ol>
590 - <li><?php _e( 'Give your endpoint a <b>Unique ID</b>', 'wpgetapi' ); ?></li>
591 - <li><?php _e( 'Add the <b>Endpoint</b> which can be found in your API docs', 'wpgetapi' ); ?></li>
592 - <li><?php _e( 'Set the <b>Method</b> - GET for getting data & POST for sending data to the API', 'wpgetapi' ); ?></li>
593 - <li><?php _e( 'Set the desired <b>Results Format</b>', 'wpgetapi' ); ?></li>
594 - <li><?php _e( 'Other fields are optional & will depend on your API', 'wpgetapi' ); ?></li>
595 - <li><?php _e( 'Hit the Save button', 'wpgetapi' ); ?></li>
596 - <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>
597 472 </ol>
598 473 </div>
599 -
600 - <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>
601 484
485 + <hr>
486 +
602 487 <div class="box">
603 488 <strong><?php esc_html_e( 'Getting Help', 'wpgetapi' ); ?></strong>
604 489 <ul>
605 - <li><?php
490 + <li><?php
606 491 printf(
607 - esc_html__( 'View the %1$s', 'cmb2' ),
608 - '<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>'
609 495 );
610 496 ?></li>
611 - <li><?php
612 - printf(
613 - esc_html__( 'View the %1$s', 'cmb2' ),
614 - '<a target="_blank" href="https://wpgetapi.com/docs/frequently-asked-questions/?utm_campaign=Docs&utm_medium=Admin&utm_source=User">FAQs</a>'
615 - );
616 - ?></li>
617 - <li><?php
618 - printf(
619 - esc_html__( 'Do more with the %1$s', 'cmb2' ),
620 - '<a target="_blank" href="https://wpgetapi.com/downloads/pro-plugin/?utm_campaign=Pro&utm_medium=Admin&utm_source=User">PRO Plugin</a>'
621 - );
622 - ?></li>
623 497 </ul>
624 498 </div>
625 499
626 500 <?php
@@ -640,41 +514,38 @@
640 514 ob_start();
641 515 ?>
642 516
643 517 <div class="box">
644 - <strong><?php esc_html_e( 'Setup Instructions', 'wpgetapi' ); ?></strong>
518 + <h3><?php esc_html_e( 'Setup Instructions', 'wpgetapi' ); ?></h3>
645 519 <ol>
646 - <li><?php _e( 'Name your API in the <b>API Name</b> field', 'wpgetapi' ); ?></li>
647 - <li><?php _e( 'Give your API a <b>Unique ID</b>', 'wpgetapi' ); ?></li>
648 - <li><?php _e( 'Add the <b>Base URL</b> of your API. This can be found in the docs of your API', 'wpgetapi' ); ?></li>
649 - <li><?php _e( 'Hit the Save button', 'wpgetapi' ); ?></li>
650 - <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>
651 523 </ol>
652 524 </div>
653 525
654 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>
655 535
536 + <hr>
537 +
656 538 <div class="box">
657 539 <strong><?php esc_html_e( 'Getting Help', 'wpgetapi' ); ?></strong>
658 540 <ul>
659 - <li><?php
541 + <li><?php
660 542 printf(
661 - esc_html__( 'View the %1$s', 'cmb2' ),
662 - '<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>'
663 546 );
664 547 ?></li>
665 - <li><?php
666 - printf(
667 - esc_html__( 'View the %1$s', 'cmb2' ),
668 - '<a target="_blank" href="https://wpgetapi.com/docs/frequently-asked-questions/?utm_campaign=Docs&utm_medium=Admin&utm_source=User">FAQs</a>'
669 - );
670 - ?></li>
671 - <li><?php
672 - printf(
673 - esc_html__( 'Do more with the %1$s', 'cmb2' ),
674 - '<a target="_blank" href="https://wpgetapi.com/downloads/pro-plugin/?utm_campaign=Pro&utm_medium=Admin&utm_source=User">PRO Plugin</a>'
675 - );
676 - ?></li>
677 548 </ul>
678 549 </div>
679 550
680 551 <?php
@@ -683,36 +554,19 @@
683 554 return $content;
684 555
685 556 }
686 557
687 -
688 558 /**
689 559 * Tabs don't immmediately appear on save, so this hack!
690 560 * @since 0.1.0
691 561 */
692 562 public function redirect( $object_id, $updated ) {
693 -
694 563 if( $object_id == 'wpgetapi_setup' ) {
695 -
696 - add_settings_error( 'wpgetapi-notices', '', 'Saved, reloading page...', 'updated' );
564 + add_settings_error( 'wpgetapi-notices', '', 'Settings saved.', 'updated' );
697 565 settings_errors( 'wpgetapi-notices' );
698 - ?>
699 -
700 - <script>
701 - setTimeout(function() {
702 - location.reload();
703 - }, 1000);
704 - </script>
705 - <?php
706 -
707 - } else if ( strpos( $object_id, 'wpgetapi_' ) !== false ) {
708 -
709 - $text = apply_filters( 'wpgetapi_admin_notice_text', __( 'Saved.', 'wpgetapi' ), $object_id );
710 - add_settings_error( 'wpgetapi-notices', '', $text, 'updated' );
711 - settings_errors( 'wpgetapi-notices' );
712 -
566 + wp_redirect( admin_url( 'admin.php?page=' . $object_id ) );
567 + exit;
713 568 }
714 -
715 569 }
716 570
717 571
718 572 /**