MP_Logs::get_all_logs()

Get all logs.


Return Return

(array) Logs.


Top ↑

Source Source

File: mortgage-platform/Inc/Base/MP_Logs.php

    public function get_all_logs()
    {
	    $found = false;
	    $logs_data = wp_cache_get(MortgagePlatform::$prefix.'logs', MortgagePlatform::$domain, false, $found);

	    if (! $found) {
		    $leads     = $this->query_all_logs();
		    $logs_data = array();

		    if ( $leads->have_posts() ) :
			    while ( $leads->have_posts() ) :
				    $leads->the_post();

				    $logs = array_reverse( get_post_meta( $leads->post->ID, MortgagePlatform::$prefix . 'lead_log' ) );
				    if ( ! empty( $logs ) ) :
					    foreach ( $logs as $log ) {
						    if ( $log ) {
							    foreach ( $log as $k => $l ) {
								    $value = explode( ' : ', $l );

								    $date        = $value[0];
								    $lead_id     = array(
									    'v' => get_edit_post_link( $leads->post->ID ),
									    'f' => (string) $leads->post->ID,
								    );
								    $status      = $value[1];
								    $description = $k;

								    array_push( $logs_data, array( $date, $lead_id, $status, $description ) );
							    }
						    }
					    }
				    endif;
			    endwhile;
		    endif;

		    wp_reset_postdata();

		    $this->sort_logs( $logs_data );
		    wp_cache_set(MortgagePlatform::$prefix.'logs', $logs_data, MortgagePlatform::$domain, WEEK_IN_SECONDS);

	    }

        return $logs_data;
    }

Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0 Introduced.