本文整理汇总了PHP中icl_cache_clear函数的典型用法代码示例。如果您正苦于以下问题:PHP icl_cache_clear函数的具体用法?PHP icl_cache_clear怎么用?PHP icl_cache_clear使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了icl_cache_clear函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: clear
function clear()
{
$this->data = array();
if ($this->cache_to_option) {
icl_cache_clear($this->name . '_cache_class');
}
}
示例2: save_post_actions
/**
* @param int $pidd
* @param WP_Post $post
*
* @return void
*/
public function save_post_actions($pidd, $post)
{
global $sitepress;
wp_defer_term_counting(true);
$post = isset($post) ? $post : get_post($pidd);
// exceptions
if (!$this->has_save_post_action($post)) {
wp_defer_term_counting(false);
return;
}
$default_language = $sitepress->get_default_language();
// allow post arguments to be passed via wp_insert_post directly and not be expected on $_POST exclusively
$post_vars = (array) $_POST;
foreach ((array) $post as $k => $v) {
$post_vars[$k] = $v;
}
$post_vars['post_type'] = isset($post_vars['post_type']) ? $post_vars['post_type'] : $post->post_type;
$post_id = isset($post_vars['post_ID']) ? $post_vars['post_ID'] : $pidd;
//latter case for XML-RPC publishing
$language_code = $this->get_save_post_lang($post_id, $sitepress);
$trid = $this->get_save_post_trid($post_id, $post->post_status);
// after getting the right trid set the source language from it by referring to the root translation
// of this trid, in case no proper source language has been set yet
$source_language = isset($source_language) ? $source_language : $this->get_save_post_source_lang($trid, $language_code, $default_language);
$this->maybe_set_elid($trid, $post->post_type, $language_code, $post_id, $source_language);
$translation_sync = $this->get_sync_helper();
$original_id = $this->get_original_element($post_id);
if ($original_id) {
$translation_sync->sync_with_translations($original_id, $post_vars);
}
require_once ICL_PLUGIN_PATH . '/inc/cache.php';
icl_cache_clear($post_vars['post_type'] . 's_per_language', true);
wp_defer_term_counting(false);
}
示例3: repair_broken_assignments
/**
* Runs various database repair and cleanup actions on icl_translations
*
* @return int Number of rows in icl_translations that were fixed
*/
public function repair_broken_assignments()
{
$rows_fixed = $this->fix_missing_original();
$rows_fixed += $this->fix_wrong_source_language();
$rows_fixed += $this->fix_broken_type_assignments();
icl_cache_clear();
wp_cache_init();
return $rows_fixed;
}
示例4: make_duplicate
function make_duplicate($master_post_id, $lang)
{
global $wpml_post_translations;
do_action('icl_before_make_duplicate', $master_post_id, $lang);
$master_post = get_post($master_post_id);
$is_duplicated = false;
$translations = $wpml_post_translations->get_element_translations($master_post_id, false, false);
if (isset($translations[$lang])) {
$post_array['ID'] = $translations[$lang];
if (WPML_WordPress_Actions::is_bulk_trash($post_array['ID']) || WPML_WordPress_Actions::is_bulk_untrash($post_array['ID'])) {
return true;
}
$is_duplicated = get_post_meta($translations[$lang], '_icl_lang_duplicate_of', true);
}
$post_array['post_author'] = $master_post->post_author;
$post_array['post_date'] = $master_post->post_date;
$post_array['post_date_gmt'] = $master_post->post_date_gmt;
$duplicated_post_content = $this->duplicate_post_content($lang, $master_post);
$post_array['post_content'] = addslashes_gpc($duplicated_post_content);
$duplicated_post_title = $this->duplicate_post_title($lang, $master_post);
$post_array['post_title'] = addslashes_gpc($duplicated_post_title);
$duplicated_post_excerpt = $this->duplicate_post_excerpt($lang, $master_post);
$post_array['post_excerpt'] = addslashes_gpc($duplicated_post_excerpt);
if ($this->sitepress->get_setting('sync_post_status')) {
$sync_post_status = true;
} else {
$sync_post_status = !isset($post_array['ID']) || $this->sitepress->get_setting('sync_delete') && $master_post->post_status === 'trash' || $is_duplicated;
}
if ($sync_post_status || isset($post_array['ID']) && get_post_status($post_array['ID']) === 'auto-draft') {
$post_array['post_status'] = $master_post->post_status;
}
$post_array['comment_status'] = $master_post->comment_status;
$post_array['ping_status'] = $master_post->ping_status;
$post_array['post_name'] = $master_post->post_name;
if ($master_post->post_parent) {
$parent = $this->sitepress->get_object_id($master_post->post_parent, $master_post->post_type, false, $lang);
$post_array['post_parent'] = $parent;
}
$post_array['menu_order'] = $master_post->menu_order;
$post_array['post_type'] = $master_post->post_type;
$post_array['post_mime_type'] = $master_post->post_mime_type;
$trid = $this->sitepress->get_element_trid($master_post->ID, 'post_' . $master_post->post_type);
$id = $this->save_duplicate($post_array, $lang);
require_once ICL_PLUGIN_PATH . '/inc/cache.php';
icl_cache_clear();
global $ICL_Pro_Translation;
/** @var WPML_Pro_Translation $ICL_Pro_Translation */
if ($ICL_Pro_Translation) {
$ICL_Pro_Translation->_content_fix_links_to_translated_content($id, $lang);
}
if (!is_wp_error($id)) {
$ret = $this->run_wpml_actions($master_post, $trid, $lang, $id, $post_array);
} else {
$ret = false;
}
return $ret;
}
示例5: run
/**
* Runs various database repair and cleanup actions on icl_translations.
*
* @return int Number of rows in icl_translations that were fixed
*/
public function run()
{
$rows_fixed = $this->fix_broken_duplicate_rows();
$rows_fixed += $this->fix_missing_original();
$rows_fixed += $this->fix_wrong_source_language();
$rows_fixed += $this->fix_broken_taxonomy_assignments();
$rows_fixed += $this->fix_broken_post_assignments();
$rows_fixed += $this->fix_broken_type_assignments();
icl_cache_clear();
wp_cache_init();
return $rows_fixed;
}
示例6: save_post_actions
public function save_post_actions($pidd, $post)
{
global $sitepress, $wpdb;
wp_defer_term_counting(true);
$post = isset($post) ? $post : get_post($pidd);
// exceptions
if (!$this->has_save_post_action($post)) {
wp_defer_term_counting(false);
return;
}
if (WPML_WordPress_Actions::is_bulk_trash($pidd) || WPML_WordPress_Actions::is_bulk_untrash($pidd)) {
return;
}
$default_language = $sitepress->get_default_language();
// allow post arguments to be passed via wp_insert_post directly and not be expected on $_POST exclusively
$post_vars = (array) $_POST;
foreach ((array) $post as $k => $v) {
$post_vars[$k] = $v;
}
$post_vars['post_type'] = isset($post_vars['post_type']) ? $post_vars['post_type'] : $post->post_type;
$post_id = $pidd;
if (isset($post_vars['action']) && $post_vars['action'] === 'post-quickpress-publish') {
$language_code = $default_language;
} else {
$post_id = isset($post_vars['post_ID']) ? $post_vars['post_ID'] : $pidd;
//latter case for XML-RPC publishing
$language_code = $this->get_save_post_lang($post_id, $sitepress);
}
if ($this->is_inline_action($post_vars) && !($language_code = $this->get_element_lang_code($post_id))) {
return;
}
if (isset($post_vars['icl_translation_of']) && is_numeric($post_vars['icl_translation_of'])) {
$translation_of_data_prepared = $wpdb->prepare("SELECT trid, language_code\n\t\t\t\t FROM {$wpdb->prefix}icl_translations\n\t\t\t\t WHERE element_id=%d\n\t\t\t\t AND element_type=%s", $post_vars['icl_translation_of'], 'post_' . $post->post_type);
list($trid, $source_language) = $wpdb->get_row($translation_of_data_prepared, 'ARRAY_N');
}
$trid = isset($trid) && $trid ? $trid : $this->get_save_post_trid($post_id, $post->post_status);
// after getting the right trid set the source language from it by referring to the root translation
// of this trid, in case no proper source language has been set yet
$source_language = isset($source_language) ? $source_language : $this->get_save_post_source_lang($trid, $language_code, $default_language);
$this->maybe_set_elid($trid, $post->post_type, $language_code, $post_id, $source_language);
$translation_sync = $this->get_sync_helper();
$original_id = $this->get_original_element($post_id);
if ($original_id) {
$translation_sync->sync_with_translations($original_id, $post_vars);
}
if (isset($post_vars['icl_tn_note'])) {
update_post_meta($post_id, '_icl_translator_note', $post_vars['icl_tn_note']);
}
require_once ICL_PLUGIN_PATH . '/inc/cache.php';
icl_cache_clear($post_vars['post_type'] . 's_per_language', true);
wp_defer_term_counting(false);
}
示例7: untrashed_post_actions
function untrashed_post_actions($post_id)
{
if ($this->settings['sync_delete']) {
global $wpdb;
static $untrashed_posts = array();
$post_type = $wpdb->get_var("SELECT post_type FROM {$wpdb->posts} WHERE ID={$post_id}");
if (isset($untrashed_posts[$post_id])) {
return;
// avoid infinite loop
}
$untrashed_posts[$post_id] = $post_id;
$trid = $this->get_element_trid($post_id, 'post_' . $post_type);
$translations = $this->get_element_translations($trid, 'post_' . $post_type);
foreach ($translations as $t) {
if ($t->element_id != $post_id) {
wp_untrash_post($t->element_id);
}
}
require_once ICL_PLUGIN_PATH . '/inc/cache.php';
icl_cache_clear($post_type . 's_per_language');
}
}
示例8: icl_plugin_upgrade
function icl_plugin_upgrade()
{
global $wpdb;
$iclsettings = get_option('icl_sitepress_settings');
require_once ICL_PLUGIN_PATH . '/inc/cache.php';
icl_cache_clear('locale_cache_class');
icl_cache_clear('flags_cache_class');
icl_cache_clear('language_name_cache_class');
if (get_option('icl_sitepress_version') && version_compare(get_option('icl_sitepress_version'), '1.7.2', '<')) {
$wpdb->update($wpdb->prefix . 'icl_flags', array('flag' => 'ku.png'), array('lang_code' => 'ku'));
$wpdb->update($wpdb->prefix . 'icl_languages_translations', array('name' => 'Magyar'), array('language_code' => 'hu', 'display_language_code' => 'hu'));
$wpdb->update($wpdb->prefix . 'icl_languages_translations', array('name' => 'Hrvatski'), array('language_code' => 'hr', 'display_language_code' => 'hr'));
$wpdb->update($wpdb->prefix . 'icl_languages_translations', array('name' => 'فارسی'), array('language_code' => 'fa', 'display_language_code' => 'fa'));
}
if (get_option('icl_sitepress_version') && version_compare(get_option('icl_sitepress_version'), '1.7.3', '<')) {
$wpdb->update($wpdb->prefix . 'icl_languages_translations', array('name' => 'پارسی'), array('language_code' => 'fa', 'display_language_code' => 'fa'));
}
if (get_option('icl_sitepress_version') && version_compare(get_option('icl_sitepress_version'), '1.7.7', '<')) {
if (!isset($iclsettings['promote_wpml'])) {
$iclsettings['promote_wpml'] = 0;
update_option('icl_sitepress_settings', $iclsettings);
}
if (!isset($iclsettings['auto_adjust_ids'])) {
$iclsettings['auto_adjust_ids'] = 0;
update_option('icl_sitepress_settings', $iclsettings);
}
$wpdb->query("UPDATE {$wpdb->prefix}icl_translations SET element_type='tax_post_tag' WHERE element_type='tag'");
// @since 3.1.5 - mysql_* function deprecated in php 5.5+
$wpdb->query("UPDATE {$wpdb->prefix}icl_translations SET element_type='tax_category' WHERE element_type='category'");
}
if (get_option('icl_sitepress_version') && version_compare(get_option('icl_sitepress_version'), '1.7.8', '<')) {
$res = $wpdb->get_results("SELECT ID, post_type FROM {$wpdb->posts}");
$post_types = array();
foreach ($res as $row) {
$post_types[$row->post_type][] = $row->ID;
}
foreach ($post_types as $type => $ids) {
if (!empty($ids)) {
$q = "UPDATE {$wpdb->prefix}icl_translations SET element_type=%s WHERE element_type='post' AND element_id IN(" . join(',', $ids) . ")";
$q_prepared = $wpdb->prepare($q, 'post_' . $type);
$wpdb->query($q_prepared);
// @since 3.1.5 - mysql_* function deprecated in php 5.5+
}
}
// fix categories & tags in icl_translations
$res = $wpdb->get_results("SELECT term_taxonomy_id, taxonomy FROM {$wpdb->term_taxonomy}");
foreach ($res as $row) {
$icltr = $wpdb->get_row($wpdb->prepare("SELECT translation_id, element_type FROM {$wpdb->prefix}icl_translations WHERE element_id=%d AND element_type LIKE %s", array($row->term_taxonomy_id, wpml_like_escape('tax_') . '%')));
if ('tax_' . $row->taxonomy != $icltr->element_type) {
$wpdb->update($wpdb->prefix . 'icl_translations', array('element_type' => 'tax_' . $row->taxonomy), array('translation_id' => $icltr->translation_id));
}
}
}
if (get_option('icl_sitepress_version') && version_compare(get_option('icl_sitepress_version'), '2.0.0', '<')) {
include_once ICL_PLUGIN_PATH . '/inc/upgrade-functions/upgrade-2.0.0.php';
if (empty($iclsettings['migrated_2_0_0'])) {
define('ICL_MULTI_STEP_UPGRADE', true);
return;
// GET OUT AND DO NOT SET THE NEW VERSION
}
}
if (get_option('icl_sitepress_version') && version_compare(get_option('icl_sitepress_version'), '2.0.4', '<')) {
$sql = "ALTER TABLE {$wpdb->prefix}icl_translation_status ADD COLUMN `_prevstate` longtext";
$wpdb->query($sql);
}
$versions = array('2.0.5', '2.2.2', '2.3.0', '2.3.1', '2.3.3', '2.4.0', '2.5.0', '2.5.2', '2.6.0', '2.7', '2.9', '2.9.3', '3.1', '3.1.5', '3.1.8', '3.1.9.5', '3.2', '3.2.3', '3.3', '3.3.7');
foreach ($versions as $version) {
icl_upgrade_version($version);
}
//Forcing upgrade logic when ICL_SITEPRESS_DEV_VERSION is defined
//This allow to run the logic between different alpha/beta/RC versions
//since we are now storing only the formal version in the options
if (defined('ICL_SITEPRESS_DEV_VERSION')) {
icl_upgrade_version(ICL_SITEPRESS_DEV_VERSION, true);
}
if (version_compare(get_option('icl_sitepress_version'), ICL_SITEPRESS_VERSION, '<')) {
update_option('icl_sitepress_version', ICL_SITEPRESS_VERSION);
}
}
示例9: wpml_switch_post_language
/**
* Ajax handler for switching the language of a post.
*/
public static function wpml_switch_post_language()
{
global $sitepress, $wpdb;
$to = false;
$post_id = false;
if (isset($_POST['wpml_to'])) {
$to = $_POST['wpml_to'];
}
if (isset($_POST['wpml_post_id'])) {
$post_id = $_POST['wpml_post_id'];
}
$result = false;
set_transient(md5($sitepress->get_current_user()->ID . 'current_user_post_edit_lang'), $to);
if ($post_id && $to) {
$post_type = get_post_type($post_id);
$wpml_post_type = 'post_' . $post_type;
$trid = $sitepress->get_element_trid($post_id, $wpml_post_type);
/* Check if a translation in that language already exists with a different post id.
* If so, then don't perform this action.
*/
$query_for_existing_translation = $wpdb->prepare("\tSELECT translation_id, element_id\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM {$wpdb->prefix}icl_translations\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE element_type = %s\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND trid = %d\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND language_code = %s", $wpml_post_type, $trid, $to);
$existing_translation = $wpdb->get_row($query_for_existing_translation);
if ($existing_translation && $existing_translation->element_id != $post_id) {
$result = false;
} else {
$sitepress->set_element_language_details($post_id, $wpml_post_type, $trid, $to);
// Synchronize the posts terms languages. Do not create automatic translations though.
WPML_Terms_Translations::sync_post_terms_language($post_id);
require_once ICL_PLUGIN_PATH . '/inc/cache.php';
icl_cache_clear($post_type . 's_per_language', true);
$result = $to;
}
}
wp_send_json_success($result);
}
示例10: save_translation
//.........这里部分代码省略.........
if ($sitepress_settings['sync_private_flag'] && $original_post->post_status == 'private') {
$postarr['post_status'] = 'private';
}
if ($sitepress_settings['sync_post_date']) {
$postarr['post_date'] = $original_post->post_date;
}
//set as draft or the same status as original post
$postarr['post_status'] = !$sitepress_settings['translated_document_status'] ? 'draft' : $original_post->post_status;
if ($original_post->post_parent) {
$post_parent_trid = $wpdb->get_var("SELECT trid FROM {$wpdb->prefix}icl_translations\n\t\t\t\t\t\tWHERE element_type='post_{$original_post->post_type}' AND element_id='{$original_post->post_parent}'");
if ($post_parent_trid) {
$parent_id = $wpdb->get_var("SELECT element_id FROM {$wpdb->prefix}icl_translations\n\t\t\t\t\t\t\tWHERE element_type='post_{$original_post->post_type}' AND trid='{$post_parent_trid}' AND language_code='{$job->language_code}'");
}
}
if (isset($parent_id) && $sitepress_settings['sync_page_parent']) {
$_POST['post_parent'] = $postarr['post_parent'] = $parent_id;
$_POST['parent_id'] = $postarr['parent_id'] = $parent_id;
}
$_POST['trid'] = $trid;
$_POST['lang'] = $job->language_code;
$_POST['skip_sitepress_actions'] = true;
$postarr = apply_filters('icl_pre_save_pro_translation', $postarr);
if (isset($element_id)) {
// it's an update so dont change the url
$postarr['post_name'] = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM {$wpdb->posts} WHERE ID=%d", $element_id));
}
if (isset($element_id)) {
// it's an update so dont change post date
$existing_post = get_post($element_id);
$postarr['post_date'] = $existing_post->post_date;
$postarr['post_date_gmt'] = $existing_post->post_date_gmt;
}
$new_post_id = $this->icl_insert_post($postarr, $job->language_code);
icl_cache_clear($postarr['post_type'] . 's_per_language');
// clear post counter per language in cache
do_action('icl_pro_translation_saved', $new_post_id, $data['fields']);
// Allow identical slugs
$post_name = sanitize_title($postarr['post_title']);
// for Translated documents options:Page URL = Translate
if (isset($data['fields']['URL']['data']) && $data['fields']['URL']['data']) {
$post_name = $data['fields']['URL']['data'];
}
$post_name_rewritten = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM {$wpdb->posts} WHERE ID=%d", $new_post_id));
$post_name_base = $post_name;
if ($post_name != $post_name_rewritten || $postarr['post_type'] == 'post' || $postarr['post_type'] == 'page') {
$incr = 1;
do {
$exists = $wpdb->get_var($wpdb->prepare("\n\t\t\t\t\t\t\tSELECT p.ID FROM {$wpdb->posts} p\n\t\t\t\t\t\t\t\tJOIN {$wpdb->prefix}icl_translations t ON t.element_id = p.ID\n\t\t\t\t\t\t\tWHERE p.ID <> %d AND t.language_code = %s AND p.post_name=%s\n\t\t\t\t\t\t", $new_post_id, $job->language_code, $post_name));
if ($exists) {
$incr++;
} else {
break;
}
$post_name = $post_name_base . '-' . $incr;
} while ($exists);
$wpdb->update($wpdb->posts, array('post_name' => $post_name), array('ID' => $new_post_id));
}
$ICL_Pro_Translation->_content_fix_links_to_translated_content($new_post_id, $job->language_code);
// update body translation with the links fixed
$new_post_content = $wpdb->get_var($wpdb->prepare("SELECT post_content FROM {$wpdb->posts} WHERE ID=%d", $new_post_id));
foreach ($job->elements as $jel) {
if ($jel->field_type == 'body') {
$fields_data_translated = $this->encode_field_data($new_post_content, $jel->field_format);
break;
}
}
示例11: icl_sitepress_deactivate
function icl_sitepress_deactivate()
{
icl_disable_capabilities();
wp_clear_scheduled_hook('update_wpml_config_index');
require_once ICL_PLUGIN_PATH . '/inc/cache.php';
icl_cache_clear();
}
示例12: convert_to_post
//.........这里部分代码省略.........
// If embedded content is allowed, re-add KSES filtering
if ( WPRSS_FTP_Utils::multiboolean( $allow_embedded_content ) === TRUE ) {
kses_init_filters();
}
if ( !is_wp_error( $inserted_id ) ) {
if ( is_object( $inserted_id ) ) {
if ( isset( $inserted_id['ID'] ) ) {
$inserted_id = $inserted_id['ID'];
}
elseif ( isset( $inserted_id->ID ) ) {
$inserted_id = $inserted_id->ID;
}
}
WPRSS_FTP_Utils::log_object( 'Post created', $inserted_id, __FUNCTION__, WPRSS_FTP_Utils::LOG_LEVEL_INFO );
if ( $user === NULL )
WPRSS_FTP_Utils::log( 'Failed to determine a user for post #$inserted_id', $error_source, WPRSS_FTP_Utils::LOG_LEVEL_WARNING );
// Update the post format
set_post_format( $inserted_id, $post_format );
if ( function_exists( 'wpml_update_translatable_content' ) ) {
if ( $post_language === '' || $post_language === NULL ) {
$post_language = ICL_LANGUAGE_CODE;
}
// Might be needed by WPML?
$_POST['icl_post_language '] = $post_language;
// Update the translation for the created post
wpml_add_translatable_content( 'post_' . $post_type, $inserted_id, $post_language );
wpml_update_translatable_content( 'post_' . $post_type, $inserted_id, $post_language );
icl_cache_clear($post_type.'s_per_language');
WPRSS_FTP_Utils::log_object( 'Post translated', $post_language, __FUNCTION__, WPRSS_FTP_Utils::LOG_LEVEL_INFO );
}
/*==============================================
* 5) ADD THE POST META DATA
*/
WPRSS_FTP_Utils::log( 'Adding post meta', __FUNCTION__, WPRSS_FTP_Utils::LOG_LEVEL_INFO );
$thumbnail = '';
$enclosure_image = '';
if ( $enclosure = $item->get_enclosure() ) {
$thumbnail = $enclosure->get_thumbnail();
$enclosure_image = $enclosure->get_link();
$enclosure_player = $enclosure->get_player();
WPRSS_FTP_Utils::log( 'Item has enclosure', __FUNCTION__, WPRSS_FTP_Utils::LOG_LEVEL_INFO );
}
// Prepare the post meta, and pass though the wprss_ftp_post_meta filter.
// Note: Prepend '!' to ignore the 'wprss_ftp_' prefix
$post_meta_data = apply_filters(
'wprss_ftp_post_meta',
array(
'!wprss_item_permalink' => $permalink,
'feed_source' => $source,
'media:thumbnail' => $thumbnail,
'enclosure:thumbnail' => $enclosure_image,
'enclosure_link' => $enclosure_image, // Included twice for code readablity
'enclosure_player' => $enclosure_player,
'import_date' => time(),
'!wprss_item_date' => $date_timestamp, // Required by core
'!wprss_feed_id' => $source,
示例13: delete_language
function delete_language($lang_id)
{
global $wpdb, $sitepress;
$lang = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}icl_languages WHERE id=%d", $lang_id));
if ($lang) {
if (in_array($lang->code, $this->built_in_languages)) {
$error = __("Error: This is a built in language. You can't delete it.", 'sitepress');
} else {
$wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}icl_languages WHERE id=%d", $lang_id));
$wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}icl_languages_translations WHERE language_code=%s", $lang->code));
$translation_ids = $wpdb->get_col($wpdb->prepare("SELECT translation_id FROM {$wpdb->prefix}icl_translations WHERE language_code=%s", $lang->code));
if ($translation_ids) {
$rids = $wpdb->get_col("SELECT rid FROM {$wpdb->prefix}icl_translation_status WHERE translation_id IN (" . wpml_prepare_in($translation_ids, '%d') . ")");
if ($rids) {
$job_ids = $wpdb->get_col("SELECT job_id FROM {$wpdb->prefix}icl_translate_job WHERE rid IN (" . wpml_prepare_in($rids, '%d') . ")");
if ($job_ids) {
$wpdb->query("DELETE FROM {$wpdb->prefix}icl_translate WHERE job_id IN (" . wpml_prepare_in($job_ids, '%d') . ")");
}
}
}
// delete posts
$post_ids = $wpdb->get_col($wpdb->prepare("SELECT element_id FROM {$wpdb->prefix}icl_translations WHERE element_type LIKE %s AND language_code=%s", array(wpml_like_escape('post_') . '%', $lang->code)));
remove_action('delete_post', array($sitepress, 'delete_post_actions'));
foreach ($post_ids as $post_id) {
wp_delete_post($post_id, true);
}
add_action('delete_post', array($sitepress, 'delete_post_actions'));
// delete terms
remove_action('delete_term', array($sitepress, 'delete_term'), 1, 3);
$tax_ids = $wpdb->get_col($wpdb->prepare("SELECT element_id FROM {$wpdb->prefix}icl_translations WHERE element_type LIKE %s AND language_code=%s", array(wpml_like_escape('tax_') . '%', $lang->code)));
foreach ($tax_ids as $tax_id) {
$row = $wpdb->get_row($wpdb->prepare("SELECT term_id, taxonomy FROM {$wpdb->term_taxonomy} WHERE term_taxonomy_id=%d", $tax_id));
if ($row) {
wp_delete_term($row->term_id, $row->taxonomy);
}
}
add_action('delete_term', array($sitepress, 'delete_term'), 1, 3);
// delete comments
global $IclCommentsTranslation;
remove_action('delete_comment', array($IclCommentsTranslation, 'delete_comment_actions'));
foreach ($post_ids as $post_id) {
wp_delete_post($post_id, true);
}
add_action('delete_comment', array($IclCommentsTranslation, 'delete_comment_actions'));
$wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}icl_translations WHERE language_code=%s", $lang->code));
$wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}icl_strings WHERE language=%s", $lang->code));
$wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}icl_string_translations WHERE language=%s", $lang->code));
$wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}icl_locale_map WHERE code=%s", $lang->code));
$wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}icl_flags WHERE lang_code=%s", $lang->code));
icl_cache_clear(false);
$sitepress->icl_translations_cache->clear();
$sitepress->clear_flags_cache();
$sitepress->icl_language_name_cache->clear();
$this->message(sprintf(__("The language %s was deleted.", 'sitepress'), '<strong>' . $lang->code . '</strong>'));
}
} else {
$error = __('Error: Language not found.', 'sitepress');
}
if (!empty($error)) {
$this->error($error);
}
}
示例14: save_translation
//.........这里部分代码省略.........
if ($sitepress_settings['sync_private_flag'] && $original_post->post_status == 'private') {
$postarr['post_status'] = 'private';
}
if ($sitepress_settings['sync_post_date']) {
$postarr['post_date'] = $original_post->post_date;
}
//set as draft or the same status as original post
$postarr['post_status'] = !$sitepress_settings['translated_document_status'] ? 'draft' : $original_post->post_status;
if ($original_post->post_parent) {
$post_parent_trid = $wpdb->get_var("SELECT trid FROM {$wpdb->prefix}icl_translations\n WHERE element_type='post_{$original_post->post_type}' AND element_id='{$original_post->post_parent}'");
if ($post_parent_trid) {
$parent_id = $wpdb->get_var("SELECT element_id FROM {$wpdb->prefix}icl_translations\n WHERE element_type='post_{$original_post->post_type}' AND trid='{$post_parent_trid}' AND language_code='{$job->language_code}'");
}
}
if (isset($parent_id) && $sitepress_settings['sync_page_parent']) {
$_POST['post_parent'] = $postarr['post_parent'] = $parent_id;
$_POST['parent_id'] = $postarr['parent_id'] = $parent_id;
}
$_POST['trid'] = $trid;
$_POST['lang'] = $job->language_code;
$_POST['skip_sitepress_actions'] = true;
$postarr = apply_filters('icl_pre_save_pro_translation', $postarr);
if (isset($element_id)) {
// it's an update so dont change the url
$postarr['post_name'] = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM {$wpdb->posts} WHERE ID=%d", $element_id));
}
if (isset($element_id)) {
// it's an update so dont change post date
$existing_post = get_post($element_id);
$postarr['post_date'] = $existing_post->post_date;
$postarr['post_date_gmt'] = $existing_post->post_date_gmt;
}
$new_post_id = $this->icl_insert_post($postarr, $job->language_code);
icl_cache_clear($postarr['post_type'] . 's_per_language');
// clear post counter per language in cache
// set taxonomies for users with limited caps
if (!current_user_can('manage-categories') && !empty($postarr['tax_input'])) {
foreach ($postarr['tax_input'] as $taxonomy => $terms) {
wp_set_post_terms($new_post_id, $terms, $taxonomy, FALSE);
// true to append to existing tags | false to replace existing tags
}
}
do_action('icl_pro_translation_saved', $new_post_id, $data['fields']);
// Allow identical slugs
$post_name = sanitize_title($postarr['post_title']);
$post_name_rewritten = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM {$wpdb->posts} WHERE ID=%d", $new_post_id));
$post_name_base = $post_name;
if ($post_name != $post_name_rewritten) {
$incr = 1;
do {
$exists = $wpdb->get_var($wpdb->prepare("\n SELECT p.ID FROM {$wpdb->posts} p\n JOIN {$wpdb->prefix}icl_translations t ON t.element_id = p.ID AND t.element_type=%s\n WHERE p.ID <> %d AND t.language_code = %s AND p.post_name=%s\n ", 'post_' . $postarr['post_type'], $new_post_id, $job->language_code, $post_name));
if ($exists) {
$incr++;
} else {
break;
}
$post_name = $post_name_base . '-' . $incr;
} while ($exists);
$wpdb->update($wpdb->posts, array('post_name' => $post_name), array('ID' => $new_post_id));
}
$ICL_Pro_Translation->_content_fix_links_to_translated_content($new_post_id, $job->language_code);
// update body translation with the links fixed
$new_post_content = $wpdb->get_var($wpdb->prepare("SELECT post_content FROM {$wpdb->posts} WHERE ID=%d", $new_post_id));
foreach ($job->elements as $jel) {
if ($jel->field_type == 'body') {
$fields_data_translated = $this->encode_field_data($new_post_content, $jel->field_format);
示例15: icl_plugin_upgrade
function icl_plugin_upgrade()
{
global $wpdb, $sitepress_settings, $sitepress;
if (defined('ICL_DEBUG_MODE') && ICL_DEBUG_MODE && (is_writable(ICL_PLUGIN_PATH) || is_writable(ICL_PLUGIN_PATH . '/upgrade.log'))) {
$mig_debug = @fopen(ICL_PLUGIN_PATH . '/upgrade.log', 'w');
} else {
$mig_debug = false;
}
$iclsettings = get_option('icl_sitepress_settings');
// upgrade actions
// 1. reset ajx_health_flag
$iclsettings['ajx_health_checked'] = 0;
update_option('icl_sitepress_settings', $iclsettings);
// clear any caches
if ($mig_debug) {
fwrite($mig_debug, "Clearing cache \n");
}
require_once ICL_PLUGIN_PATH . '/inc/cache.php';
icl_cache_clear('locale_cache_class');
icl_cache_clear('flags_cache_class');
icl_cache_clear('language_name_cache_class');
icl_cache_clear('cms_nav_offsite_url_cache_class');
if ($mig_debug) {
fwrite($mig_debug, "Cleared cache \n");
}
if (get_option('icl_sitepress_version') && version_compare(get_option('icl_sitepress_version'), '0.9.3', '<')) {
require_once ICL_PLUGIN_PATH . '/inc/lang-data.inc';
$wpdb->query("UPDATE {$wpdb->prefix}icl_languages SET english_name='Norwegian Bokmål', code='nb' WHERE english_name='Norwegian'");
foreach ($langs_names['Norwegian Bokm?l']['tr'] as $k => $display) {
if (!trim($display)) {
$display = 'Norwegian Bokm?l';
}
$wpdb->insert($wpdb->prefix . 'icl_languages_translations', array('language_code' => 'nb', 'display_language_code' => $lang_codes[$k], 'name' => $display));
}
$wpdb->insert($wpdb->prefix . 'icl_languages', array('code' => 'pa', 'english_name' => 'Punjabi'));
foreach ($langs_names['Punjabi']['tr'] as $k => $display) {
if (!trim($display)) {
$display = 'Punjabi';
}
$wpdb->insert($wpdb->prefix . 'icl_languages_translations', array('language_code' => 'pa', 'display_language_code' => $lang_codes[$k], 'name' => $display));
}
$wpdb->insert($wpdb->prefix . 'icl_languages', array('code' => 'pt-br', 'english_name' => 'Portuguese, Brazil'));
foreach ($langs_names['Portuguese, Brazil']['tr'] as $k => $display) {
if (!trim($display)) {
$display = 'Portuguese, Brazil';
}
$wpdb->insert($wpdb->prefix . 'icl_languages_translations', array('language_code' => 'pt-br', 'display_language_code' => $lang_codes[$k], 'name' => $display));
}
$wpdb->insert($wpdb->prefix . 'icl_languages', array('code' => 'pt-pt', 'english_name' => 'Portuguese, Portugal'));
foreach ($langs_names['Portuguese, Portugal']['tr'] as $k => $display) {
if (!trim($display)) {
$display = 'Portuguese, Portugal';
}
$wpdb->insert($wpdb->prefix . 'icl_languages_translations', array('language_code' => 'pt-pt', 'display_language_code' => $lang_codes[$k], 'name' => $display));
}
}
if (get_option('icl_sitepress_version') && version_compare(get_option('icl_sitepress_version'), '0.9.9', '<')) {
$iclsettings['icl_lso_flags'] = 0;
$iclsettings['icl_lso_native_lang'] = 1;
$iclsettings['icl_lso_display_lang'] = 1;
update_option('icl_sitepress_settings', $iclsettings);
// flags table
$table_name = $wpdb->prefix . 'icl_flags';
if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) {
$sql = "\r\n CREATE TABLE `{$table_name}` (\r\n `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,\r\n `lang_code` VARCHAR( 10 ) NOT NULL ,\r\n `flag` VARCHAR( 32 ) NOT NULL ,\r\n `from_template` TINYINT NOT NULL DEFAULT '0',\r\n UNIQUE (`lang_code`)\r\n ) \r\n ";
mysql_query($sql);
}
$codes = $wpdb->get_col("SELECT code FROM {$wpdb->prefix}icl_languages");
foreach ($codes as $code) {
if (!$code) {
continue;
}
if (!file_exists(ICL_PLUGIN_PATH . '/res/flags/' . $code . '.png')) {
$file = 'nil.png';
} else {
$file = $code . '.png';
}
$wpdb->insert($wpdb->prefix . 'icl_flags', array('lang_code' => $code, 'flag' => $file));
}
//fix norwegian records
mysql_query("UPDATE {$wpdb->prefix}icl_languages SET code='nb', english_name='Norwegian Bokmål' WHERE english_name LIKE 'Norwegian Bokm%'");
mysql_query("UPDATE {$wpdb->prefix}icl_languages_translations SET language_code='nb' WHERE language_code=''");
}
// version 1.0.1
if (get_option('icl_sitepress_version') && version_compare(get_option('icl_sitepress_version'), '1.0.1', '<')) {
$sitepress_settings = get_option('icl_sitepress_settings');
if ($sitepress_settings['existing_content_language_verified']) {
include ICL_PLUGIN_PATH . '/modules/icl-translation/db-scheme.php';
}
}
// version 1.0.2
if (get_option('icl_sitepress_version') && version_compare(get_option('icl_sitepress_version'), '1.0.2', '<')) {
//fix norwegian records
$wpdb->query("UPDATE {$wpdb->prefix}icl_languages SET code='nb', english_name='Norwegian Bokmål' WHERE english_name LIKE 'Norwegian Bokm%'");
$wpdb->query("UPDATE {$wpdb->prefix}icl_languages_translations SET language_code='nb' WHERE language_code=''");
$wpdb->query("UPDATE {$wpdb->prefix}icl_languages_translations SET display_language_code='nb' WHERE display_language_code=''");
$wpdb->query("ALTER TABLE {$wpdb->prefix}icl_translations DROP KEY translation");
// get elements with duplicates
$res = $wpdb->get_results("SELECT element_id, element_type, COUNT(translation_id) AS c FROM {$wpdb->prefix}icl_translations GROUP BY element_id, element_type HAVING c > 1");
foreach ($res as $r) {
//.........这里部分代码省略.........