lightspeeddevelopment /
lsx-health-plan
| 1 | <?php |
||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 2 | namespace lsx_health_plan\classes; |
||
| 3 | use lsx_health_plan\functions; |
||
|
0 ignored issues
–
show
The type
lsx_health_plan\functions was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 4 | |||
| 5 | /** |
||
| 6 | * LSX Health Plan Admin Class. |
||
| 7 | * |
||
| 8 | * @package lsx-health-plan |
||
| 9 | */ |
||
| 10 | class Post_Type { |
||
| 11 | |||
| 12 | /** |
||
| 13 | * Holds class instance |
||
| 14 | * |
||
| 15 | * @since 1.0.0 |
||
| 16 | * |
||
| 17 | * @var object \lsx_health_plan\classes\Post_Type() |
||
| 18 | */ |
||
| 19 | protected static $instance = null; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * The post types available |
||
| 23 | * |
||
| 24 | * @var array |
||
| 25 | */ |
||
| 26 | public $post_types = array(); |
||
| 27 | |||
| 28 | /** |
||
| 29 | * The related post type connections |
||
| 30 | * |
||
| 31 | * @var array |
||
| 32 | */ |
||
| 33 | public $connections = array(); |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Constructor |
||
| 37 | */ |
||
| 38 | public function __construct() { |
||
|
0 ignored issues
–
show
|
|||
| 39 | $this->enable_post_types(); |
||
| 40 | add_filter( 'lsx_health_plan_post_types', array( $this, 'enable_post_types' ) ); |
||
| 41 | foreach ( $this->post_types as $index => $post_type ) { |
||
|
0 ignored issues
–
show
|
|||
| 42 | $is_disabled = \lsx_health_plan\functions\get_option( $post_type . '_disabled', false ); |
||
| 43 | // Check if exercises is enabled, if so disable the videos. |
||
| 44 | if ( 'video' === $post_type && false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
||
|
0 ignored issues
–
show
|
|||
| 45 | $is_disabled = true; |
||
| 46 | } |
||
| 47 | |||
| 48 | if ( true === $is_disabled || 1 === $is_disabled || 'on' === $is_disabled ) { |
||
|
0 ignored issues
–
show
|
|||
| 49 | unset( $this->post_types[ $index ] ); |
||
| 50 | } else { |
||
| 51 | require_once LSX_HEALTH_PLAN_PATH . 'classes/post-types/class-' . $post_type . '.php'; |
||
| 52 | $classname = ucwords( $post_type ); |
||
| 53 | $this->$post_type = call_user_func_array( '\\lsx_health_plan\classes\\' . $classname . '::get_instance', array() ); |
||
| 54 | } |
||
| 55 | } |
||
| 56 | } |
||
|
0 ignored issues
–
show
|
|||
| 57 | |||
| 58 | /** |
||
| 59 | * Return an instance of this class. |
||
| 60 | * |
||
| 61 | * @since 1.0.0 |
||
| 62 | * |
||
| 63 | * @return object \lsx_health_plan\classes\Post_Type() A single instance of this class. |
||
| 64 | */ |
||
| 65 | public static function get_instance() { |
||
| 66 | // If the single instance hasn't been set, set it now. |
||
| 67 | if ( null === self::$instance ) { |
||
|
0 ignored issues
–
show
|
|||
| 68 | self::$instance = new self(); |
||
| 69 | } |
||
|
0 ignored issues
–
show
|
|||
| 70 | return self::$instance; |
||
| 71 | } |
||
|
0 ignored issues
–
show
|
|||
| 72 | |||
| 73 | /** |
||
|
0 ignored issues
–
show
|
|||
| 74 | * Enable our post types |
||
| 75 | * |
||
| 76 | * @return void |
||
|
0 ignored issues
–
show
|
|||
| 77 | */ |
||
| 78 | public function enable_post_types( $post_types = array() ) { |
||
| 79 | $post_types = array( |
||
| 80 | 'plan', |
||
| 81 | 'workout', |
||
| 82 | 'meal', |
||
| 83 | 'recipe', |
||
| 84 | 'tip', |
||
| 85 | 'video', |
||
| 86 | 'exercise', |
||
| 87 | ); |
||
| 88 | $this->post_types = $post_types; |
||
| 89 | return $post_types; |
||
| 90 | } |
||
|
0 ignored issues
–
show
|
|||
| 91 | } |
||
| 92 |