lightspeeddevelopment /
lsx-health-plan
| 1 | <?php |
||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 2 | namespace lsx_health_plan\classes; |
||
| 3 | |||
| 4 | /** |
||
| 5 | * Contains the downloads functions post type |
||
| 6 | * |
||
| 7 | * @package lsx-health-plan |
||
| 8 | */ |
||
| 9 | class Download_Monitor { |
||
| 10 | |||
| 11 | /** |
||
| 12 | * Holds class instance |
||
| 13 | * |
||
| 14 | * @since 1.0.0 |
||
| 15 | * |
||
| 16 | * @var object \lsx_health_plan\classes\Download_Monitor() |
||
| 17 | */ |
||
| 18 | protected static $instance = null; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Holds post_type slug used as an index |
||
| 22 | * |
||
| 23 | * @since 1.0.0 |
||
| 24 | * |
||
| 25 | * @var string |
||
| 26 | */ |
||
| 27 | public $slug = 'download'; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Constructor |
||
| 31 | */ |
||
| 32 | public function __construct() { |
||
|
0 ignored issues
–
show
|
|||
| 33 | add_action( 'cmb2_admin_init', array( $this, 'downloads_post_type_metaboxes' ), 5 ); |
||
| 34 | add_action( 'cmb2_admin_init', array( $this, 'download_connections' ), 5 ); |
||
| 35 | add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 ); |
||
| 36 | } |
||
|
0 ignored issues
–
show
|
|||
| 37 | |||
| 38 | /** |
||
| 39 | * Return an instance of this class. |
||
| 40 | * |
||
| 41 | * @since 1.0.0 |
||
| 42 | * |
||
| 43 | * @return object \lsx_health_plan\classes\Download_Monitor() A single instance of this class. |
||
| 44 | */ |
||
| 45 | public static function get_instance() { |
||
| 46 | // If the single instance hasn't been set, set it now. |
||
| 47 | if ( null === self::$instance ) { |
||
|
0 ignored issues
–
show
|
|||
| 48 | self::$instance = new self(); |
||
| 49 | } |
||
|
0 ignored issues
–
show
|
|||
| 50 | return self::$instance; |
||
| 51 | } |
||
|
0 ignored issues
–
show
|
|||
| 52 | |||
| 53 | /** |
||
| 54 | * Enables the Bi Directional relationships |
||
| 55 | * |
||
| 56 | * @param array $connections |
||
|
0 ignored issues
–
show
|
|||
| 57 | * @return void |
||
|
0 ignored issues
–
show
|
|||
| 58 | */ |
||
| 59 | public function enable_connections( $connections = array() ) { |
||
| 60 | $connections['dlm_download']['connected_pages'] = 'connected_downloads'; |
||
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 5 spaces
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. Loading history...
|
|||
| 61 | $connections['dlm_download']['connected_workouts'] = 'connected_downloads'; |
||
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 1 space but found 2 spaces
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. Loading history...
|
|||
| 62 | $connections['dlm_download']['connected_meals'] = 'connected_downloads'; |
||
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 5 spaces
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. Loading history...
|
|||
| 63 | $connections['dlm_download']['connected_recipes'] = 'connected_downloads'; |
||
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 3 spaces
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. Loading history...
|
|||
| 64 | |||
| 65 | //Post Type Connections |
||
|
0 ignored issues
–
show
|
|||
| 66 | $connections['workout']['connected_downloads'] = 'connected_workouts'; |
||
| 67 | $connections['meal']['connected_downloads'] = 'connected_meals'; |
||
| 68 | $connections['recipe']['connected_downloads'] = 'connected_recipes'; |
||
| 69 | $connections['page']['connected_downloads'] = 'connected_pages'; |
||
| 70 | return $connections; |
||
| 71 | } |
||
|
0 ignored issues
–
show
|
|||
| 72 | |||
| 73 | /** |
||
| 74 | * Define the metabox and field configurations. |
||
| 75 | */ |
||
| 76 | public function downloads_post_type_metaboxes() { |
||
| 77 | $cmb = new_cmb2_box( array( |
||
|
0 ignored issues
–
show
|
|||
| 78 | 'id' => $this->slug . '_connections_metabox', |
||
| 79 | 'title' => __( 'Connections', 'lsx-health-plan' ), |
||
| 80 | 'object_types' => array( 'dlm_download' ), // Post type |
||
|
0 ignored issues
–
show
|
|||
| 81 | 'context' => 'normal', |
||
| 82 | 'priority' => 'high', |
||
| 83 | 'show_names' => true, |
||
| 84 | ) ); |
||
|
0 ignored issues
–
show
For multi-line function calls, the closing parenthesis should be on a new line.
If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line: someFunctionCall(
$firstArgument,
$secondArgument,
$thirdArgument
); // Closing parenthesis on a new line.
Loading history...
|
|||
| 85 | $cmb->add_field( array( |
||
|
0 ignored issues
–
show
|
|||
| 86 | 'name' => __( 'Pages', 'lsx-health-plan' ), |
||
| 87 | 'id' => 'connected_pages', |
||
| 88 | 'type' => 'post_search_ajax', |
||
| 89 | // Optional : |
||
|
0 ignored issues
–
show
|
|||
| 90 | 'limit' => 10, // Limit selection to X items only (default 1) |
||
|
0 ignored issues
–
show
|
|||
| 91 | 'sortable' => true, // Allow selected items to be sortable (default false) |
||
|
0 ignored issues
–
show
|
|||
| 92 | 'query_args' => array( |
||
| 93 | 'post_type' => array( 'page' ), |
||
| 94 | 'post_status' => array( 'publish' ), |
||
| 95 | 'posts_per_page' => -1, |
||
| 96 | ), |
||
| 97 | ) ); |
||
|
0 ignored issues
–
show
For multi-line function calls, the closing parenthesis should be on a new line.
If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line: someFunctionCall(
$firstArgument,
$secondArgument,
$thirdArgument
); // Closing parenthesis on a new line.
Loading history...
|
|||
| 98 | $cmb->add_field( array( |
||
|
0 ignored issues
–
show
|
|||
| 99 | 'name' => __( 'Workouts', 'lsx-health-plan' ), |
||
| 100 | 'id' => 'connected_workouts', |
||
| 101 | 'type' => 'post_search_ajax', |
||
| 102 | // Optional : |
||
|
0 ignored issues
–
show
|
|||
| 103 | 'limit' => 10, // Limit selection to X items only (default 1) |
||
|
0 ignored issues
–
show
|
|||
| 104 | 'sortable' => true, // Allow selected items to be sortable (default false) |
||
|
0 ignored issues
–
show
|
|||
| 105 | 'query_args' => array( |
||
| 106 | 'post_type' => array( 'workout' ), |
||
| 107 | 'post_status' => array( 'publish' ), |
||
| 108 | 'posts_per_page' => -1, |
||
| 109 | ), |
||
| 110 | ) ); |
||
|
0 ignored issues
–
show
For multi-line function calls, the closing parenthesis should be on a new line.
If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line: someFunctionCall(
$firstArgument,
$secondArgument,
$thirdArgument
); // Closing parenthesis on a new line.
Loading history...
|
|||
| 111 | $cmb->add_field( array( |
||
|
0 ignored issues
–
show
|
|||
| 112 | 'name' => __( 'Meals', 'lsx-health-plan' ), |
||
| 113 | 'id' => 'connected_meals', |
||
| 114 | 'type' => 'post_search_ajax', |
||
| 115 | // Optional : |
||
|
0 ignored issues
–
show
|
|||
| 116 | 'limit' => 10, // Limit selection to X items only (default 1) |
||
|
0 ignored issues
–
show
|
|||
| 117 | 'sortable' => true, // Allow selected items to be sortable (default false) |
||
|
0 ignored issues
–
show
|
|||
| 118 | 'query_args' => array( |
||
| 119 | 'post_type' => array( 'meal' ), |
||
| 120 | 'post_status' => array( 'publish' ), |
||
| 121 | 'posts_per_page' => -1, |
||
| 122 | ), |
||
| 123 | ) ); |
||
|
0 ignored issues
–
show
For multi-line function calls, the closing parenthesis should be on a new line.
If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line: someFunctionCall(
$firstArgument,
$secondArgument,
$thirdArgument
); // Closing parenthesis on a new line.
Loading history...
|
|||
| 124 | $cmb->add_field( array( |
||
|
0 ignored issues
–
show
|
|||
| 125 | 'name' => __( 'Recipe', 'lsx-health-plan' ), |
||
| 126 | 'id' => 'connected_recipes', |
||
| 127 | 'type' => 'post_search_ajax', |
||
| 128 | // Optional : |
||
|
0 ignored issues
–
show
|
|||
| 129 | 'limit' => 10, // Limit selection to X items only (default 1) |
||
|
0 ignored issues
–
show
|
|||
| 130 | 'sortable' => true, // Allow selected items to be sortable (default false) |
||
|
0 ignored issues
–
show
|
|||
| 131 | 'query_args' => array( |
||
| 132 | 'post_type' => array( 'recipe' ), |
||
| 133 | 'post_status' => array( 'publish' ), |
||
| 134 | 'posts_per_page' => -1, |
||
| 135 | ), |
||
| 136 | ) ); |
||
|
0 ignored issues
–
show
For multi-line function calls, the closing parenthesis should be on a new line.
If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line: someFunctionCall(
$firstArgument,
$secondArgument,
$thirdArgument
); // Closing parenthesis on a new line.
Loading history...
|
|||
| 137 | } |
||
|
0 ignored issues
–
show
|
|||
| 138 | |||
| 139 | /** |
||
| 140 | * Registers the workout connections on the plan post type. |
||
| 141 | * |
||
| 142 | * @return void |
||
| 143 | */ |
||
| 144 | public function download_connections() { |
||
| 145 | $cmb = new_cmb2_box( array( |
||
|
0 ignored issues
–
show
|
|||
| 146 | 'id' => $this->slug . '_metabox', |
||
| 147 | 'title' => __( 'Downloads', 'lsx-health-plan' ), |
||
| 148 | 'object_types' => array( 'workout', 'meal', 'recipe' ), // Post type |
||
|
0 ignored issues
–
show
|
|||
| 149 | 'context' => 'normal', |
||
| 150 | 'priority' => 'high', |
||
| 151 | 'show_names' => true, |
||
| 152 | ) ); |
||
|
0 ignored issues
–
show
For multi-line function calls, the closing parenthesis should be on a new line.
If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line: someFunctionCall(
$firstArgument,
$secondArgument,
$thirdArgument
); // Closing parenthesis on a new line.
Loading history...
|
|||
| 153 | $cmb->add_field( array( |
||
|
0 ignored issues
–
show
|
|||
| 154 | 'name' => __( 'Downloads', 'lsx-health-plan' ), |
||
| 155 | 'desc' => __( "Add the pdf's connected to this day plan, using the field provided.", 'lsx-health-plan' ), |
||
| 156 | 'id' => 'connected_downloads', |
||
| 157 | 'type' => 'post_search_ajax', |
||
| 158 | // Optional |
||
|
0 ignored issues
–
show
|
|||
| 159 | 'limit' => 15, // Limit selection to X items only (default 1) |
||
|
0 ignored issues
–
show
|
|||
| 160 | 'sortable' => true, // Allow selected items to be sortable (default false) |
||
|
0 ignored issues
–
show
|
|||
| 161 | 'query_args' => array( |
||
| 162 | 'post_type' => array( 'dlm_download' ), |
||
| 163 | 'post_status' => array( 'publish' ), |
||
| 164 | 'posts_per_page' => -1, |
||
| 165 | ), |
||
| 166 | ) ); |
||
|
0 ignored issues
–
show
For multi-line function calls, the closing parenthesis should be on a new line.
If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line: someFunctionCall(
$firstArgument,
$secondArgument,
$thirdArgument
); // Closing parenthesis on a new line.
Loading history...
|
|||
| 167 | } |
||
|
0 ignored issues
–
show
|
|||
| 168 | } |
||
| 169 |