Ejemplo n.º 1
0
 public static function load()
 {
     self::$option_key = self::get_option_key();
     self::$options = self::get_options();
     // Register settings, and fields
     add_action('admin_init', array(__CLASS__, 'register_settings'));
     // Check if we need to flush rewrites rules
     add_action('update_option_' . self::KEY, array(__CLASS__, 'updated_option_trigger_flush_rules'), 10, 2);
     // Remove records when records TTL is shortened
     add_action('update_option_' . self::KEY, array(__CLASS__, 'updated_option_ttl_remove_records'), 10, 2);
     add_filter('mainwp_wp_stream_serialized_labels', array(__CLASS__, 'get_settings_translations'));
     // Ajax callback function to search users
     add_action('wp_ajax_mainwp_stream_get_users', array(__CLASS__, 'get_users'));
     // Ajax callback function to search IPs
     add_action('wp_ajax_mainwp_stream_get_ips', array(__CLASS__, 'get_ips'));
 }
Ejemplo n.º 2
0
 public static function is_logging_enabled($column, $value)
 {
     $excluded_values = MainWP_WP_Stream_Settings::get_excluded_by_key($column);
     $bool = !in_array($value, $excluded_values);
     return $bool;
 }
Ejemplo n.º 3
0
 public static function add_excluded_record_args($args)
 {
     // Remove record of excluded connector
     $args['connector__not_in'] = MainWP_WP_Stream_Settings::get_excluded_by_key('connectors');
     // Remove record of excluded context
     $args['context__not_in'] = MainWP_WP_Stream_Settings::get_excluded_by_key('contexts');
     // Remove record of excluded actions
     $args['action__not_in'] = MainWP_WP_Stream_Settings::get_excluded_by_key('actions');
     // Remove record of excluded author
     $args['author__not_in'] = MainWP_WP_Stream_Settings::get_excluded_by_key('authors');
     // Remove record of excluded author role
     $args['author_role__not_in'] = MainWP_WP_Stream_Settings::get_excluded_by_key('roles');
     // Remove record of excluded ip
     $args['ip__not_in'] = MainWP_WP_Stream_Settings::get_excluded_by_key('ip_addresses');
     return $args;
 }
Ejemplo n.º 4
0
 function get_network_options($options, $option_key)
 {
     if (is_network_admin()) {
         $options = wp_parse_args((array) get_site_option($option_key, array()), MainWP_WP_Stream_Settings::get_defaults($option_key));
     }
     return $options;
 }
Ejemplo n.º 5
0
 public static function purge_scheduled_action()
 {
     global $wpdb;
     // Don't purge if in Network Admin if Stream isn't network enabled
     if (is_network_admin() && is_multisite() && !is_plugin_active_for_network(MAINWP_WP_STREAM_PLUGIN)) {
         return;
     }
     if (is_multisite() && is_plugin_active_for_network(MAINWP_WP_STREAM_PLUGIN)) {
         $options = (array) get_site_option(MainWP_WP_Stream_Settings::NETWORK_KEY, array());
     } else {
         $options = MainWP_WP_Stream_Settings::get_options();
     }
     $days = $options['general_records_ttl'];
     $date = new DateTime('now', $timezone = new DateTimeZone('UTC'));
     $date->sub(DateInterval::createFromDateString("{$days} days"));
     $where = $wpdb->prepare(' AND `stream`.`created` < %s', $date->format('Y-m-d H:i:s'));
     if (is_multisite() && !is_plugin_active_for_network(MAINWP_WP_STREAM_PLUGIN)) {
         $where .= $wpdb->prepare(' AND `blog_id` = %d', get_current_blog_id());
     }
     $wpdb->query($wpdb->prepare("DELETE `stream`, `context`, `meta`\n\t\t\t\tFROM {$wpdb->mainwp_reports} AS `stream`\n\t\t\t\tLEFT JOIN {$wpdb->mainwp_reportscontext} AS `context`\n\t\t\t\tON `context`.`record_id` = `stream`.`ID`\n\t\t\t\tLEFT JOIN {$wpdb->mainwp_reportsmeta} AS `meta`\n\t\t\t\tON `meta`.`record_id` = `stream`.`ID`\n\t\t\t\tWHERE `stream`.`type` = %s\n\t\t\t\t{$where};", 'stream', $date->format('Y-m-d H:i:s')));
 }