PluginProbe
WPGet API – Connect to any external REST API / 1.9.0
WPGet API – Connect to any external REST API v1.9.0
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 +94 -132 2.0.41.9.0 View file →
@@ -203,9 +203,9 @@
203 203 'sortable' => true, // beta
204 204 ),
205 205 'fields' => array(
206 206 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>',
207 + 'name' => __( 'API Name', 'wpgetapi' ),
208 208 'id' => 'name',
209 209 'type' => 'text',
210 210 'attributes' => array(
211 211 'required' => true,
@@ -210,12 +210,12 @@
210 210 'attributes' => array(
211 211 'required' => true,
212 212 'placeholder' => 'Google Maps',
213 213 ),
214 - 'desc' => '',
214 + 'desc' => __( 'The name of the API you are connecting to.', 'wpgetapi' ),
215 215 ),
216 216 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>',
217 + 'name' => __( 'Unique ID', 'wpgetapi' ),
218 218 'id' => 'id',
219 219 'type' => 'text',
220 220 'attributes' => array(
221 221 'required' => true,
@@ -220,13 +220,12 @@
220 220 'attributes' => array(
221 221 'required' => true,
222 222 'placeholder' => 'google_maps',
223 223 ),
224 - 'desc' => '',
225 - 'sanitization_cb' => 'wpgetapi_sanitize_unique_id'
224 + 'desc' => __( 'A unique ID for your API. Lowercase letters and underscores only.', 'wpgetapi' ),
226 225 ),
227 226 array(
228 - 'name' => __( 'Base URL', 'wpgetapi' ) . '<span class="dashicons dashicons-editor-help" data-tip="' . __( 'The base URL of the API you are connecting to.', 'wpgetapi' ) . '"></span>',
227 + 'name' => __( 'Base URL', 'wpgetapi' ),
229 228 'id' => 'base_url',
230 229 'type' => 'text',
231 230 'attributes' => array(
232 231 'required' => true,
@@ -231,9 +230,9 @@
231 230 'attributes' => array(
232 231 'required' => true,
233 232 'placeholder' => 'https://maps.googleapis.com/maps/api',
234 233 ),
235 - 'desc' => '',
234 + 'desc' => __( 'The base URL of the API you are connecting to.', 'wpgetapi' ),
236 235 ),
237 236
238 237 )
239 238 );
@@ -252,14 +251,13 @@
252 251
253 252 $fields = array();
254 253
255 254 $cache_disabled = $this->pro_plugin ? '' : 'disabled';
256 - $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=Pro&utm_medium=Admin&utm_source=Cache">View PRO Plugin</a>';
257 - $cache_desc = $this->pro_plugin ? '' : 'Available in PRO plugin.';
255 + $cache_url = $this->pro_plugin ? '<a target="_blank" href="https://wpgetapi.com/docs/caching-api-calls/">Help <span class="dashicons dashicons-external"></span></a>' : '<a target="_blank" href="https://wpgetapi.com/downloads/pro-plugin/?utm_campaign=Cache Pro Plugin&utm_medium=Admin&utm_source=User">PRO Plugin<span class="dashicons dashicons-external"></span></a>';
258 256
259 257 $endpoint_fields = apply_filters( 'wpgetapi_fields_endpoints', array(
260 258 array(
261 - '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>',
259 + 'name' => __( 'Unique ID', 'wpgetapi' ),
262 260 'id' => 'id',
263 261 'type' => 'text',
264 262 'classes' => 'field-id',
265 263 'attributes' => array(
@@ -265,16 +263,15 @@
265 263 'attributes' => array(
266 264 'required' => true,
267 265 'placeholder' => 'new_endpoint',
268 266 ),
269 - 'desc' => '',
267 + 'desc' => __( 'A unique ID for this endpoint. Lowercase letters and underscores only.', 'wpgetapi' ),
270 268 'before_row' => "wpgetapi_output_top_of_endpoint",
271 269 'api_id' => $api_id,
272 - 'sanitization_cb' => 'wpgetapi_sanitize_unique_id'
273 270
274 271 ),
275 272 array(
276 - '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>',
273 + 'name' => __( 'Endpoint', 'wpgetapi' ),
277 274 'id' => 'endpoint',
278 275 'type' => 'text',
279 276 'classes' => 'field-endpoint',
280 277 'attributes' => array(
@@ -280,12 +277,12 @@
280 277 'attributes' => array(
281 278 'required' => true,
282 279 'placeholder' => '/newendpoint',
283 280 ),
284 - 'desc' => '',
281 + 'desc' => __( 'The endpoint that will be appended to the base URL.', 'wpgetapi' ),
285 282 ),
286 283 array(
287 - '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>',
284 + 'name' => __( 'Method', 'wpgetapi' ),
288 285 'id' => 'method',
289 286 'type' => 'select',
290 287 'classes' => 'field-method',
291 288 'attributes' => array(
@@ -294,22 +291,15 @@
294 291 'options' => array(
295 292 'GET' => 'GET',
296 293 'POST' => 'POST',
297 294 'PUT' => 'PUT',
298 - 'PATCH' => 'PATCH',
299 295 'DELETE' => 'DELETE',
300 296 ),
301 - 'desc' => '',
297 + 'desc' => __( 'The request method for this endpoint.', 'wpgetapi' ),
302 298 ),
303 299
304 300 array(
305 - 'name' => __( 'Results Format', 'wpgetapi' ) .
306 - '<span class="dashicons dashicons-editor-help" data-tip="' .
307 - sprintf(
308 - __( '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' ),
309 - 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>' )
310 - ) .
311 - '"></span>',
301 + 'name' => __( 'Results Format', 'wpgetapi' ),
312 302 'id' => 'results_format',
313 303 'type' => 'select',
314 304 'classes' => 'field-results-format',
315 305 'attributes' => array(
@@ -315,120 +305,75 @@
315 305 'attributes' => array(
316 306 'required' => true,
317 307 ),
318 308 'options_cb' => 'wpgetapi_results_format_options',
319 - 'desc' => ''
309 + 'desc' => sprintf(
310 + __( 'The format of the results. %1s', 'wpgetapi' ),
311 + '<a target="_blank" href="https://wpgetapi.com/docs/format-api-data-as-html/?utm_campaign=Shortcode JSON&utm_medium=Admin&utm_source=User">More options <span class="dashicons dashicons-external"></span></a>'
312 + )
320 313 ),
321 314
322 315 array(
323 - 'name' => __( 'Cache Time', 'wpgetapi' ) .
324 - '<span class="dashicons dashicons-editor-help" data-tip="' .
325 - sprintf(
326 - __( 'The time in seconds to cache this request for. %1s', 'wpgetapi' ),
327 - htmlentities( '<br>' . $cache_url )
328 - ) .
329 - '"></span>',
316 + 'name' => __( 'Cache Time', 'wpgetapi' ),
330 317 'id' => 'cache_time',
331 318 'type' => 'text',
332 319 'classes' => 'field-cache-time',
333 320 'attributes' => array(
334 - 'placeholder' => '3600',
321 + 'placeholder' => '',
335 322 $cache_disabled => $cache_disabled,
336 323 ),
337 - 'desc' => $cache_desc
324 + 'desc' => sprintf(
325 + __( 'The time in seconds to cache this request for. %1s', 'wpgetapi' ),
326 + $cache_url
327 + )
338 328 ),
339 329
340 330 array(
341 - 'name' => __( 'Query String', 'wpgetapi' ) .
342 - '<span class="dashicons dashicons-editor-help" data-tip="' .
343 - sprintf(
344 - __( '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' ),
345 - 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>' )
346 - ) .
347 - '"></span>',
331 + 'name' => __( 'Query String', 'wpgetapi' ),
348 332 'id' => 'query_parameters',
349 333 'type' => 'parameter',
350 334 'classes' => 'field-query-parameters',
351 335 'repeatable' => true,
352 - 'desc' => ''
336 + 'desc' => sprintf(
337 + __( 'Parameters as name/value pairs that will be appended to the URL. %1s', 'wpgetapi' ),
338 + '<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>'
339 + )
353 340 ),
354 341 array(
355 - 'name' => __( 'Headers', 'wpgetapi' ) .
356 - '<span class="dashicons dashicons-editor-help" data-tip="' .
357 - sprintf(
358 - __( 'Parameters as name/value pairs, sent in the Headers. %1s', 'wpgetapi' ),
359 - 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>' )
360 - ) .
361 - '"></span>',
342 + 'name' => __( 'Headers', 'wpgetapi' ),
362 343 'id' => 'header_parameters',
363 344 'type' => 'parameter',
364 345 'classes' => 'field-header-parameters',
365 346 'repeatable' => true,
366 - 'desc' => ''
347 + 'desc' => sprintf(
348 + __( 'Parameters as name/value pairs, sent in the headers. %1s', 'wpgetapi' ),
349 + '<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>'
350 + )
367 351 ),
368 352 array(
369 - 'name' => __( 'Body POST Fields', 'wpgetapi' ) .
370 - '<span class="dashicons dashicons-editor-help" data-tip="' .
371 - sprintf(
372 - __( 'Parameters as name/value pairs, sent in the Body as POST fields. %1s', 'wpgetapi' ),
373 - 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>' )
374 - ) .
375 - '"></span>',
353 + 'name' => __( 'Body POST Fields', 'wpgetapi' ),
376 354 'id' => 'body_parameters',
377 355 'type' => 'parameter',
378 356 'classes' => 'field-body-parameters',
379 357 'repeatable' => true,
380 - 'desc' => ''
358 + 'desc' => sprintf(
359 + __( 'Parameters as name/value pairs, sent in the body as POST fields. %1s', 'wpgetapi' ),
360 + '<a target="_blank" href="https://wpgetapi.com/docs/sending-post-fields-in-request/?utm_campaign=Body&utm_medium=Admin&utm_source=User">Help <span class="dashicons dashicons-external"></span></a>'
361 + )
381 362 ),
382 363 array(
383 - 'name' => __( 'Encode Body', 'wpgetapi' ) . '<span class="dashicons dashicons-editor-help" data-tip="' . __( 'Encoding of the above Body parameters.', 'wpgetapi' ) . '"></span>',
364 + 'name' => __( 'Encode Body', 'wpgetapi' ),
384 365 'id' => 'body_json_encode',
385 366 'type' => 'select',
386 367 'classes' => 'field-body-json-encode',
387 368 'options' => array(
388 - 'false' => __( 'No encoding (raw)', 'wpgetapi' ),
389 - 'true' => __( 'JSON encode', 'wpgetapi' ),
390 - 'url' => __( 'URL encode (x-www-form-urlencoded)', 'wpgetapi' ),
391 - 'base64' => __( 'Base64 encode', 'wpgetapi' ),
392 - 'xml' => __( 'XML format (available in PRO)', 'wpgetapi' ),
393 -
369 + 'false' => __( 'No encoding (raw)', 'wpgetapi' ),
370 + 'true' => __( 'JSON encode', 'wpgetapi' ),
371 + 'url' => __( 'URL encode (x-www-form-urlencoded)', 'wpgetapi' ),
372 + 'xml' => __( 'XML format (available in PRO only)', 'wpgetapi' ),
394 373 ),
395 - 'desc' => '',
374 + 'desc' => __( 'Encoding of the above Body parameters. ', 'wpgetapi' ),
396 375 ),
397 - array(
398 - 'name' => __( 'Actions', 'wpgetapi' ) . '<span class="dashicons dashicons-editor-help" data-tip="' .
399 - sprintf(
400 - __( 'Call this endpoint when your chosen action runs. This feature is available in the PRO plugin. %1s', 'wpgetapi' ),
401 - htmlentities( '<br><a target="_blank" href="https://wpgetapi.com/downloads/pro-plugin/?utm_campaign=Pro&utm_medium=Admin&utm_source=Actions">View PRO Plugin</a>' )
402 - ) .
403 - '"></span>',
404 - 'id' => 'actions',
405 - 'type' => 'select',
406 - 'classes' => 'field-actions',
407 - 'desc' => __( 'Available in PRO plugin.', 'wpgetapi' ),
408 - 'options' => array(
409 - '' => __( '-- No Action --', 'wpgetapi-extras' ),
410 - 'new_post_published' => __( 'Post/Custom Post - New Post Published', 'wpgetapi-extras' ),
411 - 'transition_post_status' => __( 'Post/Custom Post - Status Changed', 'wpgetapi-extras' ),
412 - 'delete_post' => __( 'Post/Custom Post - Delete Post', 'wpgetapi-extras' ),
413 -
414 - 'user_register' => __( 'User - New User Registered', 'wpgetapi-extras' ),
415 - 'delete_user' => __( 'User - Delete User', 'wpgetapi-extras' ),
416 - 'user_login' => __( 'User - User Logs In', 'wpgetapi-extras' ),
417 - 'woocommerce_new_product' => __( 'WooCommerce - New Product Created', 'wpgetapi-extras' ),
418 - 'woocommerce_new_order' => __( 'WooCommerce - New Order Created', 'wpgetapi-extras' ),
419 - 'woocommerce_order_status_changed' => __( 'WooCommerce - Order Status Changed', 'wpgetapi-extras' ),
420 - 'contact_form_7' => __( 'Contact Form 7', 'wpgetapi-extras' ),
421 - 'gravity_forms' => __( 'Gravity Forms', 'wpgetapi-extras' ),
422 - 'wpforms' => __( 'WPForms', 'wpgetapi-extras' ),
423 - 'jetformbuilder' => __( 'JetFormBuilder', 'wpgetapi-extras' ),
424 - 'formidable_forms' => __( 'Formidable Forms', 'wpgetapi-extras' ),
425 - 'pmp' => __( 'Paid Memberships Pro - After Checkout', 'wpgetapi-extras' ),
426 - 'edd' => __( 'Easy Digital Downloads - Complete Purchase', 'wpgetapi-extras' ),
427 - ),
428 - 'default' => '',
429 - )
430 -
431 376 ) );
432 377
433 378
434 379 $fields[] = array(
@@ -589,9 +534,13 @@
589 534 var output = JSON.parse( response );
590 535
591 536 jQuery( '.wpgetapi-test-area[data-endpoint="' + output.endpoint_id + '"] .handle' ).show();
592 537
593 - jQuery( '.wpgetapi-test-area[data-endpoint="' + output.endpoint_id + '"] .wpgetapi-result' ).html( output.data);
538 + jQuery( '.wpgetapi-test-area[data-endpoint="' + output.endpoint_id + '"] .wpgetapi-result' ).html(
539 + '<div class="side-notice"><p>These results contain the raw output of your API call as well as extra debugging information for testing purposes. <br>' +
540 + 'Using the shortcode or the template tag on the front end will display the Data Output section as shown below. The data can be formatted any way you like, depending on your requirements.</p></div>' +
541 + output.data
542 + );
594 543
595 544 // enable button
596 545 $( '.wpgetapi-test-area[data-endpoint="' + output.endpoint_id + '"] .test-button' ).attr( 'disabled', false );
597 546
@@ -624,9 +573,9 @@
624 573
625 574 ?>
626 575
627 576 <div class="box">
628 - <h4><?php esc_html_e( 'Endpoint Instructions', 'wpgetapi' ); ?></h4>
577 + <strong><?php esc_html_e( 'Endpoint Instructions', 'wpgetapi' ); ?></strong>
629 578 <ol>
630 579 <li><?php _e( 'Give your endpoint a <b>Unique ID</b>', 'wpgetapi' ); ?></li>
631 580 <li><?php _e( 'Add the <b>Endpoint</b> which can be found in your API docs', 'wpgetapi' ); ?></li>
632 581 <li><?php _e( 'Set the <b>Method</b> - GET for getting data & POST for sending data to the API', 'wpgetapi' ); ?></li>
@@ -636,10 +585,34 @@
636 585 <li><?php _e( 'Copy the Template Tag or Shortcode & paste into page, post or theme file', 'wpgetapi' ); ?></li>
637 586 </ol>
638 587 </div>
639 588
640 - <?php echo $this->help_box(); ?>
589 + <hr>
641 590
591 + <div class="box">
592 + <strong><?php esc_html_e( 'Getting Help', 'wpgetapi' ); ?></strong>
593 + <ul>
594 + <li><?php
595 + printf(
596 + esc_html__( 'View the %1$s', 'cmb2' ),
597 + '<a target="_blank" href="https://wpgetapi.com/docs/quick-start-guide/?utm_campaign=Docs&utm_medium=Admin&utm_source=User">Quick Start Guide</a>'
598 + );
599 + ?></li>
600 + <li><?php
601 + printf(
602 + esc_html__( 'View the %1$s', 'cmb2' ),
603 + '<a target="_blank" href="https://wpgetapi.com/docs/frequently-asked-questions/?utm_campaign=Docs&utm_medium=Admin&utm_source=User">FAQs</a>'
604 + );
605 + ?></li>
606 + <li><?php
607 + printf(
608 + esc_html__( 'Do more with the %1$s', 'cmb2' ),
609 + '<a target="_blank" href="https://wpgetapi.com/downloads/pro-plugin/?utm_campaign=Pro&utm_medium=Admin&utm_source=User">PRO Plugin</a>'
610 + );
611 + ?></li>
612 + </ul>
613 + </div>
614 +
642 615 <?php
643 616 $content = ob_get_contents();
644 617 ob_end_clean();
645 618 return $content;
@@ -656,9 +629,9 @@
656 629 ob_start();
657 630 ?>
658 631
659 632 <div class="box">
660 - <h4><?php esc_html_e( 'Setup Instructions', 'wpgetapi' ); ?></h4>
633 + <strong><?php esc_html_e( 'Setup Instructions', 'wpgetapi' ); ?></strong>
661 634 <ol>
662 635 <li><?php _e( 'Name your API in the <b>API Name</b> field', 'wpgetapi' ); ?></li>
663 636 <li><?php _e( 'Give your API a <b>Unique ID</b>', 'wpgetapi' ); ?></li>
664 637 <li><?php _e( 'Add the <b>Base URL</b> of your API. This can be found in the docs of your API', 'wpgetapi' ); ?></li>
@@ -666,31 +639,12 @@
666 639 <li><?php _e( 'Visit the new tab that will be created', 'wpgetapi' ); ?></li>
667 640 </ol>
668 641 </div>
669 642
670 - <?php echo $this->help_box(); ?>
671 -
672 - <?php
673 - $content = ob_get_contents();
674 - ob_end_clean();
675 - return $content;
676 -
677 - }
678 -
679 -
680 - /**
681 - *
682 - * @since 1.4.4
683 - */
684 - public function help_box() {
685 -
686 - ob_start();
687 - ?>
688 -
689 643 <hr>
690 644
691 - <div class="box help-box">
692 - <h4><?php esc_html_e( 'Getting Help', 'wpgetapi' ); ?></h4>
645 + <div class="box">
646 + <strong><?php esc_html_e( 'Getting Help', 'wpgetapi' ); ?></strong>
693 647 <ul>
694 648 <li><?php
695 649 printf(
696 650 esc_html__( 'View the %1$s', 'cmb2' ),
@@ -702,12 +656,14 @@
702 656 esc_html__( 'View the %1$s', 'cmb2' ),
703 657 '<a target="_blank" href="https://wpgetapi.com/docs/frequently-asked-questions/?utm_campaign=Docs&utm_medium=Admin&utm_source=User">FAQs</a>'
704 658 );
705 659 ?></li>
706 -
707 - <?php if( ! $this->pro_plugin ) { ?>
708 - <a class="button" target="_blank" href="https://wpgetapi.com/downloads/pro-plugin/?utm_campaign=Pro&utm_medium=Admin&utm_source=User"><?php esc_html_e( 'Do more with the PRO Plugin', 'cmb2' ); ?></a>
709 - <?php } ?>
660 + <li><?php
661 + printf(
662 + esc_html__( 'Do more with the %1$s', 'cmb2' ),
663 + '<a target="_blank" href="https://wpgetapi.com/downloads/pro-plugin/?utm_campaign=Pro&utm_medium=Admin&utm_source=User">PRO Plugin</a>'
664 + );
665 + ?></li>
710 666 </ul>
711 667 </div>
712 668
713 669 <?php
@@ -723,9 +679,9 @@
723 679 * @since 0.1.0
724 680 */
725 681 public function redirect( $object_id, $updated ) {
726 682
727 - if( strpos( $object_id, 'wpgetapi_' ) !== false && strpos( $object_id, 'wpgetapi_api_importer' ) == false ) {
683 + if( $object_id == 'wpgetapi_setup' ) {
728 684
729 685 add_settings_error( 'wpgetapi-notices', '', 'Saved, reloading page...', 'updated' );
730 686 settings_errors( 'wpgetapi-notices' );
731 687 ?>
@@ -732,13 +688,19 @@
732 688
733 689 <script>
734 690 setTimeout(function() {
735 691 location.reload();
736 - }, 200);
692 + }, 1000);
737 693 </script>
738 694 <?php
739 695
740 - }
696 + } else if ( strpos( $object_id, 'wpgetapi_' ) !== false ) {
697 +
698 + $text = apply_filters( 'wpgetapi_admin_notice_text', __( 'Saved.', 'wpgetapi' ), $object_id );
699 + add_settings_error( 'wpgetapi-notices', '', $text, 'updated' );
700 + settings_errors( 'wpgetapi-notices' );
701 +
702 + }
741 703
742 704 }
743 705
744 706