Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $export = $_GET['export'];
- if($export == '1'){
- require( './wp-load.php' );
- if (!class_exists('ICL_Array2XML')) {
- /**
- * Converts array to XML
- */
- class ICL_Array2XML
- {
- var $text;
- var $arrays, $keys, $node_flag, $depth, $xml_parser;
- function array2xml($array, $root) {
- $this->depth = 1;
- $this->text = "<?xml version=\"1.0\" encoding=\""
- . get_option('blog_charset'). "\"?>\r\n<$root>\r\n";
- $this->text .= $this->array_transform($array);
- $this->text .="</$root>";
- return $this->text;
- }
- function array_transform($array) {
- $output = '';
- $indent = str_repeat(' ', $this->depth * 4);
- $child_key = false;
- if (isset($array['__key'])) {
- $child_key = $array['__key'];
- unset($array['__key']);
- }
- foreach ($array as $key => $value) {
- if (!is_array($value)) {
- if (empty($key)) {
- continue;
- }
- $key = $child_key ? $child_key : $key;
- $output .= $indent . "<$key>" . htmlspecialchars($value, ENT_QUOTES) . "</$key>\r\n";
- } else {
- $this->depth++;
- $key = $child_key ? $child_key : $key;
- $output_temp = $this->array_transform($value);
- if (!empty($output_temp)) {
- $output .= $indent . "<$key>\r\n";
- $output .= $output_temp;
- $output .= $indent . "</$key>\r\n";
- }
- $this->depth--;
- }
- }
- return $output;
- }
- }
- }
- function wpvref_export_wpml_settings() {
- global $wpdb;
- $data = null;
- $settings = get_option('icl_sitepress_settings', null);
- if ($settings) {
- //require_once dirname(__FILE__) . '/includes/array2xml.php';
- $xml = new ICL_Array2XML();
- $settings['translation-management']['__custom_fields_readonly_config_prev']['__key'] = 'item';
- $settings['translation-management']['custom_fields_readonly_config']['__key'] = 'item';
- // Add the active languages.
- $settings['active_languages'] = array();
- $table_name = $wpdb->prefix.'icl_languages';
- if($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") == $table_name){
- $results = $wpdb->get_results("SELECT code, active FROM {$wpdb->prefix}icl_languages WHERE 1 ", ARRAY_A);
- foreach ($results as $item) {
- $settings['wpv_active_languages'][$item['code']] = $item['active'];
- }
- }
- $data = $xml->array2xml($settings, 'wpml');
- }
- return $data;
- }
- // Export WPML
- $wpml = wpvref_export_wpml_settings();
- if ($wpml) {
- //file to put the data in
- //$wpml_file = ABSPATH . '_wpv_demo/' . basename($site['site_url']) . '/wpml.xml';
- $wpml_file = ABSPATH . 'wpml.xml';
- if(file_put_contents($wpml_file, $wpml) !== FALSE){
- echo "Your wpml settings have been successfully exported. You will find them in the wpml.xml file located in your WordPress root folder.";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement