Redirect_404_Vehicles::extract_make( WP $wp_obj )
Finds the vehicle make from the request whether it was a search or a request for a specific vehicle that no longer exists.
Parameters Parameters
- $wp_obj
-
(WP) (Required) Current WordPress environment instance (passed by reference).
Return Return
(string) A vehicle manufacturer name
Source Source
File: includes/class-redirect-404-vehicles.php
protected function extract_make( $wp_obj ) { if ( ! $this->is_request_for_vehicle( $wp_obj ) ) { return ''; } // if this is a search, the make might be in its own query variable. // $wp_obj is not a WP_Query and does not have a get() method. if ( isset( $wp_obj->query_vars['make'] ) && '' !== $wp_obj->query_vars['make'] ) { return $wp_obj->query_vars['make']; } // if this is a request for a single vehicle, parse the make out of the slug. if ( isset( $wp_obj->query_vars[ INVP::POST_TYPE ] ) && '' !== $wp_obj->query_vars[ INVP::POST_TYPE ] ) { $slug_pieces = explode( '-', $wp_obj->query_vars[ INVP::POST_TYPE ] ); if ( 2 <= count( $slug_pieces ) // is the first piece a number of no more than 4 digits? // We are looking for a slug like 2000-acura-integra. && 4 >= strlen( $slug_pieces[0] ) && is_numeric( $slug_pieces[0] ) ) { return $slug_pieces[1]; } } return ''; }
Expand full source codeCollapse full source codeView on Github