PluginProbe
WPGet API – Connect to any external REST API / 1.0.1
WPGet API – Connect to any external REST API v1.0.1
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
wpgetapi / includes / functions.php

functions.php in WPGet API – Connect to any external REST API 1.0.1, at includes/functions.php

52 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * Pretty print when debugging is enabled in options
5 */
6 if (!function_exists('pp')) {
7 function wpgetapi_pp( $array ) {
8 echo '<pre style="white-space:pre-wrap;">';
9 print_r( $array );
10 echo '</pre>' . "\n";
11 }
12 }
13
14
15 /**
16 * Dropdown options for results_format
17 *
18 */
19 function wpgetapi_results_format_options( $field ) {
20
21 $options = apply_filters( 'wpgetapi_results_format_options', array(
22 'json_string' => 'JSON (as string)',
23 'json_decoded' => 'JSON (as array data)',
24 ) );
25
26 return $options;
27
28 }
29
30 /**
31 * Recursive sanitation for text or array
32 *
33 * @param $array_or_string (array|string)
34 * @since 1.0.0
35 * @return mixed
36 */
37 function wpgetapi_sanitize_text_or_array($array_or_string) {
38 if( is_string($array_or_string) ){
39 $array_or_string = sanitize_text_field($array_or_string);
40 }elseif( is_array($array_or_string) ){
41 foreach ( $array_or_string as $key => &$value ) {
42 if ( is_array( $value ) ) {
43 $value = wpgetapi_sanitize_text_or_array($value);
44 }
45 else {
46 $value = sanitize_text_field( $value );
47 }
48 }
49 }
50
51 return $array_or_string;
52 }