function __construct()
 {
     parent::__construct(array('plural' => 'String Translation', 'ajax' => false));
     $this->languages = hocwp_get_qtranslate_x_enabled_languages();
     $this->strings = hocwp_get_registered_string_language();
     $this->active_strings = hocwp_get_active_registered_string_language();
     if (!is_array($this->active_strings)) {
         $this->active_strings = array();
     }
     $this->groups = array_unique(wp_list_pluck($this->strings, 'context'));
     $this->selected_group = empty($_GET['group']) || !in_array($_GET['group'], $this->groups) ? -1 : $_GET['group'];
     $this->save_translations();
 }
コード例 #2
0
function hocwp_translate_x_string_transaltion_update()
{
    if (isset($_REQUEST['hocwp_action']) && 'string_translation' == $_REQUEST['hocwp_action']) {
        unset($_REQUEST['hocwp_action']);
        $search = hocwp_get_method_value('s', 'request');
        $strings = hocwp_get_method_value('strings');
        if (hocwp_array_has_value($strings)) {
            $mo = new HOCWP_MO();
            $saved_strings = hocwp_get_registered_string_language();
            foreach ($strings as $encrypted_string) {
                unset($saved_strings[$encrypted_string]);
                $mo->delete_from_db($encrypted_string, true);
            }
            update_option('hocwp_string_translations', $saved_strings);
            hocwp_delete_transient('hocwp_string_translation_registered');
        }
        $args = array_intersect_key($_REQUEST, array_flip(array('s', 'paged', 'group')));
        if (!empty($search)) {
            $args['s'] = $search;
        }
        if (!empty($args['s'])) {
            $args['s'] = urlencode($args['s']);
        }
        $translations = hocwp_get_method_value('translation');
        if (hocwp_array_has_value($translations)) {
            foreach ($translations as $key => $value) {
                if (!empty($value)) {
                    $mo = hocwp_get_post_by_column('post_title', 'hocwp_mo_' . $key, OBJECT, array('post_type' => 'hocwp_mo'));
                    if (is_a($mo, 'WP_Post')) {
                        $obj = new HOCWP_MO($mo->ID);
                        $obj->export_to_db($mo->post_excerpt, $value);
                    }
                }
            }
        }
        $url = add_query_arg($args, wp_get_referer());
        wp_safe_redirect($url);
        exit;
    }
}