Completed
Push — master ( 0eab3b...1440f0 )
by Warwick
15s queued 12s
created

get_sharing_text()   B

Complexity

Conditions 7
Paths 5

Size

Total Lines 13
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
eloc 10
c 0
b 0
f 0
nc 5
nop 1
dl 0
loc 13
rs 8.8333
1
<?php
2
/**
3
 * LSX Search functions.
4
 *
5
 * @package lsx-search
6
 */
7
8
namespace lsx\sharing\includes\functions;
9
10
/**
11
 * Gets a specific option from the array.
12
 *
13
 * @return boolean
14
 */
15
function is_button_disabled( $post_type = '', $service = '' ) {
16
	$sharing = lsx_sharing();
17
	$option  = false;
18
	if ( false === $sharing->is_new_options && isset( $sharing->options['display'] ) && ! empty( $sharing->options['display'][ 'sharing_disable_' . $service ] ) ) {
19
		$option = true;
20
	} elseif ( true === $sharing->is_new_options && ! empty( $sharing->options[ $post_type . '_disable_' . $service ] ) ) {
21
		$option = true;
22
	}
23
	return $option;
24
}
25
26
/**
27
 * Gets a specific option from the array.
28
 *
29
 * @return boolean
30
 */
31
function is_pt_disabled( $post_type = '' ) {
32
	$sharing = lsx_sharing();
33
	$option  = false;
34
	if ( false === $sharing->is_new_options && isset( $sharing->options['display'] ) && ! empty( $sharing->options['display'][ 'sharing_disable_pt_' . $post_type ] ) ) {
35
		$option = true;
36
	} elseif ( true === $sharing->is_new_options && isset( $sharing->options[ $post_type . '_disable_pt' ] ) ) {
37
		$option = true;
38
	}
39
	return $option;
40
}
41
42
/**
43
 * If the sharing has been disabled.
44
 *
45
 * @return boolean
46
 */
47
function is_disabled() {
48
	$sharing = lsx_sharing();
49
	$option  = false;
50
	if ( false === $sharing->is_new_options && isset( $sharing->options['display'] ) && ! empty( $sharing->options['display']['sharing_disable_all'] ) ) {
51
		$option = true;
52
	} elseif ( true === $sharing->is_new_options && isset( $sharing->options['global_disable_all'] ) ) {
53
		$option = true;
54
	}
55
	return $option;
56
}
57
58
/**
59
 * Gets the sharing text.
60
 *
61
 * @return string
62
 */
63
function get_sharing_text( $post_type = '' ) {
64
	$sharing = lsx_sharing();
65
	$text    = '';
66
	if ( false === $sharing->is_new_options && isset( $sharing->options['display'] ) && ! empty( $sharing->options['display']['sharing_label_text'] ) ) {
67
		$text = $sharing->options['display']['sharing_label_text'];
68
	} elseif ( true === $sharing->is_new_options ) {
69
		if ( isset( $sharing->options[ $post_type . '_label_text' ] ) ) {
70
			$text = $sharing->options[ $post_type . '_label_text' ];
71
		} elseif ( isset( $sharing->options['global_label_text'] ) ) {
72
			$text = $sharing->options['global_label_text'];
73
		}
74
	}
75
	return $text;
76
}
77