HEX
Server: LiteSpeed
System: Linux server240.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
User: creaqbdc (8964)
PHP: 8.0.30
Disabled: NONE
Upload Files
File: //proc/self/cwd/wp-content/plugins/essential-blocks/includes/Core/ModifyWPCore.php
<?php
namespace EssentialBlocks\Core;

use EssentialBlocks\Traits\HasSingletone;

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

class ModifyWPCore {

	use HasSingletone;

	public function __construct() {
		$post_types = get_post_types(
			array(
				'public' => true,
			)
		);

		if ( is_array( $post_types ) && count( $post_types ) > 0 ) {
			foreach ( $post_types as $post ) {
				add_filter( 'rest_' . $post . '_collection_params', array( $this, 'filterPostQueryArgs' ), 2, 10 );
			}
		}
	}

	public static function filterPostQueryArgs( $query_params, $post_type ) {
		$query_params['orderby']['enum'] = array_merge( $query_params['orderby']['enum'], array( 'rand', 'menu_order', 'comment_count' ) );
		return $query_params;
	}
}