HEX
Server: Apache/2.4.41
System: Linux mainweb 5.4.0-182-generic #202-Ubuntu SMP Fri Apr 26 12:29:36 UTC 2024 x86_64
User: nationalmedicaregrp (1119)
PHP: 8.3.7
Disabled: exec,passthru,shell_exec,system,popen,proc_open,pcntl_exec
Upload Files
File: /home/flbestac/public_html/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;
	}
}