Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/mets.corals.io/wp-content/plugins/searchwp/includes/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/mets.corals.io/wp-content/plugins/searchwp/includes/Rest.php
<?php

/**
 * SearchWP REST API search handler.
 *
 * @package SearchWP
 * @author  Jon Christopher
 */

namespace SearchWP;

/**
 * Class Rest is responsible for taking over REST searches.
 *
 * @since 4.0
 */
class Rest extends \WP_REST_Post_Search_Handler {

	/**
	 * Searches the object type content for a given search request.
	 *
	 * @since 5.0.0
	 *
	 * @param WP_REST_Request $request Full REST request.
	 * @return array Associative array containing an `WP_REST_Search_Handler::RESULT_IDS` containing
	 *               an array of found IDs and `WP_REST_Search_Handler::RESULT_TOTAL` containing the
	 *               total count for the matching search results.
	 */
	public function search_items( \WP_REST_Request $request ) {
		$args = [
			'engine' => apply_filters( 'searchwp\rest\engine', 'default', [ 'request' => $request ] ),
			'fields' => 'ids',
		];

		if ( ! empty( $request['search'] ) ) {
			$args['s'] = $request['search'];
		}

		if ( ! empty( $request['page'] ) ) {
			$args['page'] = $request['page'];
		}

		if ( ! empty( $request['per_page'] ) ) {
			$args['posts_per_page'] = $request['per_page'];
		}

		if ( ! empty( $request['subtype'] ) ) {
			$args['post_type'] = $request['subtype'];

			if ( in_array( 'any', $args['post_type'], true ) ) {
				$args['post_type'] = 'any';
			}
		}

		$args  = apply_filters( 'searchwp\rest\args', $args, [ 'request' => $request ] );
		$query = empty( $args['s'] ) || empty( $args['engine'] ) ? new \WP_Query( $args ) : new \SWP_Query( $args );
		$found = $query->posts;
		$total = $query->found_posts;

		return [
			self::RESULT_IDS   => $found,
			self::RESULT_TOTAL => $total,
		];
	}
}

Spamworldpro Mini