admin
9 years ago
plugins
9 years ago
widget
9 years ago
fixes-archive.php
9 years ago
fixes-archives.php
9 years ago
fixes-calendar.php
9 years ago
fixes-dates.php
9 years ago
fixes-misc.php
9 years ago
fixes-permalinks.php
9 years ago
general.php
9 years ago
install.php
9 years ago
parsidate.php
9 years ago
settings.php
9 years ago
fixes-archive.php
45 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Fixes archives and make them compatible with Shamsi date |
| 4 | * |
| 5 | * @package WP-Parsidate |
| 6 | * @subpackage Fixes/Archives |
| 7 | * @author Mobin Ghasempoor |
| 8 | */ |
| 9 | |
| 10 | add_filter( 'wp_title', 'wpp_fix_title', 10000, 2 ); |
| 11 | add_filter( 'pre_get_document_title', 'wpp_fix_title', 10000 ); // WP 4.4+ |
| 12 | |
| 13 | /** |
| 14 | * Fixes titles for archives |
| 15 | * |
| 16 | * @param string $title Archive title |
| 17 | * @param string $sep Separator |
| 18 | * @param string $sep_location Separator location |
| 19 | * |
| 20 | * @return string New archive title |
| 21 | */ |
| 22 | function wpp_fix_title( $title, $sep = '-', $sep_location = 'right' ) { |
| 23 | global $persian_month_names, $wp_query, $wpp_settings; |
| 24 | $query = $wp_query->query; |
| 25 | |
| 26 | if ( ! is_archive() || $wpp_settings['persian_date'] == 'disable' ) { |
| 27 | return $title; |
| 28 | } |
| 29 | |
| 30 | if ( $sep_location == 'right' ) { |
| 31 | $query = array_reverse( $query ); |
| 32 | } |
| 33 | |
| 34 | if ( isset( $query['monthnum'] ) ) { |
| 35 | $query['monthnum'] = $persian_month_names[ intval( $query['monthnum'] ) ]; |
| 36 | $title = implode( " ", $query ) . " $sep " . get_bloginfo( "name" ); |
| 37 | } |
| 38 | |
| 39 | if ( $wpp_settings['conv_page_title'] != 'disable' ) { |
| 40 | $title = fixnumber( $title ); |
| 41 | } |
| 42 | |
| 43 | return $title; |
| 44 | } |
| 45 |