function prepare_items() { $data = $this->strings; $active_data = $this->active_strings; $s = empty($_GET['s']) ? '' : wp_unslash($_GET['s']); foreach ($data as $key => $row) { if (-1 !== $this->selected_group && $row['context'] !== $this->selected_group || !empty($s) && stripos($row['name'], $s) === false && stripos($row['string'], $s) === false) { unset($data[$key]); } } $count = 0; foreach ($data as $key => $row) { $data[$key]['row'] = $count; $mo = new HOCWP_MO(); $translation = $mo->import_from_db($row['string']); $data[$key]['translation'] = $translation; if (!isset($active_data[$key])) { $data[$key]['bulk_action'] = true; } $count++; } $per_page = $this->get_items_per_page('hocwp_string_translation_posts_per_page'); $this->_column_headers = array($this->get_columns(), array(), $this->get_sortable_columns()); if (!empty($_GET['orderby'])) { usort($data, array(&$this, 'usort_reorder')); } $total_items = count($data); $this->items = array_slice($data, ($this->get_pagenum() - 1) * $per_page, $per_page); $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page, 'total_pages' => ceil($total_items / $per_page))); }
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; } }