function wpml_tm_word_count_init() { global $sitepress, $wpdb; $wpml_wp_api = $sitepress->get_wp_api(); $wpml_tm_words_count = new WPML_TM_Words_Count($wpdb, $sitepress); $wpml_tm_words_count->init(); new WPML_TM_Words_Count_Resources($wpml_wp_api); new WPML_TM_Words_Count_Box_UI($wpml_wp_api); $wpml_tm_words_count_summary = new WPML_TM_Words_Count_Summary_UI($wpml_tm_words_count, $wpml_wp_api); new WPML_TM_Words_Count_AJAX($wpml_tm_words_count, $wpml_tm_words_count_summary, $wpml_wp_api); }
public function get_summary() { $result = false; $source_language = filter_input(INPUT_GET, 'source_language', FILTER_DEFAULT); $valid_nonce = check_ajax_referer('wpml_words_count_summary', 'nonce', false); if ($valid_nonce) { $rows = array(); if ($source_language) { $rows = $this->wpml_tm_words_count->get_summary($source_language); } if (count($rows)) { $this->wpml_tm_words_count_summary->rows = $rows; $result = $this->wpml_tm_words_count_summary->get_view(); } } if ($result) { return $this->wpml_wp_api->wp_send_json_success($result); } else { return $this->wpml_wp_api->wp_send_json_error('Error!'); } }
public function get_summary() { $result = false; $source_language = filter_input(INPUT_GET, 'source_language', FILTER_DEFAULT); $offset = filter_input(INPUT_GET, 'offset', FILTER_DEFAULT); $valid_nonce = check_ajax_referer('wpml_words_count_summary', 'nonce', false); if ($valid_nonce) { $rows = array(); if ($source_language) { $rows = $this->wpml_tm_words_count->get_summary($source_language, $offset); $overall_count = array_shift($rows); } if (count($rows) && isset($overall_count)) { $this->wpml_tm_words_count_summary->rows = $rows; $result = $this->wpml_tm_words_count_summary->get_view() . '<span id="wpml_tm_wc_post_ratio" style="display:none;">' . (int) ($overall_count * 100) . '%</span>'; } } if ($result) { return $this->wpml_wp_api->wp_send_json_success($result); } else { return $this->wpml_wp_api->wp_send_json_error('Error!'); } }