| Conditions | 7 |
| Paths | 13 |
| Total Lines | 33 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 37 | * @return string |
||
| 38 | */ |
||
| 39 | public function check_base( $url, $options ) { |
||
| 40 | if ( ! is_string( $url ) || empty( $url ) ) { |
||
| 41 | return $url; |
||
| 42 | } |
||
| 43 | |||
| 44 | global $wp_rewrite; |
||
| 45 | |||
| 46 | $base_defined = $options->base_defined; |
||
| 47 | |||
| 48 | $permastruct = $wp_rewrite->get_extra_permastruct( $options->get_tax_query() ); |
||
| 49 | if ( $permastruct ) { |
||
| 50 | $permastruct = explode( '/', $permastruct ); |
||
| 51 | end( $permastruct ); |
||
| 52 | $permastruct = prev( $permastruct ); |
||
| 53 | if ( false !== $permastruct ) { |
||
| 54 | $base_defined = $permastruct; |
||
| 55 | } |
||
| 56 | } |
||
| 57 | |||
| 58 | $base_option = get_option( $options->base_option ); |
||
| 59 | if ( empty( $base_option ) ) { |
||
| 60 | $base_option = $options->base_defined; |
||
| 61 | } |
||
| 62 | |||
| 63 | if ( $base_defined != $base_option ) { |
||
| 64 | $search = '/' . $base_defined . '/'; |
||
| 65 | $replace = '/' . $base_option . '/'; |
||
| 66 | $count = 1; |
||
| 67 | $url = str_replace( $search, $replace, $url, $count ); |
||
| 68 | } |
||
| 69 | |||
| 70 | return $url; |
||
| 74 |