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/untold/app/admin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/vhosts/untold/app/admin/rest-work.php
<?php

	use Theme\Models\Work;

	/**
	 * Add related work to work post type
	 */
	add_action('rest_api_init', 'rest_related_work');

	function rest_related_work() {
		register_rest_field('work',
			'related',
			[
				'get_callback'    => function ($object) {
					$terms = get_the_terms($object['id'], 'work-type');
					$ids   = [];

					if($terms) {
						foreach($terms as $term) {
							$ids[] = $term->term_id;
						}

						$work = Work::getPostsRest([
							'post_type'      => 'work',
							'post__not_in'   => [$object['id']], // exclude self
							'posts_per_page' => 2,
							'tax_query'      => [
								[
									'taxonomy' => 'work-type',
									'field'    => 'id',
									'terms'    => $ids,
								],
							],
						]);


						return $work;
					}

					return NULL;
				},
				'update_callback' => NULL,
				'schema'          => NULL,
			]
		);
	}

	/**
	 * Work clients
	 */
	add_action('rest_api_init', function () {
		register_rest_field('work',
			'client',
			[
				'get_callback'    => function ($object) {
					$client = get_the_terms($object['id'], 'client');

					if(is_array($client)) {
						$client = $client[0];
					}

					return $client;
				},
				'update_callback' => NULL,
				'schema'          => NULL,
			]
		);
	});

	/**
	 * Work recognition
	 */
	add_action('rest_api_init', function () {
		register_rest_field('work',
			'recognition',
			[
				'get_callback'    => function ($object) {
					$client = get_field('recognition', $object['id'], TRUE);
					//$client = explode(',', $client);
					//
					//foreach($client as &$c) {
					//	$c = trim($c);
					//}

					return $client;
				},
				'update_callback' => NULL,
				'schema'          => NULL,
			]
		);
	});

	/**
	 * Work template
	 */
	add_action('rest_api_init', function () {
		register_rest_field('work',
			'template',
			[
				'get_callback'    => function ($object) {
					$template = get_the_terms($object['id'], 'template-type');

					if(is_array($template)) {
						$template = $template[0]->name;
					}

					return $template;
				},
				'update_callback' => NULL,
				'schema'          => NULL,
			]
		);
	});

	/**
	 * Work types
	 */
	add_action('rest_api_init', function () {
		register_rest_field('work',
			'work-type',
			[
				'get_callback'    => function ($object) {
					$template = get_the_terms($object['id'], 'work-type');

					return $template;
				},
				'update_callback' => NULL,
				'schema'          => NULL,
			]
		);
	});


	/**
	 * Services
	 */
	add_action('rest_api_init', function () {
		register_rest_field('work',
			'service',
			[
				'get_callback'    => function ($object) {
					$template = get_the_terms($object['id'], 'service');

					return $template;
				},
				'update_callback' => NULL,
				'schema'          => NULL,
			]
		);
	});

Youez - 2016 - github.com/yon3zu
LinuXploit