Issues (1066)

includes/functions.php (1 issue)

1
<?php
2
/**
3
 * Functions
4
 *
5
 * @package   LSX Projects
6
 * @author    LightSpeed
7
 * @license   GPL3
8
 * @link
9
 * @copyright 2016 LightSpeed
10
 */
11
12
/**
13
 * Add our action to init to set up our vars first.
14
 */
15
function lsx_projects_load_plugin_textdomain() {
16
	load_plugin_textdomain( 'lsx-projects', false, basename( LSX_PROJECTS_PATH ) . '/languages' );
17
}
18
add_action( 'init', 'lsx_projects_load_plugin_textdomain' );
19
20
/**
21
 * Wraps the output class in a function to be called in templates
22
 */
23
function lsx_projects( $args ) {
24
	$lsx_projects = new LSX_Projects;
25
	echo wp_kses_post( $lsx_projects->output( $args ) );
26
}
27
28
/**
29
 * Shortcode
30
 */
31
function lsx_projects_shortcode( $atts ) {
32
	$lsx_projects = new LSX_Projects;
33
	return $lsx_projects->output( $atts );
34
}
35
add_shortcode( 'lsx_projects', 'lsx_projects_shortcode' );
36
37
/**
38
 * Wraps the output class in a function to be called in templates
39
 */
40
function lsx_groups_list() {
41
	do_action( 'lsx_groups_list' );
42
}
43
44
function lsx_child_group_list() {
45
	do_action( 'lsx_child_group_list' );
46
}
47
48
function lsx_projects_list() {
49
	do_action( 'lsx_projects_list' );
50
}
51
52
function lsx_projects_sidebar() {
53
	do_action( 'lsx_projects_sidebar' );
54
}
55
56
function lsx_projects_single_tag() {
57
	do_action( 'lsx_projects_single_tag' );
58
}
59
60
/**
61
 * Wrapper function around cmb2_get_option
62
 * @since  0.1.0
63
 * @param  string $key     Options array key
64
 * @param  mixed  $default Optional default value
65
 * @return mixed           Option value
66
 */
67
function projects_get_options() {
68
	$options = array();
69
	if ( function_exists( 'tour_operator' ) ) {
70
		$options = get_option( '_lsx-to_settings', false );
71
	} else {
72
		$options = get_option( '_lsx_settings', false );
73
74
		if ( false === $options ) {
75
			$options = get_option( '_lsx_lsx-settings', false );
76
		}
77
	}
78
79
	// If there are new CMB2 options available, then use those.
80
	$new_options = get_option( 'lsx_projects_options', false );
81
	if ( false !== $new_options ) {
82
		$options['display'] = $new_options;
83
	}
84
	return $options;
85
}
86
87
/**
88
 * Wrapper function around cmb2_get_option
89
 * @since  0.1.0
90
 * @param  string $key     Options array key
91
 * @param  mixed  $default Optional default value
92
 * @return mixed           Option value
93
 */
94
function projects_get_option( $key = '', $default = false ) {
95
	$options = array();
96
	$value   = $default;
97
	if ( function_exists( 'tour_operator' ) ) {
98
		$options = get_option( '_lsx-to_settings', false );
99
	} else {
100
		$options = get_option( '_lsx_settings', false );
101
102
		if ( false === $options ) {
103
			$options = get_option( '_lsx_lsx-settings', false );
104
		}
105
	}
106
107
	// If there are new CMB2 options available, then use those.
108
	$new_options = get_option( 'lsx_projects_options', false );
109
	if ( false !== $new_options ) {
110
		$options['display'] = $new_options;
111
	}
112
113
	if ( isset( $options['display'] ) && isset( $options['display'][ $key ] ) ) {
114
		$value = $options['display'][ $key ];
115
	}
116
	return $value;
117
}
118
119
120
/**
121
 * Remove "Archives:"  from the projects archive title
122
 *
123
 * @param [type] $title
0 ignored issues
show
Documentation Bug introduced by
The doc comment [type] at position 0 could not be parsed: Unknown type name '[' at position 0 in [type].
Loading history...
124
 * @return void
125
 */
126
function portfolio_modify_archive_title( $title ) {
127
	if ( ! is_post_type_archive( 'project' ) ) {
128
		return $title;
129
	}
130
	$title = __( 'Portfolio', 'lsx' );
131
	return $title;
132
}
133
add_filter( 'get_the_archive_title', 'portfolio_modify_archive_title', 10, 1 );
134