/** * This function is use to check whether or not a record should be excluded from the log * * @param $connector string name of the connector being logged * @param $context string name of the context being logged * @param $action string name of the action being logged * @param $user_id int id of the user being logged * @param $ip string ip address being logged * @return bool */ public function is_record_excluded($connector, $context, $action, $user = null, $ip = null) { if (is_null($user)) { $user = wp_get_current_user(); } if (is_null($ip)) { $ip = wp_stream_filter_input(INPUT_SERVER, 'REMOTE_ADDR', FILTER_VALIDATE_IP); } else { $ip = wp_stream_filter_var($ip, FILTER_VALIDATE_IP); } $user_role = isset($user->roles[0]) ? $user->roles[0] : null; $record = array('connector' => $connector, 'context' => $context, 'action' => $action, 'author' => $user->ID, 'role' => $user_role, 'ip_address' => $ip); $exclude_settings = isset(WP_Stream_Settings::$options['exclude_rules']) ? WP_Stream_Settings::$options['exclude_rules'] : array(); if (isset($exclude_settings['exclude_row']) && !empty($exclude_settings['exclude_row'])) { foreach ($exclude_settings['exclude_row'] as $key => $value) { // Prepare values $author_or_role = isset($exclude_settings['author_or_role'][$key]) ? $exclude_settings['author_or_role'][$key] : ''; $connector = isset($exclude_settings['connector'][$key]) ? $exclude_settings['connector'][$key] : ''; $context = isset($exclude_settings['context'][$key]) ? $exclude_settings['context'][$key] : ''; $action = isset($exclude_settings['action'][$key]) ? $exclude_settings['action'][$key] : ''; $ip_address = isset($exclude_settings['ip_address'][$key]) ? $exclude_settings['ip_address'][$key] : ''; $exclude = array('connector' => !empty($connector) ? $connector : null, 'context' => !empty($context) ? $context : null, 'action' => !empty($action) ? $action : null, 'ip_address' => !empty($ip_address) ? $ip_address : null, 'author' => is_numeric($author_or_role) ? $author_or_role : null, 'role' => !empty($author_or_role) && !is_numeric($author_or_role) ? $author_or_role : null); $exclude_rules = array_filter($exclude, 'strlen'); if (!empty($exclude_rules)) { $excluded = true; foreach ($exclude_rules as $exclude_key => $exclude_value) { if ($record[$exclude_key] !== $exclude_value) { $excluded = false; break; } } if ($excluded) { return true; } } } } return false; }
/** * Log user requests to retrieve passwords * * @action retrieve_password * * @param string $user_login */ public function callback_retrieve_password($user_login) { if (wp_stream_filter_var($user_login, FILTER_VALIDATE_EMAIL)) { $user = get_user_by('email', $user_login); } else { $user = get_user_by('login', $user_login); } $this->log(__('%s\'s password was requested to be reset', 'stream'), array('display_name' => $user->display_name), $user->ID, 'sessions', 'forgot-password', $user->ID); }
/** * Query records * * @param array Query args * * @return array Stream Records */ public function query($args) { global $wpdb; $defaults = array('search' => null, 'search_field' => 'summary', 'record_after' => null, 'date' => null, 'date_from' => null, 'date_to' => null, 'date_after' => null, 'date_before' => null, 'record' => null, 'record__in' => array(), 'record__not_in' => array(), 'records_per_page' => get_option('posts_per_page', 20), 'paged' => 1, 'order' => 'desc', 'orderby' => 'date', 'fields' => array()); // Additional property fields $properties = array('user_id' => null, 'user_role' => null, 'ip' => null, 'object_id' => null, 'site_id' => null, 'blog_id' => null, 'connector' => null, 'context' => null, 'action' => null); /** * Filter allows additional query properties to be added * * @return array Array of query properties */ $properties = apply_filters('wp_stream_query_properties', $properties); // Add property fields to defaults, including their __in/__not_in variations foreach ($properties as $property => $default) { if (!isset($defaults[$property])) { $defaults[$property] = $default; } $defaults["{$property}__in"] = array(); $defaults["{$property}__not_in"] = array(); } $args = wp_parse_args($args, $defaults); /** * Filter allows additional arguments to query $args * * @return array Array of query arguments */ $args = apply_filters('wp_stream_query_args', $args); $join = ''; $where = ''; /** * PARSE CORE PARAMS */ if (is_numeric($args['site_id'])) { $where .= $wpdb->prepare(" AND {$wpdb->stream}.site_id = %d", $args['site_id']); } if (is_numeric($args['blog_id'])) { $where .= $wpdb->prepare(" AND {$wpdb->stream}.blog_id = %d", $args['blog_id']); } if (is_numeric($args['object_id'])) { $where .= $wpdb->prepare(" AND {$wpdb->stream}.object_id = %d", $args['object_id']); } if (is_numeric($args['user_id'])) { $where .= $wpdb->prepare(" AND {$wpdb->stream}.user_id = %d", $args['user_id']); } if (!empty($args['user_role'])) { $where .= $wpdb->prepare(" AND {$wpdb->stream}.user_role = %s", $args['user_role']); } if (!empty($args['search'])) { $field = !empty($args['search_field']) ? $args['search_field'] : 'summary'; $where .= $wpdb->prepare(" AND {$wpdb->stream}.{$field} LIKE %s", "%{$args['search']}%"); } if (!empty($args['connector'])) { $where .= $wpdb->prepare(" AND {$wpdb->stream}.connector = %s", $args['connector']); } if (!empty($args['context'])) { $where .= $wpdb->prepare(" AND {$wpdb->stream}.context = %s", $args['context']); } if (!empty($args['action'])) { $where .= $wpdb->prepare(" AND {$wpdb->stream}.action = %s", $args['action']); } if (!empty($args['ip'])) { $where .= $wpdb->prepare(" AND {$wpdb->stream}.ip = %s", wp_stream_filter_var($args['ip'], FILTER_VALIDATE_IP)); } /** * PARSE DATE PARAM FAMILY */ if (!empty($args['date_from'])) { $date = get_gmt_from_date(date('Y-m-d H:i:s', strtotime($args['date_from'] . ' 00:00:00'))); $where .= $wpdb->prepare(" AND DATE({$wpdb->stream}.created) >= %s", $date); } if (!empty($args['date_to'])) { $date = get_gmt_from_date(date('Y-m-d H:i:s', strtotime($args['date_to'] . ' 23:59:59'))); $where .= $wpdb->prepare(" AND DATE({$wpdb->stream}.created) <= %s", $date); } if (!empty($args['date_after'])) { $date = get_gmt_from_date(date('Y-m-d H:i:s', strtotime($args['date_after']))); $where .= $wpdb->prepare(" AND DATE({$wpdb->stream}.created) > %s", $date); } if (!empty($args['date_before'])) { $date = get_gmt_from_date(date('Y-m-d H:i:s', strtotime($args['date_before']))); $where .= $wpdb->prepare(" AND DATE({$wpdb->stream}.created) < %s", $date); } if (!empty($args['date'])) { $args['date_from'] = date('Y-m-d', strtotime($args['date'])) . ' 00:00:00'; $args['date_to'] = date('Y-m-d', strtotime($args['date'])) . ' 23:59:59'; } /** * PARSE __IN PARAM FAMILY */ $ins = array(); foreach ($args as $arg => $value) { if ('__in' === substr($arg, -4)) { $ins[$arg] = $value; } } if (!empty($ins)) { foreach ($ins as $key => $value) { if (empty($value) || !is_array($value)) { continue; } $field = str_replace(array('record_', '__in'), '', $key); $field = empty($field) ? 'ID' : $field; $type = is_numeric(array_shift($value)) ? '%d' : '%s'; if (!empty($value)) { $format = '(' . join(',', array_fill(0, count($value), $type)) . ')'; $where .= $wpdb->prepare(" AND {$wpdb->stream}.%s IN {$format}", $field, $value); } } } /** * PARSE __NOT_IN PARAM FAMILY */ $not_ins = array(); foreach ($args as $arg => $value) { if ('__not_in' === substr($arg, -8)) { $not_ins[$arg] = $value; } } if (!empty($not_ins)) { foreach ($not_ins as $key => $value) { if (empty($value) || !is_array($value)) { continue; } $field = str_replace(array('record_', '__not_in'), '', $key); $field = empty($field) ? 'ID' : $field; $type = is_numeric(array_shift($value)) ? '%d' : '%s'; if (!empty($value)) { $format = '(' . join(',', array_fill(0, count($value), $type)) . ')'; $where .= $wpdb->prepare(" AND {$wpdb->stream}.%s NOT IN {$format}", $field, $value); } } } /** * PARSE PAGINATION PARAMS */ $limits = ''; $page = absint($args['paged']); $per_page = absint($args['records_per_page']); if ($per_page >= 0) { $offset = absint(($page - 1) * $per_page); $limits = "LIMIT {$offset}, {$per_page}"; } /** * PARSE ORDER PARAMS */ $order = esc_sql($args['order']); $orderby = esc_sql($args['orderby']); $orderable = array('ID', 'site_id', 'blog_id', 'object_id', 'user_id', 'user_role', 'summary', 'created', 'connector', 'context', 'action'); if (in_array($orderby, $orderable)) { $orderby = sprintf('%s.%s', $wpdb->stream, $orderby); } elseif ('meta_value_num' === $orderby && !empty($args['meta_key'])) { $orderby = "CAST({$wpdb->streammeta}.meta_value AS SIGNED)"; } elseif ('meta_value' === $orderby && !empty($args['meta_key'])) { $orderby = "{$wpdb->streammeta}.meta_value"; } else { $orderby = "{$wpdb->stream}.ID"; } $orderby = "ORDER BY {$orderby} {$order}"; /** * PARSE FIELDS PARAMETER */ $fields = (array) $args['fields']; $selects = array(); if (!empty($fields)) { foreach ($fields as $field) { // We'll query the meta table later if ('meta' === $field) { continue; } $selects[] = sprintf("{$wpdb->stream}.%s", $field); } } else { $selects[] = "{$wpdb->stream}.*"; } $select = implode(', ', $selects); /** * BUILD THE FINAL QUERY */ $query = "SELECT SQL_CALC_FOUND_ROWS {$select}\n\t\tFROM {$wpdb->stream}\n\t\t{$join}\n\t\tWHERE 1=1 {$where}\n\t\t{$orderby}\n\t\t{$limits}"; /** * Filter allows the final query to be modified before execution * * @param string $query * @param array $args * * @return string */ $query = apply_filters('wp_stream_db_query', $query, $args); /** * QUERY THE DATABASE FOR RESULTS */ $results = $wpdb->get_results($query); // Hold the number of records found $this->found_records = absint($wpdb->get_var('SELECT FOUND_ROWS()')); // Add meta to the records, when applicable if (empty($fields) || in_array('meta', $fields)) { $results = $this->add_record_meta($results); } return (array) $results; }
/** * Query Stream records * * @param array|string $args Query args * @return array Stream Records */ public function query($args) { global $wpdb; $defaults = array('records_per_page' => get_option('posts_per_page'), 'paged' => 1, 'search' => null, 'type' => 'stream', 'object_id' => null, 'ip' => null, 'site_id' => is_multisite() ? get_current_site()->id : 1, 'blog_id' => is_network_admin() ? null : get_current_blog_id(), 'author' => null, 'author_role' => null, 'date' => null, 'date_from' => null, 'date_to' => null, 'visibility' => null, 'record_greater_than' => null, 'record__in' => array(), 'record__not_in' => array(), 'record_parent' => '', 'record_parent__in' => array(), 'record_parent__not_in' => array(), 'author__in' => array(), 'author__not_in' => array(), 'author_role__in' => array(), 'author_role__not_in' => array(), 'ip__in' => array(), 'ip__not_in' => array(), 'order' => 'desc', 'orderby' => 'ID', 'meta_query' => array(), 'context_query' => array(), 'fields' => '', 'ignore_context' => null, 'hide_excluded' => !empty(WP_Stream_Settings::$options['exclude_hide_previous_records'])); $args = wp_parse_args($args, $defaults); /** * Filter allows additional arguments to query $args * * @param array Array of query arguments * @return array Updated array of query arguments */ $args = apply_filters('wp_stream_query_args', $args); if (true === $args['hide_excluded']) { $args = self::add_excluded_record_args($args); } $join = ''; $where = ''; // Only join with context table for correct types of records if (!$args['ignore_context']) { $join = sprintf(' INNER JOIN %1$s ON ( %1$s.record_id = %2$s.ID )', $wpdb->streamcontext, $wpdb->stream); } /** * PARSE CORE FILTERS */ if ($args['object_id']) { $where .= $wpdb->prepare(" AND {$wpdb->stream}.object_id = %d", $args['object_id']); } if ($args['type']) { $where .= $wpdb->prepare(" AND {$wpdb->stream}.type = %s", $args['type']); } if ($args['ip']) { $where .= $wpdb->prepare(" AND {$wpdb->stream}.ip = %s", wp_stream_filter_var($args['ip'], FILTER_VALIDATE_IP)); } if (is_numeric($args['site_id'])) { $where .= $wpdb->prepare(" AND {$wpdb->stream}.site_id = %d", $args['site_id']); } if (is_numeric($args['blog_id'])) { $where .= $wpdb->prepare(" AND {$wpdb->stream}.blog_id = %d", $args['blog_id']); } if ($args['search']) { $where .= $wpdb->prepare(" AND {$wpdb->stream}.summary LIKE %s", "%{$args['search']}%"); } if ($args['author'] || '0' === $args['author']) { $where .= $wpdb->prepare(" AND {$wpdb->stream}.author = %d", (int) $args['author']); } if ($args['author_role']) { $where .= $wpdb->prepare(" AND {$wpdb->stream}.author_role = %s", $args['author_role']); } if ($args['visibility']) { $where .= $wpdb->prepare(" AND {$wpdb->stream}.visibility = %s", $args['visibility']); } /** * PARSE DATE FILTERS */ if ($args['date']) { $where .= $wpdb->prepare(" AND DATE({$wpdb->stream}.created) = %s", $args['date']); } else { if ($args['date_from']) { $where .= $wpdb->prepare(" AND DATE({$wpdb->stream}.created) >= %s", $args['date_from']); } if ($args['date_to']) { $where .= $wpdb->prepare(" AND DATE({$wpdb->stream}.created) <= %s", $args['date_to']); } } /** * PARSE __IN PARAM FAMILY */ if ($args['record_greater_than']) { $where .= $wpdb->prepare(" AND {$wpdb->stream}.ID > %d", (int) $args['record_greater_than']); } if ($args['record__in']) { $record__in = array_filter((array) $args['record__in'], 'is_numeric'); if (!empty($record__in)) { $record__in_format = '(' . join(',', array_fill(0, count($record__in), '%d')) . ')'; $where .= $wpdb->prepare(" AND {$wpdb->stream}.ID IN {$record__in_format}", $record__in); } } if ($args['record__not_in']) { $record__not_in = array_filter((array) $args['record__not_in'], 'is_numeric'); if (!empty($record__not_in)) { $record__not_in_format = '(' . join(',', array_fill(0, count($record__not_in), '%d')) . ')'; $where .= $wpdb->prepare(" AND {$wpdb->stream}.ID NOT IN {$record__not_in_format}", $record__not_in); } } if ($args['record_parent']) { $where .= $wpdb->prepare(" AND {$wpdb->stream}.parent = %d", (int) $args['record_parent']); } if ($args['record_parent__in']) { $record_parent__in = array_filter((array) $args['record_parent__in'], 'is_numeric'); if (!empty($record_parent__in)) { $record_parent__in_format = '(' . join(',', array_fill(0, count($record_parent__in), '%d')) . ')'; $where .= $wpdb->prepare(" AND {$wpdb->stream}.parent IN {$record_parent__in_format}", $record_parent__in); } } if ($args['record_parent__not_in']) { $record_parent__not_in = array_filter((array) $args['record_parent__not_in'], 'is_numeric'); if (!empty($record_parent__not_in)) { $record_parent__not_in_format = '(' . join(',', array_fill(0, count($record_parent__not_in), '%d')) . ')'; $where .= $wpdb->prepare(" AND {$wpdb->stream}.parent NOT IN {$record_parent__not_in_format}", $record_parent__not_in); } } if ($args['author__in']) { $author__in = array_filter((array) $args['author__in'], 'is_numeric'); if (!empty($author__in)) { $author__in_format = '(' . join(',', array_fill(0, count($author__in), '%d')) . ')'; $where .= $wpdb->prepare(" AND {$wpdb->stream}.author IN {$author__in_format}", $author__in); } } if ($args['author__not_in']) { $author__not_in = array_filter((array) $args['author__not_in'], 'is_numeric'); if (!empty($author__not_in)) { $author__not_in_format = '(' . join(',', array_fill(0, count($author__not_in), '%d')) . ')'; $where .= $wpdb->prepare(" AND {$wpdb->stream}.author NOT IN {$author__not_in_format}", $author__not_in); } } if ($args['author_role__in']) { if (!empty($args['author_role__in'])) { $author_role__in = '(' . join(',', array_fill(0, count($args['author_role__in']), '%s')) . ')'; $where .= $wpdb->prepare(" AND {$wpdb->stream}.author_role IN {$author_role__in}", $args['author_role__in']); } } if ($args['author_role__not_in']) { if (!empty($args['author_role__not_in'])) { $author_role__not_in = '(' . join(',', array_fill(0, count($args['author_role__not_in']), '%s')) . ')'; $where .= $wpdb->prepare(" AND {$wpdb->stream}.author_role NOT IN {$author_role__not_in}", $args['author_role__not_in']); } } if ($args['ip__in']) { if (!empty($args['ip__in'])) { $ip__in = '(' . join(',', array_fill(0, count($args['ip__in']), '%s')) . ')'; $where .= $wpdb->prepare(" AND {$wpdb->stream}.ip IN {$ip__in}", $args['ip__in']); } } if ($args['ip__not_in']) { if (!empty($args['ip__not_in'])) { $ip__not_in = '(' . join(',', array_fill(0, count($args['ip__not_in']), '%s')) . ')'; $where .= $wpdb->prepare(" AND {$wpdb->stream}.ip NOT IN {$ip__not_in}", $args['ip__not_in']); } } /** * PARSE META QUERY PARAMS */ $meta_query = new WP_Meta_Query(); $meta_query->parse_query_vars($args); if (!empty($meta_query->queries)) { $mclauses = $meta_query->get_sql('stream', $wpdb->stream, 'ID'); $join .= str_replace('stream_id', 'record_id', $mclauses['join']); $where .= str_replace('stream_id', 'record_id', $mclauses['where']); } /** * PARSE CONTEXT PARAMS */ if (!$args['ignore_context']) { $context_query = new WP_Stream_Context_Query($args); $cclauses = $context_query->get_sql(); $join .= $cclauses['join']; $where .= $cclauses['where']; } /** * PARSE PAGINATION PARAMS */ $page = intval($args['paged']); $perpage = intval($args['records_per_page']); if ($perpage >= 0) { $offset = ($page - 1) * $perpage; $limits = "LIMIT {$offset}, {$perpage}"; } else { $limits = ''; } /** * PARSE ORDER PARAMS */ $order = esc_sql($args['order']); $orderby = esc_sql($args['orderby']); $orderable = array('ID', 'site_id', 'blog_id', 'object_id', 'author', 'author_role', 'summary', 'visibility', 'parent', 'type', 'created'); if (in_array($orderby, $orderable)) { $orderby = $wpdb->stream . '.' . $orderby; } elseif (in_array($orderby, array('connector', 'context', 'action'))) { $orderby = $wpdb->streamcontext . '.' . $orderby; } elseif ('meta_value_num' === $orderby && !empty($args['meta_key'])) { $orderby = "CAST({$wpdb->streammeta}.meta_value AS SIGNED)"; } elseif ('meta_value' === $orderby && !empty($args['meta_key'])) { $orderby = "{$wpdb->streammeta}.meta_value"; } else { $orderby = "{$wpdb->stream}.ID"; } $orderby = 'ORDER BY ' . $orderby . ' ' . $order; /** * PARSE FIELDS PARAMETER */ $fields = $args['fields']; $select = "{$wpdb->stream}.*"; if (!$args['ignore_context']) { $select .= ", {$wpdb->streamcontext}.context, {$wpdb->streamcontext}.action, {$wpdb->streamcontext}.connector"; } if ('ID' === $fields) { $select = "{$wpdb->stream}.ID"; } elseif ('summary' === $fields) { $select = "{$wpdb->stream}.summary, {$wpdb->stream}.ID"; } /** * BUILD UP THE FINAL QUERY */ $sql = "SELECT SQL_CALC_FOUND_ROWS {$select}\n\t\tFROM {$wpdb->stream}\n\t\t{$join}\n\t\tWHERE 1=1 {$where}\n\t\t{$orderby}\n\t\t{$limits}"; /** * Allows developers to change final SQL of Stream Query * * @param string $sql SQL statement * @param array $args Arguments passed to query * @return string */ $sql = apply_filters('wp_stream_query', $sql, $args); $results = $wpdb->get_results($sql); if ('with-meta' === $fields && is_array($results) && $results) { $ids = array_map('absint', wp_list_pluck($results, 'ID')); $sql_meta = sprintf("SELECT * FROM {$wpdb->streammeta} WHERE record_id IN ( %s )", implode(',', $ids)); $meta = $wpdb->get_results($sql_meta); $ids_f = array_flip($ids); foreach ($meta as $meta_record) { $results[$ids_f[$meta_record->record_id]]->meta[$meta_record->meta_key][] = $meta_record->meta_value; } } return $results; }
/** * This function is use to check whether or not a record should be excluded from the log * * @param string $connector Name of the connector being logged * @param string $context Name of the context being logged * @param string $action Name of the action being logged * @param \WP_User $user The user being logged * @param string $ip IP address being logged * * @return bool */ public function is_record_excluded($connector, $context, $action, $user = null, $ip = null) { if (is_null($user)) { $user = wp_get_current_user(); } if (is_null($ip)) { $ip = wp_stream_filter_input(INPUT_SERVER, 'REMOTE_ADDR', FILTER_VALIDATE_IP); } else { $ip = wp_stream_filter_var($ip, FILTER_VALIDATE_IP); } $user_role = isset($user->roles[0]) ? $user->roles[0] : null; $record = array('connector' => $connector, 'context' => $context, 'action' => $action, 'author' => $user->ID, 'role' => $user_role, 'ip_address' => $ip); $exclude_settings = isset($this->plugin->settings->options['exclude_rules']) ? $this->plugin->settings->options['exclude_rules'] : array(); if (is_multisite() && is_plugin_active_for_network($this->plugin->locations['plugin']) && !is_network_admin()) { $multisite_options = (array) get_site_option('wp_stream_network', array()); $multisite_exclude_settings = isset($multisite_options['exclude_rules']) ? $multisite_options['exclude_rules'] : array(); if (!empty($multisite_exclude_settings)) { foreach ($multisite_exclude_settings['exclude_row'] as $key => $rule) { $exclude_settings['exclude_row'][] = $multisite_exclude_settings['exclude_row'][$key]; $exclude_settings['author_or_role'][] = $multisite_exclude_settings['author_or_role'][$key]; $exclude_settings['connector'][] = $multisite_exclude_settings['connector'][$key]; $exclude_settings['context'][] = $multisite_exclude_settings['context'][$key]; $exclude_settings['action'][] = $multisite_exclude_settings['action'][$key]; $exclude_settings['ip_address'][] = $multisite_exclude_settings['ip_address'][$key]; } } } if (isset($exclude_settings['exclude_row']) && !empty($exclude_settings['exclude_row'])) { foreach ($exclude_settings['exclude_row'] as $key => $value) { // Prepare values $author_or_role = isset($exclude_settings['author_or_role'][$key]) ? $exclude_settings['author_or_role'][$key] : ''; $connector = isset($exclude_settings['connector'][$key]) ? $exclude_settings['connector'][$key] : ''; $context = isset($exclude_settings['context'][$key]) ? $exclude_settings['context'][$key] : ''; $action = isset($exclude_settings['action'][$key]) ? $exclude_settings['action'][$key] : ''; $ip_address = isset($exclude_settings['ip_address'][$key]) ? $exclude_settings['ip_address'][$key] : ''; $exclude = array('connector' => !empty($connector) ? $connector : null, 'context' => !empty($context) ? $context : null, 'action' => !empty($action) ? $action : null, 'ip_address' => !empty($ip_address) ? $ip_address : null, 'author' => is_numeric($author_or_role) ? absint($author_or_role) : null, 'role' => !empty($author_or_role) && !is_numeric($author_or_role) ? $author_or_role : null); $exclude_rules = array_filter($exclude, 'strlen'); if (!empty($exclude_rules)) { $excluded = true; foreach ($exclude_rules as $exclude_key => $exclude_value) { if ($record[$exclude_key] !== $exclude_value) { $excluded = false; break; } } if ($excluded) { return true; } } } } return false; }
/** * Check if we need to record action for IP * * @param null $ip * * @return mixed|void */ public static function is_logging_enabled_for_ip($ip = null) { if (is_null($ip)) { $ip = wp_stream_filter_input(INPUT_SERVER, 'REMOTE_ADDR', FILTER_VALIDATE_IP); } else { $ip = wp_stream_filter_var($ip, FILTER_VALIDATE_IP); } // If ip is not valid the we will log the action if (false === $ip) { $bool = true; } else { $bool = self::is_logging_enabled('ip_addresses', $ip); } /** * Filter to exclude actions of a specific ip from being logged * * @param bool True if logging is enable else false * @param string $ip Current user ip address * @param string Current class name * * @return bool */ return apply_filters('wp_stream_ip_record_log', $bool, $ip, get_called_class()); }