Completed
Push — master ( eef885...465d0c )
by
unknown
30:08 queued 12:49
created

Post_Util   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A construct() 0 1 1
A is_parent() 0 7 3
1
<?php
2
/**
3
 * Gestion des posts
4
 *
5
 * @package Evarisk\Plugin
6
 */
7
8
namespace eoxia;
9
10
if ( ! defined( 'ABSPATH' ) ) {
11
	exit;
12
}
13
14
if ( ! class_exists( '\eoxia\Post_Util' ) ) {
15
	/**
16
	 * Gestion des posts
17
	 *
18
	 * @author Jimmy Latour <[email protected]>
19
	 * @version 1.1.0.0
20
	 */
21
	class Post_Util extends \eoxia\Singleton_Util {
22
		/**
23
		 * Le constructeur obligatoirement pour utiliser la classe \eoxia\Singleton_Util
24
		 *
25
		 * @return void nothing
26
		 */
27
		protected function construct() {}
28
29
		/**
30
		 * Est ce que le post est un parent des enfants ?
31
		 *
32
		 * @param int $parent_id (test: 10) L'id du post parent.
33
		 * @param int $children_id (test: 11) L'id du post enfant.
34
		 *
35
		 * @return bool true|false
36
		 */
37
		public static function is_parent( $parent_id, $children_id ) {
38
			$list_parent_id = get_post_ancestors( $children_id );
39
			if ( ! empty( $list_parent_id ) && in_array( $parent_id, $list_parent_id, true ) ) {
40
				return true;
41
			}
42
			return false;
43
		}
44
	}
45
}
46