lightspeeddevelopment /
to-activities
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * LSX_Activities_Admin |
||
| 4 | * |
||
| 5 | * @package LSX_Activities_Admin |
||
| 6 | * @author LightSpeed |
||
| 7 | * @license GPL-2.0+ |
||
| 8 | * @link |
||
| 9 | * @copyright 2018 LightSpeedDevelopment |
||
| 10 | */ |
||
| 11 | |||
| 12 | /** |
||
| 13 | * Main plugin class. |
||
| 14 | * |
||
| 15 | * @package LSX_Activities_Admin |
||
| 16 | * @author LightSpeed |
||
| 17 | */ |
||
| 18 | |||
| 19 | class LSX_Activities_Admin extends LSX_Activities { |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Constructor |
||
| 23 | */ |
||
| 24 | public function __construct() { |
||
| 25 | $this->set_vars(); |
||
| 26 | |||
| 27 | add_filter( 'lsx_get_post-types_configs', array( $this, 'post_type_config' ), 10, 1 ); |
||
| 28 | add_filter( 'lsx_get_metaboxes_configs', array( $this, 'meta_box_config' ), 10, 1 ); |
||
| 29 | |||
| 30 | add_filter( 'lsx_to_destination_custom_fields', array( $this, 'custom_fields' ) ); |
||
| 31 | add_filter( 'lsx_to_tour_custom_fields', array( $this, 'custom_fields' ) ); |
||
| 32 | add_filter( 'lsx_to_accommodation_custom_fields', array( $this, 'custom_fields' ) ); |
||
| 33 | |||
| 34 | add_filter( 'lsx_to_team_custom_fields', array( $this, 'custom_fields' ) ); |
||
| 35 | add_filter( 'lsx_to_special_custom_fields', array( $this, 'custom_fields' ) ); |
||
| 36 | add_filter( 'lsx_to_review_custom_fields', array( $this, 'custom_fields' ) ); |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Register the activity post type config |
||
| 41 | * |
||
| 42 | * @param $objects |
||
| 43 | * @return array |
||
| 44 | */ |
||
| 45 | public function post_type_config( $objects ) { |
||
| 46 | foreach ( $this->post_types as $key => $label ) { |
||
| 47 | if ( file_exists( LSX_ACTIVITIES_PATH . 'includes/post-types/config-' . $key . '.php' ) ) { |
||
| 48 | $objects[ $key ] = include LSX_ACTIVITIES_PATH . 'includes/post-types/config-' . $key . '.php'; |
||
| 49 | } |
||
| 50 | } |
||
| 51 | return $objects; |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Register the activity metabox config |
||
| 56 | * |
||
| 57 | * @param $meta_boxes |
||
| 58 | * @return array |
||
| 59 | */ |
||
| 60 | public function meta_box_config( $meta_boxes ) { |
||
| 61 | foreach ( $this->post_types as $key => $label ) { |
||
| 62 | if ( file_exists( LSX_ACTIVITIES_PATH . 'includes/metaboxes/config-' . $key . '.php' ) ) { |
||
| 63 | $meta_boxes[ $key ] = include LSX_ACTIVITIES_PATH . 'includes/metaboxes/config-' . $key . '.php'; |
||
| 64 | } |
||
| 65 | } |
||
| 66 | return $meta_boxes; |
||
|
0 ignored issues
–
show
|
|||
| 67 | } |
||
| 68 | |||
| 69 | /** |
||
| 70 | * Adds in the gallery fields to the Tour Operators Post Types. |
||
| 71 | */ |
||
| 72 | public function custom_fields( $fields ) { |
||
| 73 | global $post, $typenow, $current_screen; |
||
| 74 | |||
| 75 | $post_type = false; |
||
| 76 | |||
| 77 | if ( $post && $post->post_type ) { |
||
| 78 | $post_type = $post->post_type; |
||
| 79 | } elseif ( $typenow ) { |
||
| 80 | $post_type = $typenow; |
||
| 81 | } elseif ( $current_screen && $current_screen->post_type ) { |
||
| 82 | $post_type = $current_screen->post_type; |
||
| 83 | } elseif ( isset( $_REQUEST['post_type'] ) ) { |
||
|
0 ignored issues
–
show
|
|||
| 84 | $post_type = sanitize_key( $_REQUEST['post_type'] ); |
||
|
0 ignored issues
–
show
|
|||
| 85 | } elseif ( isset( $_REQUEST['post'] ) ) { |
||
|
0 ignored issues
–
show
|
|||
| 86 | $post_type = get_post_type( sanitize_key( $_REQUEST['post'] ) ); |
||
|
0 ignored issues
–
show
|
|||
| 87 | } |
||
| 88 | |||
| 89 | if ( false !== $post_type ) { |
||
| 90 | $fields[] = array( |
||
| 91 | 'id' => 'activity_title', |
||
|
0 ignored issues
–
show
|
|||
| 92 | 'name' => 'Activities', |
||
| 93 | 'type' => 'title', |
||
| 94 | 'cols' => 12, |
||
| 95 | ); |
||
| 96 | $fields[] = array( |
||
| 97 | 'id' => 'activity_to_' . $post_type, |
||
|
0 ignored issues
–
show
|
|||
| 98 | 'name' => 'Activities related with this ' . $post_type, |
||
|
0 ignored issues
–
show
|
|||
| 99 | 'type' => 'post_select', |
||
|
0 ignored issues
–
show
|
|||
| 100 | 'use_ajax' => false, |
||
|
0 ignored issues
–
show
|
|||
| 101 | 'query' => array( |
||
|
0 ignored issues
–
show
|
|||
| 102 | 'post_type' => 'activity', |
||
|
0 ignored issues
–
show
|
|||
| 103 | 'nopagin' => true, |
||
|
0 ignored issues
–
show
|
|||
| 104 | 'posts_per_page' => '-1', |
||
| 105 | 'orderby' => 'title', |
||
|
0 ignored issues
–
show
|
|||
| 106 | 'order' => 'ASC', |
||
|
0 ignored issues
–
show
|
|||
| 107 | ), |
||
| 108 | 'repeatable' => true, |
||
| 109 | 'allow_none' => true, |
||
| 110 | 'cols' => 12, |
||
|
0 ignored issues
–
show
|
|||
| 111 | ); |
||
| 112 | } |
||
| 113 | return $fields; |
||
| 114 | } |
||
| 115 | } |
||
| 116 | new LSX_Activities_Admin(); |
||
| 117 |