| @@ -2,9 +2,9 @@ | ||
| 2 | 2 | |
| 3 | 3 | /* |
| 4 | 4 | * Pretty print when debugging is enabled in options |
| 5 | 5 | */ |
| 6 | -if (!function_exists('wpgetapi_pp')) { | |
| 6 | +if (!function_exists('pp')) { | |
| 7 | 7 | function wpgetapi_pp( $array ) { |
| 8 | 8 | echo '<pre style="white-space:pre-wrap;">'; |
| 9 | 9 | print_r( $array ); |
| 10 | 10 | echo '</pre>' . "\n"; |
| @@ -13,20 +13,21 @@ | ||
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * Dropdown options for results_format |
| 17 | - * It is set up this way so we can easily add the filter to be able to add extra format options | |
| 18 | 17 | * |
| 19 | 18 | */ |
| 20 | 19 | function wpgetapi_results_format_options( $field ) { |
| 20 | + | |
| 21 | 21 | $options = apply_filters( 'wpgetapi_results_format_options', array( |
| 22 | - 'json_string' => __( 'JSON string', 'wpgetapi' ), | |
| 23 | - 'json_decoded' => __( 'PHP array data', 'wpgetapi' ), | |
| 22 | + 'json_string' => 'JSON (as string)', | |
| 23 | + 'json_decoded' => 'JSON (as array data)', | |
| 24 | 24 | ) ); |
| 25 | + | |
| 25 | 26 | return $options; |
| 27 | + | |
| 26 | 28 | } |
| 27 | 29 | |
| 28 | - | |
| 29 | 30 | /** |
| 30 | 31 | * Recursive sanitation for text or array |
| 31 | 32 | * |
| 32 | 33 | * @param $array_or_string (array|string) |
| @@ -47,65 +48,5 @@ | ||
| 47 | 48 | } |
| 48 | 49 | } |
| 49 | 50 | |
| 50 | 51 | return $array_or_string; |
| 51 | -} | |
| 52 | - | |
| 53 | - | |
| 54 | -/** | |
| 55 | - * wpgetapi_output_endpoint_test_area | |
| 56 | - * | |
| 57 | - */ | |
| 58 | -function wpgetapi_output_top_of_endpoint( $field_args, $field ) { | |
| 59 | - | |
| 60 | - ob_start(); | |
| 61 | - | |
| 62 | - $test_disabled = true; | |
| 63 | - | |
| 64 | - if( $field->value ) | |
| 65 | - $test_disabled = false; | |
| 66 | - | |
| 67 | - ?> | |
| 68 | - | |
| 69 | - <pre class="functions"> | |
| 70 | - <div class="wrapper"><div>Template Tag:</div> </span><span class="wpgetapi-template-tag wpgetapi-copy">wpgetapi_endpoint( '<?php esc_html_e( $field->args['api_id'] ); ?>', '<span class='endpoint_id'></span>', array('debug' => false) );</span> <span title="Copy Template Tag" class="copy-this dashicons dashicons-admin-page"></span></div> | |
| 71 | - <div class="wrapper"><div>Shortcode:</div> <span class="wpgetapi-shortcode wpgetapi-copy">[wpgetapi_endpoint api_id='<?php esc_html_e( $field->args['api_id'] ); ?>' endpoint_id='<span class='endpoint_id'></span>' debug='false']</span> <span title="Copy Shortcode" class="copy-this dashicons dashicons-admin-page"></span></div> | |
| 72 | - </pre> | |
| 73 | - | |
| 74 | - <div class="wpgetapi-test-area" data-endpoint="<?php esc_attr_e( $field->value ); ?>" data-api="<?php esc_attr_e( $field->args['api_id'] ); ?>"> | |
| 75 | - | |
| 76 | - <span class="handle" style="display:none">Hide/Show Results</span> | |
| 77 | - | |
| 78 | - <?php do_action( 'wpgetapi_admin_before_test_result' ); ?> | |
| 79 | - | |
| 80 | - <div class="wpgetapi-result"></div> | |
| 81 | - </div> | |
| 82 | - | |
| 83 | - <div class="fields-wrapper"> | |
| 84 | - | |
| 85 | - <?php | |
| 86 | - | |
| 87 | - $content = ob_get_contents(); | |
| 88 | - ob_end_clean(); | |
| 89 | - return $content; | |
| 90 | - | |
| 91 | -} | |
| 92 | - | |
| 93 | - | |
| 94 | -/** | |
| 95 | - * Ensure our unique ID's are only lowercase and underscores | |
| 96 | - * | |
| 97 | - * @param mixed $value The unsanitized value from the form. | |
| 98 | - * @param array $field_args Array of field arguments. | |
| 99 | - * @param CMB2_Field $field The field object | |
| 100 | - * | |
| 101 | - * @return mixed Sanitized value to be stored. | |
| 102 | - */ | |
| 103 | -function wpgetapi_sanitize_unique_id( $value, $field_args, $field ) { | |
| 104 | - $sanitized_value = sanitize_file_name( $value ); | |
| 105 | - $sanitized_value = str_replace("-", "_", $sanitized_value ); | |
| 106 | - $sanitized_value = str_replace(".", "_", $sanitized_value ); | |
| 107 | - $sanitized_value = str_replace("^", "_", $sanitized_value ); | |
| 108 | - $sanitized_value = str_replace("@", "_", $sanitized_value ); | |
| 109 | - return $sanitized_value; | |
| 110 | -} | |
| 111 | - | |
| 52 | +} | |