HEX
Server: nginx/1.24.0
System: Linux iZm5eic9piryinoecjybjoZ 3.10.0-1160.114.2.el7.x86_64 #1 SMP Wed Mar 20 15:54:52 UTC 2024 x86_64
User: www (1000)
PHP: 8.2.28
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot/h3.iyingtaos.cn/wp-content/plugins/bulk-delete/include/util/query.php
<?php
/**
 * Utility and wrapper functions for WP_Query.
 *
 * @since 5.5
 */
defined( 'ABSPATH' ) || exit; // Exit if accessed directly.

/**
 * Process delete options array and build query.
 *
 * @param array $delete_options Delete Options.
 * @param array $options        (optional) Options query.
 *
 * @return array
 */
function bd_build_query_options( $delete_options, $options = array() ) {
	// private posts.
	if ( isset( $delete_options['private'] ) ) {
		if ( $delete_options['private'] ) {
			$options['post_status'] = 'private';
		} else {
			if ( ! isset( $options['post_status'] ) ) {
				$options['post_status'] = 'publish';
			}
		}
	}

	// limit to query.
	if ( $delete_options['limit_to'] > 0 ) {
		$options['showposts'] = $delete_options['limit_to'];
	} else {
		$options['nopaging'] = 'true';
	}

	// post type.
	if ( isset( $delete_options['post_type'] ) ) {
		$options['post_type'] = $delete_options['post_type'];
	}

	// exclude sticky posts.
	if ( isset( $delete_options['exclude_sticky'] ) && ( true === $delete_options['exclude_sticky'] ) ) {
		$options['post__not_in'] = get_option( 'sticky_posts' );
	}

	// date query.
	if ( $delete_options['restrict'] ) {
		if ( 'before' === $delete_options['date_op'] || 'after' === $delete_options['date_op'] ) {
			$options['date_query'] = array(
				array(
					'column'                   => 'post_date',
					$delete_options['date_op'] => "{$delete_options['days']} day ago",
				),
			);
		}
	}

	return $options;
}

/**
 * Wrapper for WP_query.
 *
 * Adds some performance enhancing defaults.
 *
 * @since  5.5
 *
 * @param array $options List of options.
 *
 * @return array Result array
 */
function bd_query( $options ) {
	$defaults = array(
		'cache_results'          => false, // don't cache results.
		'update_post_meta_cache' => false, // No need to fetch post meta fields.
		'update_post_term_cache' => false, // No need to fetch taxonomy fields.
		'no_found_rows'          => true,  // No need for pagination.
		'fields'                 => 'ids', // retrieve only ids.
	);

	$options = wp_parse_args( $options, $defaults );

	$wp_query = new WP_Query();

	/**
	 * This action runs before the query happens.
	 *
	 * @since 5.5
	 * @since 5.6 added $wp_query param.
	 *
	 * @param \WP_Query $wp_query Query object.
	 */
	do_action( 'bd_before_query', $wp_query );

	$posts = $wp_query->query( $options );

	/**
	 * This action runs after the query happens.
	 *
	 * @since 5.5
	 * @since 5.6 added $wp_query param.
	 *
	 * @param \WP_Query $wp_query Query object.
	 */
	do_action( 'bd_after_query', $wp_query );

	return $posts;
}