Skip to content

Commit

Permalink
Merge pull request #137 from petenelson/develop
Browse files Browse the repository at this point in the history
1.6.7 release
  • Loading branch information
petenelson authored Mar 31, 2019
2 parents f170692 + fedaadb commit 1473bc3
Show file tree
Hide file tree
Showing 8 changed files with 351 additions and 232 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ env:
- WP_VERSION=4.8 WP_MULTISITE=0
- WP_VERSION=4.9 WP_MULTISITE=0
- WP_VERSION=5.0 WP_MULTISITE=0
- WP_VERSION=5.1 WP_MULTISITE=0
- WP_VERSION=master WP_MULTISITE=1
- WP_VERSION=4.7 WP_MULTISITE=1
- WP_VERSION=4.8 WP_MULTISITE=1
- WP_VERSION=4.9 WP_MULTISITE=1
- WP_VERSION=5.0 WP_MULTISITE=1
- WP_VERSION=5.1 WP_MULTISITE=1

services:
- mysql
Expand Down
2 changes: 1 addition & 1 deletion admin/class-wp-rest-api-log-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static public function register_scripts() {
$highlight_style = apply_filters( 'wp-rest-api-log-admin-highlight-js-style', 'github' );

// https://github.com/zenorocha/clipboard.js
$clipboard_version = apply_filters( 'wp-rest-api-log-admin-clipboard-js-version', '1.7.0' );
$clipboard_version = apply_filters( 'wp-rest-api-log-admin-clipboard-js-version', '2.0.0' );

wp_register_script( 'wp-rest-api-log-admin-highlight-js', 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/' . $highlight_version . '/highlight.min.js' );
wp_register_style( 'wp-rest-api-log-admin-highlight-js', 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/' . $highlight_version . '/styles/' . $highlight_style . '.min.css' );
Expand Down
40 changes: 40 additions & 0 deletions includes/settings/class-wp-rest-api-log-settings-general.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class WP_REST_API_Log_Settings_General extends WP_REST_API_Log_Settings_Base {
static public function plugins_loaded() {
add_action( 'admin_init', array( __CLASS__, 'register_general_settings' ) );
add_filter( 'wp-rest-api-log-settings-tabs', array( __CLASS__, 'add_tab') );
add_action( 'admin_notices', array( __CLASS__, 'display_db_notice') );
add_action( 'wp_ajax_wp-rest-api-log-db-notice-dismiss', array( __CLASS__, 'dismiss_db_notice') );
}


Expand All @@ -24,6 +26,7 @@ static public function add_tab( $tabs ) {
static public function get_default_settings() {
return array(
'logging-enabled' => '1',
'purge-days' => '7',
);
}

Expand Down Expand Up @@ -92,6 +95,43 @@ static public function sanitize_settings( $settings ) {

return $settings;
}

/**
* Displays an admin notice about running the plugin in production.
*
* @return void
*/
public static function display_db_notice() {

$screen = get_current_screen();

if ( 'settings_page_wp-rest-api-log-settings' === $screen->id && false === get_option( 'wp-rest-api-log-db-notice-dismissed' ) ) {
?>
<div class="notice notice-warning is-dismissible" id="wp-rest-api-log-admin-db-notice">
<p><?php _e( 'Use caution when using this plugin on a production site with a large amount of REST API traffic. It logs a large amount of data and can greatly increase the size of your database.', 'wp-rest-api-log' ); ?></p>
</div>

<script type="text/javascript">
jQuery( '#wp-rest-api-log-admin-db-notice' ).on( 'click', '.notice-dismiss', function() {
jQuery.post( window.ajaxurl, {
action: 'wp-rest-api-log-db-notice-dismiss',
} );
} );
</script>
<?php
}
}

/**
* Sets an option to dismiss the admin production database notice.
*
* @return void
*/
public static function dismiss_db_notice() {
$key = 'wp-rest-api-log-db-notice-dismissed';
delete_option( $key );
add_option( $key, '1', '', 'no' );
}
}

}
Expand Down
Loading

0 comments on commit 1473bc3

Please sign in to comment.