plugin = $plugin; if (version_compare($plugin->acf_version(), '5.6.0') < 0) { $this->initialize(); } // actions acf_field::__construct(); } /* * initialize * * This function will setup the field type data * * @type function * @date 5/03/2014 * @since 5.0.0 * * @param n/a * @return n/a */ function initialize() { // vars $this->name = 'qtranslate_wysiwyg'; $this->label = __("Wysiwyg Editor (qTranslate)",'acf'); $this->category = __("qTranslate",'acf'); $this->defaults = array( 'tabs' => 'all', 'toolbar' => 'full', 'media_upload' => 1, 'default_value' => '', 'delay' => 0 ); // add acf_the_content filters if (method_exists($this, 'add_filters')) { $this->add_filters(); } } /* * render_field() * * Create the HTML interface for your field * * @param $field - an array holding all the field's data * * @type action * @since 3.6 * @date 23/01/13 */ function render_field($field) { // global global $wp_version; // enqueue acf_enqueue_uploader(); // vars $id = uniqid('acf-editor-'); $default_editor = 'html'; $show_tabs = true; $button = ''; // get height $height = acf_get_user_setting('wysiwyg_height', 300); $height = max( $height, 300 ); // minimum height is 300 // detect mode if( !user_can_richedit() ) { $show_tabs = false; } elseif( $field['tabs'] == 'visual' ) { // case: visual tab only $default_editor = 'tinymce'; $show_tabs = false; } elseif( $field['tabs'] == 'text' ) { // case: text tab only $show_tabs = false; } elseif( wp_default_editor() == 'tinymce' ) { // case: both tabs $default_editor = 'tinymce'; } // must be logged in tp upload if( !current_user_can('upload_files') ) { $field['media_upload'] = 0; } // mode $switch_class = ($default_editor === 'html') ? 'html-active' : 'tmce-active'; // filter value for editor remove_filter( 'acf_the_editor_content', 'format_for_editor', 10, 2 ); remove_filter( 'acf_the_editor_content', 'wp_htmledit_pre', 10, 1 ); remove_filter( 'acf_the_editor_content', 'wp_richedit_pre', 10, 1 ); // WP 4.3 if( version_compare($wp_version, '4.3', '>=' ) ) { add_filter( 'acf_the_editor_content', 'format_for_editor', 10, 2 ); $button = 'data-wp-editor-id="' . $id . '"'; // WP < 4.3 } else { $function = ($default_editor === 'html') ? 'wp_htmledit_pre' : 'wp_richedit_pre'; add_filter('acf_the_editor_content', $function, 10, 1); $button = 'onclick="switchEditors.switchto(this);"'; } global $q_config; $languages = qtrans_getSortedLanguages(true); $values = qtrans_split($field['value'], $quicktags = true); $currentLanguage = $this->plugin->get_active_language(); echo '