PluginProbe
Property Hive / 2.2.6
Property Hive v2.2.6
2.3.0 2.2.6 2.2.5 2.2.4 2.2.3 2.2.2 1.4.46 1.4.47 1.4.48 1.4.49 1.4.5 1.4.50 1.4.51 1.4.52 1.4.53 1.4.54 1.4.55 1.4.56 1.4.57 1.4.58 1.4.59 1.4.6 1.4.60 1.4.61 1.4.62 All 260 releases
propertyhive / includes / class-ph-text-substitution.php

class-ph-text-substitution.php in Property Hive 2.2.6, at includes/class-ph-text-substitution.php

43 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit; // Exit if accessed directly
5 }
6
7 class PH_Text_Substitution {
8
9 public function __construct() {
10
11 $current_settings = get_option( 'propertyhive_template_assistant', array() );
12
13 if ( isset($current_settings['text_translations']) && is_array($current_settings['text_translations']) && !empty($current_settings['text_translations']) )
14 {
15 add_filter( 'gettext', array( $this, 'do_text_translation'), 20, 3 );
16 }
17 }
18
19 public function do_text_translation( $translated_text, $text, $domain )
20 {
21 if ( $domain != 'propertyhive' )
22 {
23 return $translated_text;
24 }
25
26 $current_settings = get_option( 'propertyhive_template_assistant', array() );
27
28 if ( isset($current_settings['text_translations']) && is_array($current_settings['text_translations']) && !empty($current_settings['text_translations']) )
29 {
30 foreach ( $current_settings['text_translations'] as $text_translation )
31 {
32 if ( isset($text_translation['search']) && $text_translation['search'] == $translated_text )
33 {
34 $translated_text = $text_translation['replace'];
35 }
36 }
37 }
38
39 return $translated_text;
40 }
41 }
42
43 new PH_Text_Substitution();