"; } function domina($data = '') { $text = $this->sanitize_text($data); # replaced this: # $c_eng = $this->count_it($text, '/\w+/u'); # with this: $c_eng = $this->count_it($text, '/[\p{Latin}\d\_]+/u'); $c_heb = $this->count_it($text, '/[\x{05B0}-\x{05F4}\x{FB1D}-\x{FBF4}]+/u'); $c_arb = $this->count_it($text, '/[\x{060C}-\x{06FE}\x{FB50}-\x{FEFC}]+/u'); $dir = ($c_eng >= ($c_heb + $c_arb)) ? 'ltr' : 'rtl'; $align = ($dir == 'rtl') ? 'right' : 'left'; $data = "
" . $data . "
"; return $data; } function sanitize_text($data = '') { $sanitized = preg_replace('/<.*?>/x', '', $data); // remove html content $sanitized = preg_replace('/[0-9]+/', '', $sanitized); // remove numbers content return $sanitized; } function count_it($data = '', $match) { $i = 0; while (preg_match($match, $data, $x, PREG_OFFSET_CAPTURE)) { $i += strlen($x[0][0]); $data = substr($data,$x[0][1] + strlen($x[0][0])); } return $i; } function post_direction() { add_action('wp_head', array(&$this, 'banner')); add_filter('the_content', array(&$this, 'domina')); add_filter('the_excerpt', array(&$this, 'domina')); } } $countit = new post_direction(); ?>