| @@ -97,11 +97,8 @@ | ||
| 97 | 97 | add_action( 'admin_footer', array( $this, 'load_testing_javascript' ) ); |
| 98 | 98 | |
| 99 | 99 | add_action( 'wp_ajax_wpgetapi_test_endpoint', array( $this, 'test_the_endpoint' ) ); |
| 100 | 100 | |
| 101 | - add_action( 'wp_ajax_wpgetapi_export_endpoints', array( $this, 'export_endpoints' ) ); | |
| 102 | - add_action( 'wp_ajax_wpgetapi_import_endpoints', array( $this, 'import_endpoints' ) ); | |
| 103 | - | |
| 104 | 101 | } |
| 105 | 102 | |
| 106 | 103 | |
| 107 | 104 | /** |
| @@ -153,9 +150,9 @@ | ||
| 153 | 150 | $option_metabox[] = array( |
| 154 | 151 | 'title' => __( 'Setup', 'wpgetapi' ), |
| 155 | 152 | 'menu_title' => __( 'Setup', 'wpgetapi' ), |
| 156 | 153 | 'id' => 'wpgetapi_setup', |
| 157 | - 'desc' => __( 'Add the details of the API(s) you are using. Endpoints will be setup in the next step after hitting save.', 'wpgetapi' ), | |
| 154 | + 'desc' => __( 'Add the details of the API(s) you are using. Endpoints will be setup in the next step after saving your API(s).', 'wpgetapi' ), | |
| 158 | 155 | 'show_on' => array( 'key' => 'options-page', 'value' => array( 'wpgetapi_setup' ), ), |
| 159 | 156 | 'show_names' => true, |
| 160 | 157 | 'fields' => $this->setup_fields(), |
| 161 | 158 | ); |
| @@ -206,9 +203,9 @@ | ||
| 206 | 203 | 'sortable' => true, // beta |
| 207 | 204 | ), |
| 208 | 205 | 'fields' => array( |
| 209 | 206 | array( |
| 210 | - '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' ), | |
| 211 | 208 | 'id' => 'name', |
| 212 | 209 | 'type' => 'text', |
| 213 | 210 | 'attributes' => array( |
| 214 | 211 | 'required' => true, |
| @@ -213,12 +210,12 @@ | ||
| 213 | 210 | 'attributes' => array( |
| 214 | 211 | 'required' => true, |
| 215 | 212 | 'placeholder' => 'Google Maps', |
| 216 | 213 | ), |
| 217 | - 'desc' => '', | |
| 214 | + 'desc' => __( 'The name of the API you are connecting to.', 'wpgetapi' ), | |
| 218 | 215 | ), |
| 219 | 216 | array( |
| 220 | - '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' ), | |
| 221 | 218 | 'id' => 'id', |
| 222 | 219 | 'type' => 'text', |
| 223 | 220 | 'attributes' => array( |
| 224 | 221 | 'required' => true, |
| @@ -223,13 +220,12 @@ | ||
| 223 | 220 | 'attributes' => array( |
| 224 | 221 | 'required' => true, |
| 225 | 222 | 'placeholder' => 'google_maps', |
| 226 | 223 | ), |
| 227 | - 'desc' => '', | |
| 228 | - 'sanitization_cb' => 'wpgetapi_sanitize_unique_id' | |
| 224 | + 'desc' => __( 'A unique ID for your API. Lowercase letters and underscores only.', 'wpgetapi' ), | |
| 229 | 225 | ), |
| 230 | 226 | array( |
| 231 | - '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' ), | |
| 232 | 228 | 'id' => 'base_url', |
| 233 | 229 | 'type' => 'text', |
| 234 | 230 | 'attributes' => array( |
| 235 | 231 | 'required' => true, |
| @@ -234,9 +230,9 @@ | ||
| 234 | 230 | 'attributes' => array( |
| 235 | 231 | 'required' => true, |
| 236 | 232 | 'placeholder' => 'https://maps.googleapis.com/maps/api', |
| 237 | 233 | ), |
| 238 | - 'desc' => '', | |
| 234 | + 'desc' => __( 'The base URL of the API you are connecting to.', 'wpgetapi' ), | |
| 239 | 235 | ), |
| 240 | 236 | |
| 241 | 237 | ) |
| 242 | 238 | ); |
| @@ -255,14 +251,13 @@ | ||
| 255 | 251 | |
| 256 | 252 | $fields = array(); |
| 257 | 253 | |
| 258 | 254 | $cache_disabled = $this->pro_plugin ? '' : 'disabled'; |
| 259 | - $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>'; | |
| 260 | - $cache_desc = $this->pro_plugin ? '' : 'Available in PRO plugin.'; | |
| 255 | + $cache_url = $this->pro_plugin ? '<a target="_blank" href="https://wpgetapi.com/downloads/pro-plugin/?utm_campaign=Cache Pro Plugin&utm_medium=Admin&utm_source=User">Pro <span class="dashicons dashicons-external"></span></a>' : '<a target="_blank" href="https://wpgetapi.com/docs/caching-api-calls/">Help <span class="dashicons dashicons-external"></span></a>'; | |
| 261 | 256 | |
| 262 | 257 | $endpoint_fields = apply_filters( 'wpgetapi_fields_endpoints', array( |
| 263 | 258 | array( |
| 264 | - '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' ), | |
| 265 | 260 | 'id' => 'id', |
| 266 | 261 | 'type' => 'text', |
| 267 | 262 | 'classes' => 'field-id', |
| 268 | 263 | 'attributes' => array( |
| @@ -268,16 +263,15 @@ | ||
| 268 | 263 | 'attributes' => array( |
| 269 | 264 | 'required' => true, |
| 270 | 265 | 'placeholder' => 'new_endpoint', |
| 271 | 266 | ), |
| 272 | - 'desc' => '', | |
| 267 | + 'desc' => __( 'A unique ID for this endpoint. Lowercase letters and underscores only.', 'wpgetapi' ), | |
| 273 | 268 | 'before_row' => "wpgetapi_output_top_of_endpoint", |
| 274 | 269 | 'api_id' => $api_id, |
| 275 | - 'sanitization_cb' => 'wpgetapi_sanitize_unique_id' | |
| 276 | 270 | |
| 277 | 271 | ), |
| 278 | 272 | array( |
| 279 | - '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' ), | |
| 280 | 274 | 'id' => 'endpoint', |
| 281 | 275 | 'type' => 'text', |
| 282 | 276 | 'classes' => 'field-endpoint', |
| 283 | 277 | 'attributes' => array( |
| @@ -283,12 +277,12 @@ | ||
| 283 | 277 | 'attributes' => array( |
| 284 | 278 | 'required' => true, |
| 285 | 279 | 'placeholder' => '/newendpoint', |
| 286 | 280 | ), |
| 287 | - 'desc' => '', | |
| 281 | + 'desc' => __( 'The endpoint that will be appended to the base URL.', 'wpgetapi' ), | |
| 288 | 282 | ), |
| 289 | 283 | array( |
| 290 | - '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' ), | |
| 291 | 285 | 'id' => 'method', |
| 292 | 286 | 'type' => 'select', |
| 293 | 287 | 'classes' => 'field-method', |
| 294 | 288 | 'attributes' => array( |
| @@ -297,22 +291,29 @@ | ||
| 297 | 291 | 'options' => array( |
| 298 | 292 | 'GET' => 'GET', |
| 299 | 293 | 'POST' => 'POST', |
| 300 | 294 | 'PUT' => 'PUT', |
| 301 | - 'PATCH' => 'PATCH', | |
| 302 | - 'DELETE' => 'DELETE', | |
| 303 | 295 | ), |
| 304 | - 'desc' => '', | |
| 296 | + 'desc' => __( 'The request method for this endpoint.', 'wpgetapi' ), | |
| 305 | 297 | ), |
| 306 | 298 | |
| 307 | 299 | array( |
| 308 | - 'name' => __( 'Results Format', 'wpgetapi' ) . | |
| 309 | - '<span class="dashicons dashicons-editor-help" data-tip="' . | |
| 310 | - sprintf( | |
| 311 | - __( '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' ), | |
| 312 | - 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>' ) | |
| 313 | - ) . | |
| 314 | - '"></span>', | |
| 300 | + 'name' => __( 'Cache Time', 'wpgetapi' ), | |
| 301 | + 'id' => 'cache_time', | |
| 302 | + 'type' => 'text', | |
| 303 | + 'classes' => 'field-cache-time', | |
| 304 | + 'attributes' => array( | |
| 305 | + 'placeholder' => '', | |
| 306 | + $cache_disabled => $cache_disabled, | |
| 307 | + ), | |
| 308 | + 'desc' => sprintf( | |
| 309 | + __( 'How many seconds to cache this request for (when set to GET method). %1s', 'wpgetapi' ), | |
| 310 | + $cache_url | |
| 311 | + ) | |
| 312 | + ), | |
| 313 | + | |
| 314 | + array( | |
| 315 | + 'name' => __( 'Results Format', 'wpgetapi' ), | |
| 315 | 316 | 'id' => 'results_format', |
| 316 | 317 | 'type' => 'select', |
| 317 | 318 | 'classes' => 'field-results-format', |
| 318 | 319 | 'attributes' => array( |
| @@ -318,122 +319,59 @@ | ||
| 318 | 319 | 'attributes' => array( |
| 319 | 320 | 'required' => true, |
| 320 | 321 | ), |
| 321 | 322 | 'options_cb' => 'wpgetapi_results_format_options', |
| 322 | - 'desc' => '' | |
| 323 | + 'desc' => __( 'The format of the results.', 'wpgetapi' ), | |
| 323 | 324 | ), |
| 324 | 325 | |
| 325 | 326 | array( |
| 326 | - 'name' => __( 'Cache Time', 'wpgetapi' ) . | |
| 327 | - '<span class="dashicons dashicons-editor-help" data-tip="' . | |
| 328 | - sprintf( | |
| 329 | - __( 'The time in seconds to cache this request for. %1s', 'wpgetapi' ), | |
| 330 | - htmlentities( '<br>' . $cache_url ) | |
| 331 | - ) . | |
| 332 | - '"></span>', | |
| 333 | - 'id' => 'cache_time', | |
| 334 | - 'type' => 'text', | |
| 335 | - 'classes' => 'field-cache-time', | |
| 336 | - 'attributes' => array( | |
| 337 | - 'placeholder' => '3600', | |
| 338 | - $cache_disabled => $cache_disabled, | |
| 339 | - ), | |
| 340 | - 'desc' => $cache_desc | |
| 341 | - ), | |
| 342 | - | |
| 343 | - array( | |
| 344 | - 'name' => __( 'Query String', 'wpgetapi' ) . | |
| 345 | - '<span class="dashicons dashicons-editor-help" data-tip="' . | |
| 346 | - sprintf( | |
| 347 | - __( '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' ), | |
| 348 | - 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>' ) | |
| 349 | - ) . | |
| 350 | - '"></span>', | |
| 327 | + 'name' => __( 'Query String', 'wpgetapi' ), | |
| 351 | 328 | 'id' => 'query_parameters', |
| 352 | 329 | 'type' => 'parameter', |
| 353 | 330 | 'classes' => 'field-query-parameters', |
| 354 | 331 | 'repeatable' => true, |
| 355 | - 'desc' => '' | |
| 332 | + 'desc' => sprintf( | |
| 333 | + __( 'Parameters as name/value pairs that will be appended to the URL. %1s', 'wpgetapi' ), | |
| 334 | + '<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>' | |
| 335 | + ) | |
| 356 | 336 | ), |
| 357 | 337 | array( |
| 358 | - 'name' => __( 'Headers', 'wpgetapi' ) . | |
| 359 | - '<span class="dashicons dashicons-editor-help" data-tip="' . | |
| 360 | - sprintf( | |
| 361 | - __( 'Parameters as name/value pairs, sent in the Headers. %1s', 'wpgetapi' ), | |
| 362 | - 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>' ) | |
| 363 | - ) . | |
| 364 | - '"></span>', | |
| 338 | + 'name' => __( 'Headers', 'wpgetapi' ), | |
| 365 | 339 | 'id' => 'header_parameters', |
| 366 | 340 | 'type' => 'parameter', |
| 367 | 341 | 'classes' => 'field-header-parameters', |
| 368 | 342 | 'repeatable' => true, |
| 369 | - 'desc' => '' | |
| 343 | + 'desc' => sprintf( | |
| 344 | + __( 'Parameters as name/value pairs, sent in the headers. %1s', 'wpgetapi' ), | |
| 345 | + '<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>' | |
| 346 | + ) | |
| 370 | 347 | ), |
| 371 | 348 | array( |
| 372 | - 'name' => __( 'Body POST Fields', 'wpgetapi' ) . | |
| 373 | - '<span class="dashicons dashicons-editor-help" data-tip="' . | |
| 374 | - sprintf( | |
| 375 | - __( 'Parameters as name/value pairs, sent in the Body as POST fields. %1s', 'wpgetapi' ), | |
| 376 | - 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>' ) | |
| 377 | - ) . | |
| 378 | - '"></span>', | |
| 349 | + 'name' => __( 'Body POST Fields', 'wpgetapi' ), | |
| 379 | 350 | 'id' => 'body_parameters', |
| 380 | 351 | 'type' => 'parameter', |
| 381 | 352 | 'classes' => 'field-body-parameters', |
| 382 | 353 | 'repeatable' => true, |
| 383 | - 'desc' => '' | |
| 354 | + 'desc' => sprintf( | |
| 355 | + __( 'Parameters as name/value pairs, sent in the body as POST fields. %1s', 'wpgetapi' ), | |
| 356 | + '<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>' | |
| 357 | + ) | |
| 384 | 358 | ), |
| 385 | 359 | array( |
| 386 | - 'name' => __( 'Encode Body', 'wpgetapi' ) . '<span class="dashicons dashicons-editor-help" data-tip="' . __( 'Encoding of the above Body parameters.', 'wpgetapi' ) . '"></span>', | |
| 360 | + 'name' => __( 'Encode Body', 'wpgetapi' ), | |
| 387 | 361 | 'id' => 'body_json_encode', |
| 388 | 362 | 'type' => 'select', |
| 389 | 363 | 'classes' => 'field-body-json-encode', |
| 390 | - 'options' => array( | |
| 391 | - 'false' => __( 'No encoding (raw)', 'wpgetapi' ), | |
| 392 | - 'true' => __( 'JSON encode', 'wpgetapi' ), | |
| 393 | - 'url' => __( 'URL encode (x-www-form-urlencoded)', 'wpgetapi' ), | |
| 394 | - 'base64' => __( 'Base64 encode', 'wpgetapi' ), | |
| 395 | - 'xml' => __( 'XML format (available in PRO)', 'wpgetapi' ), | |
| 396 | - | |
| 364 | + 'options' => array( | |
| 365 | + 'false' => __( 'No encoding', 'wpgetapi' ), | |
| 366 | + 'true' => __( 'JSON encode', 'wpgetapi' ), | |
| 367 | + 'url' => __( 'URL encode', 'wpgetapi' ), | |
| 397 | 368 | ), |
| 398 | - 'desc' => '', | |
| 369 | + 'desc' => __( 'Encoding of the above Body parameters (if they are set). ', 'wpgetapi' ), | |
| 399 | 370 | ), |
| 400 | - array( | |
| 401 | - 'name' => __( 'Actions', 'wpgetapi' ) . '<span class="dashicons dashicons-editor-help" data-tip="' . | |
| 402 | - sprintf( | |
| 403 | - __( 'Call this endpoint when your chosen action runs. This feature is available in the PRO plugin. %1s', 'wpgetapi' ), | |
| 404 | - 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>' ) | |
| 405 | - ) . | |
| 406 | - '"></span>', | |
| 407 | - 'id' => 'actions', | |
| 408 | - 'type' => 'select', | |
| 409 | - 'classes' => 'field-actions', | |
| 410 | - 'desc' => __( 'Available in PRO plugin.', 'wpgetapi' ), | |
| 411 | - 'options' => array( | |
| 412 | - '' => __( '-- No Action --', 'wpgetapi-extras' ), | |
| 413 | - 'new_post_published' => __( 'Post/Custom Post - New Post Published', 'wpgetapi-extras' ), | |
| 414 | - 'transition_post_status' => __( 'Post/Custom Post - Status Changed', 'wpgetapi-extras' ), | |
| 415 | - 'delete_post' => __( 'Post/Custom Post - Delete Post', 'wpgetapi-extras' ), | |
| 371 | + ) ); | |
| 416 | 372 | |
| 417 | - 'user_register' => __( 'User - New User Registered', 'wpgetapi-extras' ), | |
| 418 | - 'delete_user' => __( 'User - Delete User', 'wpgetapi-extras' ), | |
| 419 | - 'user_login' => __( 'User - User Logs In', 'wpgetapi-extras' ), | |
| 420 | - 'woocommerce_new_product' => __( 'WooCommerce - New Product Created', 'wpgetapi-extras' ), | |
| 421 | - 'woocommerce_new_order' => __( 'WooCommerce - New Order Created', 'wpgetapi-extras' ), | |
| 422 | - 'woocommerce_order_status_changed' => __( 'WooCommerce - Order Status Changed', 'wpgetapi-extras' ), | |
| 423 | - 'contact_form_7' => __( 'Contact Form 7', 'wpgetapi-extras' ), | |
| 424 | - 'gravity_forms' => __( 'Gravity Forms', 'wpgetapi-extras' ), | |
| 425 | - 'wpforms' => __( 'WPForms', 'wpgetapi-extras' ), | |
| 426 | - 'jetformbuilder' => __( 'JetFormBuilder', 'wpgetapi-extras' ), | |
| 427 | - 'formidable_forms' => __( 'Formidable Forms', 'wpgetapi-extras' ), | |
| 428 | - 'pmp' => __( 'Paid Memberships Pro - After Checkout', 'wpgetapi-extras' ), | |
| 429 | - 'edd' => __( 'Easy Digital Downloads - Complete Purchase', 'wpgetapi-extras' ), | |
| 430 | - ), | |
| 431 | - 'default' => '', | |
| 432 | - ) | |
| 433 | 373 | |
| 434 | - ) ); | |
| 435 | - | |
| 436 | 374 | $fields[] = array( |
| 437 | 375 | 'id' => 'endpoints', |
| 438 | 376 | 'type' => 'group', |
| 439 | 377 | 'name' => '', |
| @@ -442,13 +380,10 @@ | ||
| 442 | 380 | 'group_title' => __( 'Endpoint {#}', 'wpgetapi' ), |
| 443 | 381 | 'add_button' => __( 'Add Endpoint', 'wpgetapi' ), |
| 444 | 382 | 'remove_button' => __( 'Remove Endpoint', 'wpgetapi' ), |
| 445 | 383 | 'sortable' => true, // beta |
| 446 | - //'closed' => true, | |
| 447 | 384 | ), |
| 448 | - 'before_group' => '<pre class="url"><div>Base URL:</div> <span>' . $base_url . '</span></pre> | |
| 449 | - <div class="import-export"><a href="#TB_inline?&width=600&height=550&inlineId=my-content-id" class="button thickbox">Import/Export</a></div> | |
| 450 | - <div class="collapse open"><a class="button" title="Collapse all endpoints"><span class="dashicons dashicons-arrow-down"></span></a></div>', | |
| 385 | + 'before_group' => '<pre class="url">Base URL: <span>' . $base_url . '</span></pre>', | |
| 451 | 386 | 'fields' => $endpoint_fields, |
| 452 | 387 | ); |
| 453 | 388 | |
| 454 | 389 | return apply_filters( 'wpgetapi_fields', $fields ); |
| @@ -455,10 +390,11 @@ | ||
| 455 | 390 | |
| 456 | 391 | } |
| 457 | 392 | |
| 458 | 393 | |
| 394 | + | |
| 395 | + | |
| 459 | 396 | public function add_options_pages() { |
| 460 | - add_thickbox(); | |
| 461 | 397 | |
| 462 | 398 | $option_tabs = self::option_fields(); |
| 463 | 399 | |
| 464 | 400 | foreach ($option_tabs as $index => $option_tab) { |
| @@ -463,9 +399,9 @@ | ||
| 463 | 399 | |
| 464 | 400 | foreach ($option_tabs as $index => $option_tab) { |
| 465 | 401 | if ( $index == 0) { |
| 466 | 402 | |
| 467 | - $this->options_pages[] = add_menu_page( $this->title, $this->menu_title, 'manage_options', $option_tab['id'], array( $this, 'admin_page_display' ), 'none' | |
| 403 | + $this->options_pages[] = add_menu_page( $this->title, $this->menu_title, 'manage_options', $option_tab['id'], array( $this, 'admin_page_display' ), 'dashicons-editor-code' | |
| 468 | 404 | ); //Link admin menu to first tab |
| 469 | 405 | |
| 470 | 406 | 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 |
| 471 | 407 | } else { |
| @@ -493,15 +429,12 @@ | ||
| 493 | 429 | <div class="wrap wpgetapi"> |
| 494 | 430 | |
| 495 | 431 | <div class="main_content_cell"> |
| 496 | 432 | |
| 497 | - <h1 class="wp-heading-inline"> | |
| 498 | - <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> | |
| 499 | - </h1> | |
| 433 | + <h1 class="wp-heading-inline"><?php esc_html_e( $this->title, 'wpgetapi' ) ?></h1> | |
| 500 | 434 | <!-- Options Page Nav Tabs --> |
| 501 | 435 | <h2 class="nav-tab-wrapper"> |
| 502 | 436 | <?php foreach ($option_tabs as $option_tab) : |
| 503 | - | |
| 504 | 437 | $tab_slug = $option_tab['id']; |
| 505 | 438 | $nav_class = 'nav-tab'; |
| 506 | 439 | if ( $tab_slug == $_GET['page'] ) { |
| 507 | 440 | $nav_class .= ' nav-tab-active'; //add active class to current tab |
| @@ -506,30 +439,20 @@ | ||
| 506 | 439 | if ( $tab_slug == $_GET['page'] ) { |
| 507 | 440 | $nav_class .= ' nav-tab-active'; //add active class to current tab |
| 508 | 441 | $tab_forms[] = $option_tab; //add current tab to forms to be rendered |
| 509 | 442 | } |
| 510 | - | |
| 511 | - ?> | |
| 512 | - | |
| 513 | - <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> | |
| 514 | - | |
| 443 | + ?> | |
| 444 | + <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> | |
| 515 | 445 | <?php endforeach; ?> |
| 516 | 446 | </h2> |
| 517 | 447 | <!-- End of Nav Tabs --> |
| 518 | 448 | |
| 519 | - <?php | |
| 520 | - //render all tab forms (normaly just 1 form) | |
| 521 | - foreach ($tab_forms as $tab_form) : ?> | |
| 449 | + <?php foreach ($tab_forms as $tab_form) : //render all tab forms (normaly just 1 form) | |
| 450 | + | |
| 451 | + ?> | |
| 522 | 452 | |
| 523 | 453 | <div id="<?php esc_attr_e($tab_form['id']); ?>" class="cmb-form group"> |
| 524 | 454 | <div class="metabox-holder"> |
| 525 | - | |
| 526 | - <div id="my-content-id" style="display:none;"> | |
| 527 | - <div> | |
| 528 | - <?php echo $this->get_import_export(); ?> | |
| 529 | - </div> | |
| 530 | - </div> | |
| 531 | - | |
| 532 | 455 | <div class="pmpbox pad"> |
| 533 | 456 | <h3 class="title"><?php esc_html_e($tab_form['title'], 'wpgetapi'); ?></h3> |
| 534 | 457 | <div class="desc"><?php echo wp_kses_post( $tab_form['desc'] ); ?></div> |
| 535 | 458 | <?php cmb2_metabox_form( $tab_form, $tab_form['id'], $tab_form ); ?> |
| @@ -572,128 +495,9 @@ | ||
| 572 | 495 | wp_die(); // this is required to terminate immediately and return a proper response |
| 573 | 496 | |
| 574 | 497 | } |
| 575 | 498 | |
| 576 | - public function get_import_export() { | |
| 577 | - ob_start(); ?> | |
| 578 | 499 | |
| 579 | - <div class="wpgetapi-export"> | |
| 580 | - <h3><span class="dashicons dashicons-download"></span> Export Endpoints</h3> | |
| 581 | - <p>Export the endpoints for this API.<br>After clicking the button below, copy the entire contents of the export.</p> | |
| 582 | - <button class="button button-primary">Export Endpoints</button> | |
| 583 | - <div class="message"></div> | |
| 584 | - </div> | |
| 585 | - | |
| 586 | - <div class="wpgetapi-import"> | |
| 587 | - <h3><span class="dashicons dashicons-upload"></span> Import Endpoints</h3> | |
| 588 | - <p>Paste your exported JSON data into the field below to import endpoints into this API.</p> | |
| 589 | - <textarea></textarea> | |
| 590 | - <button class="button button-primary">Import Endpoints</button> | |
| 591 | - <div class="message"></div> | |
| 592 | - </div> | |
| 593 | - | |
| 594 | - <?php | |
| 595 | - $content = ob_get_contents(); | |
| 596 | - ob_end_clean(); | |
| 597 | - return $content; | |
| 598 | - } | |
| 599 | - | |
| 600 | - /** | |
| 601 | - * AJAX function to get our endpoints for export. | |
| 602 | - * | |
| 603 | - */ | |
| 604 | - public function export_endpoints() { | |
| 605 | - $api_id = sanitize_text_field( $_POST['api_id'] ); | |
| 606 | - $data = get_option( $api_id ); | |
| 607 | - | |
| 608 | - if( ! isset( $data['endpoints'] ) ) | |
| 609 | - wp_die(); | |
| 610 | - | |
| 611 | - $encryption = new WpGetApi_Encryption(); | |
| 612 | - | |
| 613 | - foreach ( $data['endpoints'] as $i => $endpoint ) { | |
| 614 | - if( isset( $endpoint['query_parameters'] ) ) { | |
| 615 | - foreach ( $endpoint['query_parameters'] as $i2 => $query_parameters ) { | |
| 616 | - if( isset( $query_parameters['value'] ) ) | |
| 617 | - $data['endpoints'][ $i ]['query_parameters'][ $i2 ]['value'] = $encryption->decrypt( $query_parameters['value'] ); | |
| 618 | - } | |
| 619 | - } | |
| 620 | - if( isset( $endpoint['header_parameters'] ) ) { | |
| 621 | - foreach ( $endpoint['header_parameters'] as $i2 => $header_parameters ) { | |
| 622 | - if( isset( $header_parameters['value'] ) ) | |
| 623 | - $data['endpoints'][ $i ]['header_parameters'][ $i2 ]['value'] = $encryption->decrypt( $header_parameters['value'] ); | |
| 624 | - } | |
| 625 | - } | |
| 626 | - if( isset( $endpoint['body_parameters'] ) ) { | |
| 627 | - foreach ( $endpoint['body_parameters'] as $i2 => $body_parameters ) { | |
| 628 | - if( isset( $body_parameters['value'] ) ) | |
| 629 | - $data['endpoints'][ $i ]['body_parameters'][ $i2 ]['value'] = $encryption->decrypt( $body_parameters['value'] ); | |
| 630 | - } | |
| 631 | - } | |
| 632 | - } | |
| 633 | - | |
| 634 | - echo json_encode( $data ); | |
| 635 | - wp_die(); // this is required to terminate immediately and return a proper response | |
| 636 | - } | |
| 637 | - | |
| 638 | - /** | |
| 639 | - * AJAX function to import our endpoints. | |
| 640 | - * | |
| 641 | - */ | |
| 642 | - public function import_endpoints() { | |
| 643 | - | |
| 644 | - $api_id = sanitize_text_field( $_POST['api_id'] ); | |
| 645 | - $textarea = sanitize_textarea_field( $_POST['textarea'] ); | |
| 646 | - $existing_data = get_option( $api_id ); | |
| 647 | - | |
| 648 | - if( ! $textarea ) { | |
| 649 | - echo 'No data found.'; | |
| 650 | - wp_die(); | |
| 651 | - } | |
| 652 | - | |
| 653 | - $new_data = json_decode( stripslashes( $textarea ), true ); | |
| 654 | - if( ! isset( $new_data['endpoints'] ) ){ | |
| 655 | - echo 'No endpoints found.'; | |
| 656 | - wp_die(); | |
| 657 | - } | |
| 658 | - | |
| 659 | - $encryption = new WpGetApi_Encryption(); | |
| 660 | - | |
| 661 | - foreach ( $new_data['endpoints'] as $i => $endpoint ) { | |
| 662 | - if( isset( $endpoint['query_parameters'] ) ) { | |
| 663 | - foreach ( $endpoint['query_parameters'] as $i2 => $query_parameters ) { | |
| 664 | - if( isset( $query_parameters['value'] ) ) | |
| 665 | - $new_data['endpoints'][ $i ]['query_parameters'][ $i2 ]['value'] = $encryption->encrypt( $query_parameters['value'] ); | |
| 666 | - } | |
| 667 | - } | |
| 668 | - if( isset( $endpoint['header_parameters'] ) ) { | |
| 669 | - foreach ( $endpoint['header_parameters'] as $i2 => $header_parameters ) { | |
| 670 | - if( isset( $header_parameters['value'] ) ) | |
| 671 | - $new_data['endpoints'][ $i ]['header_parameters'][ $i2 ]['value'] = $encryption->encrypt( $header_parameters['value'] ); | |
| 672 | - } | |
| 673 | - } | |
| 674 | - if( isset( $endpoint['body_parameters'] ) ) { | |
| 675 | - foreach ( $endpoint['body_parameters'] as $i2 => $body_parameters ) { | |
| 676 | - if( isset( $body_parameters['value'] ) ) | |
| 677 | - $new_data['endpoints'][ $i ]['body_parameters'][ $i2 ]['value'] = $encryption->encrypt( $body_parameters['value'] ); | |
| 678 | - } | |
| 679 | - } | |
| 680 | - } | |
| 681 | - | |
| 682 | - // if no existing endpoints, simply add it | |
| 683 | - if( ! $existing_data ) { | |
| 684 | - update_option( $api_id, $new_data ); | |
| 685 | - } else { | |
| 686 | - | |
| 687 | - $merged['endpoints'] = array_merge( $existing_data['endpoints'], $new_data['endpoints'] ); | |
| 688 | - update_option( $api_id, $merged ); | |
| 689 | - } | |
| 690 | - | |
| 691 | - echo 'Successfully imported. Reloading...'; | |
| 692 | - wp_die(); // this is required to terminate immediately and return a proper response | |
| 693 | - } | |
| 694 | - | |
| 695 | - | |
| 696 | 500 | public function load_testing_javascript() { ?> |
| 697 | 501 | |
| 698 | 502 | <script type="text/javascript" > |
| 699 | 503 | |
| @@ -698,103 +502,8 @@ | ||
| 698 | 502 | <script type="text/javascript" > |
| 699 | 503 | |
| 700 | 504 | jQuery(document).ready(function($) { |
| 701 | 505 | |
| 702 | - /** | |
| 703 | - * Collapse the endpoints | |
| 704 | - * | |
| 705 | - */ | |
| 706 | - $('body').on( 'click', '.wpgetapi .collapse .button', function(){ | |
| 707 | - | |
| 708 | - var $this = $(this); | |
| 709 | - var $collapse = $(this).parents('.collapse'); | |
| 710 | - var status = 'open'; | |
| 711 | - | |
| 712 | - $collapse.toggleClass('open'); | |
| 713 | - | |
| 714 | - if( ! $collapse.hasClass( 'open' ) ) | |
| 715 | - status = 'closed'; | |
| 716 | - | |
| 717 | - var $endpoints = $( '#endpoints_repeat .postbox.cmb-repeatable-grouping' ); | |
| 718 | - $endpoints.each( function() { | |
| 719 | - | |
| 720 | - if( status == 'closed' ) { | |
| 721 | - $( this ).addClass('closed'); | |
| 722 | - } else { | |
| 723 | - $( this ).removeClass('closed'); | |
| 724 | - } | |
| 725 | - | |
| 726 | - }); | |
| 727 | - | |
| 728 | - }); | |
| 729 | - | |
| 730 | - /** | |
| 731 | - * Run the export | |
| 732 | - * | |
| 733 | - */ | |
| 734 | - $('body').on( 'click', '.wpgetapi-export .button', function(){ | |
| 735 | - | |
| 736 | - var $this = $(this); | |
| 737 | - var api_id = $('.wpgetapi.wrap').find( '.cmb-form.group' ).attr( 'id' ); | |
| 738 | - | |
| 739 | - // disable button | |
| 740 | - $this.attr( 'disabled', true ); | |
| 741 | - | |
| 742 | - var data = { | |
| 743 | - 'action': 'wpgetapi_export_endpoints', | |
| 744 | - 'api_id': api_id, | |
| 745 | - }; | |
| 746 | - | |
| 747 | - // send and get response | |
| 748 | - jQuery.post(ajaxurl, data, function( response ) { | |
| 749 | - $( '.wpgetapi-export .message' ).show().html( response ); | |
| 750 | - // enable button | |
| 751 | - $( '.wpgetapi-export .button' ).attr( 'disabled', false ); | |
| 752 | - | |
| 753 | - }); | |
| 754 | - | |
| 755 | - }); | |
| 756 | - | |
| 757 | - /** | |
| 758 | - * Run the import | |
| 759 | - * | |
| 760 | - */ | |
| 761 | - $('body').on( 'click', '.wpgetapi-import .button', function(){ | |
| 762 | - | |
| 763 | - var $this = $(this); | |
| 764 | - var api_id = $('.wpgetapi.wrap').find( '.cmb-form.group' ).attr( 'id' ); | |
| 765 | - var textarea = $('.wpgetapi-import textarea').val(); | |
| 766 | - | |
| 767 | - // disable button | |
| 768 | - $this.attr( 'disabled', true ); | |
| 769 | - | |
| 770 | - var data = { | |
| 771 | - 'action': 'wpgetapi_import_endpoints', | |
| 772 | - 'textarea': textarea, | |
| 773 | - 'api_id': api_id, | |
| 774 | - }; | |
| 775 | - | |
| 776 | - // send and get response | |
| 777 | - jQuery.post(ajaxurl, data, function( response ) { | |
| 778 | - | |
| 779 | - $( '.wpgetapi-import .message' ).html( response ); | |
| 780 | - | |
| 781 | - if( response == 'Successfully imported. Reloading...' ) { | |
| 782 | - setTimeout(function(){ | |
| 783 | - location.reload(); | |
| 784 | - }, 2000); | |
| 785 | - } else { | |
| 786 | - $( '.wpgetapi-import .button' ).attr( 'disabled', false ); | |
| 787 | - } | |
| 788 | - | |
| 789 | - }); | |
| 790 | - | |
| 791 | - }); | |
| 792 | - | |
| 793 | - /** | |
| 794 | - * Run the endpoint test | |
| 795 | - * | |
| 796 | - */ | |
| 797 | 506 | $('body').on( 'click', '.wpgetapi-test-area .test-button', function(){//delegated |
| 798 | 507 | |
| 799 | 508 | var $this = $(this); |
| 800 | 509 | var area = $this.parents( '.wpgetapi-test-area' ); |
| @@ -814,11 +523,16 @@ | ||
| 814 | 523 | jQuery.post(ajaxurl, data, function( response ) { |
| 815 | 524 | |
| 816 | 525 | var output = JSON.parse( response ); |
| 817 | 526 | |
| 818 | - $( '.wpgetapi-test-area[data-endpoint="' + output.endpoint_id + '"] .handle' ).show(); | |
| 819 | - $( '.wpgetapi-test-area[data-endpoint="' + output.endpoint_id + '"] .wpgetapi-result' ).html( output.data); | |
| 527 | + jQuery( '.wpgetapi-test-area[data-endpoint="' + output.endpoint_id + '"] .handle' ).show(); | |
| 820 | 528 | |
| 529 | + jQuery( '.wpgetapi-test-area[data-endpoint="' + output.endpoint_id + '"] .wpgetapi-result' ).html( | |
| 530 | + '<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>' + | |
| 531 | + '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>' + | |
| 532 | + output.data | |
| 533 | + ); | |
| 534 | + | |
| 821 | 535 | // enable button |
| 822 | 536 | $( '.wpgetapi-test-area[data-endpoint="' + output.endpoint_id + '"] .test-button' ).attr( 'disabled', false ); |
| 823 | 537 | |
| 824 | 538 | }); |
| @@ -850,22 +564,41 @@ | ||
| 850 | 564 | |
| 851 | 565 | ?> |
| 852 | 566 | |
| 853 | 567 | <div class="box"> |
| 854 | - <h4><?php esc_html_e( 'Endpoint Instructions', 'wpgetapi' ); ?></h4> | |
| 568 | + <h3><?php esc_html_e( 'Endpoint Instructions', 'wpgetapi' ); ?></h3> | |
| 855 | 569 | <ol> |
| 856 | - <li><?php _e( 'Give your endpoint a <b>Unique ID</b>', 'wpgetapi' ); ?></li> | |
| 857 | - <li><?php _e( 'Add the <b>Endpoint</b> which can be found in your API docs', 'wpgetapi' ); ?></li> | |
| 858 | - <li><?php _e( 'Set the <b>Method</b> - GET for getting data & POST for sending data to the API', 'wpgetapi' ); ?></li> | |
| 859 | - <li><?php _e( 'Set the desired <b>Results Format</b>', 'wpgetapi' ); ?></li> | |
| 860 | - <li><?php _e( 'Other fields are optional & will depend on your API', 'wpgetapi' ); ?></li> | |
| 861 | - <li><?php _e( 'Hit the Save button', 'wpgetapi' ); ?></li> | |
| 862 | - <li><?php _e( 'Copy the Template Tag or Shortcode & paste into page, post or theme file', 'wpgetapi' ); ?></li> | |
| 570 | + <li><?php esc_html_e( 'Fill in the Unique ID with lowercase letters and underscores only. something_like_this', 'wpgetapi' ); ?></li> | |
| 571 | + <li><?php esc_html_e( 'Add the Endpoint which can be found in the docs of your API.', 'wpgetapi' ); ?></li> | |
| 572 | + <li><?php esc_html_e( 'Set the Method. Usually GET for getting data from the API and POST when sending data to the API.', 'wpgetapi' ); ?></li> | |
| 573 | + <li><?php esc_html_e( 'Set the desired Results Format.', 'wpgetapi' ); ?></li> | |
| 574 | + <li><?php esc_html_e( 'The rest of the fields are optional and will depend on the API you using.', 'wpgetapi' ); ?></li> | |
| 575 | + <li><?php esc_html_e( 'Hit the Save button.', 'wpgetapi' ); ?></li> | |
| 576 | + <li><?php esc_html_e( 'After saving, copy the Template Tag or the Shortcode and paste into appropriate place (page, post, theme file).', 'wpgetapi' ); ?></li> | |
| 863 | 577 | </ol> |
| 864 | 578 | </div> |
| 865 | 579 | |
| 866 | - <?php echo $this->help_box(); ?> | |
| 580 | + <hr> | |
| 867 | 581 | |
| 582 | + <?php | |
| 583 | + if( ! $this->pro_plugin ) { | |
| 584 | + $this->pro_banner(); | |
| 585 | + echo '<hr>'; | |
| 586 | + } | |
| 587 | + ?> | |
| 588 | + | |
| 589 | + <div class="box"> | |
| 590 | + <strong><?php esc_html_e( 'Getting Help', 'wpgetapi' ); ?></strong> | |
| 591 | + <ul> | |
| 592 | + <li><?php | |
| 593 | + printf( | |
| 594 | + esc_html__( 'Visit our website to %1$s.', 'cmb2' ), | |
| 595 | + '<a target="_blank" href="https://wpgetapi.com/docs/?utm_campaign=Docs&utm_medium=Admin&utm_source=User">view the docs</a>' | |
| 596 | + ); | |
| 597 | + ?></li> | |
| 598 | + </ul> | |
| 599 | + </div> | |
| 600 | + | |
| 868 | 601 | <?php |
| 869 | 602 | $content = ob_get_contents(); |
| 870 | 603 | ob_end_clean(); |
| 871 | 604 | return $content; |
| @@ -882,20 +615,39 @@ | ||
| 882 | 615 | ob_start(); |
| 883 | 616 | ?> |
| 884 | 617 | |
| 885 | 618 | <div class="box"> |
| 886 | - <h4><?php esc_html_e( 'Setup Instructions', 'wpgetapi' ); ?></h4> | |
| 619 | + <h3><?php esc_html_e( 'Setup Instructions', 'wpgetapi' ); ?></h3> | |
| 887 | 620 | <ol> |
| 888 | - <li><?php _e( 'Name your API in the <b>API Name</b> field', 'wpgetapi' ); ?></li> | |
| 889 | - <li><?php _e( 'Give your API a <b>Unique ID</b>', 'wpgetapi' ); ?></li> | |
| 890 | - <li><?php _e( 'Add the <b>Base URL</b> of your API. This can be found in the docs of your API', 'wpgetapi' ); ?></li> | |
| 891 | - <li><?php _e( 'Hit the Save button', 'wpgetapi' ); ?></li> | |
| 892 | - <li><?php _e( 'Visit the new tab that will be created', 'wpgetapi' ); ?></li> | |
| 621 | + <li><?php esc_html_e( 'Fill in the API Name. You can name this whatever you like.', 'wpgetapi' ); ?></li> | |
| 622 | + <li><?php esc_html_e( 'Fill in the Unique ID with lowercase letters and underscores only. something_like_this', 'wpgetapi' ); ?></li> | |
| 623 | + <li><?php esc_html_e( 'Add the Base URL of your API. This can be found in the docs of your API.', 'wpgetapi' ); ?></li> | |
| 624 | + <li><?php esc_html_e( 'Hit the Save button.', 'wpgetapi' ); ?></li> | |
| 625 | + <li><?php esc_html_e( 'After saving, visit the new tab that will be created.', 'wpgetapi' ); ?></li> | |
| 893 | 626 | </ol> |
| 894 | 627 | </div> |
| 895 | 628 | |
| 896 | - <?php echo $this->help_box(); ?> | |
| 629 | + <hr> | |
| 630 | + | |
| 631 | + <?php | |
| 632 | + if( ! $this->pro_plugin ) { | |
| 633 | + $this->pro_banner(); | |
| 634 | + echo '<hr>'; | |
| 635 | + } | |
| 636 | + ?> | |
| 897 | 637 | |
| 638 | + <div class="box"> | |
| 639 | + <strong><?php esc_html_e( 'Getting Help', 'wpgetapi' ); ?></strong> | |
| 640 | + <ul> | |
| 641 | + <li><?php | |
| 642 | + printf( | |
| 643 | + esc_html__( 'Visit our website to %1$s.', 'cmb2' ), | |
| 644 | + '<a target="_blank" href="https://wpgetapi.com/docs/?utm_campaign=Docs&utm_medium=Admin&utm_source=User">view the docs</a>' | |
| 645 | + ); | |
| 646 | + ?></li> | |
| 647 | + </ul> | |
| 648 | + </div> | |
| 649 | + | |
| 898 | 650 | <?php |
| 899 | 651 | $content = ob_get_contents(); |
| 900 | 652 | ob_end_clean(); |
| 901 | 653 | return $content; |
| @@ -902,49 +654,35 @@ | ||
| 902 | 654 | |
| 903 | 655 | } |
| 904 | 656 | |
| 905 | 657 | |
| 658 | + | |
| 906 | 659 | /** |
| 907 | - * | |
| 660 | + * Banner for the pro plugin. | |
| 908 | 661 | * @since 1.4.4 |
| 909 | 662 | */ |
| 910 | - public function help_box() { | |
| 663 | + public function pro_banner() { | |
| 911 | 664 | |
| 912 | - ob_start(); | |
| 913 | 665 | ?> |
| 914 | 666 | |
| 915 | - <hr> | |
| 916 | - | |
| 917 | - <div class="box help-box"> | |
| 918 | - <h4><?php esc_html_e( 'Getting Help', 'wpgetapi' ); ?></h4> | |
| 667 | + <div class="box pro"> | |
| 668 | + <h4><?php esc_html_e( 'Upgrade to the Pro Plugin', 'wpgetapi' ); ?></h4> | |
| 919 | 669 | <ul> |
| 920 | - <li><?php | |
| 921 | - printf( | |
| 922 | - esc_html__( 'View the %1$s', 'cmb2' ), | |
| 923 | - '<a target="_blank" href="https://wpgetapi.com/docs/quick-start-guide/?utm_campaign=Docs&utm_medium=Admin&utm_source=User">Quick Start Guide</a>' | |
| 924 | - ); | |
| 925 | - ?></li> | |
| 926 | - <li><?php | |
| 927 | - printf( | |
| 928 | - esc_html__( 'View the %1$s', 'cmb2' ), | |
| 929 | - '<a target="_blank" href="https://wpgetapi.com/docs/frequently-asked-questions/?utm_campaign=Docs&utm_medium=Admin&utm_source=User">FAQs</a>' | |
| 930 | - ); | |
| 931 | - ?></li> | |
| 932 | - | |
| 933 | - <?php if( ! $this->pro_plugin ) { ?> | |
| 934 | - <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> | |
| 935 | - <?php } ?> | |
| 670 | + <li><?php esc_html_e( 'Cache API calls', 'wpgetapi' ); ?></li> | |
| 671 | + <li><?php esc_html_e( 'Dynamic variables', 'wpgetapi' ); ?></li> | |
| 672 | + <li><?php esc_html_e( 'Get nested data', 'wpgetapi' ); ?></li> | |
| 673 | + <li><?php esc_html_e( 'Base64 encoding', 'wpgetapi' ); ?></li> | |
| 674 | + <li><?php esc_html_e( 'Format as HTML', 'wpgetapi' ); ?></li> | |
| 675 | + <li><?php esc_html_e( 'Format as a number', 'wpgetapi' ); ?></li> | |
| 676 | + <li><?php esc_html_e( 'XML format', 'wpgetapi' ); ?></li> | |
| 936 | 677 | </ul> |
| 678 | + <a class="button" href="https://wpgetapi.com/downloads/pro-plugin/"><?php esc_html_e( 'Get the Pro Plugin', 'wpgetapi' ); ?></a> | |
| 937 | 679 | </div> |
| 938 | 680 | |
| 939 | - <?php | |
| 940 | - $content = ob_get_contents(); | |
| 941 | - ob_end_clean(); | |
| 942 | - return $content; | |
| 681 | + <?php | |
| 943 | 682 | |
| 944 | 683 | } |
| 945 | 684 | |
| 946 | - | |
| 947 | 685 | /** |
| 948 | 686 | * Tabs don't immmediately appear on save, so this hack! |
| 949 | 687 | * @since 0.1.0 |
| 950 | 688 | */ |
| @@ -949,11 +687,11 @@ | ||
| 949 | 687 | * @since 0.1.0 |
| 950 | 688 | */ |
| 951 | 689 | public function redirect( $object_id, $updated ) { |
| 952 | 690 | |
| 953 | - if( strpos( $object_id, 'wpgetapi_' ) !== false && strpos( $object_id, 'wpgetapi_api_importer' ) == false ) { | |
| 691 | + if( $object_id == 'wpgetapi_setup' ) { | |
| 954 | 692 | |
| 955 | - add_settings_error( 'wpgetapi-notices', '', 'Saved, reloading page...', 'updated' ); | |
| 693 | + add_settings_error( 'wpgetapi-notices', '', 'Settings saved, reloading page...', 'updated' ); | |
| 956 | 694 | settings_errors( 'wpgetapi-notices' ); |
| 957 | 695 | ?> |
| 958 | 696 | |
| 959 | 697 | <script> |
| @@ -958,13 +696,19 @@ | ||
| 958 | 696 | |
| 959 | 697 | <script> |
| 960 | 698 | setTimeout(function() { |
| 961 | 699 | location.reload(); |
| 962 | - }, 200); | |
| 700 | + }, 1000); | |
| 963 | 701 | </script> |
| 964 | 702 | <?php |
| 965 | 703 | |
| 966 | - } | |
| 704 | + } else if ( strpos( $object_id, 'wpgetapi_' ) !== false ) { | |
| 705 | + | |
| 706 | + $text = apply_filters( 'wpgetapi_admin_notice_text', __( 'Settings saved.', 'wpgetapi' ), $object_id ); | |
| 707 | + add_settings_error( 'wpgetapi-notices', '', $text, 'updated' ); | |
| 708 | + settings_errors( 'wpgetapi-notices' ); | |
| 709 | + | |
| 710 | + } | |
| 967 | 711 | |
| 968 | 712 | } |
| 969 | 713 | |
| 970 | 714 | |