@@ -31,22 +31,22 @@ discard block |
||
31 | 31 | * @param array $post_types an array of the post types to redirect. |
32 | 32 | * @param array $taxonomies an array of the taxonomies to redirect. |
33 | 33 | */ |
34 | - public function __construct($plugin_path=false,$post_types=false,$taxonomies=false) { |
|
35 | - if(false !== $plugin_path){ |
|
34 | + public function __construct($plugin_path = false, $post_types = false, $taxonomies = false) { |
|
35 | + if (false !== $plugin_path) { |
|
36 | 36 | $this->plugin_path = $plugin_path; |
37 | 37 | |
38 | - add_filter( 'lsx_to_widget_path', array( $this, 'widget_path'), 10, 2 ); |
|
39 | - add_filter( 'lsx_to_content_path', array( $this, 'content_path'), 10, 3 ); |
|
38 | + add_filter('lsx_to_widget_path', array($this, 'widget_path'), 10, 2); |
|
39 | + add_filter('lsx_to_content_path', array($this, 'content_path'), 10, 3); |
|
40 | 40 | |
41 | - if(false !== $post_types){ |
|
41 | + if (false !== $post_types) { |
|
42 | 42 | $this->post_types = $post_types; |
43 | - add_filter( 'template_include', array( $this, 'post_type_archive_template_include'), 99 ); |
|
44 | - add_filter( 'template_include', array( $this, 'post_type_single_template_include'), 99 ); |
|
45 | - add_filter( 'template_include', array( $this, 'search_template_include'), 99 ); |
|
43 | + add_filter('template_include', array($this, 'post_type_archive_template_include'), 99); |
|
44 | + add_filter('template_include', array($this, 'post_type_single_template_include'), 99); |
|
45 | + add_filter('template_include', array($this, 'search_template_include'), 99); |
|
46 | 46 | } |
47 | - if(false !== $taxonomies){ |
|
47 | + if (false !== $taxonomies) { |
|
48 | 48 | $this->taxonomies = $taxonomies; |
49 | - add_filter( 'template_include', array( $this, 'taxonomy_template_include'), 99 ); |
|
49 | + add_filter('template_include', array($this, 'taxonomy_template_include'), 99); |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | } |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | * @param $template |
58 | 58 | * @return $template |
59 | 59 | */ |
60 | - public function post_type_archive_template_include( $template ) { |
|
60 | + public function post_type_archive_template_include($template) { |
|
61 | 61 | |
62 | - if ( is_main_query() && is_post_type_archive($this->post_types)) { |
|
62 | + if (is_main_query() && is_post_type_archive($this->post_types)) { |
|
63 | 63 | $current_post_type = get_post_type(); |
64 | - if ( '' == locate_template( array( 'archive-'.$current_post_type.'.php' ) ) && file_exists( $this->plugin_path.'templates/archive-'.$current_post_type.'.php' )) { |
|
65 | - $template = $this->plugin_path.'templates/archive-'.$current_post_type.'.php'; |
|
64 | + if ('' == locate_template(array('archive-' . $current_post_type . '.php')) && file_exists($this->plugin_path . 'templates/archive-' . $current_post_type . '.php')) { |
|
65 | + $template = $this->plugin_path . 'templates/archive-' . $current_post_type . '.php'; |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | return $template; |
@@ -76,11 +76,11 @@ discard block |
||
76 | 76 | * @return $template |
77 | 77 | */ |
78 | 78 | public function post_type_single_template_include($template) { |
79 | - if ( is_main_query() && is_singular($this->post_types) ) { |
|
79 | + if (is_main_query() && is_singular($this->post_types)) { |
|
80 | 80 | $current_post_type = get_post_type(); |
81 | 81 | |
82 | - if ( '' == locate_template( array( 'single-'.$current_post_type.'.php' ) ) && file_exists( $this->plugin_path.'templates/single-'.$current_post_type.'.php') ) { |
|
83 | - $template = $this->plugin_path.'templates/single-'.$current_post_type.'.php'; |
|
82 | + if ('' == locate_template(array('single-' . $current_post_type . '.php')) && file_exists($this->plugin_path . 'templates/single-' . $current_post_type . '.php')) { |
|
83 | + $template = $this->plugin_path . 'templates/single-' . $current_post_type . '.php'; |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | return $template; |
@@ -95,11 +95,11 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function taxonomy_template_include($template) { |
97 | 97 | |
98 | - if ( is_main_query() && is_tax($this->taxonomies) ) { |
|
98 | + if (is_main_query() && is_tax($this->taxonomies)) { |
|
99 | 99 | $current_taxonomy = get_query_var('taxonomy'); |
100 | 100 | |
101 | - if ( '' == locate_template( array( 'taxonomy-'.$current_taxonomy.'.php' ) ) && file_exists( $this->plugin_path.'templates/taxonomy-'.$current_taxonomy.'.php') ) { |
|
102 | - $template = $this->plugin_path.'templates/taxonomy-'.$current_taxonomy.'.php'; |
|
101 | + if ('' == locate_template(array('taxonomy-' . $current_taxonomy . '.php')) && file_exists($this->plugin_path . 'templates/taxonomy-' . $current_taxonomy . '.php')) { |
|
102 | + $template = $this->plugin_path . 'templates/taxonomy-' . $current_taxonomy . '.php'; |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | return $template; |
@@ -112,11 +112,11 @@ discard block |
||
112 | 112 | * |
113 | 113 | * @return $template |
114 | 114 | */ |
115 | - public function search_template_include( $template ) { |
|
115 | + public function search_template_include($template) { |
|
116 | 116 | |
117 | - if ( is_main_query() && is_search() ) { |
|
118 | - if ( file_exists( $this->plugin_path.'templates/search.php' )) { |
|
119 | - $template = $this->plugin_path.'templates/search.php'; |
|
117 | + if (is_main_query() && is_search()) { |
|
118 | + if (file_exists($this->plugin_path . 'templates/search.php')) { |
|
119 | + $template = $this->plugin_path . 'templates/search.php'; |
|
120 | 120 | } |
121 | 121 | } |
122 | 122 | return $template; |
@@ -132,26 +132,26 @@ discard block |
||
132 | 132 | public function content_part($slug, $name = null) { |
133 | 133 | $template = array(); |
134 | 134 | $name = (string) $name; |
135 | - if ( '' !== $name ){ |
|
135 | + if ('' !== $name) { |
|
136 | 136 | $template = "{$slug}-{$name}.php"; |
137 | - }else{ |
|
137 | + }else { |
|
138 | 138 | $template = "{$slug}.php"; |
139 | 139 | } |
140 | 140 | $original_name = $template; |
141 | - $path = apply_filters('lsx_to_content_path','',get_post_type()); |
|
141 | + $path = apply_filters('lsx_to_content_path', '', get_post_type()); |
|
142 | 142 | |
143 | - if ( '' == locate_template( array( $template ) ) && file_exists( $path.'templates/'.$template) ) { |
|
144 | - $template = $path.'templates/'.$template; |
|
145 | - }elseif(file_exists( get_stylesheet_directory().'/'.$template)){ |
|
146 | - $template = get_stylesheet_directory().'/'.$template; |
|
147 | - }else{ |
|
143 | + if ('' == locate_template(array($template)) && file_exists($path . 'templates/' . $template)) { |
|
144 | + $template = $path . 'templates/' . $template; |
|
145 | + }elseif (file_exists(get_stylesheet_directory() . '/' . $template)) { |
|
146 | + $template = get_stylesheet_directory() . '/' . $template; |
|
147 | + }else { |
|
148 | 148 | $template = false; |
149 | 149 | } |
150 | 150 | |
151 | - if(false !== $template){ |
|
152 | - load_template( $template, false ); |
|
151 | + if (false !== $template) { |
|
152 | + load_template($template, false); |
|
153 | 153 | }else { |
154 | - echo wp_kses_post('<p>No '.$original_name.' can be found.</p>'); |
|
154 | + echo wp_kses_post('<p>No ' . $original_name . ' can be found.</p>'); |
|
155 | 155 | } |
156 | 156 | } |
157 | 157 | |
@@ -163,9 +163,9 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @return $path |
165 | 165 | */ |
166 | - public function widget_path($path,$slug) { |
|
167 | - if((false !== $this->post_types && in_array($slug,$this->post_types)) |
|
168 | - || (false !== $this->taxonomies && in_array($slug,$this->taxonomies)) || 'post' === $slug){ |
|
166 | + public function widget_path($path, $slug) { |
|
167 | + if ((false !== $this->post_types && in_array($slug, $this->post_types)) |
|
168 | + || (false !== $this->taxonomies && in_array($slug, $this->taxonomies)) || 'post' === $slug) { |
|
169 | 169 | $path = $this->plugin_path; |
170 | 170 | } |
171 | 171 | return $path; |
@@ -179,9 +179,9 @@ discard block |
||
179 | 179 | * |
180 | 180 | * @return $path |
181 | 181 | */ |
182 | - public function content_path($path,$slug) { |
|
183 | - if((false !== $this->post_types && in_array($slug,$this->post_types)) |
|
184 | - || (false !== $this->taxonomies && in_array($slug,$this->taxonomies)) || 'post' === $slug){ |
|
182 | + public function content_path($path, $slug) { |
|
183 | + if ((false !== $this->post_types && in_array($slug, $this->post_types)) |
|
184 | + || (false !== $this->taxonomies && in_array($slug, $this->taxonomies)) || 'post' === $slug) { |
|
185 | 185 | $path = $this->plugin_path; |
186 | 186 | } |
187 | 187 | return $path; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | $name = (string) $name; |
135 | 135 | if ( '' !== $name ){ |
136 | 136 | $template = "{$slug}-{$name}.php"; |
137 | - }else{ |
|
137 | + } else{ |
|
138 | 138 | $template = "{$slug}.php"; |
139 | 139 | } |
140 | 140 | $original_name = $template; |
@@ -142,15 +142,15 @@ discard block |
||
142 | 142 | |
143 | 143 | if ( '' == locate_template( array( $template ) ) && file_exists( $path.'templates/'.$template) ) { |
144 | 144 | $template = $path.'templates/'.$template; |
145 | - }elseif(file_exists( get_stylesheet_directory().'/'.$template)){ |
|
145 | + } elseif(file_exists( get_stylesheet_directory().'/'.$template)){ |
|
146 | 146 | $template = get_stylesheet_directory().'/'.$template; |
147 | - }else{ |
|
147 | + } else{ |
|
148 | 148 | $template = false; |
149 | 149 | } |
150 | 150 | |
151 | 151 | if(false !== $template){ |
152 | 152 | load_template( $template, false ); |
153 | - }else { |
|
153 | + } else { |
|
154 | 154 | echo wp_kses_post('<p>No '.$original_name.' can be found.</p>'); |
155 | 155 | } |
156 | 156 | } |
@@ -10,180 +10,180 @@ |
||
10 | 10 | |
11 | 11 | class LSX_TO_Template_Redirects { |
12 | 12 | |
13 | - /** |
|
14 | - * Plugin Path |
|
15 | - */ |
|
16 | - public $plugin_path = false; |
|
13 | + /** |
|
14 | + * Plugin Path |
|
15 | + */ |
|
16 | + public $plugin_path = false; |
|
17 | 17 | |
18 | - /** |
|
19 | - * Post Types |
|
20 | - */ |
|
21 | - public $post_types = false; |
|
18 | + /** |
|
19 | + * Post Types |
|
20 | + */ |
|
21 | + public $post_types = false; |
|
22 | 22 | |
23 | - /** |
|
24 | - * Taxonomies |
|
25 | - */ |
|
26 | - public $taxonomies = false; |
|
23 | + /** |
|
24 | + * Taxonomies |
|
25 | + */ |
|
26 | + public $taxonomies = false; |
|
27 | 27 | |
28 | - /** |
|
29 | - * Initialize the plugin by setting localization, filters, and administration functions. |
|
30 | - * |
|
31 | - * @param array $post_types an array of the post types to redirect. |
|
32 | - * @param array $taxonomies an array of the taxonomies to redirect. |
|
33 | - */ |
|
34 | - public function __construct($plugin_path=false,$post_types=false,$taxonomies=false) { |
|
35 | - if(false !== $plugin_path){ |
|
36 | - $this->plugin_path = $plugin_path; |
|
28 | + /** |
|
29 | + * Initialize the plugin by setting localization, filters, and administration functions. |
|
30 | + * |
|
31 | + * @param array $post_types an array of the post types to redirect. |
|
32 | + * @param array $taxonomies an array of the taxonomies to redirect. |
|
33 | + */ |
|
34 | + public function __construct($plugin_path=false,$post_types=false,$taxonomies=false) { |
|
35 | + if(false !== $plugin_path){ |
|
36 | + $this->plugin_path = $plugin_path; |
|
37 | 37 | |
38 | - add_filter( 'lsx_to_widget_path', array( $this, 'widget_path'), 10, 2 ); |
|
39 | - add_filter( 'lsx_to_content_path', array( $this, 'content_path'), 10, 3 ); |
|
38 | + add_filter( 'lsx_to_widget_path', array( $this, 'widget_path'), 10, 2 ); |
|
39 | + add_filter( 'lsx_to_content_path', array( $this, 'content_path'), 10, 3 ); |
|
40 | 40 | |
41 | - if(false !== $post_types){ |
|
42 | - $this->post_types = $post_types; |
|
43 | - add_filter( 'template_include', array( $this, 'post_type_archive_template_include'), 99 ); |
|
44 | - add_filter( 'template_include', array( $this, 'post_type_single_template_include'), 99 ); |
|
45 | - add_filter( 'template_include', array( $this, 'search_template_include'), 99 ); |
|
46 | - } |
|
47 | - if(false !== $taxonomies){ |
|
48 | - $this->taxonomies = $taxonomies; |
|
49 | - add_filter( 'template_include', array( $this, 'taxonomy_template_include'), 99 ); |
|
50 | - } |
|
51 | - } |
|
52 | - } |
|
41 | + if(false !== $post_types){ |
|
42 | + $this->post_types = $post_types; |
|
43 | + add_filter( 'template_include', array( $this, 'post_type_archive_template_include'), 99 ); |
|
44 | + add_filter( 'template_include', array( $this, 'post_type_single_template_include'), 99 ); |
|
45 | + add_filter( 'template_include', array( $this, 'search_template_include'), 99 ); |
|
46 | + } |
|
47 | + if(false !== $taxonomies){ |
|
48 | + $this->taxonomies = $taxonomies; |
|
49 | + add_filter( 'template_include', array( $this, 'taxonomy_template_include'), 99 ); |
|
50 | + } |
|
51 | + } |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * Redirect wordpress to the archive template located in the plugin |
|
56 | - * |
|
57 | - * @param $template |
|
58 | - * @return $template |
|
59 | - */ |
|
60 | - public function post_type_archive_template_include( $template ) { |
|
54 | + /** |
|
55 | + * Redirect wordpress to the archive template located in the plugin |
|
56 | + * |
|
57 | + * @param $template |
|
58 | + * @return $template |
|
59 | + */ |
|
60 | + public function post_type_archive_template_include( $template ) { |
|
61 | 61 | |
62 | - if ( is_main_query() && is_post_type_archive($this->post_types)) { |
|
63 | - $current_post_type = get_post_type(); |
|
64 | - if ( '' == locate_template( array( 'archive-'.$current_post_type.'.php' ) ) && file_exists( $this->plugin_path.'templates/archive-'.$current_post_type.'.php' )) { |
|
65 | - $template = $this->plugin_path.'templates/archive-'.$current_post_type.'.php'; |
|
66 | - } |
|
67 | - } |
|
68 | - return $template; |
|
69 | - } |
|
62 | + if ( is_main_query() && is_post_type_archive($this->post_types)) { |
|
63 | + $current_post_type = get_post_type(); |
|
64 | + if ( '' == locate_template( array( 'archive-'.$current_post_type.'.php' ) ) && file_exists( $this->plugin_path.'templates/archive-'.$current_post_type.'.php' )) { |
|
65 | + $template = $this->plugin_path.'templates/archive-'.$current_post_type.'.php'; |
|
66 | + } |
|
67 | + } |
|
68 | + return $template; |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * Redirect wordpress to the single template located in the plugin |
|
73 | - * |
|
74 | - * @param $template |
|
75 | - * |
|
76 | - * @return $template |
|
77 | - */ |
|
78 | - public function post_type_single_template_include($template) { |
|
79 | - if ( is_main_query() && is_singular($this->post_types) ) { |
|
80 | - $current_post_type = get_post_type(); |
|
71 | + /** |
|
72 | + * Redirect wordpress to the single template located in the plugin |
|
73 | + * |
|
74 | + * @param $template |
|
75 | + * |
|
76 | + * @return $template |
|
77 | + */ |
|
78 | + public function post_type_single_template_include($template) { |
|
79 | + if ( is_main_query() && is_singular($this->post_types) ) { |
|
80 | + $current_post_type = get_post_type(); |
|
81 | 81 | |
82 | - if ( '' == locate_template( array( 'single-'.$current_post_type.'.php' ) ) && file_exists( $this->plugin_path.'templates/single-'.$current_post_type.'.php') ) { |
|
83 | - $template = $this->plugin_path.'templates/single-'.$current_post_type.'.php'; |
|
84 | - } |
|
85 | - } |
|
86 | - return $template; |
|
87 | - } |
|
82 | + if ( '' == locate_template( array( 'single-'.$current_post_type.'.php' ) ) && file_exists( $this->plugin_path.'templates/single-'.$current_post_type.'.php') ) { |
|
83 | + $template = $this->plugin_path.'templates/single-'.$current_post_type.'.php'; |
|
84 | + } |
|
85 | + } |
|
86 | + return $template; |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * Redirect wordpress to the taxonomy located in the plugin |
|
91 | - * |
|
92 | - * @param $template |
|
93 | - * |
|
94 | - * @return $template |
|
95 | - */ |
|
96 | - public function taxonomy_template_include($template) { |
|
89 | + /** |
|
90 | + * Redirect wordpress to the taxonomy located in the plugin |
|
91 | + * |
|
92 | + * @param $template |
|
93 | + * |
|
94 | + * @return $template |
|
95 | + */ |
|
96 | + public function taxonomy_template_include($template) { |
|
97 | 97 | |
98 | - if ( is_main_query() && is_tax($this->taxonomies) ) { |
|
99 | - $current_taxonomy = get_query_var('taxonomy'); |
|
98 | + if ( is_main_query() && is_tax($this->taxonomies) ) { |
|
99 | + $current_taxonomy = get_query_var('taxonomy'); |
|
100 | 100 | |
101 | - if ( '' == locate_template( array( 'taxonomy-'.$current_taxonomy.'.php' ) ) && file_exists( $this->plugin_path.'templates/taxonomy-'.$current_taxonomy.'.php') ) { |
|
102 | - $template = $this->plugin_path.'templates/taxonomy-'.$current_taxonomy.'.php'; |
|
103 | - } |
|
104 | - } |
|
105 | - return $template; |
|
106 | - } |
|
101 | + if ( '' == locate_template( array( 'taxonomy-'.$current_taxonomy.'.php' ) ) && file_exists( $this->plugin_path.'templates/taxonomy-'.$current_taxonomy.'.php') ) { |
|
102 | + $template = $this->plugin_path.'templates/taxonomy-'.$current_taxonomy.'.php'; |
|
103 | + } |
|
104 | + } |
|
105 | + return $template; |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * Redirect wordpress to the search template located in the plugin |
|
110 | - * |
|
111 | - * @param $template |
|
112 | - * |
|
113 | - * @return $template |
|
114 | - */ |
|
115 | - public function search_template_include( $template ) { |
|
108 | + /** |
|
109 | + * Redirect wordpress to the search template located in the plugin |
|
110 | + * |
|
111 | + * @param $template |
|
112 | + * |
|
113 | + * @return $template |
|
114 | + */ |
|
115 | + public function search_template_include( $template ) { |
|
116 | 116 | |
117 | - if ( is_main_query() && is_search() ) { |
|
118 | - if ( file_exists( $this->plugin_path.'templates/search.php' )) { |
|
119 | - $template = $this->plugin_path.'templates/search.php'; |
|
120 | - } |
|
121 | - } |
|
122 | - return $template; |
|
123 | - } |
|
117 | + if ( is_main_query() && is_search() ) { |
|
118 | + if ( file_exists( $this->plugin_path.'templates/search.php' )) { |
|
119 | + $template = $this->plugin_path.'templates/search.php'; |
|
120 | + } |
|
121 | + } |
|
122 | + return $template; |
|
123 | + } |
|
124 | 124 | |
125 | - /** |
|
126 | - * Redirect wordpress to the single template located in the plugin |
|
127 | - * |
|
128 | - * @param $template |
|
129 | - * |
|
130 | - * @return $template |
|
131 | - */ |
|
132 | - public function content_part($slug, $name = null) { |
|
133 | - $template = array(); |
|
134 | - $name = (string) $name; |
|
135 | - if ( '' !== $name ){ |
|
136 | - $template = "{$slug}-{$name}.php"; |
|
137 | - }else{ |
|
138 | - $template = "{$slug}.php"; |
|
139 | - } |
|
140 | - $original_name = $template; |
|
141 | - $path = apply_filters('lsx_to_content_path','',get_post_type()); |
|
125 | + /** |
|
126 | + * Redirect wordpress to the single template located in the plugin |
|
127 | + * |
|
128 | + * @param $template |
|
129 | + * |
|
130 | + * @return $template |
|
131 | + */ |
|
132 | + public function content_part($slug, $name = null) { |
|
133 | + $template = array(); |
|
134 | + $name = (string) $name; |
|
135 | + if ( '' !== $name ){ |
|
136 | + $template = "{$slug}-{$name}.php"; |
|
137 | + }else{ |
|
138 | + $template = "{$slug}.php"; |
|
139 | + } |
|
140 | + $original_name = $template; |
|
141 | + $path = apply_filters('lsx_to_content_path','',get_post_type()); |
|
142 | 142 | |
143 | - if ( '' == locate_template( array( $template ) ) && file_exists( $path.'templates/'.$template) ) { |
|
144 | - $template = $path.'templates/'.$template; |
|
145 | - }elseif(file_exists( get_stylesheet_directory().'/'.$template)){ |
|
146 | - $template = get_stylesheet_directory().'/'.$template; |
|
147 | - }else{ |
|
148 | - $template = false; |
|
149 | - } |
|
143 | + if ( '' == locate_template( array( $template ) ) && file_exists( $path.'templates/'.$template) ) { |
|
144 | + $template = $path.'templates/'.$template; |
|
145 | + }elseif(file_exists( get_stylesheet_directory().'/'.$template)){ |
|
146 | + $template = get_stylesheet_directory().'/'.$template; |
|
147 | + }else{ |
|
148 | + $template = false; |
|
149 | + } |
|
150 | 150 | |
151 | - if(false !== $template){ |
|
152 | - load_template( $template, false ); |
|
153 | - }else { |
|
154 | - echo wp_kses_post('<p>No '.$original_name.' can be found.</p>'); |
|
155 | - } |
|
156 | - } |
|
151 | + if(false !== $template){ |
|
152 | + load_template( $template, false ); |
|
153 | + }else { |
|
154 | + echo wp_kses_post('<p>No '.$original_name.' can be found.</p>'); |
|
155 | + } |
|
156 | + } |
|
157 | 157 | |
158 | - /** |
|
159 | - * Redirect wordpress to the widget template located in the plugin |
|
160 | - * |
|
161 | - * @param $path |
|
162 | - * @param $post_type |
|
163 | - * |
|
164 | - * @return $path |
|
165 | - */ |
|
166 | - public function widget_path($path,$slug) { |
|
167 | - if((false !== $this->post_types && in_array($slug,$this->post_types)) |
|
168 | - || (false !== $this->taxonomies && in_array($slug,$this->taxonomies)) || 'post' === $slug){ |
|
169 | - $path = $this->plugin_path; |
|
170 | - } |
|
171 | - return $path; |
|
172 | - } |
|
158 | + /** |
|
159 | + * Redirect wordpress to the widget template located in the plugin |
|
160 | + * |
|
161 | + * @param $path |
|
162 | + * @param $post_type |
|
163 | + * |
|
164 | + * @return $path |
|
165 | + */ |
|
166 | + public function widget_path($path,$slug) { |
|
167 | + if((false !== $this->post_types && in_array($slug,$this->post_types)) |
|
168 | + || (false !== $this->taxonomies && in_array($slug,$this->taxonomies)) || 'post' === $slug){ |
|
169 | + $path = $this->plugin_path; |
|
170 | + } |
|
171 | + return $path; |
|
172 | + } |
|
173 | 173 | |
174 | - /** |
|
175 | - * Redirect wordpress to the single template located in the plugin |
|
176 | - * |
|
177 | - * @param $path |
|
178 | - * @param $post_type |
|
179 | - * |
|
180 | - * @return $path |
|
181 | - */ |
|
182 | - public function content_path($path,$slug) { |
|
183 | - if((false !== $this->post_types && in_array($slug,$this->post_types)) |
|
184 | - || (false !== $this->taxonomies && in_array($slug,$this->taxonomies)) || 'post' === $slug){ |
|
185 | - $path = $this->plugin_path; |
|
186 | - } |
|
187 | - return $path; |
|
188 | - } |
|
174 | + /** |
|
175 | + * Redirect wordpress to the single template located in the plugin |
|
176 | + * |
|
177 | + * @param $path |
|
178 | + * @param $post_type |
|
179 | + * |
|
180 | + * @return $path |
|
181 | + */ |
|
182 | + public function content_path($path,$slug) { |
|
183 | + if((false !== $this->post_types && in_array($slug,$this->post_types)) |
|
184 | + || (false !== $this->taxonomies && in_array($slug,$this->taxonomies)) || 'post' === $slug){ |
|
185 | + $path = $this->plugin_path; |
|
186 | + } |
|
187 | + return $path; |
|
188 | + } |
|
189 | 189 | } |
190 | 190 | \ No newline at end of file |
@@ -24,16 +24,16 @@ discard block |
||
24 | 24 | public function __construct() { |
25 | 25 | $this->set_vars(); |
26 | 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 ); |
|
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 | 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' ) ); |
|
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 | 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' ) ); |
|
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 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | * @param $objects |
43 | 43 | * @return array |
44 | 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'; |
|
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 | 49 | } |
50 | 50 | } |
51 | 51 | return $objects; |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | * @param $meta_boxes |
58 | 58 | * @return array |
59 | 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'; |
|
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 | 64 | } |
65 | 65 | } |
66 | 66 | return $meta_boxes; |
@@ -69,24 +69,24 @@ discard block |
||
69 | 69 | /** |
70 | 70 | * Adds in the gallery fields to the Tour Operators Post Types. |
71 | 71 | */ |
72 | - public function custom_fields( $fields ) { |
|
72 | + public function custom_fields($fields) { |
|
73 | 73 | global $post, $typenow, $current_screen; |
74 | 74 | |
75 | 75 | $post_type = false; |
76 | 76 | |
77 | - if ( $post && $post->post_type ) { |
|
77 | + if ($post && $post->post_type) { |
|
78 | 78 | $post_type = $post->post_type; |
79 | - } elseif ( $typenow ) { |
|
79 | + } elseif ($typenow) { |
|
80 | 80 | $post_type = $typenow; |
81 | - } elseif ( $current_screen && $current_screen->post_type ) { |
|
81 | + } elseif ($current_screen && $current_screen->post_type) { |
|
82 | 82 | $post_type = $current_screen->post_type; |
83 | - } elseif ( isset( $_REQUEST['post_type'] ) ) { |
|
84 | - $post_type = sanitize_key( $_REQUEST['post_type'] ); |
|
85 | - } elseif ( isset( $_REQUEST['post'] ) ) { |
|
86 | - $post_type = get_post_type( sanitize_key( $_REQUEST['post'] ) ); |
|
83 | + } elseif (isset($_REQUEST['post_type'])) { |
|
84 | + $post_type = sanitize_key($_REQUEST['post_type']); |
|
85 | + } elseif (isset($_REQUEST['post'])) { |
|
86 | + $post_type = get_post_type(sanitize_key($_REQUEST['post'])); |
|
87 | 87 | } |
88 | 88 | |
89 | - if ( false !== $post_type ) { |
|
89 | + if (false !== $post_type) { |
|
90 | 90 | $fields[] = array( |
91 | 91 | 'id' => 'activity_title', |
92 | 92 | 'name' => 'Activities', |
@@ -18,99 +18,99 @@ |
||
18 | 18 | |
19 | 19 | class LSX_Activities_Admin extends LSX_Activities { |
20 | 20 | |
21 | - /** |
|
22 | - * Constructor |
|
23 | - */ |
|
24 | - public function __construct() { |
|
25 | - $this->set_vars(); |
|
21 | + /** |
|
22 | + * Constructor |
|
23 | + */ |
|
24 | + public function __construct() { |
|
25 | + $this->set_vars(); |
|
26 | 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 ); |
|
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 | 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' ) ); |
|
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 | 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 | - } |
|
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 | 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; |
|
52 | - } |
|
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; |
|
52 | + } |
|
53 | 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; |
|
67 | - } |
|
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; |
|
67 | + } |
|
68 | 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; |
|
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 | 74 | |
75 | - $post_type = false; |
|
75 | + $post_type = false; |
|
76 | 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'] ) ) { |
|
84 | - $post_type = sanitize_key( $_REQUEST['post_type'] ); |
|
85 | - } elseif ( isset( $_REQUEST['post'] ) ) { |
|
86 | - $post_type = get_post_type( sanitize_key( $_REQUEST['post'] ) ); |
|
87 | - } |
|
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'] ) ) { |
|
84 | + $post_type = sanitize_key( $_REQUEST['post_type'] ); |
|
85 | + } elseif ( isset( $_REQUEST['post'] ) ) { |
|
86 | + $post_type = get_post_type( sanitize_key( $_REQUEST['post'] ) ); |
|
87 | + } |
|
88 | 88 | |
89 | - if ( false !== $post_type ) { |
|
90 | - $fields[] = array( |
|
91 | - 'id' => 'activity_title', |
|
92 | - 'name' => 'Activities', |
|
93 | - 'type' => 'title', |
|
94 | - 'cols' => 12, |
|
95 | - ); |
|
96 | - $fields[] = array( |
|
97 | - 'id' => 'activity_to_' . $post_type, |
|
98 | - 'name' => 'Activities related with this ' . $post_type, |
|
99 | - 'type' => 'post_select', |
|
100 | - 'use_ajax' => false, |
|
101 | - 'query' => array( |
|
102 | - 'post_type' => 'activity', |
|
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 | - } |
|
113 | - return $fields; |
|
114 | - } |
|
89 | + if ( false !== $post_type ) { |
|
90 | + $fields[] = array( |
|
91 | + 'id' => 'activity_title', |
|
92 | + 'name' => 'Activities', |
|
93 | + 'type' => 'title', |
|
94 | + 'cols' => 12, |
|
95 | + ); |
|
96 | + $fields[] = array( |
|
97 | + 'id' => 'activity_to_' . $post_type, |
|
98 | + 'name' => 'Activities related with this ' . $post_type, |
|
99 | + 'type' => 'post_select', |
|
100 | + 'use_ajax' => false, |
|
101 | + 'query' => array( |
|
102 | + 'post_type' => 'activity', |
|
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 | + } |
|
113 | + return $fields; |
|
114 | + } |
|
115 | 115 | } |
116 | 116 | new LSX_Activities_Admin(); |
@@ -14,7 +14,7 @@ |
||
14 | 14 | |
15 | 15 | // If this file is called directly, abort. |
16 | 16 | if ( ! defined( 'WPINC' ) ) { |
17 | - die; |
|
17 | + die; |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | define( 'LSX_ACTIVITIES_PATH', plugin_dir_path( __FILE__ ) ); |
@@ -13,14 +13,14 @@ |
||
13 | 13 | */ |
14 | 14 | |
15 | 15 | // If this file is called directly, abort. |
16 | -if ( ! defined( 'WPINC' ) ) { |
|
16 | +if ( ! defined('WPINC')) { |
|
17 | 17 | die; |
18 | 18 | } |
19 | 19 | |
20 | -define( 'LSX_ACTIVITIES_PATH', plugin_dir_path( __FILE__ ) ); |
|
21 | -define( 'LSX_ACTIVITIES_CORE', __FILE__ ); |
|
22 | -define( 'LSX_ACTIVITIES_URL', plugin_dir_url( __FILE__ ) ); |
|
23 | -define( 'LSX_ACTIVITIES_VER', '1.1.2' ); |
|
20 | +define('LSX_ACTIVITIES_PATH', plugin_dir_path(__FILE__)); |
|
21 | +define('LSX_ACTIVITIES_CORE', __FILE__); |
|
22 | +define('LSX_ACTIVITIES_URL', plugin_dir_url(__FILE__)); |
|
23 | +define('LSX_ACTIVITIES_VER', '1.1.2'); |
|
24 | 24 | |
25 | 25 | /* ======================= Below is the Plugin Class init ========================= */ |
26 | 26 |