function hocwp_translate_text($text, $echo = false) { if (hocwp_qtranslate_x_installed()) { $tmp = $text; $three_chars = substr($text, -3); if ('[:]' == $three_chars) { $current_language = hocwp_get_current_language(); $current_language = '[:' . $current_language . ']'; if (false !== strpos($text, $current_language)) { $text = apply_filters('translate_text', $text); } else { $text = $tmp; } } } if ($echo) { echo $text; } return $text; }
function hocwp_get_sidebar_info($post) { $post_id = $post->ID; $active = (bool) hocwp_get_post_meta('active', $post_id); $sidebar_id = hocwp_get_post_meta('sidebar_id', $post_id); $default = (bool) hocwp_get_post_meta('sidebar_default', $post_id); if (empty($sidebar_id)) { $sidebar_id = $post->post_name; } $sidebar_name = hocwp_get_value_by_key('sidebar_name', $post_id); if (empty($sidebar_name)) { $sidebar_name = $post->post_title; } if (hocwp_qtranslate_x_installed()) { $sidebar_name = apply_filters('translate_text', $sidebar_name, $lang = null, $flags = 0); } $sidebar_description = hocwp_get_post_meta('sidebar_description', $post_id); $sidebar_tag = hocwp_get_post_meta('sidebar_tag', $post_id); if (empty($sidebar_tag)) { $sidebar_tag = 'div'; } $args = array('id' => hocwp_sanitize_id($sidebar_id), 'name' => strip_tags($sidebar_name), 'description' => strip_tags($sidebar_description), 'tag' => strtolower($sidebar_tag), 'active' => $active, 'default' => $default); return $args; }
{ $sections['hocwp_string_translation'] = __('String Translation', 'hocwp-theme'); return $sections; } function hocwp_qtranslate_x_admin_section_field() { qtranxf_admin_section_start('hocwp_string_translation'); echo '<br>'; $table = new HOCWP_Table_String_Translation(hocwp_get_all_mo_posts()); $table->prepare_items(); $table->search_box(__('Search translations', 'hocwp-theme'), 'translations'); $table->display(); hocwp_field_input_hidden(array('id' => 'hocwp_action', 'value' => 'string_translation')); qtranxf_admin_section_end('hocwp_string_translation'); } if (hocwp_qtranslate_x_installed()) { add_filter('qtranslate_admin_sections', 'hocwp_qtranslate_x_admin_sections'); add_action('qtranslate_configuration', 'hocwp_qtranslate_x_admin_section_field'); } function hocwp_get_all_mo_posts($args = array()) { $defaults = array('post_type' => 'hocwp_mo', 'posts_per_page' => -1); $args = wp_parse_args($args, $defaults); $query = hocwp_query($args); return $query->posts; } function hocwp_get_qtranslate_x_config() { return $GLOBALS['q_config']; } function hocwp_get_qtranslate_x_enabled_languages()