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