Plugin Directory

Changeset 1536246


Ignore:
Timestamp:
11/18/2016 11:01:29 AM (9 years ago)
Author:
funkjedi
Message:

Syncing with Github

Location:
acf-qtranslate/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • acf-qtranslate/trunk/acf-qtranslate.php

    r1536127 r1536246  
    44Plugin URI: http://github.com/funkjedi/acf-qtranslate
    55Description: Provides multilingual versions of the text, text area, and wysiwyg fields.
    6 Version: 1.7.15
     6Version: 1.7.16
    77Author: funkjedi
    88Author URI: http://funkjedi.com
  • acf-qtranslate/trunk/assets/acf_4/qtranslatex.js

    r1536127 r1536246  
    2828    });
    2929
     30    var post_type = jQuery('#post_type').val();
     31
     32    // Whitelist fields for translation
     33    function isTranslatableField(field){
     34        if (post_type === 'acf-field-group') {
     35            if (field.id.match(/acf-field-field_[a-z0-9]+_label/))         return true;
     36            if (field.id.match(/acf-field-field_[a-z0-9]+_instructions/))  return true;
     37            if (field.id.match(/acf-field-field_[a-z0-9]+_default_value/)) return true;
     38            return false;
     39        }
     40        return true;
     41    }
     42
    3043    // Watch and add content hooks when new fields are added
    31     var timeoutContentHooksTinyMCE;
    3244    jQuery(document).on('acf/setup_fields', function(e, new_field) {
    3345        new_field = jQuery(new_field);
     
    4052                return;
    4153            }
     54
     55            if (!isTranslatableField(field)) return;
    4256
    4357            qTranslateConfig.qtx.addContentHookC(this, field.closest('form').get(0));
     
    5670        // Run in a setTimeout block to give the tinyMCE instance
    5771        // enough time to initialize before setting the editor hooks
    58         clearTimeout(timeoutContentHooksTinyMCE);
    59         timeoutContentHooksTinyMCE = setTimeout(function(){
    60             qTranslateConfig.qtx.addContentHooksTinyMCE();
     72        setTimeout(function(){
    6173            jQuery.each(tinyMCE.editors, function(i, ed){
    62                 var mceInit = tinyMCEPreInit.mceInit[ed.id];
    63                     console.log('initEditors:',mceInit);
    64                 if (mceInit && mceInit.init_instance_callback) {
    65                     mceInit.init_instance_callback(ed);
    66                 }
     74                setEditorHooks(ed);
    6775            });
    68         }, 50);
     76        },50);
    6977    });
    7078
     
    7785    });
    7886
     87
     88    // Extracted from qTranslate-X
     89    // admin/js/common.js#L840
     90    function setEditorHooks(ed) {
     91        var id = ed.id;
     92        if (!id) return;
     93        var h=qTranslateConfig.qtx.hasContentHook(id);
     94        if(!h || h.mce) return;
     95        h.mce=ed;
     96        ed.getContainer().className += ' qtranxs-translatable';
     97        ed.getElement().className += ' qtranxs-translatable';
     98        var updateTinyMCEonInit = h.updateTinyMCEonInit;
     99        if (updateTinyMCEonInit == null) {
     100            var text_e = ed.getContent({format: 'html'}).replace(/\s+/g,'');
     101            var text_h = h.contentField.value.replace(/\s+/g,'');
     102            updateTinyMCEonInit = text_e != text_h;
     103        }
     104        if (updateTinyMCEonInit) {
     105            text = h.contentField.value;
     106            if (h.wpautop && window.switchEditors) {
     107                text = window.switchEditors.wpautop(text);
     108            }
     109            h.mce.setContent(text,{format: 'html'});
     110        }
     111        return h;
     112    }
     113
    79114});
  • acf-qtranslate/trunk/assets/acf_5/qtranslatex.js

    r1536127 r1536246  
    3737        });
    3838
     39        var post_type = jQuery('#post_type').val();
     40
     41        // Whitelist fields for translation
     42        function isTranslatableField(field){
     43            if (post_type === 'acf-field-group') {
     44                if (field.id.match(/acf_fields-\d+-label/))         return true;
     45                if (field.id.match(/acf_fields-\d+-instructions/))  return true;
     46                if (field.id.match(/acf_fields-\d+-default_value/)) return true;
     47                return false;
     48            }
     49            return true;
     50        }
     51
    3952        // Setup field types
    4053        jQuery.each(field_types, function(field_type, selector) {
     
    4457                var form = jQuery(this).closest('form').get(0);
    4558                var field = jQuery(this).find(selector).get(0);
     59                if (!isTranslatableField(field)) return;
    4660                qTranslateConfig.qtx.addContentHookC(field, form);
    4761            });
     
    5165                var form = $el.closest('form').get(0);
    5266                var field = $el.find(selector).get(0);
     67                if (!isTranslatableField(field)) return;
    5368                qTranslateConfig.qtx.addContentHookC(field, form);
    5469
  • acf-qtranslate/trunk/readme.txt

    r1536127 r1536246  
    44Requires at least: 3.5.0
    55Tested up to: 4.6.1
    6 Version: 1.7.15
    7 Stable tag: 1.7.15
     6Version: 1.7.16
     7Stable tag: 1.7.16
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    5959
    6060== Changelog ==
     61
     62= 1.7.16 =
     63* Bug Fix: Fixed ACF4 support for standard WYSIWYG field
     64* Bug Fix: Updated ACF4 qTranslate WYSIWYG field
     65* Bug Fix: Prevent translation of key `acf-field-group` fields
    6166
    6267= 1.7.15 =
  • acf-qtranslate/trunk/src/acf_4/fields/wysiwyg.php

    r1519271 r1536246  
    3030        );
    3131
     32        // Create an acf version of the_content filter (acf_the_content)
     33        if( isset($GLOBALS['wp_embed']) ) {
     34
     35            add_filter( 'acf_the_content', array( $GLOBALS['wp_embed'], 'run_shortcode' ), 8 );
     36            add_filter( 'acf_the_content', array( $GLOBALS['wp_embed'], 'autoembed' ), 8 );
     37
     38        }
     39
     40        add_filter( 'acf_the_content', 'capital_P_dangit', 11 );
     41        add_filter( 'acf_the_content', 'wptexturize' );
     42        add_filter( 'acf_the_content', 'convert_smilies' );
     43        add_filter( 'acf_the_content', 'convert_chars' );
     44        add_filter( 'acf_the_content', 'wpautop' );
     45        add_filter( 'acf_the_content', 'shortcode_unautop' );
     46        //add_filter( 'acf_the_content', 'prepend_attachment' ); *should only be for the_content (causes double image on attachment page)
     47        add_filter( 'acf_the_content', 'do_shortcode', 11);
     48
    3249        acf_field::__construct();
     50
     51        // filters
     52        add_filter( 'acf/fields/wysiwyg/toolbars', array( $this, 'toolbars'), 1, 1 );
     53        add_filter( 'mce_external_plugins', array( $this, 'mce_external_plugins'), 20, 1 );
    3354    }
    3455
     
    6283        $values = qtrans_split($field['value'], $quicktags = true);
    6384        $currentLanguage = $this->plugin->get_active_language();
    64        
     85
     86        // vars
     87        //$id = uniqid('acf-editor-');
     88        $id = 'wysiwyg-' . $field['id'] . '-' . uniqid();
     89        $default_editor = 'tinymce';
     90
    6591        // filter value for editor
    66         remove_all_filters('acf_the_editor_content');
    67        
     92        remove_filter( 'acf_the_editor_content', 'format_for_editor', 10, 2 );
     93        remove_filter( 'acf_the_editor_content', 'wp_htmledit_pre', 10, 1 );
     94        remove_filter( 'acf_the_editor_content', 'wp_richedit_pre', 10, 1 );
     95
    6896        // WP 4.3
    69         if( version_compare($wp_version, '4.3', '>=' ) ) {             
    70             add_filter( 'acf_the_editor_content', 'format_for_editor' );   
     97        if( version_compare($wp_version, '4.3', '>=' ) ) {
     98            add_filter( 'acf_the_editor_content', 'format_for_editor', 10, 2 );
    7199        // WP < 4.3
    72         } else {       
    73             $function = user_can_richedit() ? 'wp_richedit_pre' : 'wp_htmledit_pre';   
    74             add_filter('acf_the_editor_content', $function);           
     100        } else {
     101            $function = user_can_richedit() ? 'wp_richedit_pre' : 'wp_htmledit_pre';
     102            add_filter('acf_the_editor_content', $function, 10, 1);
    75103        }
    76104
     
    83111
    84112        foreach ($languages as $language):
    85             $value = $values[$language];
    86113            $id = 'wysiwyg-' . $field['id'] . '-' . uniqid();
    87114            $name = $field['name'] . "[$language]";
    88             $class = ($language === $currentLanguage) ? 'acf_wysiwyg wp-editor-wrap current-language' : 'acf_wysiwyg wp-editor-wrap';
     115            $class = ($language === $currentLanguage) ? 'current-language' : '';
     116            $value = apply_filters('acf_the_editor_content', $values[$language], 'tinymce');
    89117
    90118            ?>
    91             <div id="wp-<?php echo $id; ?>-wrap" class="<?php echo $class; ?>" data-toolbar="<?php echo $field['toolbar']; ?>" data-upload="<?php echo $field['media_upload']; ?>" data-language="<?php echo $language; ?>">
    92                 <?php if( user_can_richedit() && $field['media_upload'] == 'yes' ): ?>
    93                     <?php if( version_compare($wp_version, '3.3', '<') ): ?>
    94                         <div id="editor-toolbar">
    95                             <div id="media-buttons" class="hide-if-no-js">
    96                                 <?php do_action( 'media_buttons' ); ?>
    97                             </div>
    98                         </div>
    99                     <?php else: ?>
    100                         <div id="wp-<?php echo $id; ?>-editor-tools" class="wp-editor-tools">
    101                             <div id="wp-<?php echo $id; ?>-media-buttons" class="hide-if-no-js wp-media-buttons">
    102                                 <?php do_action( 'media_buttons' ); ?>
    103                             </div>
    104                         </div>
     119            <div id="wp-<?php echo $id; ?>-wrap" class="acf_wysiwyg wp-core-ui wp-editor-wrap tmce-active <?php echo $class; ?>" data-toolbar="<?php echo $field['toolbar']; ?>" data-upload="<?php echo $field['media_upload']; ?>" data-language="<?php echo $language; ?>">
     120                <div id="wp-<?php echo $id; ?>-editor-tools" class="wp-editor-tools hide-if-no-js">
     121                    <?php if( user_can_richedit() && $field['media_upload'] == 'yes' ): ?>
     122                    <div id="wp-<?php echo $id; ?>-media-buttons" class="wp-media-buttons">
     123                        <?php do_action( 'media_buttons', $id ); ?>
     124                    </div>
    105125                    <?php endif; ?>
    106                 <?php endif; ?>
     126                </div>
    107127                <div id="wp-<?php echo $id; ?>-editor-container" class="wp-editor-container">
    108                     <textarea id="<?php echo $id; ?>" class="qtx-wp-editor-area" name="<?php echo $name; ?>" ><?php echo apply_filters( 'acf_the_editor_content', $value, 'tinymce' ); ?></textarea>
     128                    <textarea id="<?php echo $id; ?>" class="qtx-wp-editor-area" name="<?php echo $name; ?>"><?php echo $value; ?></textarea>
    109129                </div>
    110130            </div>
     131
    111132        <?php endforeach;
    112133
  • acf-qtranslate/trunk/src/plugin.php

    r1536127 r1536246  
    1717        add_action('after_setup_theme',               array($this, 'after_setup_theme'), -10);
    1818        add_action('acf/input/admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
     19        add_action('admin_footer',                    array($this, 'admin_footer'));
    1920        add_action('admin_menu',                      array($this, 'admin_menu'));
    2021        add_action('admin_init',                      array($this, 'admin_init'));
     
    167168
    168169    /**
     170     * Output a hidden block that can be use to force qTranslate-X
     171     * to include the LSB.
     172     */
     173    public function admin_footer() {
     174        echo '<span id="acf-qtranslate-lsb-shim" style="display:none">[:en]LSB[:]</span>';
     175    }
     176
     177    /**
    169178     * Add settings link on plugin page.
    170179     * @param array
     
    183192    public function qtranslate_load_admin_page_config($config)
    184193    {
    185         $config['acf-options-page'] = array(
    186             'pages'   => array('admin.php' => 'page='),
    187             'anchors' => array('poststuff' => array('where' => 'first last')),
    188             'forms'   => array(
     194        $config['acf-display-nodes'] = array(
     195            'pages' => array('post.php' => '', 'admin.php' => 'page='),
     196            'forms' => array(
     197                'wpwrap' => array(
     198                    'fields' => array(
     199                        'lsb-shim' => array(
     200                            'jquery' => '#acf-qtranslate-lsb-shim',
     201                            'encode' => 'display',
     202                        ),
     203                        'acf4-field-group-handle' => array(
     204                            'jquery' => '.acf_postbox h2 span,.acf_postbox h3 span',
     205                            'encode' => 'display',
     206                        ),
     207                        'acf5-field-group-handle' => array(
     208                            'jquery' => '.acf-postbox h2 span,.acf-postbox h3 span',
     209                            'encode' => 'display',
     210                        ),
     211                        'acf5-field-label' => array(
     212                            'jquery' => '.acf-field .acf-label label',
     213                            'encode' => 'display',
     214                        ),
     215                        'acf5-field-description' => array(
     216                            'jquery' => '.acf-field .acf-label p.description',
     217                            'encode' => 'display',
     218                        ),
     219                )),
     220            ),
     221        );
     222
     223        $config['acf-field-group'] = array(
     224            'pages'     => array('post.php' => ''),
     225            'post_type' => 'acf-field-group',
     226            'forms'     => array(
    189227                'post' => array(
    190228                    'fields' => array(
    191                         'acf4-field-group-hX' => array(
    192                             'jquery' => '.acf_postbox h2 span,.acf_postbox h3 span',
    193                             'encode' => 'display',
    194                         ),
    195                         'acf5-field-group-hX' => array(
    196                             'jquery' => '.acf-postbox h2 span,.acf-postbox h3 span',
     229                        'field-group-object-label' => array(
     230                            'jquery' => '.li-field-label .edit-field',
    197231                            'encode' => 'display',
    198232                        ),
Note: See TracChangeset for help on using the changeset viewer.