| | 878 | * Retrieve the date endian from the permalink structure |
| | 879 | * |
| | 880 | * @since 3.5.0 |
| | 881 | * @access public |
| | 882 | * |
| | 883 | * @return array |
| | 884 | */ |
| | 885 | function get_date_endian() { |
| | 886 | // The date permalink must have year, month, and day separated by slashes. |
| | 887 | $alternative_endians = array( '%day%/%monthnum%/%year%', '%monthnum%/%day%/%year%' ); |
| | 888 | |
| | 889 | $date_endian = ''; |
| | 890 | |
| | 891 | foreach ( $alternative_endians as $endian ) { |
| | 892 | if ( false !== strpos( $this->permalink_structure, $endian ) ) { |
| | 893 | $date_endian = $endian; |
| | 894 | break; |
| | 895 | } |
| | 896 | } |
| | 897 | |
| | 898 | if ( empty( $date_endian ) ) |
| | 899 | $date_endian = $this->default_date_endian; |
| | 900 | |
| | 901 | return $date_endian; |
| | 902 | } |
| | 903 | |
| | 904 | /** |
| 898 | | // The date permalink must have year, month, and day separated by slashes. |
| 899 | | $endians = array('%year%/%monthnum%/%day%', '%day%/%monthnum%/%year%', '%monthnum%/%day%/%year%'); |
| 900 | | |
| 901 | | $this->date_structure = ''; |
| 902 | | $date_endian = ''; |
| 903 | | |
| 904 | | foreach ( $endians as $endian ) { |
| 905 | | if ( false !== strpos($this->permalink_structure, $endian) ) { |
| 906 | | $date_endian= $endian; |
| 907 | | break; |
| 908 | | } |
| 909 | | } |
| 910 | | |
| 911 | | if ( empty($date_endian) ) |
| 912 | | $date_endian = '%year%/%monthnum%/%day%'; |
| 913 | | |
| 1264 | | //build a list from the rewritecode and queryreplace arrays, that will look something like |
| 1265 | | //tagname=$matches[i] where i is the current $i |
| 1266 | | for ( $i = 0; $i < $num_tokens; ++$i ) { |
| 1267 | | if ( 0 < $i ) |
| 1268 | | $queries[$i] = $queries[$i - 1] . '&'; |
| 1269 | | else |
| 1270 | | $queries[$i] = ''; |
| | 1282 | |
| | 1283 | if ( EP_DATE === $ep_mask && $this->default_date_endian !== $this->get_date_endian() ) { |
| | 1284 | $reformatted = array( '%year%', array( '%monthnum%', '%year%' ) ); |
| | 1285 | switch ( $this->get_date_endian() ) { |
| | 1286 | case '%day%/%monthnum%/%year%': |
| | 1287 | $reformatted[] = array( '%day%', '%monthnum%', '%year%' ); |
| | 1288 | break; |
| | 1289 | case '%monthnum%/%day%/%year%': |
| | 1290 | $reformatted[] = array( '%monthnum%', '%day%', '%year%' ); |
| | 1291 | break; |
| | 1292 | } |
| | 1293 | |
| | 1294 | foreach ( $reformatted as $tokens ) { |
| | 1295 | if ( ! is_array( $tokens ) ) |
| | 1296 | $tokens = array( $tokens ); |
| 1272 | | $query_token = str_replace($this->rewritecode, $this->queryreplace, $tokens[0][$i]) . $this->preg_index($i+1); |
| 1273 | | $queries[$i] .= $query_token; |
| | 1298 | $query_parts = array(); |
| | 1299 | foreach ( $tokens as $i => $token ) |
| | 1300 | $query_parts[] = str_replace( $this->rewritecode, $this->queryreplace, $token ) . $this->preg_index( $i + 1 ); |
| | 1301 | |
| | 1302 | $queries[] = join( '&', $query_parts ); |
| | 1303 | } |
| | 1304 | } else { |
| | 1305 | //build a list from the rewritecode and queryreplace arrays, that will look something like |
| | 1306 | //tagname=$matches[i] where i is the current $i |
| | 1307 | for ( $i = 0; $i < $num_tokens; ++$i ) { |
| | 1308 | if ( 0 < $i ) |
| | 1309 | $queries[$i] = $queries[$i - 1] . '&'; |
| | 1310 | else |
| | 1311 | $queries[$i] = ''; |
| | 1312 | |
| | 1313 | $query_token = str_replace($this->rewritecode, $this->queryreplace, $tokens[0][$i]) . $this->preg_index($i+1); |
| | 1314 | $queries[$i] .= $query_token; |
| | 1315 | } |
| 1295 | | //get the struct for this dir, and trim slashes off the front |
| 1296 | | $struct .= $dirs[$j] . '/'; //accumulate. see comment near explode('/', $structure) above |
| | 1347 | if ( EP_DATE === $ep_mask && $this->default_date_endian !== $this->get_date_endian() ) { |
| | 1348 | $struct = $front . $dirs[$j]; |
| | 1349 | } else { |
| | 1350 | //get the struct for this dir, and trim slashes off the front |
| | 1351 | $struct .= $dirs[$j] . '/'; //accumulate. see comment near explode('/', $structure) above |
| | 1352 | } |
| | 1353 | |