PluginProbe
Datafeedr API / 1.4.3
Datafeedr API v1.4.3
1.4.3 1.4.2 1.0.125 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.2 1.0.20 1.0.21 1.0.22 1.0.23 1.0.24 1.0.25 1.0.26 1.0.27 1.0.28 1.0.29 1.0.3 1.0.30 1.0.31 1.0.32 All 182 releases
← All changes | classes/class-dfrapi-tools.php +54 -31 1.0.17 → 1.4.3 View file →
@@ -14,28 +14,26 @@
14 14
15 15 public function __construct() {
16 16 $this->key = 'dfrapi_tools';
17 17 add_action( 'admin_init', array( &$this, 'register_settings' ) );
18 - add_action( 'admin_menu', array( $this, 'admin_menu' ) );
19 - add_action( 'admin_notices', array( $this, 'admin_notice' ) );
18 + add_action( 'admin_menu', array( $this, 'admin_menu' ), 40 );
19 + add_action( 'admin_notices', array( $this, 'admin_notice' ) );
20 20 }
21 -
21 +
22 22 function admin_menu() {
23 23 add_submenu_page(
24 24 'dfrapi',
25 - __( 'Tools — Datafeedr API', DFRAPI_DOMAIN ),
26 - __( 'Tools', DFRAPI_DOMAIN ),
27 - 'manage_options',
25 + __( 'Tools — Datafeedr API', 'datafeedr-api' ),
26 + __( 'Tools', 'datafeedr-api' ),
27 + 'manage_options',
28 28 $this->key,
29 - array( $this, 'output' )
29 + array( $this, 'output' )
30 30 );
31 31 }
32 -
32 +
33 33 function admin_notice() {
34 34 if ( isset( $_GET['settings-updated'] ) && $_GET['settings-updated'] == true && isset( $_GET['page'] ) && $this->key == $_GET['page'] ) {
35 - echo '<div class="updated"><p>';
36 - _e( 'Updated!', DFRAPI_DOMAIN );
37 - echo '</p></div>';
35 + dfrapi_admin_notice( __( 'Updated!', 'datafeedr-api' ), 'success' );
38 36 }
39 37 }
40 38
41 39 function output() {
@@ -41,15 +39,15 @@
41 39 function output() {
42 40 echo '<div class="wrap" id="' . $this->key . '">';
43 41 echo '<h2>' . dfrapi_setting_pages( $this->page ) . ' &#8212; Datafeedr API</h2>';
44 42 ?>
45 -
43 +
46 44 <script>
47 45 jQuery(function($) {
48 -
46 +
49 47 $('#dfrapi_delete_cached_api_data').on('click',function(e) {
50 48 $("#dfrapi_delete_cached_api_data_result").hide();
51 - $("#dfrapi_delete_cached_api_data").text('<?php _e("Deleting...", DFRAPI_DOMAIN); ?>').addClass('button-disabled');
49 + $("#dfrapi_delete_cached_api_data").text('<?php _e("Deleting...", 'datafeedr-api'); ?>').addClass('button-disabled');
52 50 $.ajax({
53 51 type: "POST",
54 52 url: "<?php echo admin_url( 'admin-ajax.php' ); ?>",
55 53 data: {
@@ -56,18 +54,36 @@
56 54 action: "dfrapi_delete_cached_api_data",
57 55 dfrapi_security: "<?php echo wp_create_nonce( 'dfrapi_ajax_nonce' ); ?>"
58 56 }
59 57 }).done(function(html) {
60 - $("#dfrapi_delete_cached_api_data").text('<?php _e("Delete Cached API Data", DFRAPI_DOMAIN); ?>').removeClass('button-disabled');
58 + $("#dfrapi_delete_cached_api_data").text('<?php _e("Delete Cached API Data", 'datafeedr-api'); ?>').removeClass('button-disabled');
61 59 $("#dfrapi_delete_cached_api_data_result").show().html(html);
62 -
60 +
63 61 });
64 62 e.preventDefault();
65 - }); // $('#dfrapi_delete_cached_api_data').on('click',function(e) {
66 -
63 + }); // $('#dfrapi_delete_cached_api_data').on('click',function(e) {
64 +
65 + $('#dfrapi_test_api_connection').on('click',function(e) {
66 + $("#dfrapi_test_api_connection_result").hide();
67 + $("#dfrapi_test_api_connection").text('<?php _e("Testing...", 'datafeedr-api'); ?>').addClass('button-disabled');
68 + $.ajax({
69 + type: "POST",
70 + url: "<?php echo admin_url( 'admin-ajax.php' ); ?>",
71 + data: {
72 + action: "dfrapi_test_api_connection",
73 + dfrapi_security: "<?php echo wp_create_nonce( 'dfrapi_ajax_nonce' ); ?>"
74 + }
75 + }).done(function(html) {
76 + $("#dfrapi_test_api_connection").text('<?php _e("Test Connection", 'datafeedr-api'); ?>').removeClass('button-disabled');
77 + $("#dfrapi_test_api_connection_result").show().html(html);
78 +
79 + });
80 + e.preventDefault();
81 + }); // $('#dfrapi_delete_cached_api_data').on('click',function(e) {
82 +
67 83 }); // jQuery(function($) {
68 84 </script>
69 -
85 +
70 86 <?php
71 87
72 88 settings_fields( $this->page );
73 89 do_settings_sections( $this->page);
@@ -72,27 +88,34 @@
72 88 settings_fields( $this->page );
73 89 do_settings_sections( $this->page);
74 90 echo '</div>';
75 91 }
76 -
92 +
77 93 function register_settings() {
78 - register_setting( $this->page, $this->key, array( $this, 'validate' ) );
79 -
80 - // Delete transient data.
81 - add_settings_section( 'delete_transient_data', __( 'Delete Cached API Data', DFRAPI_DOMAIN ), array( &$this, 'section_delete_transient_data_desc' ), $this->page );
94 +
95 + add_settings_section( 'test_connection', __( 'Test API Connection', 'datafeedr-api' ), array( &$this, 'section_test_connection_desc' ), $this->page );
96 + add_settings_section( 'delete_transient_data', __( 'Delete Cached API Data', 'datafeedr-api' ), array( &$this, 'section_delete_transient_data_desc' ), $this->page );
82 97 }
83 -
98 +
84 99 function section_delete_transient_data_desc() { ?>
85 - <p><?php _e( 'Deleting cached data will not affect your store, however, it will require multiple API requests in order to re-build the data. Typically, you only delete cached data when Datafeedr Support instructs you to do so.', DFRAPI_DOMAIN ); ?></p>
86 - <p><a href="#" id="dfrapi_delete_cached_api_data" class="button"><?php _e("Delete Cached API Data", DFRAPI_DOMAIN); ?></a></p>
87 - <div id="dfrapi_delete_cached_api_data_result" style="padding: 10px; border: 1px solid silver; display: none; background: #FFF; color: green;"></div>
88 - <hr />
100 + <p><?php _e( 'Deleting cached data will not affect your store, however, it will require multiple API requests in order to re-build the data. Typically, you only delete cached data when Datafeedr Support instructs you to do so.', 'datafeedr-api' ); ?></p>
101 + <p><a href="#" id="dfrapi_delete_cached_api_data" class="button"><?php _e("Delete Cached API Data", 'datafeedr-api'); ?></a></p>
102 + <div id="dfrapi_delete_cached_api_data_result" style="padding: 10px; border: 1px solid silver; display: none; background: #FFF; color: green;"></div>
103 + <hr />
89 104 <?php
90 105 }
91 -
106 +
107 + function section_test_connection_desc() { ?>
108 + <p><?php _e( 'Test your web server\'s connection to the Datafeedr API servers. This will not count against your overall API request count.', 'datafeedr-api' ); ?></p>
109 + <p><a href="#" id="dfrapi_test_api_connection" class="button"><?php _e("Test Connection", 'datafeedr-api'); ?></a></p>
110 + <div id="dfrapi_test_api_connection_result" style="padding: 10px; border: 1px solid silver; display: none; background: #FFF;"></div>
111 + <hr />
112 + <?php
113 + }
114 +
92 115 function validate( $input ) {
93 116 return $input;
94 117 }
95 -
118 +
96 119 } // class Dfrapi_Tools
97 120
98 121 } // class_exists check