MslsOptionsQuery::get_postlink()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 1
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
1
<?php
2
/**
3
 * MslsOptionsQuery
4
 * @author Dennis Ploetner <[email protected]>
5
 * @since 0.9.8
6
 */
7
8
namespace lloc\Msls;
9
10
/**
11
 * OptionsQuery
12
 *
13
 * @package Msls
14
 */
15
class MslsOptionsQuery extends MslsOptions {
16
17
	/**
18
	 * Rewrite with front
19
	 * @var bool
20
	 */
21
	public $with_front = true;
22
23
	/**
24
	 * Factory method
25
	 *
26
	 * @codeCoverageIgnore
27
	 *
28
	 * @param int $id This parameter is unused here
29
	 *
30
	 * @return MslsOptionsQuery
31
	 */
32
	public static function create( $id = 0 ) {
33
		if ( is_day() ) {
34
			return new MslsOptionsQueryDay(
35
				get_query_var( 'year' ),
36
				get_query_var( 'monthnum' ),
37
				get_query_var( 'day' )
38
			);
39
		}
40
		elseif ( is_month() ) {
41
			return new MslsOptionsQueryMonth(
42
				get_query_var( 'year' ),
43
				get_query_var( 'monthnum' )
44
			);
45
		}
46
		elseif ( is_year() ) {
47
			return new MslsOptionsQueryYear(
48
				get_query_var( 'year' )
49
			);
50
		}
51
		elseif ( is_author() ) {
52
			return new MslsOptionsQueryAuthor(
53
				get_queried_object_id()
54
			);
55
		}
56
		elseif ( is_post_type_archive() ) {
57
			return new MslsOptionsQueryPostType(
58
				get_query_var( 'post_type' )
59
			);
60
		}
61
62
		return null;
63
	}
64
65
	/**
66
	 * Get postlink
67
	 *
68
	 * @param string $language
69
	 * @return string
70
	 */
71
	public function get_postlink( $language ) {
72
		if ( $this->has_value( $language ) ) {
73
			$link = $this->get_current_link();
74
			if ( ! empty( $link ) ) {
75
				return apply_filters( 'check_url', $link, $this );
76
			}
77
		}
78
		return '';
79
	}
80
81
}
82