| @@ -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 | /** |
| @@ -206,20 +203,19 @@ | ||
| 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 | - 'classes' => 'api-name', | |
| 214 | 210 | 'attributes' => array( |
| 215 | 211 | 'required' => true, |
| 216 | 212 | 'placeholder' => 'Google Maps', |
| 217 | 213 | ), |
| 218 | - 'desc' => '', | |
| 214 | + 'desc' => __( 'The name of the API you are connecting to.', 'wpgetapi' ), | |
| 219 | 215 | ), |
| 220 | 216 | array( |
| 221 | - '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' ), | |
| 222 | 218 | 'id' => 'id', |
| 223 | 219 | 'type' => 'text', |
| 224 | 220 | 'attributes' => array( |
| 225 | 221 | 'required' => true, |
| @@ -224,13 +220,12 @@ | ||
| 224 | 220 | 'attributes' => array( |
| 225 | 221 | 'required' => true, |
| 226 | 222 | 'placeholder' => 'google_maps', |
| 227 | 223 | ), |
| 228 | - 'desc' => '', | |
| 229 | - 'sanitization_cb' => 'wpgetapi_sanitize_unique_id' | |
| 224 | + 'desc' => __( 'A unique ID for your API. Lowercase letters and underscores only.', 'wpgetapi' ), | |
| 230 | 225 | ), |
| 231 | 226 | array( |
| 232 | - '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' ), | |
| 233 | 228 | 'id' => 'base_url', |
| 234 | 229 | 'type' => 'text', |
| 235 | 230 | 'attributes' => array( |
| 236 | 231 | 'required' => true, |
| @@ -235,9 +230,9 @@ | ||
| 235 | 230 | 'attributes' => array( |
| 236 | 231 | 'required' => true, |
| 237 | 232 | 'placeholder' => 'https://maps.googleapis.com/maps/api', |
| 238 | 233 | ), |
| 239 | - 'desc' => '', | |
| 234 | + 'desc' => __( 'The base URL of the API you are connecting to.', 'wpgetapi' ), | |
| 240 | 235 | ), |
| 241 | 236 | |
| 242 | 237 | ) |
| 243 | 238 | ); |
| @@ -256,43 +251,41 @@ | ||
| 256 | 251 | |
| 257 | 252 | $fields = array(); |
| 258 | 253 | |
| 259 | 254 | $cache_disabled = $this->pro_plugin ? '' : 'disabled'; |
| 260 | - $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>'; | |
| 261 | - $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>'; | |
| 262 | 256 | |
| 263 | 257 | $endpoint_fields = apply_filters( 'wpgetapi_fields_endpoints', array( |
| 264 | 258 | array( |
| 265 | - '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' ), | |
| 266 | 260 | 'id' => 'id', |
| 267 | 261 | 'type' => 'text', |
| 268 | - 'classes' => 'field-id field-half', | |
| 262 | + 'classes' => 'field-id', | |
| 269 | 263 | 'attributes' => array( |
| 270 | 264 | 'required' => true, |
| 271 | 265 | 'placeholder' => 'new_endpoint', |
| 272 | 266 | ), |
| 273 | - 'desc' => '', | |
| 267 | + 'desc' => __( 'A unique ID for this endpoint. Lowercase letters and underscores only.', 'wpgetapi' ), | |
| 274 | 268 | 'before_row' => "wpgetapi_output_top_of_endpoint", |
| 275 | 269 | 'api_id' => $api_id, |
| 276 | - 'sanitization_cb' => 'wpgetapi_sanitize_unique_id' | |
| 277 | 270 | |
| 278 | 271 | ), |
| 279 | 272 | array( |
| 280 | - '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' ), | |
| 281 | 274 | 'id' => 'endpoint', |
| 282 | 275 | 'type' => 'text', |
| 283 | - 'classes' => 'field-endpoint field-half', | |
| 276 | + 'classes' => 'field-endpoint', | |
| 284 | 277 | 'attributes' => array( |
| 285 | 278 | 'required' => true, |
| 286 | 279 | 'placeholder' => '/newendpoint', |
| 287 | 280 | ), |
| 288 | - 'desc' => '', | |
| 281 | + 'desc' => __( 'The endpoint that will be appended to the base URL.', 'wpgetapi' ), | |
| 289 | 282 | ), |
| 290 | 283 | array( |
| 291 | - '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' ), | |
| 292 | 285 | 'id' => 'method', |
| 293 | 286 | 'type' => 'select', |
| 294 | - 'classes' => 'field-method field-half', | |
| 287 | + 'classes' => 'field-method', | |
| 295 | 288 | 'attributes' => array( |
| 296 | 289 | 'required' => true, |
| 297 | 290 | ), |
| 298 | 291 | 'options' => array( |
| @@ -298,159 +291,92 @@ | ||
| 298 | 291 | 'options' => array( |
| 299 | 292 | 'GET' => 'GET', |
| 300 | 293 | 'POST' => 'POST', |
| 301 | 294 | 'PUT' => 'PUT', |
| 302 | - 'PATCH' => 'PATCH', | |
| 303 | 295 | 'DELETE' => 'DELETE', |
| 304 | 296 | ), |
| 305 | - 'desc' => '', | |
| 297 | + 'desc' => __( 'The request method for this endpoint.', 'wpgetapi' ), | |
| 306 | 298 | ), |
| 307 | 299 | |
| 308 | 300 | array( |
| 309 | - 'name' => __( 'Results Format', 'wpgetapi' ) . | |
| 310 | - '<span class="dashicons dashicons-editor-help" data-tip="' . | |
| 311 | - sprintf( | |
| 312 | - __( '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' ), | |
| 313 | - 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>' ) | |
| 314 | - ) . | |
| 315 | - '"></span>', | |
| 301 | + 'name' => __( 'Results Format', 'wpgetapi' ), | |
| 316 | 302 | 'id' => 'results_format', |
| 317 | 303 | 'type' => 'select', |
| 318 | - 'classes' => 'field-results-format field-half', | |
| 304 | + 'classes' => 'field-results-format', | |
| 319 | 305 | 'attributes' => array( |
| 320 | 306 | 'required' => true, |
| 321 | 307 | ), |
| 322 | 308 | 'options_cb' => 'wpgetapi_results_format_options', |
| 323 | - '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 | + ) | |
| 324 | 313 | ), |
| 325 | 314 | |
| 326 | 315 | array( |
| 327 | - 'name' => __( 'Timeout', 'wpgetapi' ) . | |
| 328 | - '<span class="dashicons dashicons-editor-help" data-tip="How long the connection should stay open in seconds. Default is 10. If you receive curl 28 errors, try increasing this value."></span>', | |
| 329 | - 'id' => 'timeout', | |
| 330 | - 'type' => 'text', | |
| 331 | - 'default' => '10', | |
| 332 | - 'classes' => 'field-timeout field-half', | |
| 333 | - 'attributes' => array( | |
| 334 | - 'placeholder' => '10', | |
| 335 | - ), | |
| 336 | - 'desc' => '' | |
| 337 | - ), | |
| 338 | - | |
| 339 | - array( | |
| 340 | - 'name' => __( 'Cache Time', 'wpgetapi' ) . | |
| 341 | - '<span class="dashicons dashicons-editor-help" data-tip="' . | |
| 342 | - sprintf( | |
| 343 | - __( 'The time in seconds to cache this request for. %1s', 'wpgetapi' ), | |
| 344 | - htmlentities( '<br>' . $cache_url ) | |
| 345 | - ) . | |
| 346 | - '"></span>', | |
| 316 | + 'name' => __( 'Cache Time', 'wpgetapi' ), | |
| 347 | 317 | 'id' => 'cache_time', |
| 348 | 318 | 'type' => 'text', |
| 349 | - 'classes' => 'field-cache-time field-half', | |
| 319 | + 'classes' => 'field-cache-time', | |
| 350 | 320 | 'attributes' => array( |
| 351 | - 'placeholder' => '3600', | |
| 321 | + 'placeholder' => '', | |
| 352 | 322 | $cache_disabled => $cache_disabled, |
| 353 | 323 | ), |
| 354 | - 'desc' => $cache_desc, | |
| 355 | - 'after_row' => '</div>' | |
| 324 | + 'desc' => sprintf( | |
| 325 | + __( 'The time in seconds to cache this request for. %1s', 'wpgetapi' ), | |
| 326 | + $cache_url | |
| 327 | + ) | |
| 356 | 328 | ), |
| 357 | 329 | |
| 358 | 330 | array( |
| 359 | - 'name' => __( 'Query String', 'wpgetapi' ) . | |
| 360 | - '<span class="dashicons dashicons-editor-help" data-tip="' . | |
| 361 | - sprintf( | |
| 362 | - __( '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' ), | |
| 363 | - 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>' ) | |
| 364 | - ) . | |
| 365 | - '"></span>', | |
| 331 | + 'name' => __( 'Query String', 'wpgetapi' ), | |
| 366 | 332 | 'id' => 'query_parameters', |
| 367 | 333 | 'type' => 'parameter', |
| 368 | 334 | 'classes' => 'field-query-parameters', |
| 369 | 335 | 'repeatable' => true, |
| 370 | - 'desc' => '', | |
| 371 | - 'before_row' => '<div class="fields-wrapper">' | |
| 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 | + ) | |
| 372 | 340 | ), |
| 373 | 341 | array( |
| 374 | - 'name' => __( 'Headers', 'wpgetapi' ) . | |
| 375 | - '<span class="dashicons dashicons-editor-help" data-tip="' . | |
| 376 | - sprintf( | |
| 377 | - __( 'Parameters as name/value pairs, sent in the Headers. %1s', 'wpgetapi' ), | |
| 378 | - 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>' ) | |
| 379 | - ) . | |
| 380 | - '"></span>', | |
| 342 | + 'name' => __( 'Headers', 'wpgetapi' ), | |
| 381 | 343 | 'id' => 'header_parameters', |
| 382 | 344 | 'type' => 'parameter', |
| 383 | 345 | 'classes' => 'field-header-parameters', |
| 384 | 346 | 'repeatable' => true, |
| 385 | - '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 | + ) | |
| 386 | 351 | ), |
| 387 | 352 | array( |
| 388 | - 'name' => __( 'Body', 'wpgetapi' ) . | |
| 389 | - '<span class="dashicons dashicons-editor-help" data-tip="' . | |
| 390 | - sprintf( | |
| 391 | - __( 'Parameters as name/value pairs, sent in the Body as POST fields. %1s', 'wpgetapi' ), | |
| 392 | - 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>' ) | |
| 393 | - ) . | |
| 394 | - '"></span>', | |
| 353 | + 'name' => __( 'Body POST Fields', 'wpgetapi' ), | |
| 395 | 354 | 'id' => 'body_parameters', |
| 396 | 355 | 'type' => 'parameter', |
| 397 | 356 | 'classes' => 'field-body-parameters', |
| 398 | 357 | 'repeatable' => true, |
| 399 | - '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 | + ) | |
| 400 | 362 | ), |
| 401 | 363 | array( |
| 402 | - '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' ), | |
| 403 | 365 | 'id' => 'body_json_encode', |
| 404 | 366 | 'type' => 'select', |
| 405 | 367 | 'classes' => 'field-body-json-encode', |
| 406 | 368 | 'options' => array( |
| 407 | - 'false' => __( 'No encoding (raw)', 'wpgetapi' ), | |
| 408 | - 'true' => __( 'JSON encode', 'wpgetapi' ), | |
| 409 | - 'url' => __( 'URL encode (x-www-form-urlencoded)', 'wpgetapi' ), | |
| 410 | - 'base64' => __( 'Base64 encode', 'wpgetapi' ), | |
| 411 | - 'xml' => __( 'XML format (available in PRO)', 'wpgetapi' ), | |
| 412 | - | |
| 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' ), | |
| 413 | 373 | ), |
| 414 | - 'desc' => '', | |
| 415 | - 'after_row' => '</div>', | |
| 374 | + 'desc' => __( 'Encoding of the above Body parameters. ', 'wpgetapi' ), | |
| 416 | 375 | ), |
| 417 | - array( | |
| 418 | - 'name' => __( 'Actions', 'wpgetapi' ) . '<span class="dashicons dashicons-editor-help" data-tip="' . | |
| 419 | - sprintf( | |
| 420 | - __( 'Call this endpoint when your chosen action runs. This feature is available in the PRO plugin. %1s', 'wpgetapi' ), | |
| 421 | - 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>' ) | |
| 422 | - ) . | |
| 423 | - '"></span>', | |
| 424 | - 'id' => 'actions', | |
| 425 | - 'type' => 'select', | |
| 426 | - 'classes' => 'field-actions', | |
| 427 | - 'desc' => __( 'Available in PRO plugin.', 'wpgetapi' ), | |
| 428 | - 'options' => array( | |
| 429 | - '' => __( '-- No Action --', 'wpgetapi-extras' ), | |
| 430 | - 'new_post_published' => __( 'Post/Custom Post - New Post Published', 'wpgetapi-extras' ), | |
| 431 | - 'transition_post_status' => __( 'Post/Custom Post - Status Changed', 'wpgetapi-extras' ), | |
| 432 | - 'delete_post' => __( 'Post/Custom Post - Delete Post', 'wpgetapi-extras' ), | |
| 376 | + ) ); | |
| 433 | 377 | |
| 434 | - 'user_register' => __( 'User - New User Registered', 'wpgetapi-extras' ), | |
| 435 | - 'delete_user' => __( 'User - Delete User', 'wpgetapi-extras' ), | |
| 436 | - 'user_login' => __( 'User - User Logs In', 'wpgetapi-extras' ), | |
| 437 | - 'woocommerce_new_product' => __( 'WooCommerce - New Product Created', 'wpgetapi-extras' ), | |
| 438 | - 'woocommerce_new_order' => __( 'WooCommerce - New Order Created', 'wpgetapi-extras' ), | |
| 439 | - 'woocommerce_order_status_changed' => __( 'WooCommerce - Order Status Changed', 'wpgetapi-extras' ), | |
| 440 | - 'contact_form_7' => __( 'Contact Form 7', 'wpgetapi-extras' ), | |
| 441 | - 'gravity_forms' => __( 'Gravity Forms', 'wpgetapi-extras' ), | |
| 442 | - 'wpforms' => __( 'WPForms', 'wpgetapi-extras' ), | |
| 443 | - 'jetformbuilder' => __( 'JetFormBuilder', 'wpgetapi-extras' ), | |
| 444 | - 'formidable_forms' => __( 'Formidable Forms', 'wpgetapi-extras' ), | |
| 445 | - 'pmp' => __( 'Paid Memberships Pro - After Checkout', 'wpgetapi-extras' ), | |
| 446 | - 'edd' => __( 'Easy Digital Downloads - Complete Purchase', 'wpgetapi-extras' ), | |
| 447 | - ), | |
| 448 | - 'default' => '', | |
| 449 | - ) | |
| 450 | 378 | |
| 451 | - ) ); | |
| 452 | - | |
| 453 | 379 | $fields[] = array( |
| 454 | 380 | 'id' => 'endpoints', |
| 455 | 381 | 'type' => 'group', |
| 456 | 382 | 'name' => '', |
| @@ -459,13 +385,10 @@ | ||
| 459 | 385 | 'group_title' => __( 'Endpoint {#}', 'wpgetapi' ), |
| 460 | 386 | 'add_button' => __( 'Add Endpoint', 'wpgetapi' ), |
| 461 | 387 | 'remove_button' => __( 'Remove Endpoint', 'wpgetapi' ), |
| 462 | 388 | 'sortable' => true, // beta |
| 463 | - //'closed' => true, | |
| 464 | 389 | ), |
| 465 | - 'before_group' => '<pre class="url"><div>Base URL:</div> <span>' . $base_url . '</span></pre> | |
| 466 | - <div class="import-export"><a href="#TB_inline?&width=600&height=550&inlineId=my-content-id" class="button thickbox">Import/Export</a></div> | |
| 467 | - <div class="collapse open"><a class="button" title="Collapse all endpoints"><span class="dashicons dashicons-arrow-down"></span></a></div>', | |
| 390 | + 'before_group' => '<pre class="url">Base URL: <span>' . $base_url . '</span></pre>', | |
| 468 | 391 | 'fields' => $endpoint_fields, |
| 469 | 392 | ); |
| 470 | 393 | |
| 471 | 394 | return apply_filters( 'wpgetapi_fields', $fields ); |
| @@ -473,9 +396,8 @@ | ||
| 473 | 396 | } |
| 474 | 397 | |
| 475 | 398 | |
| 476 | 399 | public function add_options_pages() { |
| 477 | - add_thickbox(); | |
| 478 | 400 | |
| 479 | 401 | $option_tabs = self::option_fields(); |
| 480 | 402 | |
| 481 | 403 | foreach ($option_tabs as $index => $option_tab) { |
| @@ -504,17 +426,11 @@ | ||
| 504 | 426 | public function admin_page_display() { |
| 505 | 427 | |
| 506 | 428 | $option_tabs = self::option_fields(); //get all option tabs |
| 507 | 429 | $tab_forms = array(); |
| 508 | - | |
| 509 | - $l = ''; | |
| 510 | - if( $this->pro_plugin ) { | |
| 511 | - $l = get_option( 'wpgetapi_pro_license_status' ); | |
| 512 | - } | |
| 513 | - | |
| 514 | 430 | ?> |
| 515 | 431 | |
| 516 | - <div class="wrap wpgetapi <?php esc_attr_e( $l ); ?>"> | |
| 432 | + <div class="wrap wpgetapi"> | |
| 517 | 433 | |
| 518 | 434 | <div class="main_content_cell"> |
| 519 | 435 | |
| 520 | 436 | <h1 class="wp-heading-inline"> |
| @@ -519,54 +435,43 @@ | ||
| 519 | 435 | |
| 520 | 436 | <h1 class="wp-heading-inline"> |
| 521 | 437 | <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> |
| 522 | 438 | </h1> |
| 439 | + <!-- Options Page Nav Tabs --> | |
| 440 | + <h2 class="nav-tab-wrapper"> | |
| 441 | + <?php foreach ($option_tabs as $option_tab) : | |
| 442 | + | |
| 443 | + $tab_slug = $option_tab['id']; | |
| 444 | + $nav_class = 'nav-tab'; | |
| 445 | + if ( $tab_slug == $_GET['page'] ) { | |
| 446 | + $nav_class .= ' nav-tab-active'; //add active class to current tab | |
| 447 | + $tab_forms[] = $option_tab; //add current tab to forms to be rendered | |
| 448 | + } | |
| 523 | 449 | |
| 524 | - <div class="outer-box"> | |
| 525 | - <!-- Options Page Nav Tabs --> | |
| 526 | - <h2 class="nav-tab-wrapper"> | |
| 527 | - <?php foreach ($option_tabs as $option_tab) : | |
| 528 | - | |
| 529 | - $tab_slug = $option_tab['id']; | |
| 530 | - $nav_class = 'nav-tab'; | |
| 531 | - if ( $tab_slug == $_GET['page'] ) { | |
| 532 | - $nav_class .= ' nav-tab-active'; //add active class to current tab | |
| 533 | - $tab_forms[] = $option_tab; //add current tab to forms to be rendered | |
| 534 | - } | |
| 450 | + ?> | |
| 451 | + | |
| 452 | + <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> | |
| 535 | 453 | |
| 536 | - ?> | |
| 537 | - | |
| 538 | - <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> | |
| 454 | + <?php endforeach; ?> | |
| 455 | + </h2> | |
| 456 | + <!-- End of Nav Tabs --> | |
| 539 | 457 | |
| 540 | - <?php endforeach; ?> | |
| 541 | - </h2> | |
| 542 | - <!-- End of Nav Tabs --> | |
| 543 | - | |
| 544 | - <?php | |
| 545 | - //render all tab forms (normaly just 1 form) | |
| 546 | - foreach ($tab_forms as $tab_form) : ?> | |
| 547 | - | |
| 548 | - <div id="<?php esc_attr_e($tab_form['id']); ?>" class="cmb-form group"> | |
| 549 | - <div class="metabox-holder"> | |
| 550 | - | |
| 551 | - <div id="my-content-id" style="display:none;"> | |
| 552 | - <div> | |
| 553 | - <?php echo $this->get_import_export(); ?> | |
| 554 | - </div> | |
| 555 | - </div> | |
| 556 | - | |
| 557 | - <div class="pmpbox pad"> | |
| 558 | - <h3 class="title"><?php esc_html_e($tab_form['title'], 'wpgetapi'); ?></h3> | |
| 559 | - <div class="desc"><?php echo wp_kses_post( $tab_form['desc'] ); ?></div> | |
| 560 | - <?php cmb2_metabox_form( $tab_form, $tab_form['id'], $tab_form ); ?> | |
| 561 | - </div> | |
| 458 | + <?php | |
| 459 | + //render all tab forms (normaly just 1 form) | |
| 460 | + foreach ($tab_forms as $tab_form) : ?> | |
| 461 | + | |
| 462 | + <div id="<?php esc_attr_e($tab_form['id']); ?>" class="cmb-form group"> | |
| 463 | + <div class="metabox-holder"> | |
| 464 | + <div class="pmpbox pad"> | |
| 465 | + <h3 class="title"><?php esc_html_e($tab_form['title'], 'wpgetapi'); ?></h3> | |
| 466 | + <div class="desc"><?php echo wp_kses_post( $tab_form['desc'] ); ?></div> | |
| 467 | + <?php cmb2_metabox_form( $tab_form, $tab_form['id'], $tab_form ); ?> | |
| 562 | 468 | </div> |
| 563 | 469 | </div> |
| 470 | + </div> | |
| 564 | 471 | |
| 565 | - <?php endforeach; ?> | |
| 472 | + <?php endforeach; ?> | |
| 566 | 473 | |
| 567 | - </div> | |
| 568 | - | |
| 569 | 474 | </div> |
| 570 | 475 | |
| 571 | 476 | <div class="sidebar_cell"> |
| 572 | 477 | |
| @@ -599,140 +504,9 @@ | ||
| 599 | 504 | wp_die(); // this is required to terminate immediately and return a proper response |
| 600 | 505 | |
| 601 | 506 | } |
| 602 | 507 | |
| 603 | - public function get_import_export() { | |
| 604 | - ob_start(); ?> | |
| 605 | 508 | |
| 606 | - <div class="wpgetapi-export"> | |
| 607 | - <h3><span class="dashicons dashicons-download"></span> Export Endpoints</h3> | |
| 608 | - <p>Export the endpoints for this API.<br>After clicking the button below, copy the entire contents of the export.</p> | |
| 609 | - <button class="button button-primary">Export Endpoints</button> | |
| 610 | - <div class="message"></div> | |
| 611 | - </div> | |
| 612 | - | |
| 613 | - <div class="wpgetapi-import"> | |
| 614 | - <h3><span class="dashicons dashicons-upload"></span> Import Endpoints</h3> | |
| 615 | - <p>Paste your exported JSON data into the field below to import endpoints into this API.</p> | |
| 616 | - <textarea></textarea> | |
| 617 | - <button class="button button-primary">Import Endpoints</button> | |
| 618 | - <div class="message"></div> | |
| 619 | - </div> | |
| 620 | - | |
| 621 | - <?php | |
| 622 | - $content = ob_get_contents(); | |
| 623 | - ob_end_clean(); | |
| 624 | - return $content; | |
| 625 | - } | |
| 626 | - | |
| 627 | - /** | |
| 628 | - * AJAX function to get our endpoints for export. | |
| 629 | - * | |
| 630 | - */ | |
| 631 | - public function export_endpoints() { | |
| 632 | - $api_id = sanitize_text_field( $_POST['api_id'] ); | |
| 633 | - $data = get_option( $api_id ); | |
| 634 | - | |
| 635 | - if( ! isset( $data['endpoints'] ) ) | |
| 636 | - wp_die(); | |
| 637 | - | |
| 638 | - $encryption = new WpGetApi_Encryption(); | |
| 639 | - | |
| 640 | - foreach ( $data['endpoints'] as $i => $endpoint ) { | |
| 641 | - if( isset( $endpoint['query_parameters'] ) ) { | |
| 642 | - foreach ( $endpoint['query_parameters'] as $i2 => $query_parameters ) { | |
| 643 | - if( isset( $query_parameters['value'] ) ) | |
| 644 | - $data['endpoints'][ $i ]['query_parameters'][ $i2 ]['value'] = $encryption->decrypt( $query_parameters['value'] ); | |
| 645 | - } | |
| 646 | - } | |
| 647 | - if( isset( $endpoint['header_parameters'] ) ) { | |
| 648 | - foreach ( $endpoint['header_parameters'] as $i2 => $header_parameters ) { | |
| 649 | - if( isset( $header_parameters['value'] ) ) | |
| 650 | - $data['endpoints'][ $i ]['header_parameters'][ $i2 ]['value'] = $encryption->decrypt( $header_parameters['value'] ); | |
| 651 | - } | |
| 652 | - } | |
| 653 | - if( isset( $endpoint['body_parameters'] ) ) { | |
| 654 | - foreach ( $endpoint['body_parameters'] as $i2 => $body_parameters ) { | |
| 655 | - if( isset( $body_parameters['value'] ) ) | |
| 656 | - $data['endpoints'][ $i ]['body_parameters'][ $i2 ]['value'] = $encryption->decrypt( $body_parameters['value'] ); | |
| 657 | - } | |
| 658 | - } | |
| 659 | - } | |
| 660 | - | |
| 661 | - echo json_encode( $data ); | |
| 662 | - wp_die(); // this is required to terminate immediately and return a proper response | |
| 663 | - } | |
| 664 | - | |
| 665 | - /** | |
| 666 | - * AJAX function to import our endpoints. | |
| 667 | - * | |
| 668 | - */ | |
| 669 | - public function import_endpoints() { | |
| 670 | - | |
| 671 | - if( ! current_user_can( 'manage_options' ) ) { | |
| 672 | - echo 'Admin privelages are required to import endpoints.'; | |
| 673 | - wp_die(); | |
| 674 | - } | |
| 675 | - | |
| 676 | - if ( isset( $_POST['nonce'] ) ) { | |
| 677 | - if ( ! wp_verify_nonce( $_POST['nonce'], 'import_endpoint_nonce' ) ) { | |
| 678 | - echo 'Nope.'; | |
| 679 | - wp_die(); | |
| 680 | - } | |
| 681 | - } | |
| 682 | - | |
| 683 | - $api_id = sanitize_text_field( $_POST['api_id'] ); | |
| 684 | - $textarea = sanitize_textarea_field( $_POST['textarea'] ); | |
| 685 | - $existing_data = get_option( $api_id ); | |
| 686 | - | |
| 687 | - if( ! $textarea ) { | |
| 688 | - echo 'No data found.'; | |
| 689 | - wp_die(); | |
| 690 | - } | |
| 691 | - | |
| 692 | - $new_data = json_decode( stripslashes( $textarea ), true ); | |
| 693 | - if( ! isset( $new_data['endpoints'] ) ){ | |
| 694 | - echo 'No endpoints found.'; | |
| 695 | - wp_die(); | |
| 696 | - } | |
| 697 | - | |
| 698 | - $encryption = new WpGetApi_Encryption(); | |
| 699 | - | |
| 700 | - foreach ( $new_data['endpoints'] as $i => $endpoint ) { | |
| 701 | - if( isset( $endpoint['query_parameters'] ) ) { | |
| 702 | - foreach ( $endpoint['query_parameters'] as $i2 => $query_parameters ) { | |
| 703 | - if( isset( $query_parameters['value'] ) ) | |
| 704 | - $new_data['endpoints'][ $i ]['query_parameters'][ $i2 ]['value'] = $encryption->encrypt( $query_parameters['value'] ); | |
| 705 | - } | |
| 706 | - } | |
| 707 | - if( isset( $endpoint['header_parameters'] ) ) { | |
| 708 | - foreach ( $endpoint['header_parameters'] as $i2 => $header_parameters ) { | |
| 709 | - if( isset( $header_parameters['value'] ) ) | |
| 710 | - $new_data['endpoints'][ $i ]['header_parameters'][ $i2 ]['value'] = $encryption->encrypt( $header_parameters['value'] ); | |
| 711 | - } | |
| 712 | - } | |
| 713 | - if( isset( $endpoint['body_parameters'] ) ) { | |
| 714 | - foreach ( $endpoint['body_parameters'] as $i2 => $body_parameters ) { | |
| 715 | - if( isset( $body_parameters['value'] ) ) | |
| 716 | - $new_data['endpoints'][ $i ]['body_parameters'][ $i2 ]['value'] = $encryption->encrypt( $body_parameters['value'] ); | |
| 717 | - } | |
| 718 | - } | |
| 719 | - } | |
| 720 | - | |
| 721 | - // if no existing endpoints, simply add it | |
| 722 | - if( ! $existing_data ) { | |
| 723 | - update_option( $api_id, $new_data, 'no' ); | |
| 724 | - } else { | |
| 725 | - | |
| 726 | - $merged['endpoints'] = array_merge( $existing_data['endpoints'], $new_data['endpoints'] ); | |
| 727 | - update_option( $api_id, $merged, 'no' ); | |
| 728 | - } | |
| 729 | - | |
| 730 | - echo 'Successfully imported. Reloading...'; | |
| 731 | - wp_die(); // this is required to terminate immediately and return a proper response | |
| 732 | - } | |
| 733 | - | |
| 734 | - | |
| 735 | 509 | public function load_testing_javascript() { ?> |
| 736 | 510 | |
| 737 | 511 | <script type="text/javascript" > |
| 738 | 512 | |
| @@ -737,109 +511,12 @@ | ||
| 737 | 511 | <script type="text/javascript" > |
| 738 | 512 | |
| 739 | 513 | jQuery(document).ready(function($) { |
| 740 | 514 | |
| 741 | - /** | |
| 742 | - * Collapse the endpoints | |
| 743 | - * | |
| 744 | - */ | |
| 745 | - $('body').on( 'click', '.wpgetapi .collapse .button', function(){ | |
| 515 | + $('body').on( 'click', '.wpgetapi-test-area .test-button', function(){//delegated | |
| 746 | 516 | |
| 747 | 517 | var $this = $(this); |
| 748 | - var $collapse = $(this).parents('.collapse'); | |
| 749 | - var status = 'open'; | |
| 750 | - | |
| 751 | - $collapse.toggleClass('open'); | |
| 752 | - | |
| 753 | - if( ! $collapse.hasClass( 'open' ) ) | |
| 754 | - status = 'closed'; | |
| 755 | - | |
| 756 | - var $endpoints = $( '#endpoints_repeat .postbox.cmb-repeatable-grouping' ); | |
| 757 | - $endpoints.each( function() { | |
| 758 | - | |
| 759 | - if( status == 'closed' ) { | |
| 760 | - $( this ).addClass('closed'); | |
| 761 | - } else { | |
| 762 | - $( this ).removeClass('closed'); | |
| 763 | - } | |
| 764 | - | |
| 765 | - }); | |
| 766 | - | |
| 767 | - }); | |
| 768 | - | |
| 769 | - /** | |
| 770 | - * Run the export | |
| 771 | - * | |
| 772 | - */ | |
| 773 | - $('body').on( 'click', '.wpgetapi-export .button', function(){ | |
| 774 | - | |
| 775 | - var $this = $(this); | |
| 776 | - var api_id = $('.wpgetapi.wrap').find( '.cmb-form.group' ).attr( 'id' ); | |
| 777 | - | |
| 778 | - // disable button | |
| 779 | - $this.attr( 'disabled', true ); | |
| 780 | - | |
| 781 | - var data = { | |
| 782 | - 'action': 'wpgetapi_export_endpoints', | |
| 783 | - 'api_id': api_id, | |
| 784 | - }; | |
| 785 | - | |
| 786 | - // send and get response | |
| 787 | - jQuery.post(ajaxurl, data, function( response ) { | |
| 788 | - $( '.wpgetapi-export .message' ).show().html( response ); | |
| 789 | - // enable button | |
| 790 | - $( '.wpgetapi-export .button' ).attr( 'disabled', false ); | |
| 791 | - | |
| 792 | - }); | |
| 793 | - | |
| 794 | - }); | |
| 795 | - | |
| 796 | - /** | |
| 797 | - * Run the import | |
| 798 | - * | |
| 799 | - */ | |
| 800 | - $('body').on( 'click', '.wpgetapi-import .button', function(){ | |
| 801 | - | |
| 802 | - var $this = $(this); | |
| 803 | - var api_id = $('.wpgetapi.wrap').find( '.cmb-form.group' ).attr( 'id' ); | |
| 804 | - var textarea = $('.wpgetapi-import textarea').val(); | |
| 805 | - | |
| 806 | - // disable button | |
| 807 | - $this.attr( 'disabled', true ); | |
| 808 | - | |
| 809 | - var data = { | |
| 810 | - 'action': 'wpgetapi_import_endpoints', | |
| 811 | - 'textarea': textarea, | |
| 812 | - 'api_id': api_id, | |
| 813 | - 'nonce': "<?php echo wp_create_nonce( 'import_endpoint_nonce' ); ?>", | |
| 814 | - }; | |
| 815 | - | |
| 816 | - // send and get response | |
| 817 | - jQuery.post(ajaxurl, data, function( response ) { | |
| 818 | - | |
| 819 | - $( '.wpgetapi-import .message' ).html( response ); | |
| 820 | - | |
| 821 | - if( response == 'Successfully imported. Reloading...' ) { | |
| 822 | - setTimeout(function(){ | |
| 823 | - location.reload(); | |
| 824 | - }, 1000); | |
| 825 | - } else { | |
| 826 | - $( '.wpgetapi-import .button' ).attr( 'disabled', false ); | |
| 827 | - } | |
| 828 | - | |
| 829 | - }); | |
| 830 | - | |
| 831 | - }); | |
| 832 | - | |
| 833 | - /** | |
| 834 | - * Run the endpoint test | |
| 835 | - * | |
| 836 | - */ | |
| 837 | - $('body').on( 'click', '.wpgetapi .test-endpoint-button', function(){//delegated | |
| 838 | - | |
| 839 | - var $this = $(this); | |
| 840 | - var $parent = $this.closest( '.cmb-repeatable-grouping' ); | |
| 841 | - var area = $parent.find( '.wpgetapi-test-area' ); | |
| 518 | + var area = $this.parents( '.wpgetapi-test-area' ); | |
| 842 | 519 | var api_id = $( area ).data( 'api' ); |
| 843 | 520 | var endpoint_id = $( area ).data( 'endpoint' ); |
| 844 | 521 | |
| 845 | 522 | // disable button |
| @@ -855,13 +532,18 @@ | ||
| 855 | 532 | jQuery.post(ajaxurl, data, function( response ) { |
| 856 | 533 | |
| 857 | 534 | var output = JSON.parse( response ); |
| 858 | 535 | |
| 859 | - $( '.wpgetapi-test-area[data-endpoint="' + output.endpoint_id + '"] .handle' ).show(); | |
| 860 | - $( '.wpgetapi-test-area[data-endpoint="' + output.endpoint_id + '"] .wpgetapi-result' ).html( output.data); | |
| 536 | + jQuery( '.wpgetapi-test-area[data-endpoint="' + output.endpoint_id + '"] .handle' ).show(); | |
| 861 | 537 | |
| 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 | + ); | |
| 543 | + | |
| 862 | 544 | // enable button |
| 863 | - $( '.wpgetapi .test-endpoint-button' ).attr( 'disabled', false ); | |
| 545 | + $( '.wpgetapi-test-area[data-endpoint="' + output.endpoint_id + '"] .test-button' ).attr( 'disabled', false ); | |
| 864 | 546 | |
| 865 | 547 | }); |
| 866 | 548 | |
| 867 | 549 | }); |
| @@ -891,9 +573,9 @@ | ||
| 891 | 573 | |
| 892 | 574 | ?> |
| 893 | 575 | |
| 894 | 576 | <div class="box"> |
| 895 | - <h4><?php esc_html_e( 'Endpoint Instructions', 'wpgetapi' ); ?></h4> | |
| 577 | + <strong><?php esc_html_e( 'Endpoint Instructions', 'wpgetapi' ); ?></strong> | |
| 896 | 578 | <ol> |
| 897 | 579 | <li><?php _e( 'Give your endpoint a <b>Unique ID</b>', 'wpgetapi' ); ?></li> |
| 898 | 580 | <li><?php _e( 'Add the <b>Endpoint</b> which can be found in your API docs', 'wpgetapi' ); ?></li> |
| 899 | 581 | <li><?php _e( 'Set the <b>Method</b> - GET for getting data & POST for sending data to the API', 'wpgetapi' ); ?></li> |
| @@ -903,10 +585,34 @@ | ||
| 903 | 585 | <li><?php _e( 'Copy the Template Tag or Shortcode & paste into page, post or theme file', 'wpgetapi' ); ?></li> |
| 904 | 586 | </ol> |
| 905 | 587 | </div> |
| 906 | 588 | |
| 907 | - <?php echo $this->help_box(); ?> | |
| 589 | + <hr> | |
| 908 | 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 | + | |
| 909 | 615 | <?php |
| 910 | 616 | $content = ob_get_contents(); |
| 911 | 617 | ob_end_clean(); |
| 912 | 618 | return $content; |
| @@ -923,9 +629,9 @@ | ||
| 923 | 629 | ob_start(); |
| 924 | 630 | ?> |
| 925 | 631 | |
| 926 | 632 | <div class="box"> |
| 927 | - <h4><?php esc_html_e( 'Setup Instructions', 'wpgetapi' ); ?></h4> | |
| 633 | + <strong><?php esc_html_e( 'Setup Instructions', 'wpgetapi' ); ?></strong> | |
| 928 | 634 | <ol> |
| 929 | 635 | <li><?php _e( 'Name your API in the <b>API Name</b> field', 'wpgetapi' ); ?></li> |
| 930 | 636 | <li><?php _e( 'Give your API a <b>Unique ID</b>', 'wpgetapi' ); ?></li> |
| 931 | 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> |
| @@ -933,29 +639,12 @@ | ||
| 933 | 639 | <li><?php _e( 'Visit the new tab that will be created', 'wpgetapi' ); ?></li> |
| 934 | 640 | </ol> |
| 935 | 641 | </div> |
| 936 | 642 | |
| 937 | - <?php echo $this->help_box(); ?> | |
| 643 | + <hr> | |
| 938 | 644 | |
| 939 | - <?php | |
| 940 | - $content = ob_get_contents(); | |
| 941 | - ob_end_clean(); | |
| 942 | - return $content; | |
| 943 | - | |
| 944 | - } | |
| 945 | - | |
| 946 | - | |
| 947 | - /** | |
| 948 | - * | |
| 949 | - * @since 1.4.4 | |
| 950 | - */ | |
| 951 | - public function help_box() { | |
| 952 | - | |
| 953 | - ob_start(); | |
| 954 | - ?> | |
| 955 | - | |
| 956 | - <div class="box help-box"> | |
| 957 | - <h4><?php esc_html_e( 'Getting Help', 'wpgetapi' ); ?></h4> | |
| 645 | + <div class="box"> | |
| 646 | + <strong><?php esc_html_e( 'Getting Help', 'wpgetapi' ); ?></strong> | |
| 958 | 647 | <ul> |
| 959 | 648 | <li><?php |
| 960 | 649 | printf( |
| 961 | 650 | esc_html__( 'View the %1$s', 'cmb2' ), |
| @@ -967,12 +656,14 @@ | ||
| 967 | 656 | esc_html__( 'View the %1$s', 'cmb2' ), |
| 968 | 657 | '<a target="_blank" href="https://wpgetapi.com/docs/frequently-asked-questions/?utm_campaign=Docs&utm_medium=Admin&utm_source=User">FAQs</a>' |
| 969 | 658 | ); |
| 970 | 659 | ?></li> |
| 971 | - | |
| 972 | - <?php if( ! $this->pro_plugin ) { ?> | |
| 973 | - <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> | |
| 974 | - <?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> | |
| 975 | 666 | </ul> |
| 976 | 667 | </div> |
| 977 | 668 | |
| 978 | 669 | <?php |
| @@ -988,9 +679,9 @@ | ||
| 988 | 679 | * @since 0.1.0 |
| 989 | 680 | */ |
| 990 | 681 | public function redirect( $object_id, $updated ) { |
| 991 | 682 | |
| 992 | - if( strpos( $object_id, 'wpgetapi_' ) !== false && strpos( $object_id, 'wpgetapi_api_importer' ) == false ) { | |
| 683 | + if( $object_id == 'wpgetapi_setup' ) { | |
| 993 | 684 | |
| 994 | 685 | add_settings_error( 'wpgetapi-notices', '', 'Saved, reloading page...', 'updated' ); |
| 995 | 686 | settings_errors( 'wpgetapi-notices' ); |
| 996 | 687 | ?> |
| @@ -997,13 +688,19 @@ | ||
| 997 | 688 | |
| 998 | 689 | <script> |
| 999 | 690 | setTimeout(function() { |
| 1000 | 691 | location.reload(); |
| 1001 | - }, 200); | |
| 692 | + }, 1000); | |
| 1002 | 693 | </script> |
| 1003 | 694 | <?php |
| 1004 | 695 | |
| 1005 | - } | |
| 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 | + } | |
| 1006 | 703 | |
| 1007 | 704 | } |
| 1008 | 705 | |
| 1009 | 706 | |