Completed
Push — master ( ea28d3...1760c1 )
by Dennis
04:45
created

MslsOptionsPost::get_postlink()   B

Complexity

Conditions 6
Paths 6

Size

Total Lines 24
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 14
nc 6
nop 1
dl 0
loc 24
rs 8.5125
c 0
b 0
f 0
1
<?php
2
/**
3
 * MslsOptionsPost
4
 * @author Dennis Ploetner <[email protected]>
5
 * @since 0.9.8
6
 */
7
8
namespace lloc\Msls;
9
10
/**
11
 * Post options
12
 * @package Msls
13
 */
14
class MslsOptionsPost extends MslsOptions {
15
16
	/**
17
	 * Separator
18
	 * @var string
19
	 */
20
	protected $sep = '_';
21
22
	/**
23
	 * Autoload
24
	 * @var string
25
	 */
26
	protected $autoload = 'no';
27
28
	/**
29
	 * Get postlink
30
	 * @param string $language
31
	 * @return string
32
	 */
33
	public function get_postlink( $language ) {
34
		if ( ! $this->has_value( $language ) ) {
35
			return '';
36
		}
37
38
		$post = get_post( (int) $this->__get( $language ) );
39
		if ( is_null( $post ) || 'publish' != $post->post_status ) {
40
			return '';
41
		}
42
43
		if ( is_null( $this->with_front ) ) {
44
			$post_object      = get_post_type_object( $post->post_type );
45
			$this->with_front = ! empty( $post_object->rewrite['with_front'] );
46
		}
47
48
		global $current_site;
49
		$blog_id = MslsBlogCollection::instance()->get_blog_id( $language );
50
		if ( $current_site->blog_id != $blog_id ) {
51
			$option = get_blog_option( $blog_id, 'msls' );
0 ignored issues
show
Unused Code introduced by
$option is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
52
			//error_log( print_r( $option, true ) );
53
		}
54
55
		return apply_filters( 'check_url', get_permalink( $post ), $this );
56
	}
57
58
	/**
59
	 * Get current link
60
	 * @return string
61
	 */
62
	public function get_current_link() {
63
		return (string) get_permalink( $this->get_arg( 0, 0 ) );
64
	}
65
66
}
67