当前位置: 首页>>代码示例>>PHP>>正文


PHP icl_xml2array函数代码示例

本文整理汇总了PHP中icl_xml2array函数的典型用法代码示例。如果您正苦于以下问题:PHP icl_xml2array函数的具体用法?PHP icl_xml2array怎么用?PHP icl_xml2array使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了icl_xml2array函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * @param string|object $file
  */
 function __construct($file = "")
 {
     if (is_object($file)) {
         $config = $file->config;
         $type = $file->type;
         $admin_text_context = $file->admin_text_context;
     } elseif (is_string($file) && $file !== "" && file_exists($file)) {
         $config = icl_xml2array(file_get_contents($file));
         $type = dirname($file) == get_template_directory() || dirname($file) == get_stylesheet_directory() ? 'theme' : 'plugin';
         $admin_text_context = basename(dirname($file));
     }
     $admin_text_config = isset($config['wpml-config']['admin-texts']) ? $config['wpml-config']['admin-texts'] : array();
     $wpml_config_all = array();
     if (isset($type) && isset($admin_text_context) && isset($admin_text_config['key'])) {
         if (isset($admin_text_config['key']['attr'])) {
             //single
             $admin_text_config['key']['type'] = $type;
             $admin_text_config['key']['context'] = $admin_text_context;
             $wpml_config_all[] = $admin_text_config['key'];
         } else {
             foreach ((array) $admin_text_config['key'] as $cf) {
                 $cf['type'] = $type;
                 $cf['context'] = $admin_text_context;
                 $wpml_config_all[] = $cf;
             }
         }
     }
     $this->config = $this->fill_wildcards($wpml_config_all);
 }
开发者ID:studiopengpeng,项目名称:ASCOMETAL,代码行数:32,代码来源:wpml-admin-text-configuration.php

示例2: init

 function init()
 {
     global $sitepress_settings;
     $ap = get_option('active_plugins');
     $i = array_intersect($ap, array_keys(self::$wpml_cpi_plugins));
     if (!empty($i)) {
         $this->plugin_cp_class = self::$wpml_cpi_plugins[array_pop($i)];
         if (class_exists($this->plugin_cp_class) && method_exists($this->plugin_cp_class, 'clear_cache')) {
             $this->settings = $sitepress_settings['modules']['caching-plugins-integration'];
             $this->validate_settings();
             add_action('icl_page_overview_top', array($this, 'menu'));
             wp_enqueue_script('wpml-cpi-scripts', ICL_PLUGIN_URL . '/modules/cache-plugins-integration/scripts.js', array(), ICL_SITEPRESS_VERSION);
             add_action('icl_ajx_custom_call', array($this, 'ajx_calls'), 1, 2);
             add_action('icl_st_add_string_translation', array($this, 'call_cache_clear'));
             add_action('icl_st_unregister_string_multi', array($this, 'call_cache_clear'));
             add_action('icl_st_unregister_string', array($this, 'call_cache_clear'));
             $ajx_request_exceptions = array('ajx_health_checked', 'save_language_pairs', 'toggle_content_translation', 'icl_admin_language_options', 'icl_page_sync_options', 'validate_language_domain', 'icl_save_theme_localization_type', 'dismiss_help', 'dismiss_page_estimate_hint', 'dismiss_upgrade_notice', 'dismiss_upgrade_notice', 'dismiss_translate_help', 'setup_got_to_step1', 'setup_got_to_step2', 'toggle_show_translations', 'icl_show_sidebar');
             if (!isset($_REQUEST['icl_ajx_action']) || !in_array($_REQUEST['icl_ajx_action'], $ajx_request_exceptions)) {
                 add_action('icl_save_settings', array($this, 'icl_save_settings_cb'), 10, 1);
             }
             // when a post is sent from the translation server
             global $HTTP_RAW_POST_DATA;
             $hrow = icl_xml2array($HTTP_RAW_POST_DATA);
             if (isset($hrow['methodCall']['methodName']['value']) && $hrow['methodCall']['methodName']['value'] == 'icanlocalize.set_translation_status') {
                 add_action('save_post', array($this, 'call_cache_clear'));
             }
         }
     }
 }
开发者ID:aarongillett,项目名称:B22-151217,代码行数:29,代码来源:cache-plugins-integration.php

