1 | <?php |
||
2 | /** |
||
3 | * LSX_TO_Vehicles_Frontend |
||
4 | * |
||
5 | * @package LSX_TO_Vehicles_Frontend |
||
6 | * @author LightSpeed |
||
7 | * @license GPL-3.0+ |
||
8 | * @link |
||
9 | * @copyright 2016 LightSpeedDevelopment |
||
10 | */ |
||
11 | |||
12 | /** |
||
13 | * Main plugin class. |
||
14 | * |
||
15 | * @package LSX_TO_Vehicles_Frontend |
||
16 | * @author LightSpeed |
||
17 | */ |
||
18 | |||
19 | class LSX_TO_Vehicles_Frontend extends LSX_TO_Vehicles { |
||
20 | |||
21 | /** |
||
22 | * Holds the $page_links array while its being built on the single team page. |
||
23 | * |
||
24 | * @var array |
||
25 | */ |
||
26 | public $page_links = false; |
||
27 | |||
28 | /** |
||
29 | * Holds the array of options. |
||
30 | * |
||
31 | * @var array |
||
32 | */ |
||
33 | public $options = false; |
||
34 | |||
35 | /** |
||
36 | * Constructor |
||
37 | */ |
||
38 | public function __construct() { |
||
39 | $this->set_vars(); |
||
40 | |||
41 | add_action( 'wp_head', array( $this, 'wp_head' ), 20, 1 ); |
||
42 | |||
43 | //add_filter( 'lsx_to_entry_class', array( $this, 'entry_class' ) ); |
||
44 | //add_action( 'init', array( $this, 'init' ) ); |
||
45 | |||
46 | if ( ! class_exists( 'LSX_TO_Template_Redirects' ) ) { |
||
47 | require_once( LSX_TO_VEHICLES_PATH . 'classes/class-lsx-to-template-redirects.php' ); |
||
48 | } |
||
49 | $this->redirects = new LSX_TO_Template_Redirects( LSX_TO_VEHICLES_PATH, array_keys( $this->post_types ) ); |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
50 | add_action( 'lsx_vehicle_content', array( $this->redirects, 'content_part' ), 10, 2 ); |
||
51 | |||
52 | add_filter( 'lsx_to_page_navigation', array( $this, 'page_links' ) ); |
||
53 | |||
54 | //add_action( 'lsx_entry_top', array( $this, 'archive_entry_top' ), 15 ); |
||
55 | //add_action( 'lsx_entry_bottom', array( $this, 'archive_entry_bottom' ) ); |
||
56 | add_action( 'lsx_content_bottom', array( $this, 'single_content_bottom' ) ); |
||
57 | |||
58 | add_action( 'lsx_banner_allowed_post_types', array( $this, 'theme_allowed_post_type_banners' ) ); |
||
59 | } |
||
60 | |||
61 | function wp_head() { |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
It is recommend to declare an explicit visibility for
wp_head .
Generally, we recommend to declare visibility for all methods in your source code. This has the advantage of clearly communication to other developers, and also yourself, how this method should be consumed. If you are not sure which visibility to choose, it is a good idea to start with
the most restrictive visibility, and then raise visibility as needed, i.e.
start with ![]() |
|||
62 | if ( is_singular( 'vehicle' ) ) { |
||
63 | remove_action( 'lsx_entry_bottom', 'lsx_to_single_entry_bottom' ); |
||
64 | } |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * Adds the template tags to the bottom of the single review |
||
69 | */ |
||
70 | public function single_content_bottom() { |
||
71 | if ( is_singular( 'vehicle' ) ) { |
||
72 | // lsx_to_review_accommodation(); |
||
73 | |||
74 | // lsx_to_review_tour(); |
||
75 | |||
76 | // lsx_to_review_destination(); |
||
77 | |||
78 | lsx_to_gallery( '<section id="gallery" class="lsx-to-section lsx-to-collapse-section"><h2 class="lsx-to-section-title lsx-to-collapse-title lsx-title" data-toggle="collapse" data-target="#collapse-gallery">' . esc_html__( 'Gallery', 'to-reviews' ) . '</h2><div id="collapse-gallery" class="collapse in"><div class="collapse-inner">', '</div></div></section>' ); |
||
79 | |||
80 | if ( function_exists( 'lsx_to_videos' ) ) { |
||
81 | lsx_to_videos( '<section id="videos" class="lsx-to-section lsx-to-collapse-section"><h2 class="lsx-to-section-title lsx-to-collapse-title lsx-title" data-toggle="collapse" data-target="#collapse-videos">' . esc_html__( 'Videos', 'to-reviews' ) . '</h2><div id="collapse-videos" class="collapse in"><div class="collapse-inner">', '</div></div></section>' ); |
||
82 | } elseif ( class_exists( 'Envira_Videos' ) ) { |
||
83 | lsx_to_envira_videos( '<section id="videos" class="lsx-to-section lsx-to-collapse-section"><h2 class="lsx-to-section-title lsx-to-collapse-title lsx-title" data-toggle="collapse" data-target="#collapse-videos">' . esc_html__( 'Videos', 'to-reviews' ) . '</h2><div id="collapse-videos" class="collapse in"><div class="collapse-inner">', '</div></div></section>' ); |
||
84 | } //lsx_to_review_posts(); |
||
85 | } |
||
86 | } |
||
87 | |||
88 | /** |
||
89 | * Adds our navigation links to the team single post |
||
90 | * |
||
91 | * @param $page_links array |
||
92 | * @return $page_links array |
||
93 | */ |
||
94 | public function page_links( $page_links ) { |
||
95 | if ( is_singular( 'vehicle' ) ) { |
||
96 | $this->page_links = $page_links; |
||
97 | $this->get_gallery_link(); |
||
98 | $this->get_videos_link(); |
||
99 | |||
100 | $page_links = $this->page_links; |
||
101 | } |
||
102 | |||
103 | return $page_links; |
||
104 | } |
||
105 | |||
106 | /** |
||
107 | * Tests for the Gallery and returns a link for the section |
||
108 | */ |
||
109 | public function get_gallery_link() { |
||
110 | $gallery_ids = get_post_meta( get_the_ID(), 'gallery', false ); |
||
111 | $envira_gallery = get_post_meta( get_the_ID(), 'envira_gallery', true ); |
||
112 | |||
113 | if ( ( ! empty( $gallery_ids ) && is_array( $gallery_ids ) ) || ( function_exists( 'envira_gallery' ) && ! empty( $envira_gallery ) && false === lsx_to_enable_envira_banner() ) ) { |
||
114 | if ( function_exists( 'envira_gallery' ) && ! empty( $envira_gallery ) && false === lsx_to_enable_envira_banner() ) { |
||
115 | // Envira Gallery. |
||
116 | $this->page_links['gallery'] = esc_html__( 'Gallery', 'to-vehicles' ); |
||
117 | return; |
||
118 | } else { |
||
119 | if ( function_exists( 'envira_dynamic' ) ) { |
||
120 | // Envira Gallery - Dynamic. |
||
121 | $this->page_links['gallery'] = esc_html__( 'Gallery', 'to-vehicles' ); |
||
122 | return; |
||
123 | } else { |
||
124 | // WordPress Gallery. |
||
125 | $this->page_links['gallery'] = esc_html__( 'Gallery', 'to-vehicles' ); |
||
126 | return; |
||
127 | } |
||
128 | } |
||
129 | } |
||
130 | } |
||
131 | |||
132 | /** |
||
133 | * Tests for the Videos and returns a link for the section |
||
134 | */ |
||
135 | public function get_videos_link() { |
||
136 | $videos_id = false; |
||
137 | |||
138 | if ( class_exists( 'Envira_Videos' ) ) { |
||
139 | $videos_id = get_post_meta( get_the_ID(), 'envira_video', true ); |
||
140 | } |
||
141 | |||
142 | if ( empty( $videos_id ) && function_exists( 'lsx_to_videos' ) ) { |
||
143 | $videos_id = get_post_meta( get_the_ID(), 'videos', true ); |
||
144 | } |
||
145 | |||
146 | if ( ! empty( $videos_id ) ) { |
||
147 | $this->page_links['videos'] = esc_html__( 'Videos', 'to-vehicles' ); |
||
148 | } |
||
149 | } |
||
150 | |||
151 | } |
||
152 | new LSX_TO_Vehicles_Frontend(); |
||
153 |