private function nonce_ok($class) { $ok = false; $class = strtolower($class); $class = str_replace('_', '-', $class); if (isset($_POST['action']) && $_POST['action'] === $class) { $nonce = filter_input(INPUT_POST, 'nonce', FILTER_SANITIZE_FULL_SPECIAL_CHARS); if ($this->sitepress->get_wp_api()->wp_verify_nonce($nonce, $class . '-nonce')) { $ok = true; } } return $ok; }
/** * Performs an SQL query assigning all terms to their correct language equivalent if it exists. * This should only be run after the previous functionality in here has finished. * Afterwards the term counts are recalculated globally, since term assignments bypassing the WordPress Core, * will not trigger any sort of update on those. */ private function reassign_terms() { $update_query = $this->wpdb->prepare("UPDATE {$this->wpdb->term_relationships} AS o,\n\t\t\t\t\t{$this->wpdb->prefix}icl_translations AS ic,\n\t\t\t\t\t{$this->wpdb->prefix}icl_translations AS iw,\n\t\t\t\t\t{$this->wpdb->prefix}icl_translations AS ip,\n\t\t\t\t\t{$this->wpdb->posts} AS p\n\t\t\t\t\t\tSET o.term_taxonomy_id = ic.element_id\n\t\t\t\t\t\tWHERE ic.trid = iw.trid\n\t\t\t\t\t\t\tAND ic.element_type = iw.element_type\n\t\t\t\t\t\t\tAND iw.element_id = o.term_taxonomy_id\n\t\t\t\t\t\t\tAND ic.language_code = ip.language_code\n\t\t\t\t\t\t\tAND ip.element_type = CONCAT('post_', p.post_type)\n\t\t\t\t\t\t\tAND ip.element_id = p.ID\n\t\t\t\t\t\t\tAND o.object_id = p.ID\n\t\t\t\t\t\t\tAND o.term_taxonomy_id != ic.element_id\n\t\t\t\t\t\t\tAND iw.element_type = %s", 'tax_' . $this->taxonomy); $rows_affected = $this->wpdb->query($update_query); if ($rows_affected) { $term_ids = $this->wpdb->get_col($this->wpdb->prepare("SELECT term_taxonomy_id FROM {$this->wpdb->term_taxonomy} WHERE taxonomy = %s", $this->taxonomy)); // Do not run the count update on taxonomies that are not actually registered as proper taxonomy objects, e.g. WooCommerce Product Attributes. $taxonomy_object = $this->sitepress->get_wp_api()->get_taxonomy($this->taxonomy); if ($taxonomy_object && isset($taxonomy_object->object_type)) { $this->sitepress->get_wp_api()->wp_update_term_count($term_ids, $this->taxonomy); } } }
/** * @return bool */ function init() { $this->attachments = array(); $this->error = null; if ($this->sitepress->get_wp_api()->is_admin()) { add_action('admin_head', array($this, 'js_scripts')); add_action('wp_ajax_set_xliff_options', array($this, 'ajax_set_xliff_options'), 10, 2); if (!$this->sitepress->get_setting('xliff_newlines')) { $this->sitepress->set_setting('xliff_newlines', WPML_XLIFF_TM_NEWLINES_REPLACE, true); } if (!$this->sitepress->get_setting('tm_xliff_version')) { $this->sitepress->set_setting('tm_xliff_version', '12', true); } if (1 < count($this->sitepress->get_active_languages())) { add_filter('wpml_translation_queue_actions', array($this, 'translation_queue_add_actions')); add_action('wpml_xliff_select_actions', array($this, 'translation_queue_xliff_select_actions'), 10, 2); add_action('wpml_translation_queue_do_actions_export_xliff', array($this, 'translation_queue_do_actions_export_xliff'), 10, 2); add_action('wpml_translation_queue_after_display', array($this, 'translation_queue_after_display'), 10, 2); add_action('wpml_translator_notification', array($this, 'translator_notification'), 10, 0); add_filter('wpml_new_job_notification', array($this, 'new_job_notification'), 10, 2); add_filter('wpml_new_job_notification_attachments', array($this, 'new_job_notification_attachments')); } if (isset($_GET['wpml_xliff_action']) && $_GET['wpml_xliff_action'] === 'download' && wp_verify_nonce($_GET['nonce'], 'xliff-export')) { $archive = $this->get_xliff_archive($_GET["xliff_version"]); $this->stream_xliff_archive($archive); } if (isset($_POST['wpml_xliff_export_all_filtered']) && wp_verify_nonce($_POST['nonce'], 'xliff-export-all-filtered')) { $job_ids = $this->get_all_filtered_job_ids(); $archive = $this->get_xliff_archive($_POST["xliff_version"], $job_ids); $this->stream_xliff_archive($archive); } if (isset($_POST['xliff_upload'])) { $this->import_xliff($_FILES['import']); if (is_wp_error($this->error)) { add_action('admin_notices', array($this, '_error')); } } if (isset($_POST['icl_tm_action']) && $_POST['icl_tm_action'] === 'save_notification_settings') { $this->sitepress->save_settings(array('include_xliff_in_notification' => isset($_POST['include_xliff']) && $_POST['include_xliff'])); } } return true; }
public static function wpml_get_table_taxonomies(SitePress $sitepress) { $taxonomies = $sitepress->get_wp_api()->get_taxonomies(array(), 'objects'); $result = array("taxonomies" => array(), "activeLanguages" => array(), "allLanguages" => array()); $sitepress->set_admin_language(); $active_langs = $sitepress->get_active_languages(); $default_lang = $sitepress->get_default_language(); $result["activeLanguages"][$default_lang] = array("label" => $active_langs[$default_lang]['display_name'], "flag" => $sitepress->get_flag_url($default_lang)); foreach ($active_langs as $code => $lang) { if ($code !== $default_lang) { $result["activeLanguages"][$code] = array("label" => $lang['display_name'], "flag" => $sitepress->get_flag_url($code)); } } $all_languages = $sitepress->get_languages(); foreach ($all_languages as $code => $lang) { $result["allLanguages"][$code] = array("label" => $lang['display_name'], "flag" => $sitepress->get_flag_url($code)); } foreach ($taxonomies as $key => $tax) { if ($sitepress->is_translated_taxonomy($key)) { $result["taxonomies"][$key] = array("label" => $tax->label, "singularLabel" => $tax->labels->singular_name, "hierarchical" => $tax->hierarchical, "name" => $key); } } return $result; }
/** * @return bool */ private function must_handle_a_canonical_url() { return !$this->has_wp_get_canonical_url() && $this->sitepress->get_wp_api()->is_front_end(); }
} include_once ICL_PLUGIN_PATH . '/inc/functions-network.php'; if (get_option('_wpml_inactive', false) && isset($wpmu_sitewide_plugins[ICL_PLUGIN_FOLDER . '/sitepress.php'])) { wpml_set_plugin_as_inactive(); return; } } if (!wp_next_scheduled('update_wpml_config_index')) { //Set cron job to update WPML config index file from CDN wp_schedule_event(time(), 'daily', 'update_wpml_config_index'); } /** @var WPML_Post_Translation $wpml_post_translations */ global $sitepress, $wpdb, $wpml_url_filters, $wpml_post_translations, $wpml_term_translations, $wpml_url_converter, $wpml_language_resolution, $wpml_slug_filter; $sitepress = new SitePress(); new WPML_Global_AJAX($sitepress); $wpml_wp_api = $sitepress->get_wp_api(); if ($wpml_wp_api->is_support_page()) { new WPML_Support_Page($wpml_wp_api); } wpml_load_query_filter(icl_get_setting('setup_complete')); $wpml_url_filters = new WPML_URL_Filters($wpml_post_translations, $wpml_url_converter, $sitepress); wpml_load_request_handler(is_admin(), $wpml_language_resolution->get_active_language_codes(), $sitepress->get_default_language()); require ICL_PLUGIN_PATH . '/inc/url-handling/wpml-slug-filter.class.php'; $wpml_slug_filter = new WPML_Slug_Filter($wpdb, $sitepress, $wpml_post_translations); /** @var array $sitepress_settings */ $sitepress_settings = $sitepress->get_settings(); wpml_load_term_filters(); wpml_maybe_setup_post_edit(); require ICL_PLUGIN_PATH . '/modules/cache-plugins-integration/cache-plugins-integration.php'; require ICL_PLUGIN_PATH . '/inc/wp-login-filters.php'; require ICL_PLUGIN_PATH . '/inc/plugins-integration.php';