Issues (924)

includes/functions.php (42 issues)

1
<?php
2
/**
3
 * LSX Search functions.
4
 *
5
 * @package lsx-search
6
 */
7
8
namespace lsx\sharing\includes\functions;
9
10
/**
11
 * Gets the sharing text.
12
 *
13
 * @return array
14
 */
15
function get_restricted_post_types() {
0 ignored issues
show
Expected 2 blank lines before function; 1 found
Loading history...
16
	$post_types = array(
17
		'page',
18
		'attachment',
19
		'forum',
20
		'topic',
21
		'lesson',
22
		'quiz',
23
		'question',
24
		'reply',
25
		'popup',
26
		'sensei_message',
27
		'envira',
28
		'soliloquy',
29
		'certificate_template',
30
		'certificate',
31
		'project',
32
	);
33
	return apply_filters( 'lsx_sharing_get_restricted_post_types', $post_types );
34
}
0 ignored issues
show
Expected 2 blank lines after function; 1 found
Loading history...
Expected 1 blank line before closing function brace; 0 found
Loading history...
35
36
/**
37
 * Gets the sharing text.
38
 *
39
 * @return array
40
 */
41
function get_to_post_types() {
42
	$post_types = array(
43
		'accommodation',
44
		'tour',
45
		'destination',
46
		'review',
47
		'special',
48
		'vehicle',
49
		'activity',
50
	);
51
	return apply_filters( 'lsx_sharing_get_to_post_types', $post_types );
52
}
0 ignored issues
show
Expected 2 blank lines after function; 1 found
Loading history...
Expected 1 blank line before closing function brace; 0 found
Loading history...
53
54
/**
55
 * Gets the LSX HP Post types
56
 *
57
 * @return array
58
 */
59
function get_hp_post_types() {
60
	$post_types = array(
61
		'workout',
62
		'exercise',
63
		'recipe',
64
		'meal',
65
		'tip',
66
	);
67
	return apply_filters( 'lsx_sharing_get_hp_post_types', $post_types );
68
}
0 ignored issues
show
Expected 2 blank lines after function; 1 found
Loading history...
Expected 1 blank line before closing function brace; 0 found
Loading history...
69
70
/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$post_type" missing
Loading history...
Coding Style Documentation introduced by
Doc comment for parameter "$service" missing
Loading history...
71
 * Gets a specific option from the array.
72
 *
73
 * @return boolean
74
 */
75
function is_button_disabled( $post_type = '', $service = '' ) {
76
	$sharing = lsx_sharing();
77
	$option  = false;
78
	if ( false === $sharing->is_new_options && isset( $sharing->options['display'] ) && ! empty( $sharing->options['display'][ 'sharing_disable_' . $service ] ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
79
		$option = true;
80
	} elseif ( true === $sharing->is_new_options && ! empty( $sharing->options[ $post_type . '_disable_' . $service ] ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
81
		$option = true;
82
	}
0 ignored issues
show
No blank line found after control structure
Loading history...
83
	return apply_filters( 'lsx_sharing_is_button_disabled', $option );
84
}
0 ignored issues
show
Expected 2 blank lines after function; 1 found
Loading history...
Expected 1 blank line before closing function brace; 0 found
Loading history...
85
86
/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$post_type" missing
Loading history...
87
 * Gets a specific option from the array.
88
 *
89
 * @return boolean
90
 */
91
function is_pt_disabled( $post_type = '' ) {
92
	$sharing = lsx_sharing();
93
	$option  = false;
94
	if ( false === $sharing->is_new_options && isset( $sharing->options['display'] ) && ! empty( $sharing->options['display'][ 'sharing_disable_pt_' . $post_type ] ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
95
		$option = true;
96
	} elseif ( true === $sharing->is_new_options && isset( $sharing->options[ $post_type . '_disable_pt' ] ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
97
		$option = true;
98
	}
0 ignored issues
show
No blank line found after control structure
Loading history...
99
	return apply_filters( 'lsx_sharing_is_pt_disabled', $option );
100
}
0 ignored issues
show
Expected 2 blank lines after function; 1 found
Loading history...
Expected 1 blank line before closing function brace; 0 found
Loading history...
101
102
/**
103
 * If the sharing has been disabled.
104
 *
105
 * @return boolean
106
 */
107
function is_disabled() {
108
	$sharing = lsx_sharing();
109
	$option  = false;
110
	if ( false === $sharing->is_new_options && isset( $sharing->options['display'] ) && ! empty( $sharing->options['display']['sharing_disable_all'] ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
111
		$option = true;
112
	} elseif ( true === $sharing->is_new_options && isset( $sharing->options['global_disable_all'] ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
113
		$option = true;
114
	}
0 ignored issues
show
No blank line found after control structure
Loading history...
115
	return apply_filters( 'lsx_sharing_is_disabled', $option );
116
}
0 ignored issues
show
Expected 2 blank lines after function; 1 found
Loading history...
Expected 1 blank line before closing function brace; 0 found
Loading history...
117
118
/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$post_type" missing
Loading history...
119
 * Gets the sharing text.
120
 *
121
 * @return string
122
 */
123
function get_sharing_text( $post_type = '' ) {
124
	$sharing = lsx_sharing();
125
	$text    = '';
126
	if ( false === $sharing->is_new_options && isset( $sharing->options['display'] ) && ! empty( $sharing->options['display']['sharing_label_text'] ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
127
		$text = $sharing->options['display']['sharing_label_text'];
128
	} elseif ( true === $sharing->is_new_options ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
129
		if ( isset( $sharing->options[ $post_type . '_label_text' ] ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
130
			$text = $sharing->options[ $post_type . '_label_text' ];
131
		} elseif ( isset( $sharing->options['global_label_text'] ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
132
			$text = $sharing->options['global_label_text'];
133
		}
134
	}
0 ignored issues
show
No blank line found after control structure
Loading history...
135
	return $text;
136
}
0 ignored issues
show
Expected 1 blank line before closing function brace; 0 found
Loading history...
137