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