示例3: request

 function request($request_url)
 {
     $results = false;
     $request_url = $this->get_adjusted_request_url($request_url);
     $this->adjust_post_data();
     $this->disable_error_reporting();
     $icanSnoopy = new IcanSnoopy();
     if (!is_readable($icanSnoopy->curl_path) || !is_executable($icanSnoopy->curl_path)) {
         $icanSnoopy->curl_path = '/usr/bin/curl';
     }
     $this->reset_error_reporting();
     $icanSnoopy->_fp_timeout = 3;
     $icanSnoopy->read_timeout = 5;
     if ('GET' === $this->method) {
         $icanSnoopy->fetch($request_url);
     } else {
         $icanSnoopy->set_submit_multipart();
         $icanSnoopy->submit($request_url, $this->post_data, $this->post_files);
     }
     if ($icanSnoopy->error || $icanSnoopy->timed_out) {
         $this->error = $icanSnoopy->error;
     } else {
         if ($this->gzipped) {
             $icanSnoopy->results = $this->gzdecode($icanSnoopy->results);
         }
         $results = icl_xml2array($icanSnoopy->results, 1);
         if (array_key_exists('info', $results) && '-1' === $results['info']['status']['attr']['err_code']) {
             $this->error = $results['info']['status']['value'];
             $results = false;
         }
     }
     return $results;
 }
开发者ID:studiopengpeng,项目名称:ASCOMETAL,代码行数:33,代码来源:class-wpml-icl-client.php

