@@ -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; |
@@ -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', |
@@ -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.1' ); |
|
| 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.1'); |
|
| 24 | 24 | |
| 25 | 25 | /* ======================= Below is the Plugin Class init ========================= */ |
| 26 | 26 | |