PluginProbe ʕ •ᴥ•ʔ
پارسی دیت – Parsi Date / 6.2.1
پارسی دیت – Parsi Date v6.2.1
6.2.1 6.2 6.1 5.1.6 5.1.7 5.1.8 5.1.8.2 6.0 trunk 1.0 1.1 1.2 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 2.0.0-alpha 2.1 2.1.1 2.1.2 2.1.3 2.1.5 2.1.6 2.1.7 2.2.0 2.2.1 2.2.2 2.2.3 2.3.0.1 2.3.0.2 2.3.1 2.3.2 2.3.3 2.3.4 3.0.1 3.0.2 3.0.3 4.0.0 4.0.1 4.0.2 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5
wp-parsidate / inc / App / Convert / FixArabic.php
wp-parsidate / inc / App / Convert Last commit date
Convert.php 3 weeks ago FixArabic.php 3 weeks ago FixNumbers.php 3 weeks ago
FixArabic.php
40 lines
1 <?php
2 /**
3 * Fix Arabic
4 *
5 * Fix Arabic alphabet in Farsi content
6 * Replace Arabic alphabet and numbers with Persian characters
7 */
8
9 namespace WPParsidate\App\Convert;
10
11 use WPParsidate\Settings\Settings;
12
13 class FixArabic {
14 public function __construct() {
15 if ( Settings::get( 'conv_arabic', false ) ) {
16 add_filter( 'the_content', [ $this, 'fixArabic' ], 1000 );
17 add_filter( 'the_title', [ $this, 'fixArabic' ], 1000 );
18 add_filter( 'comment_text', [ $this, 'fixArabic' ], 1000 );
19 add_filter( 'wp_list_categories', [ $this, 'fixArabic' ], 1000 );
20 add_filter( 'the_excerpt', [ $this, 'fixArabic' ], 1000 );
21 add_filter( 'wp_title', [ $this, 'fixArabic' ], 1000 );
22 }
23 }
24
25 /**
26 * Fix arabic foreign characters
27 *
28 * @param string $content
29 *
30 * @return string Fixed string
31 */
32 public function fixArabic( $content ): string {
33 return str_replace(
34 array( 'ي', 'ك', 'ة', '٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩' ),
35 array( 'ی', 'ک', 'ه', '۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹' ),
36 $content,
37 );
38 }
39 }
40