| @@ -1,10 +1,10 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace FilterEverything\Filter; |
| 4 | 4 | |
| 5 | -if ( ! defined('WPINC') ) { | |
| 6 | - wp_die(); | |
| 5 | +if ( ! defined('ABSPATH') ) { | |
| 6 | + exit; | |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | use FilterEverything\Filter\Pro\SeoFrontend; |
| 10 | 10 | |
| @@ -75,18 +75,26 @@ | ||
| 75 | 75 | |
| 76 | 76 | public function getFilterService() |
| 77 | 77 | { |
| 78 | 78 | if (!isset($this->services['filterservice'])) { |
| 79 | - $this->addService('filterservice', new Filter( array( 'or' => '-or-', 'and' => '-and-' ) )); | |
| 79 | + $this->addService('filterservice', new Filter() ); | |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | return $this->getService('filterservice'); |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | + public function getUrlManager() | |
| 86 | + { | |
| 87 | + if ( ! isset( $this->services['urlmanager'] ) ) { | |
| 88 | + $this->addService('urlmanager', new UrlManager() ); | |
| 89 | + } | |
| 90 | + return $this->getService('urlmanager'); | |
| 91 | + } | |
| 92 | + | |
| 85 | 93 | public function getTemplateManager() |
| 86 | 94 | { |
| 87 | 95 | if (!isset($this->services['templatemanager'])) { |
| 88 | - $this->addService('templatemanager', new TemplateManager(FLRT_PLUGIN_DIR)); | |
| 96 | + $this->addService('templatemanager', new TemplateManager(FLRT_PLUGIN_DIR_PATH)); | |
| 89 | 97 | } |
| 90 | 98 | |
| 91 | 99 | return $this->getService('templatemanager'); |
| 92 | 100 | } |
| @@ -139,12 +147,47 @@ | ||
| 139 | 147 | |
| 140 | 148 | return $this->getService('tabrenderer'); |
| 141 | 149 | } |
| 142 | 150 | |
| 151 | + /** | |
| 152 | + * Per-request filter state (parsed request, relevant sets, JSON payload). | |
| 153 | + * @since 1.9.7 | |
| 154 | + * @return FilterContext | |
| 155 | + */ | |
| 156 | + public function getFilterContext() | |
| 157 | + { | |
| 158 | + if ( ! isset( $this->services['filtercontext'] ) ) { | |
| 159 | + $this->addService( 'filtercontext', new FilterContext() ); | |
| 160 | + } | |
| 161 | + | |
| 162 | + return $this->getService( 'filtercontext' ); | |
| 163 | + } | |
| 164 | + | |
| 165 | + public function getSwatches() | |
| 166 | + { | |
| 167 | + if ( !isset( $this->services['swatches'] ) ) { | |
| 168 | + $this->addService('swatches', new Swatches() ); | |
| 169 | + } | |
| 170 | + | |
| 171 | + return $this->getService('swatches' ); | |
| 172 | + } | |
| 173 | + | |
| 174 | + /** | |
| 175 | + * Sanitizes $_GET variables and stores them in the Container | |
| 176 | + * @return false|mixed | |
| 177 | + */ | |
| 143 | 178 | public function getTheGet() |
| 144 | 179 | { |
| 145 | - if( ! $this->getParam('get') ){ | |
| 146 | - $this->storeParam( 'get', $_GET ); | |
| 180 | + if ( ! $this->getParam('get') ) { | |
| 181 | + $clean_get = []; | |
| 182 | + | |
| 183 | + if ( is_array( $_GET ) ) { | |
| 184 | + foreach ( $_GET as $param => $value ) { | |
| 185 | + $clean_get[ $param ] = flrt_string_polyfill( $value ); | |
| 186 | + } | |
| 187 | + } | |
| 188 | + | |
| 189 | + $this->storeParam( 'get', $clean_get ); | |
| 147 | 190 | } |
| 148 | 191 | |
| 149 | 192 | return $this->getParam('get'); |
| 150 | 193 | } |