Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGS-5161] Update deprecated filter call #544

Merged
merged 22 commits into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
module.exports = function( grunt ) {

'use strict';
const sass = require( 'node-sass' );
// Project configuration
grunt.initConfig( {

pkg: grunt.file.readJSON( 'package.json' ),

wp_readme_to_markdown: {
Expand Down Expand Up @@ -37,9 +36,6 @@ module.exports = function( grunt ) {
options : {
beautify : false,
preserveComments : false,
mangle : {
except : ['jQuery']
}
},

files : {
Expand All @@ -53,9 +49,6 @@ module.exports = function( grunt ) {
options : {
beautify : false,
preserveComments : false,
mangle : {
except : ['jQuery']
}
},

files : {
Expand Down Expand Up @@ -107,6 +100,10 @@ module.exports = function( grunt ) {
* Process SASS
*/
sass : {
options: {
implementation: sass,
sourceMap: true
},

dist : {

Expand Down
796 changes: 400 additions & 396 deletions README.md

Large diffs are not rendered by default.

Empty file modified bin/install-solr.sh
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion includes/class-solrpower-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function submit_schema() {
/*
* A couple of quick checks to make sure everything seems sane
*/
$error_message = SolrPower::get_instance()->sanity_check();
$error_message = SolrPower::get_instance()->environment_check();
if ( $error_message ) {
return $error_message;
}
Expand Down
6 changes: 3 additions & 3 deletions includes/class-solrpower-facet-widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function widget( $args, $instance ) {
if ( ! empty( $instance['title'] ) ) {
echo $args['before_title'] . $instance['title'] . $args['after_title'];
}
$this->facets = filter_input( INPUT_GET, 'facet', FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY );
$this->facets = filter_input( INPUT_GET, 'facet', FILTER_SANITIZE_FULL_SPECIAL_CHARS, FILTER_REQUIRE_ARRAY );
echo '<form action="' . esc_url( home_url( '/' ) ) . '" method="get" id="solr_facet">';
$this->render_searchbox();
echo '<div id="solr_facets">';
Expand Down Expand Up @@ -95,7 +95,7 @@ function fetch_facets( $echo = true ) {

$facets = SolrPower_WP_Query::get_instance()->facets;
$this->facets = $facets;
$sent_facets = filter_input( INPUT_GET, 'facet', FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY );
$sent_facets = filter_input( INPUT_GET, 'facet', FILTER_SANITIZE_FULL_SPECIAL_CHARS, FILTER_REQUIRE_ARRAY );

$output = ''; // HTML Output.

Expand Down Expand Up @@ -306,7 +306,7 @@ function htmlspecialchars_decode( $facet ) {
function solr_facet_search() {
$facet = new SolrPower_Facet_Widget();
$facet->dummy_query();
$facet->facets = filter_input( INPUT_GET, 'facet', FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY );
$facet->facets = filter_input( INPUT_GET, 'facet', FILTER_SANITIZE_FULL_SPECIAL_CHARS, FILTER_REQUIRE_ARRAY );
echo '<form action="' . esc_url( home_url( '/' ) ) . '" method="get" id="solr_facet">';
$facet->render_searchbox();
$facet->fetch_facets();
Expand Down
12 changes: 6 additions & 6 deletions includes/class-solrpower-options.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ function __construct() {
*/
function add_pages() {
add_menu_page(
'Solr Power',
'Solr Power',
__( 'Solr Power', 'solr-for-wordpress-on-pantheon' ),
__( 'Solr Power', 'solr-for-wordpress-on-pantheon' ),
'manage_options',
'solr-power',
array(
Expand Down Expand Up @@ -90,8 +90,9 @@ public function action_wpmuadminedit() {
// Mostly cribbed from wp-admin/options.php.
$option_page = sanitize_text_field( $_POST['option_page'] );
check_admin_referer( $option_page . '-options' );
$whitelist_options = apply_filters( 'whitelist_options', array() );
$options = $whitelist_options[ $option_page ];
$allowed_options = apply_filters( 'allowed_options', array() );
$options = $allowed_options[ $option_page ];

foreach ( $options as $option ) {
$option = trim( $option );
$value = null;
Expand All @@ -117,7 +118,7 @@ function options_load() {
die();
}
check_ajax_referer( 'solr_security', 'security' );
$method = filter_input( INPUT_POST, 'method', FILTER_SANITIZE_STRING );
$method = filter_input( INPUT_POST, 'method', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
if ( in_array( $method, array( 'start-index', 'resume-index' ), true ) ) {
$query_args = array();
if ( 'start-index' === $method ) {
Expand Down Expand Up @@ -322,7 +323,6 @@ function initalize_options() {
* Checks to see if any actions were taken on the settings page.
*/
function check_for_actions() {

if ( ! isset( $_POST['action'] ) || ! current_user_can( 'manage_options' ) ) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion includes/class-solrpower-wp-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ function parse_facets( $query ) {

$facets = $query->get( 'facet' );
if ( ! $facets ) {
$facets = filter_input( INPUT_GET, 'facet', FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY );
$facets = filter_input( INPUT_GET, 'facet', FILTER_SANITIZE_FULL_SPECIAL_CHARS, FILTER_REQUIRE_ARRAY );
}
if ( ! $facets ) {
if ( is_array( $this->fq ) && ! empty( $this->fq ) ) {
Expand Down
37 changes: 24 additions & 13 deletions includes/class-solrpower.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static function get_instance() {
* Instantiate the Solr Power class
*/
public function __construct() {
$method = filter_input( INPUT_GET, 'method', FILTER_SANITIZE_STRING );
$method = filter_input( INPUT_GET, 'method', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
if ( 'autocomplete' === $method ) {
add_action( 'template_redirect', array( $this, 'template_redirect' ), 1 );
add_action( 'wp_enqueue_scripts', array( $this, 'autosuggest_head' ) );
Expand All @@ -56,22 +56,33 @@ function () {

/**
* Handles actions needed on activation.
*
* @param bool $networkwide Whether the plugin is being activated network-wide.
*/
public function activate() {

public function activate( $networkwide ) {
// Check to see if we have environment variables. If not, bail. If so, create the initial options.
$error_message = SolrPower::get_instance()->sanity_check();
$error_message = SolrPower::get_instance()->environment_check();
if ( $error_message ) {
wp_die( esc_html( $error_message ) );
}

// Don't try to send a schema if we're not on Pantheon servers.
if ( ! defined( 'SOLR_PATH' ) ) {
$solr_path = wp_kses( __( '<code>SOLR_PATH</code> constant not found.', 'solr-for-wordpress-on-pantheon' ), 'code' );
$schema_message = SolrPower_Api::get_instance()->submit_schema();
if ( strpos( $schema_message, 'Error' ) ) {
wp_die( 'Submitting the schema failed with the message ' . esc_html( $schema_message ) );
// Translators: 1 The error message, 2: The SOLR_PATH constant.
$message = wp_kses( __( 'Submitting the schema failed with the message: %1$s<br /><br />%2$s', 'solr-for-wordpress-on-pantheon' ), [ 'br' => [] ] );
wp_die( sprintf( $message, esc_html( $schema_message ), $solr_path ) );
}
}

if ( is_multisite() && ! $networkwide ) {
// Translators: 1: The URL to the network admin plugins page.
$message = wp_kses_post( __( 'You are attempting to activate the plugin on a multisite as a single-site plugin. For WordPress multisites, you need to activate network-wide. Go to your <a href="%s">your Network Admin Plugins page</a> and click the Network Activate link there.', 'solr-for-wordpress-on-pantheon' ) );
wp_die( sprintf( $message, get_admin_url( 1, 'network/plugins.php' ) ) );
}

SolrPower_Options::get_instance()->initalize_options();

return;
Expand All @@ -82,7 +93,7 @@ public function activate() {
*
* @return string
*/
public function sanity_check() {
public function environment_check() {
$return_value = '';
$wp_version = get_bloginfo( 'version' );

Expand Down Expand Up @@ -184,15 +195,15 @@ public function template_redirect() {

// not a search page; don't do anything and return
// thanks to the Better Search plugin for the idea: http://wordpress.org/extend/plugins/better-search/.
$search = filter_input( INPUT_GET, 'ssearch', FILTER_SANITIZE_STRING );
$method = filter_input( INPUT_GET, 'method', FILTER_SANITIZE_STRING );
$search = filter_input( INPUT_GET, 'ssearch', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
$method = filter_input( INPUT_GET, 'method', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
if ( ( $search || $method ) === false ) {
return;
}

if ( 'autocomplete' === $method ) {
$q = filter_input( INPUT_GET, 'q', FILTER_SANITIZE_STRING );
$limit = filter_input( INPUT_GET, 'limit', FILTER_SANITIZE_STRING );
$q = filter_input( INPUT_GET, 'q', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
$limit = filter_input( INPUT_GET, 'limit', FILTER_SANITIZE_FULL_SPECIAL_CHARS );

$this->autocomplete( $q, $limit );
exit;
Expand Down Expand Up @@ -314,12 +325,12 @@ function ( $url ) {
// Ensure Solr is set to filter the query properly.
SolrPower_WP_Query::get_instance()->setup();

$paged = filter_input( INPUT_GET, 'paged', FILTER_SANITIZE_STRING );
$paged = filter_input( INPUT_GET, 'paged', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
$paged = ( false === $paged || null === $paged ) ? 1 : absint( $paged );

$args = array(
's' => filter_input( INPUT_GET, 's', FILTER_SANITIZE_STRING ),
'facets' => filter_input( INPUT_GET, 'facet', FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY ),
's' => filter_input( INPUT_GET, 's', FILTER_SANITIZE_FULL_SPECIAL_CHARS ),
'facets' => filter_input( INPUT_GET, 'facet', FILTER_SANITIZE_FULL_SPECIAL_CHARS, FILTER_REQUIRE_ARRAY ),
'posts_per_page' => get_option( 'posts_per_page' ),
'paged' => $paged,
);
Expand Down
26 changes: 13 additions & 13 deletions includes/legacy-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* Render the Solr search form
*/
function s4wp_search_form() {
$sort = filter_input( INPUT_GET, 'sort', FILTER_SANITIZE_STRING );
$order = filter_input( INPUT_GET, 'order', FILTER_SANITIZE_STRING );
$server = filter_input( INPUT_GET, 'server', FILTER_SANITIZE_STRING );
$sort = filter_input( INPUT_GET, 'sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
$order = filter_input( INPUT_GET, 'order', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
$server = filter_input( INPUT_GET, 'server', FILTER_SANITIZE_FULL_SPECIAL_CHARS );

$score_str = esc_html__( 'Score', 'solr-for-wordpress-on-pantheon' );
$date_str = esc_html__( 'Date', 'solr-for-wordpress-on-pantheon' );
Expand Down Expand Up @@ -39,21 +39,21 @@ function s4wp_search_form() {
}
$form = '<form name="searchbox" method="get" id="searchbox" action=""><input type="text" id="qrybox" name="ssearch" value="%s"/><input type="submit" id="searchbtn" /><label for="sortselect" id="sortlabel">' . esc_html__( 'Sort By:', 'solr-for-wordpress-on-pantheon' ) . '</label><select name="sort" id="sortselect">%s</select><label for="orderselect" id="orderlabel">' . __( 'Order By:', 'solr-for-wordpress-on-pantheon' ) . '</label><select name="order" id="orderselect">%s</select>%s</form>';

printf( $form, filter_input( INPUT_GET, 'ssearch', FILTER_SANITIZE_STRING ), $sortval, $orderval, $serverval );
printf( $form, filter_input( INPUT_GET, 'ssearch', FILTER_SANITIZE_FULL_SPECIAL_CHARS ), $sortval, $orderval, $serverval );
}

/**
* Render Solr search results
*/
function s4wp_search_results() {
$qry = filter_input( INPUT_GET, 'ssearch', FILTER_SANITIZE_STRING );
$offset = filter_input( INPUT_GET, 'offset', FILTER_SANITIZE_STRING );
$count = filter_input( INPUT_GET, 'count', FILTER_SANITIZE_STRING );
$fq = filter_input( INPUT_GET, 'fq', FILTER_SANITIZE_STRING );
$sort = filter_input( INPUT_GET, 'sort', FILTER_SANITIZE_STRING );
$order = filter_input( INPUT_GET, 'order', FILTER_SANITIZE_STRING );
$isdym = filter_input( INPUT_GET, 'isdym', FILTER_SANITIZE_STRING );
$server = filter_input( INPUT_GET, 'server', FILTER_SANITIZE_STRING );
$qry = filter_input( INPUT_GET, 'ssearch', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
$offset = filter_input( INPUT_GET, 'offset', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
$count = filter_input( INPUT_GET, 'count', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
$fq = filter_input( INPUT_GET, 'fq', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
$sort = filter_input( INPUT_GET, 'sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
$order = filter_input( INPUT_GET, 'order', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
$isdym = filter_input( INPUT_GET, 'isdym', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
$server = filter_input( INPUT_GET, 'server', FILTER_SANITIZE_FULL_SPECIAL_CHARS );

$plugin_s4wp_settings = s4wp_get_option();
$output_info = $plugin_s4wp_settings['s4wp_output_info'];
Expand Down Expand Up @@ -342,7 +342,7 @@ function s4wp_print_facet_items( $items, $pre = '<ul>', $post = '</ul>', $before
* @return array
*/
function s4wp_get_output_taxo( $facet, $taxo, $prefix, $fqstr, $field ) {
$qry = filter_input( INPUT_GET, 's', FILTER_SANITIZE_STRING );
$qry = filter_input( INPUT_GET, 's', FILTER_SANITIZE_FULL_SPECIAL_CHARS );

if ( count( $taxo ) == 0 ) {
return;
Expand Down
Loading