Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

MP_Websites::websites_query( bool|string $status, bool $active = true )

Query website post types.


Parameters Parameters

$status

(bool|string) (Required) 1 or 0. Unblock or block website.

$active

(bool) (Optional) true or false. Active or inactive website.

Default value: true


Top ↑

Return Return

(array|WP_Error)


Top ↑

Source Source

File: mortgage-platform/Inc/MP_Websites.php

    private function websites_query($status, $active = true)
    {
    	$found = false;
	    $array = wp_cache_get($this->website_post_type, MortgagePlatform::$domain, false, $found);

    	if(!$found){
		    $args = array(
			    'posts_per_page' => - 1,
			    'post_type'      => $this->website_post_type,
		    );
		    $query = new \WP_Query($args);
		    $array = array();
		    if ($query->have_posts()) {
			    while ($query->have_posts()) {
				    $query->the_post();
				    $meta = get_post_meta($query->post->ID, MortgagePlatform::$prefix . 'website_status', true);
				    if ($status == $meta['status']) {
					    $date = wp_date("Y-m-d H:i:s", strtotime("-30 days", strtotime(wp_date("Y-m-d H:i:s"))));
					    if ($active) {
						    if ($meta['date_update'] >= $date) {
							    $array[] = $query->post->ID;
						    }
					    } else {
						    if ($meta['date_update'] < $date) {
							    $array[] = $query->post->ID;
						    }
					    }
				    }
			    }
		    } else {
			    return new \WP_Error(204, __('Websites not found', 'mortgage_platform'));
		    }
		    wp_reset_postdata();

		    wp_cache_set($this->website_post_type, $array, MortgagePlatform::$domain, WEEK_IN_SECONDS);
	    }

        return $array;
    }

Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0 Introduced.