示例4: xmlrpc_call_actions

 function xmlrpc_call_actions($action)
 {
     global $HTTP_RAW_POST_DATA, $wpdb;
     $params = icl_xml2array($HTTP_RAW_POST_DATA);
     add_filter('is_protected_meta', array($this, 'xml_unprotect_wpml_meta'), 10, 3);
     switch ($action) {
         case 'wp.getPage':
         case 'blogger.getPost':
             // yet this doesn't return custom fields
             if (isset($params['methodCall']['params']['param'][1]['value']['int']['value'])) {
                 $page_id = $params['methodCall']['params']['param'][1]['value']['int']['value'];
                 $lang_details = $this->get_element_language_details($page_id, 'post_' . get_post_type($page_id));
                 $this->this_lang = $lang_details->language_code;
                 // set the current language to the posts language
                 update_post_meta($page_id, '_wpml_language', $lang_details->language_code);
                 update_post_meta($page_id, '_wpml_trid', $lang_details->trid);
                 $active_languages = $this->get_active_languages();
                 $res = $this->get_element_translations($lang_details->trid);
                 $translations = array();
                 foreach ($active_languages as $k => $v) {
                     if ($page_id != $res[$k]->element_id) {
                         $translations[$k] = isset($res[$k]->element_id) ? $res[$k]->element_id : 0;
                     }
                 }
                 update_post_meta($page_id, '_wpml_translations', json_encode($translations));
             }
             break;
         case 'metaWeblog.getPost':
             if (isset($params['methodCall']['params']['param'][0]['value']['int']['value'])) {
                 $page_id = $params['methodCall']['params']['param'][0]['value']['int']['value'];
                 $lang_details = $this->get_element_language_details($page_id, 'post_' . get_post_type($page_id));
                 $this->this_lang = $lang_details->language_code;
                 // set the current language to the posts language
                 update_post_meta($page_id, '_wpml_language', $lang_details->language_code);
                 update_post_meta($page_id, '_wpml_trid', $lang_details->trid);
                 $active_languages = $this->get_active_languages();
                 $res = $this->get_element_translations($lang_details->trid);
                 $translations = array();
                 foreach ($active_languages as $k => $v) {
                     if (isset($res[$k]) && $page_id != $res[$k]->element_id) {
                         $translations[$k] = isset($res[$k]->element_id) ? $res[$k]->element_id : 0;
                     }
                 }
                 update_post_meta($page_id, '_wpml_translations', json_encode($translations));
             }
             break;
         case 'metaWeblog.getRecentPosts':
             if (isset($params['methodCall']['params']['param'][3]['value']['int']['value'])) {
                 $num_posts = intval($params['methodCall']['params']['param'][3]['value']['int']['value']);
                 if ($num_posts) {
                     $posts = get_posts('suppress_filters=false&numberposts=' . $num_posts);
                     foreach ($posts as $p) {
                         $lang_details = $this->get_element_language_details($p->ID, 'post_post');
                         update_post_meta($p->ID, '_wpml_language', $lang_details->language_code);
                         update_post_meta($p->ID, '_wpml_trid', $lang_details->trid);
                         $active_languages = $this->get_active_languages();
                         $res = $this->get_element_translations($lang_details->trid);
                         $translations = array();
                         foreach ($active_languages as $k => $v) {
                             if ($p->ID != $res[$k]->element_id) {
                                 $translations[$k] = isset($res[$k]->element_id) ? $res[$k]->element_id : 0;
                             }
                         }
                         update_post_meta($p->ID, '_wpml_translations', json_encode($translations));
                     }
                 }
             }
             break;
         case 'metaWeblog.newPost':
             $custom_fields = false;
             if (is_array($params['methodCall']['params']['param'][3]['value']['struct']['member'])) {
                 foreach ($params['methodCall']['params']['param'][3]['value']['struct']['member'] as $m) {
                     if ($m['name']['value'] == 'custom_fields') {
                         $custom_fields_raw = $m['value']['array']['data']['value'];
                         break;
                     }
                 }
             }
             if (!empty($custom_fields_raw)) {
                 foreach ($custom_fields_raw as $cf) {
                     $key = $value = null;
                     foreach ($cf['struct']['member'] as $m) {
                         if ($m['name']['value'] == 'key') {
                             $key = $m['value']['string']['value'];
                         } elseif ($m['name']['value'] == 'value') {
                             $value = $m['value']['string']['value'];
                         }
                     }
                     if ($key !== null && $value !== null) {
                         $custom_fields[$key] = $value;
                     }
                 }
             }
             if (is_array($custom_fields) && isset($custom_fields['_wpml_language']) && isset($custom_fields['_wpml_trid'])) {
                 $icl_post_language = $custom_fields['_wpml_language'];
                 $icl_trid = $custom_fields['_wpml_trid'];
                 $post_type = $params['methodCall']['params']['param'][3]['value']['struct']['member'][2]['value']['string']['value'];
                 if (!$wpdb->get_var("SELECT translation_id FROM {$wpdb->prefix}icl_translations WHERE element_type='post_{$post_type}' AND trid={$icl_trid} AND language_code='{$icl_post_language}'")) {
                     $_POST['icl_post_language'] = $icl_post_language;
                     $_POST['icl_trid'] = $icl_trid;
//.........这里部分代码省略.........
开发者ID:pablomarsan,项目名称:iftheme-docs,代码行数:101,代码来源:sitepress.class.php

示例5: check_wpml_config

 function check_wpml_config()
 {
     global $sitepress_settings;
     if (empty($sitepress_settings)) {
         return;
     }
     $file = realpath(WCML_PLUGIN_PATH . '/wpml-config.xml');
     if (!file_exists($file)) {
         $this->xml_config_errors[] = __('wpml-config.xml file missing from WooCommerce Multilingual folder.', 'wpml-wcml');
     } else {
         $config = icl_xml2array(file_get_contents($file));
         if (isset($config['wpml-config'])) {
             //custom-fields
             if (isset($config['wpml-config']['custom-fields'])) {
                 if (isset($config['wpml-config']['custom-fields']['custom-field']['value'])) {
                     //single
                     $cfs[] = $config['wpml-config']['custom-fields']['custom-field'];
                 } else {
                     foreach ($config['wpml-config']['custom-fields']['custom-field'] as $cf) {
                         $cfs[] = $cf;
                     }
                 }
                 if ($cfs) {
                     foreach ($cfs as $cf) {
                         if (!isset($sitepress_settings['translation-management']['custom_fields_translation'][$cf['value']])) {
                             continue;
                         }
                         $effective_config_value = $sitepress_settings['translation-management']['custom_fields_translation'][$cf['value']];
                         $correct_config_value = $cf['attr']['action'] == 'copy' ? 1 : ($cf['attr']['action'] == 'translate' ? 2 : 0);
                         if ($effective_config_value != $correct_config_value) {
                             $this->xml_config_errors[] = sprintf(__('Custom field %s configuration from wpml-config.xml file was altered!', 'wpml-wcml'), '<i>' . $cf['value'] . '</i>');
                         }
                     }
                 }
             }
             //custom-types
             if (isset($config['wpml-config']['custom-types'])) {
                 if (isset($config['wpml-config']['custom-types']['custom-type']['value'])) {
                     //single
                     $cts[] = $config['wpml-config']['custom-types']['custom-type'];
                 } else {
                     foreach ($config['wpml-config']['custom-types']['custom-type'] as $cf) {
                         $cts[] = $cf;
                     }
                 }
                 if ($cts) {
                     foreach ($cts as $ct) {
                         if (!isset($sitepress_settings['custom_posts_sync_option'][$ct['value']])) {
                             continue;
                         }
                         $effective_config_value = $sitepress_settings['custom_posts_sync_option'][$ct['value']];
                         $correct_config_value = $ct['attr']['translate'];
                         if ($effective_config_value != $correct_config_value) {
                             $this->xml_config_errors[] = sprintf(__('Custom type %s configuration from wpml-config.xml file was altered!', 'wpml-wcml'), '<i>' . $ct['value'] . '</i>');
                         }
                     }
                 }
             }
             //taxonomies
             if (isset($config['wpml-config']['taxonomies'])) {
                 if (isset($config['wpml-config']['taxonomies']['taxonomy']['value'])) {
                     //single
                     $txs[] = $config['wpml-config']['taxonomies']['taxonomy'];
                 } else {
                     foreach ($config['wpml-config']['taxonomies']['taxonomy'] as $cf) {
                         $txs[] = $cf;
                     }
                 }
                 if ($txs) {
                     foreach ($txs as $tx) {
                         if (!isset($sitepress_settings['taxonomies_sync_option'][$tx['value']])) {
                             continue;
                         }
                         $effective_config_value = $sitepress_settings['taxonomies_sync_option'][$tx['value']];
                         $correct_config_value = $tx['attr']['translate'];
                         if ($effective_config_value != $correct_config_value) {
                             $this->xml_config_errors[] = sprintf(__('Custom taxonomy %s configuration from wpml-config.xml file was altered!', 'wpml-wcml'), '<i>' . $tx['value'] . '</i>');
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:Junaid-Farid,项目名称:gocnex,代码行数:84,代码来源:dependencies.class.php

示例6: parse_wpml_config_files

 static function parse_wpml_config_files()
 {
     $config_all['wpml-config'] = array('custom-fields' => array(), 'custom-types' => array(), 'taxonomies' => array(), 'admin-texts' => array(), 'language-switcher-settings' => array());
     if (!empty(self::$wpml_config_files)) {
         foreach (self::$wpml_config_files as $file) {
             $config = is_object($file) ? $file->config : icl_xml2array(file_get_contents($file));
             do_action('wpml_parse_config_file', $file);
             if (isset($config['wpml-config'])) {
                 $wpml_config = $config['wpml-config'];
                 $wpml_config_all = $config_all['wpml-config'];
                 $wpml_config_all = self::parse_config_index($wpml_config_all, $wpml_config, 'custom-field', 'custom-fields');
                 $wpml_config_all = self::parse_config_index($wpml_config_all, $wpml_config, 'custom-type', 'custom-types');
                 $wpml_config_all = self::parse_config_index($wpml_config_all, $wpml_config, 'taxonomy', 'taxonomies');
                 //language-switcher-settings
                 if (isset($wpml_config['language-switcher-settings']['key'])) {
                     if (!is_numeric(key($wpml_config['language-switcher-settings']['key']))) {
                         //single
                         $wpml_config_all['language-switcher-settings']['key'][] = $wpml_config['language-switcher-settings']['key'];
                     } else {
                         foreach ($wpml_config['language-switcher-settings']['key'] as $cf) {
                             $wpml_config_all['language-switcher-settings']['key'][] = $cf;
                         }
                     }
                 }
                 $config_all['wpml-config'] = $wpml_config_all;
             }
         }
         $config_all = apply_filters('icl_wpml_config_array', $config_all);
         $config_all = apply_filters('wpml_config_array', $config_all);
     }
     self::parse_wpml_config($config_all);
 }
开发者ID:aarongillett,项目名称:B22-151217,代码行数:32,代码来源:wpml-config.class.php

示例7: _request

 function _request($request, $method='GET', $formvars=null, $formfiles=null, $gzipped = false){
     global $sitepress_settings, $sitepress;
     $request = str_replace(" ", "%20", $request);
     $c = new IcanSnoopy();
     
     $debugvars =  array(
         'debug_cms' => 'WordPress',
         'debug_module' => 'WPML ' . ICL_SITEPRESS_VERSION,
         'debug_url'     => get_bloginfo('siteurl')
     );
     
     if($method == 'GET'){
         $request .= '&' . http_build_query($debugvars);    
     }else{
         $formvars += $debugvars;
     }
     
     // disable error reporting
     // needed for open_basedir restrictions (is_readable)
     $_display_errors = ini_get('display_errors');
     $_error_reporting = ini_get('error_reporting');
     ini_set('display_errors', '0');        
     ini_set('error_reporting', E_NONE);        
     
     if (!@is_readable($c->curl_path) || !@is_executable($c->curl_path)){
         $c->curl_path = '/usr/bin/curl';
     }        
     
     // restore error reporting
     // needed for open_basedir restrictions
     ini_set('display_errors', $_display_errors);        
     ini_set('error_reporting', $_error_reporting);        
     
     
     $c->_fp_timeout = 3;
     $c->read_timeout = 5;
     $url_parts = parse_url($request);
     if($sitepress_settings['troubleshooting_options']['http_communication']){
         $request = str_replace('https://','http://',$request);
     }
     if($method=='GET'){                        
         $c->fetch($request);  
         if($c->timed_out){die(__('Error:','sitepress').$c->error);}
     }else{
         $c->set_submit_multipart();          
         $c->submit($request, $formvars, $formfiles);            
         if($c->timed_out){die(__('Error:','sitepress').$c->error);}
     }
     
     if($c->error){
         $this->error = $c->error;
         return false;
     }
     
     if($gzipped){
         $c->results = $this->_gzdecode($c->results);
     }        
     $results = icl_xml2array($c->results,1);                        
     
     if(isset($results['info']) && $results['info']['status']['attr']['err_code']=='-1'){
         $this->error = $results['info']['status']['value'];            
         return false;
     }
             
     return $results;
 }
开发者ID:nunomorgadinho,项目名称:OpenWPML,代码行数:66,代码来源:icl_api.php

示例8: request

 function request($url) {
     $result = $this->request->request($url);
     if (!is_object($result)) {
         return icl_xml2array($result['body'], 1);
     } else {
         return array();
     }
 }
开发者ID:nunomorgadinho,项目名称:OpenWPML,代码行数:8,代码来源:support.php

示例9: parse_wpml_config_files

 static function parse_wpml_config_files()
 {
     if (!empty(self::$wpml_config_files)) {
         $config_all['wpml-config'] = array('custom-fields' => array(), 'custom-types' => array(), 'taxonomies' => array(), 'admin-texts' => array(), 'language-switcher-settings' => array());
         foreach (self::$wpml_config_files as $file) {
             if (is_object($file)) {
                 $config = $file->config;
                 $type = $file->type;
                 $admin_text_context = $file->admin_text_context;
             } else {
                 $config = icl_xml2array(file_get_contents($file));
                 $type = dirname($file) == get_template_directory() || dirname($file) == get_stylesheet_directory() ? 'theme' : 'plugin';
                 $admin_text_context = basename(dirname($file));
             }
             if (isset($config['wpml-config'])) {
                 $wpml_config = $config['wpml-config'];
                 $wpml_config_all = $config_all['wpml-config'];
                 $wpml_config_all = self::parse_config_index($wpml_config_all, $wpml_config, 'custom-field', 'custom-fields');
                 $wpml_config_all = self::parse_config_index($wpml_config_all, $wpml_config, 'custom-type', 'custom-types');
                 $wpml_config_all = self::parse_config_index($wpml_config_all, $wpml_config, 'taxonomy', 'taxonomies');
                 //admin-texts
                 if (isset($wpml_config['admin-texts']['key'])) {
                     if (!is_numeric(key(@current($wpml_config['admin-texts'])))) {
                         //single
                         $wpml_config['admin-texts']['key']['type'] = $type;
                         $wpml_config['admin-texts']['key']['context'] = $admin_text_context;
                         $wpml_config_all['admin-texts']['key'][] = $wpml_config['admin-texts']['key'];
                     } else {
                         foreach ((array) $wpml_config['admin-texts']['key'] as $cf) {
                             $cf['type'] = $type;
                             $cf['context'] = $admin_text_context;
                             $wpml_config_all['admin-texts']['key'][] = $cf;
                         }
                     }
                 }
                 //language-switcher-settings
                 if (isset($wpml_config['language-switcher-settings']['key'])) {
                     if (!is_numeric(key($wpml_config['language-switcher-settings']['key']))) {
                         //single
                         $wpml_config_all['language-switcher-settings']['key'][] = $wpml_config['language-switcher-settings']['key'];
                     } else {
                         foreach ($wpml_config['language-switcher-settings']['key'] as $cf) {
                             $wpml_config_all['language-switcher-settings']['key'][] = $cf;
                         }
                     }
                 }
                 $config_all['wpml-config'] = $wpml_config_all;
             }
         }
         $config_all = apply_filters('icl_wpml_config_array', $config_all);
         $config_all = apply_filters('wpml_config_array', $config_all);
         self::parse_wpml_config($config_all);
     }
 }
开发者ID:pcuervo,项目名称:odc,代码行数:54,代码来源:wpml-config.class.php

示例10: parse_wpml_config_files

 function parse_wpml_config_files()
 {
     if (!empty($this->wpml_config_files)) {
         $config_all['wpml-config'] = array('custom-fields' => array(), 'custom-types' => array(), 'taxonomies' => array(), 'admin-texts' => array(), 'language-switcher-settings' => array());
         foreach ($this->wpml_config_files as $file) {
             $config = icl_xml2array(file_get_contents($file));
             if (isset($config['wpml-config'])) {
                 //custom-fields
                 if (isset($config['wpml-config']['custom-fields'])) {
                     if (isset($config['wpml-config']['custom-fields']['custom-field']['value'])) {
                         //single
                         $config_all['wpml-config']['custom-fields']['custom-field'][] = $config['wpml-config']['custom-fields']['custom-field'];
                     } else {
                         foreach ($config['wpml-config']['custom-fields']['custom-field'] as $cf) {
                             $config_all['wpml-config']['custom-fields']['custom-field'][] = $cf;
                         }
                     }
                 }
                 //custom-types
                 if (isset($config['wpml-config']['custom-types'])) {
                     if (isset($config['wpml-config']['custom-types']['custom-type']['value'])) {
                         //single
                         $config_all['wpml-config']['custom-types']['custom-type'][] = $config['wpml-config']['custom-types']['custom-type'];
                     } else {
                         foreach ($config['wpml-config']['custom-types']['custom-type'] as $cf) {
                             $config_all['wpml-config']['custom-types']['custom-type'][] = $cf;
                         }
                     }
                 }
                 //taxonomies
                 if (isset($config['wpml-config']['taxonomies'])) {
                     if (isset($config['wpml-config']['taxonomies']['taxonomy']['value'])) {
                         //single
                         $config_all['wpml-config']['taxonomies']['taxonomy'][] = $config['wpml-config']['taxonomies']['taxonomy'];
                     } else {
                         foreach ($config['wpml-config']['taxonomies']['taxonomy'] as $cf) {
                             $config_all['wpml-config']['taxonomies']['taxonomy'][] = $cf;
                         }
                     }
                 }
                 //admin-texts
                 if (isset($config['wpml-config']['admin-texts'])) {
                     $type = dirname($file) == get_template_directory() || dirname($file) == get_stylesheet_directory() ? 'theme' : 'plugin';
                     $atid = basename(dirname($file));
                     if (!is_numeric(key(@current($config['wpml-config']['admin-texts'])))) {
                         //single
                         $config['wpml-config']['admin-texts']['key']['type'] = $type;
                         $config['wpml-config']['admin-texts']['key']['atid'] = $atid;
                         $config_all['wpml-config']['admin-texts']['key'][] = $config['wpml-config']['admin-texts']['key'];
                     } else {
                         foreach ($config['wpml-config']['admin-texts']['key'] as $cf) {
                             $cf['type'] = $type;
                             $cf['atid'] = $atid;
                             $config_all['wpml-config']['admin-texts']['key'][] = $cf;
                         }
                     }
                 }
                 //language-switcher-settings
                 if (isset($config['wpml-config']['language-switcher-settings'])) {
                     if (!is_numeric(key($config['wpml-config']['language-switcher-settings']['key']))) {
                         //single
                         $config_all['wpml-config']['language-switcher-settings']['key'][] = $config['wpml-config']['language-switcher-settings']['key'];
                     } else {
                         foreach ($config['wpml-config']['language-switcher-settings']['key'] as $cf) {
                             $config_all['wpml-config']['language-switcher-settings']['key'][] = $cf;
                         }
                     }
                 }
             }
         }
         $config_all = apply_filters('icl_wpml_config_array', $config_all);
         $this->_parse_wpml_config($config_all);
     }
 }
开发者ID:jimlongo56,项目名称:bhouse,代码行数:74,代码来源:translation-management.class.php

示例11: get_config

 /**
  * Get config from file
  */
 public function get_config()
 {
     $config_files = array();
     /**
      * First look for WPGlobus config
      */
     $config_files[] = $this->wpglobus_config_file;
     /**
      * and then look for a WPML config
      */
     $config_files[] = $this->wpml_config_file;
     $config_file = '';
     foreach ($config_files as $config_file) {
         $this->config_dir_file = '';
         /**
          * First priority: look for a config file in WP_LANG_DIR folder.
          * For example, for the theme slug `my-theme`, the file path is:
          * wp-content/languages/themes/my-theme-wpglobus-config.json
          * *
          * We'll check for both child and parent theme slugs
          */
         foreach (array(get_stylesheet(), get_template()) as $theme_slug) {
             $config_in_wp_lang_dir = WP_LANG_DIR . '/themes/' . $theme_slug . '-' . $config_file;
             if (is_file($config_in_wp_lang_dir) && is_readable($config_in_wp_lang_dir)) {
                 $this->config_dir_file = $config_in_wp_lang_dir;
                 break 2;
             }
         }
         /**
          * Then, check for the config file provided by the theme author:
          *
          * @example wp-content/themes/my-theme/wpglobus-config.json
          */
         if ($this->theme_dir['parent'] === $this->theme_dir['child']) {
             $file = $this->theme_dir['parent'] . '/' . $config_file;
             if (file_exists($file)) {
                 $this->config_dir_file = $file;
             }
         } else {
             foreach ($this->theme_dir as $relation => $dir) {
                 $file = $dir . '/' . $config_file;
                 if ('child' === $relation && file_exists($file)) {
                     /**
                      * Now config in child theme has highest priority
                      */
                     $this->config_dir_file = $file;
                     break;
                 }
                 if ('parent' === $relation && file_exists($file)) {
                     $this->config_dir_file = $file;
                 }
             }
         }
         if (!empty($this->config_dir_file)) {
             break;
         }
     }
     if (empty($this->config_dir_file)) {
         $config_file = '';
     }
     /**
      * If a configuration file has been found in the previous loop,
      * we have `$this->config_dir_file` containing the file path,
      * and the loop iterator, `$config_file`, pointing to the file type.
      */
     switch ($config_file) {
         case $this->wpglobus_config_file:
             $this->config = $this->json2array(file_get_contents($this->config_dir_file));
             $this->config_from = $this->wpglobus_config_file;
             break;
         case $this->wpml_config_file:
             /**
              * Compatibility with WPML configuration file:
              * their XML is parsed using their function, `icl_xml2array`,
              * which we copied as-is to the `lib` folder.
              *
              * @link https://wpml.org/documentation/support/language-configuration-files/
              */
             /** @noinspection PhpIncludeInspection */
             require_once WPGlobus::$PLUGIN_DIR_PATH . 'lib/xml2array.php';
             /** @noinspection PhpUndefinedFunctionInspection */
             $this->config = icl_xml2array(file_get_contents($this->config_dir_file));
             $this->config_from = $this->wpml_config_file;
             break;
     }
     if (!empty($this->config) && empty($this->config['version'])) {
         $this->config['version'] = '1';
     }
 }
开发者ID:rodica-andronache,项目名称:WPGlobus,代码行数:92,代码来源:class-wpglobus-wp-theme.php

示例12: _parse_wpml_config

 function _parse_wpml_config($file)
 {
     global $sitepress, $sitepress_settings;
     $config = icl_xml2array(file_get_contents($file));
     // custom fields
     if (!empty($config['wpml-config']['custom-fields'])) {
         if (!is_numeric(key(current($config['wpml-config']['custom-fields'])))) {
             $cf[0] = $config['wpml-config']['custom-fields']['custom-field'];
         } else {
             $cf = $config['wpml-config']['custom-fields']['custom-field'];
         }
         foreach ($cf as $c) {
             if ($c['attr']['action'] == 'translate') {
                 $action = 2;
             } elseif ($c['attr']['action'] == 'copy') {
                 $action = 1;
             } else {
                 $action = 0;
             }
             $this->settings['custom_fields_translation'][$c['value']] = $action;
             if (is_array($this->settings['custom_fields_readonly_config']) && !in_array($c['value'], $this->settings['custom_fields_readonly_config'])) {
                 $this->settings['custom_fields_readonly_config'][] = $c['value'];
             }
         }
     }
     // custom types
     $cf = array();
     if (!empty($config['wpml-config']['custom-types'])) {
         if (!is_numeric(key(current($config['wpml-config']['custom-types'])))) {
             $cf[0] = $config['wpml-config']['custom-types']['custom-type'];
         } else {
             $cf = $config['wpml-config']['custom-types']['custom-type'];
         }
         foreach ($cf as $c) {
             $translate = intval($c['attr']['translate']);
             if ($translate) {
                 $sitepress->verify_post_translations($c['value']);
             }
             $this->settings['custom_types_readonly_config'][$c['value']] = $translate;
             $sitepress_settings['custom_posts_sync_option'][$c['value']] = $translate;
         }
         add_filter('get_translatable_documents', array($this, '_override_get_translatable_documents'));
     }
     // taxonomies
     $cf = array();
     if (!empty($config['wpml-config']['taxonomies'])) {
         if (!is_numeric(key(current($config['wpml-config']['taxonomies'])))) {
             $cf[0] = $config['wpml-config']['taxonomies']['taxonomy'];
         } else {
             $cf = $config['wpml-config']['taxonomies']['taxonomy'];
         }
         foreach ($cf as $c) {
             $translate = intval($c['attr']['translate']);
             $this->settings['taxonomies_readonly_config'][$c['value']] = $translate;
             $sitepress_settings['taxonomies_sync_option'][$c['value']] = $translate;
         }
         add_filter('get_translatable_taxonomies', array($this, '_override_get_translatable_taxonomies'));
     }
     // admin texts
     if (function_exists('icl_register_string')) {
         $admin_texts = array();
         if (!empty($config['wpml-config']['admin-texts'])) {
             $type = dirname($file) == get_template_directory() || dirname($file) == get_stylesheet_directory() ? 'theme' : 'plugin';
             $atid = basename(dirname($file));
             if (!is_numeric(key(@current($config['wpml-config']['admin-texts'])))) {
                 $admin_texts[0] = $config['wpml-config']['admin-texts']['key'];
             } else {
                 $admin_texts = $config['wpml-config']['admin-texts']['key'];
             }
             foreach ($admin_texts as $a) {
                 $keys = array();
                 if (!isset($a['key'])) {
                     $arr[$a['attr']['name']] = 1;
                     continue;
                 } elseif (!is_numeric(key($a['key']))) {
                     $keys[0] = $a['key'];
                 } else {
                     $keys = $a['key'];
                 }
                 foreach ($keys as $key) {
                     if (isset($key['key'])) {
                         $arr[$a['attr']['name']][$key['attr']['name']] = $this->_read_admin_texts_recursive($key['key']);
                     } else {
                         $arr[$a['attr']['name']][$key['attr']['name']] = 1;
                     }
                 }
             }
             foreach ($arr as $key => $v) {
                 $value = get_option($key);
                 $value = maybe_unserialize($value);
                 if (false === $value) {
                     unset($arr[$key]);
                 }
                 if (is_scalar($value)) {
                     icl_register_string('admin_texts_' . $type . '_' . $atid, $key, $value);
                 } else {
                     if (is_object($value)) {
                         $value = (array) $value;
                     }
                     if (!empty($value)) {
//.........这里部分代码省略.........
开发者ID:bidhanbaral,项目名称:fotodep_store,代码行数:101,代码来源:translation-management.class.php

示例13: xmlrpc_call_actions

 function xmlrpc_call_actions($action)
 {
     $params = icl_xml2array(print_r(file_get_contents('php://input'), true));
     add_filter('is_protected_meta', array($this, 'xml_unprotect_wpml_meta'), 10, 3);
     switch ($action) {
         case 'wp.getPage':
         case 'blogger.getPost':
             // yet this doesn't return custom fields
             if (isset($params['methodCall']['params']['param'][1]['value']['int']['value'])) {
                 $page_id = $params['methodCall']['params']['param'][1]['value']['int']['value'];
                 $lang_details = $this->get_element_language_details($page_id, 'post_' . get_post_type($page_id));
                 $this->this_lang = $lang_details->language_code;
                 // set the current language to the posts language
                 update_post_meta($page_id, '_wpml_language', $lang_details->language_code);
                 update_post_meta($page_id, '_wpml_trid', $lang_details->trid);
                 $active_languages = $this->get_active_languages();
                 $res = $this->get_element_translations($lang_details->trid);
                 $translations = array();
                 foreach ($active_languages as $k => $v) {
                     if ($page_id != $res[$k]->element_id) {
                         $translations[$k] = isset($res[$k]->element_id) ? $res[$k]->element_id : 0;
                     }
                 }
                 update_post_meta($page_id, '_wpml_translations', wp_json_encode($translations));
             }
             break;
         case 'metaWeblog.getPost':
             if (isset($params['methodCall']['params']['param'][0]['value']['int']['value'])) {
                 $page_id = $params['methodCall']['params']['param'][0]['value']['int']['value'];
                 $lang_details = $this->get_element_language_details($page_id, 'post_' . get_post_type($page_id));
                 $this->this_lang = $lang_details->language_code;
                 // set the current language to the posts language
                 update_post_meta($page_id, '_wpml_language', $lang_details->language_code);
                 update_post_meta($page_id, '_wpml_trid', $lang_details->trid);
                 $active_languages = $this->get_active_languages();
                 $res = $this->get_element_translations($lang_details->trid);
                 $translations = array();
                 foreach ($active_languages as $k => $v) {
                     if (isset($res[$k]) && $page_id != $res[$k]->element_id) {
                         $translations[$k] = isset($res[$k]->element_id) ? $res[$k]->element_id : 0;
                     }
                 }
                 update_post_meta($page_id, '_wpml_translations', wp_json_encode($translations));
             }
             break;
         case 'metaWeblog.getRecentPosts':
             if (isset($params['methodCall']['params']['param'][3]['value']['int']['value'])) {
                 $num_posts = (int) $params['methodCall']['params']['param'][3]['value']['int']['value'];
                 if ($num_posts) {
                     $posts = get_posts('suppress_filters=false&numberposts=' . $num_posts);
                     foreach ($posts as $p) {
                         $lang_details = $this->get_element_language_details($p->ID, 'post_post');
                         update_post_meta($p->ID, '_wpml_language', $lang_details->language_code);
                         update_post_meta($p->ID, '_wpml_trid', $lang_details->trid);
                         $active_languages = $this->get_active_languages();
                         $res = $this->get_element_translations($lang_details->trid);
                         $translations = array();
                         foreach ($active_languages as $k => $v) {
                             if ($p->ID != $res[$k]->element_id) {
                                 $translations[$k] = isset($res[$k]->element_id) ? $res[$k]->element_id : 0;
                             }
                         }
                         update_post_meta($p->ID, '_wpml_translations', wp_json_encode($translations));
                     }
                 }
             }
             break;
     }
 }
开发者ID:studiopengpeng,项目名称:ASCOMETAL,代码行数:69,代码来源:sitepress.class.php


注:本文中的icl_xml2array函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。