Ejemplo n.º 1
0
 static function parse_wpml_config($config)
 {
     global $sitepress, $sitepress_settings, $iclTranslationManagement;
     // custom fields
     self::parse_custom_fields($config);
     $settings_helper = wpml_load_settings_helper();
     $tm_settings_tax = new WPML_TM_Settings_Update('taxonomy', 'taxonomies', $iclTranslationManagement, $sitepress, $settings_helper);
     $tm_settings_cpt = new WPML_TM_Settings_Update('custom-type', 'custom-types', $iclTranslationManagement, $sitepress, $settings_helper);
     $tm_settings_tax->update_from_config($config['wpml-config']);
     $tm_settings_cpt->update_from_config($config['wpml-config']);
     // language-switcher-settings
     if (empty($sitepress_settings['language_selector_initialized']) || isset($_GET['restore_ls_settings']) && $_GET['restore_ls_settings'] == 1) {
         if (!empty($config['wpml-config']['language-switcher-settings'])) {
             if (!is_numeric(key($config['wpml-config']['language-switcher-settings']['key']))) {
                 $cfgsettings[0] = $config['wpml-config']['language-switcher-settings']['key'];
             } else {
                 $cfgsettings = $config['wpml-config']['language-switcher-settings']['key'];
             }
             $iclsettings = $iclTranslationManagement->read_settings_recursive($cfgsettings);
             $iclsettings['language_selector_initialized'] = 1;
             $sitepress->save_settings($iclsettings);
             if (!empty($sitepress_settings['setup_complete']) && !empty($_GET['page'])) {
                 wp_redirect(admin_url('admin.php?page=' . $_GET['page'] . '&icl_ls_reset=default#icl_save_language_switcher_options'));
             }
         }
     }
     return $config;
 }
 function setUp()
 {
     parent::setUp();
     global $woocommerce_wpml, $wpml_post_translations, $wpml_term_translations;
     require_once WCML_PLUGIN_PATH . '/inc/products.class.php';
     $woocommerce_wpml->products = new WCML_Products();
     //add products for tests
     wpml_test_reg_custom_post_type('product');
     $settings_helper = wpml_load_settings_helper();
     $settings_helper->set_post_type_translatable('product');
     $this->orig_product = wpml_test_insert_post('en', 'product', false, 'product 1');
     $trid = $wpml_post_translations->get_element_trid($this->orig_product);
     $this->es_product = wpml_test_insert_post('es', 'product', $trid, 'producto 1');
     //add global attribute for tests
     $taxonomy = 'pa_color';
     wpml_test_reg_custom_taxonomy($taxonomy);
     $settings_helper = wpml_load_settings_helper();
     $settings_helper->set_taxonomy_translatable($taxonomy);
     $this->orig_term = wpml_test_insert_term('en', $taxonomy, false, 'white');
     $ttid_org = $this->orig_term['term_taxonomy_id'];
     $trid = $wpml_term_translations->get_element_trid($ttid_org);
     $this->es_term = wpml_test_insert_term('es', $taxonomy, $trid, 'blanco');
 }
Ejemplo n.º 3
0
         foreach ($_POST['icl_sync_tax'] as $k => $v) {
             $iclsettings['taxonomies_sync_option'][$k] = $v;
             if ($v) {
                 $this->verify_taxonomy_translations($k);
             }
         }
         if (isset($iclsettings)) {
             $this->save_settings($iclsettings);
         }
     }
     echo '1|';
     break;
 case 'icl_custom_posts_sync_options':
     $new_options = !empty($_POST['icl_sync_custom_posts']) ? $_POST['icl_sync_custom_posts'] : array();
     /** @var WPML_Settings_Helper $settings_helper */
     $settings_helper = wpml_load_settings_helper();
     $settings_helper->update_cpt_sync_settings($new_options);
     echo '1|';
     break;
 case 'copy_from_original':
     /*
      * apply filtering as to add further elements
      * filters will have to like as such
      * add_filter('wpml_copy_from_original_fields', 'my_copy_from_original_fields');
      *
      * function my_copy_from_original_fields( $elements ) {
      *  $custom_field = 'editor1';
      *  $elements[ 'customfields' ][ $custom_fields ] = array(
      *    'editor_name' => 'custom_editor_1',
      *    'editor_type' => 'editor',
      *    'value'       => 'test'
Ejemplo n.º 4
0
 private static function maybe_add_filter($config_type)
 {
     global $wpml_settings_helper;
     wpml_load_settings_helper();
     if ($config_type === 'taxonomies') {
         add_filter('get_translatable_taxonomies', array($wpml_settings_helper, '_override_get_translatable_taxonomies'));
     } elseif ($config_type === 'custom-types') {
         add_filter('get_translatable_documents', array($wpml_settings_helper, '_override_get_translatable_documents'));
     }
 }