# wpgetapi/1.1.0/includes/functions.php

WPGet API – Connect to any external REST API, version 1.1.0. 52 lines.

- Page: https://pluginprobe.com/plugins/wpgetapi/1.1.0/code/includes/functions.php
- Raw: https://pluginprobe.com/plugins/wpgetapi/1.1.0/raw/includes/functions.php
- Modified: 2021-11-01T02:27:36+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/wpgetapi/1.1.0/code/includes/functions.php#L10-L20`.

```php
<?php

/*
 * Pretty print when debugging is enabled in options
 */
if (!function_exists('pp')) {
    function wpgetapi_pp( $array ) {
        echo '<pre style="white-space:pre-wrap;">';
            print_r( $array );
        echo '</pre>' . "\n";
    }
}


/**
 * Dropdown options for results_format
 * 
 */
function wpgetapi_results_format_options( $field ) {
    
    $options = apply_filters( 'wpgetapi_results_format_options', array(
        'json_string' => 'JSON (as string)',
        'json_decoded' => 'JSON (as array data)',
    ) );

    return $options;

}

/**
 * Recursive sanitation for text or array
 * 
 * @param $array_or_string (array|string)
 * @since  1.0.0
 * @return mixed
 */
function wpgetapi_sanitize_text_or_array($array_or_string) {
    if( is_string($array_or_string) ){
        $array_or_string = sanitize_text_field($array_or_string);
    }elseif( is_array($array_or_string) ){
        foreach ( $array_or_string as $key => &$value ) {
            if ( is_array( $value ) ) {
                $value = wpgetapi_sanitize_text_or_array($value);
            }
            else {
                $value = sanitize_text_field( $value );
            }
        }
    }

    return $array_or_string;
}
```
