Issues (4138)

classes/integrations/class-lsx-team.php (32 issues)

1
<?php
0 ignored issues
show
This file is missing a doc comment.
Loading history...
2
namespace lsx_health_plan\classes;
3
4
/**
5
 * Contains the LSX_Team functions post type
6
 *
7
 * @package lsx-health-plan
8
 */
9
class LSX_Team {
10
11
	/**
12
	 * Holds class instance
13
	 *
14
	 * @var      object \lsx_health_plan\classes\LSX_Team()
15
	 */
16
	protected static $instance = null;
17
18
	/**
19
	 * Constructor.
20
	 */
21
	public function __construct() {
0 ignored issues
show
Expected 2 blank lines before function; 1 found
Loading history...
22
		$this->default_types = array(
0 ignored issues
show
Bug Best Practice introduced by
The property default_types does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
23
			\lsx_health_plan\functions\get_option( 'endpoint_meal', 'meal' ),
24
			\lsx_health_plan\functions\get_option( 'endpoint_exercise_single', 'exercise' ),
25
			\lsx_health_plan\functions\get_option( 'endpoint_recipe_single', 'recipe' ),
26
			\lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' ),
27
			\lsx_health_plan\functions\get_option( 'endpoint_plan', 'plan' ),
28
		);
29
		add_action( 'wp_enqueue_scripts', array( $this, 'assets' ), 5 );
30
		add_action( 'cmb2_admin_init', array( $this, 'related_team_metabox' ) );
31
		add_action( 'cmb2_admin_init', array( $this, 'additional_single_team_metabox' ) );
32
		add_action( 'lsx_entry_bottom', array( $this, 'hp_team_member_tabs' ) );
33
		add_action( 'wp_head', array( $this, 'remove_archive_original_team_header' ), 99 );
34
	}
0 ignored issues
show
Expected 1 blank line before closing function brace; 0 found
Loading history...
Expected 2 blank lines after function; 1 found
Loading history...
35
36
	/**
37
	 * Return an instance of this class.
38
	 *
39
	 * @since 1.0.0
40
	 *
41
	 * @return    object \lsx_health_plan\classes\LSX_Team()    A single instance of this class.
42
	 */
43
	public static function get_instance() {
44
		// If the single instance hasn't been set, set it now.
45
		if ( null === self::$instance ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
46
			self::$instance = new self();
47
		}
0 ignored issues
show
No blank line found after control structure
Loading history...
48
		return self::$instance;
49
	}
0 ignored issues
show
Expected 1 blank line before closing function brace; 0 found
Loading history...
Expected 2 blank lines after function; 1 found
Loading history...
50
51
	/**
52
	 * Load lsx team related css.
53
	 *
54
	 * @package    lsx
55
	 * @subpackage lsx-health-plan
56
	 *
57
	 */
0 ignored issues
show
Additional blank lines found at end of doc comment
Loading history...
58
	public function assets() {
59
		wp_enqueue_style( 'lsx-health-plan-team', LSX_HEALTH_PLAN_URL . 'assets/css/lsx-health-plan-team.css', array(), LSX_HEALTH_PLAN_VER );
60
	}
0 ignored issues
show
Expected 1 blank line before closing function brace; 0 found
Loading history...
Expected 2 blank lines after function; 1 found
Loading history...
61
62
	/**
63
	 * Define the related team member metabox and field configurations.
64
	 */
65
	public function related_team_metabox() {
66
		foreach ( $this->default_types as $type => $default_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...
67
			$cmb = new_cmb2_box(
68
				array(
69
					'id'           => $default_type . '_related_team_member__metabox',
0 ignored issues
show
Are you sure $default_type of type array|mixed can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

69
					'id'           => /** @scrutinizer ignore-type */ $default_type . '_related_team_member__metabox',
Loading history...
70
					'title'        => __( 'Related Team Member', 'lsx-health-plan' ),
71
					'object_types' => array( $default_type ), // Post type.
72
					'context'      => 'normal',
73
					'priority'     => 'low',
74
					'show_names'   => true,
75
				)
76
			);
77
78
			$cmb->add_field(
79
				array(
80
					'name'       => __( 'Related Team Member', 'lsx-health-plan' ),
81
					'desc'       => __( 'Connect the related team member that applies to this ', 'lsx-health-plan' ) . $default_type,
82
					'id'         => $default_type . '_connected_team_member',
83
					'type'       => 'post_search_ajax',
84
					'limit'      => 4,  // Limit selection to X items only (default 1).
85
					'sortable'   => true, // Allow selected items to be sortable (default false).
86
					'query_args' => array(
87
						'post_type'      => array( 'team' ),
88
						'post_status'    => array( 'publish' ),
89
						'posts_per_page' => -1,
90
					),
91
				)
92
			);
93
		}
94
95
	}
0 ignored issues
show
Expected 2 blank lines after function; 1 found
Loading history...
96
97
	/**
98
	 * Adding additional custom fields to the single members, related with Health Plan.
99
	 */
100
	public function additional_single_team_metabox() {
101
		$cmb = new_cmb2_box(
102
			array(
103
				'id'           => 'lsx__team',
104
				'title'        => '',
105
				'object_types' => array( 'team' ), // Post type.
106
				'context'      => 'normal',
107
				'priority'     => 'high',
108
				'show_names'   => true,
109
			)
110
		);
111
112
		$cmb->add_field(
113
			array(
114
				'name'       => __( 'Team Member Experience', 'lsx-health-plan' ),
0 ignored issues
show
Array double arrow not aligned correctly; expected 1 space(s) between "'name'" and double arrow, but found 7.
Loading history...
115
				'desc'       => __( 'Add additional experience to this team member', 'lsx-health-plan' ),
0 ignored issues
show
Array double arrow not aligned correctly; expected 1 space(s) between "'desc'" and double arrow, but found 7.
Loading history...
116
				'id'         => 'team_member_experience',
0 ignored issues
show
Array double arrow not aligned correctly; expected 3 space(s) between "'id'" and double arrow, but found 9.
Loading history...
117
				'type'       => 'wysiwyg',
0 ignored issues
show
Array double arrow not aligned correctly; expected 1 space(s) between "'type'" and double arrow, but found 7.
Loading history...
118
			)
119
		);
120
121
		$cmb->add_field(
122
			array(
123
				'name'       => __( 'Featured Plans', 'lsx-health-plan' ),
124
				'desc'       => __( 'Connect the related plans to this team member', 'lsx-health-plan' ),
125
				'id'         => 'connected_team_member_plan',
126
				'type'       => 'post_search_ajax',
127
				'limit'      => 3,
128
				'sortable'   => true,
129
				'query_args' => array(
130
					'post_type'      => array( 'plan' ),
131
					'post_status'    => array( 'publish' ),
132
					'posts_per_page' => -1,
133
				),
134
			)
135
		);
136
137
	}
0 ignored issues
show
Expected 2 blank lines after function; 1 found
Loading history...
138
139
	/**
140
	 * Adds custom tabs to the team member single pages.
141
	 *
142
	 * @return void
143
	 */
144
	public function hp_team_member_tabs() {
145
		if ( is_single() && is_singular( 'team' ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
146
			require_once LSX_HEALTH_PLAN_PATH . '/includes/template-tags/team.php';
147
		}
148
	}
0 ignored issues
show
Expected 1 blank line before closing function brace; 0 found
Loading history...
Expected 2 blank lines after function; 1 found
Loading history...
149
150
	public function remove_archive_original_team_header() {
0 ignored issues
show
Coding Style Documentation introduced by
Missing doc comment for function remove_archive_original_team_header()
Loading history...
151
		if (  is_single() && is_singular( 'team' ) ) {
0 ignored issues
show
Expected exactly one space after opening parenthesis; " " found.
Loading history...
Expected 0 spaces after opening bracket; 2 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
152
			remove_action( 'lsx_content_wrap_before', 'lsx_global_header' );
153
		}
154
	}
0 ignored issues
show
Expected 1 blank line before closing function brace; 0 found
Loading history...
Expected 2 blank lines after function; 0 found
Loading history...
155
}
156