name = 'wysiwyg'; $this->label = __("Wysiwyg Editor",'acf'); $this->category = __("Content",'acf'); $this->defaults = array( 'toolbar' => 'full', 'media_upload' => 'yes', 'default_value' => '', ); // Create an acf version of the_content filter (acf_the_content) if( isset($GLOBALS['wp_embed']) ) { add_filter( 'acf_the_content', array( $GLOBALS['wp_embed'], 'run_shortcode' ), 8 ); add_filter( 'acf_the_content', array( $GLOBALS['wp_embed'], 'autoembed' ), 8 ); } add_filter( 'acf_the_content', 'capital_P_dangit', 11 ); add_filter( 'acf_the_content', 'wptexturize' ); add_filter( 'acf_the_content', 'convert_smilies' ); add_filter( 'acf_the_content', 'convert_chars' ); add_filter( 'acf_the_content', 'wpautop' ); add_filter( 'acf_the_content', 'shortcode_unautop' ); //add_filter( 'acf_the_content', 'prepend_attachment' ); *should only be for the_content (causes double image on attachment page) add_filter( 'acf_the_content', 'do_shortcode', 11); // do not delete! parent::__construct(); // filters add_filter( 'acf/fields/wysiwyg/toolbars', array( $this, 'toolbars'), 1, 1 ); add_filter( 'mce_external_plugins', array( $this, 'mce_external_plugins'), 20, 1 ); } /* * mce_external_plugins * * This filter will add in the tinyMCE 'code' plugin which is missing in WP 3.9 * * @type function * @date 18/04/2014 * @since 5.0.0 * * @param $post_id (int) * @return $post_id (int) */ function mce_external_plugins( $plugins ){ // global global $wp_version; // WP 3.9 an above if( version_compare($wp_version, '3.9', '>=' ) ) { // add code $plugins['code'] = apply_filters('acf/get_info', 'dir') . 'js/tinymce.code.min.js'; } // return return $plugins; } /* * toolbars() * * This filter allowsyou to customize the WYSIWYG toolbars * * @param $toolbars - an array of toolbars * * @return $toolbars - the modified $toolbars * * @type filter * @since 3.6 * @date 23/01/13 */ function toolbars( $toolbars ) { // global global $wp_version; // vars $editor_id = 'acf_settings'; if( version_compare($wp_version, '3.9', '>=' ) ) { // Full $toolbars['Full'] = array( 1 => apply_filters( 'mce_buttons', array('bold', 'italic', 'strikethrough', 'bullist', 'numlist', 'blockquote', 'hr', 'alignleft', 'aligncenter', 'alignright', 'link', 'unlink', 'wp_more', 'spellchecker', 'fullscreen', 'wp_adv' ), $editor_id ), 2 => apply_filters( 'mce_buttons_2', array( 'formatselect', 'underline', 'alignjustify', 'forecolor', 'pastetext', 'removeformat', 'charmap', 'outdent', 'indent', 'undo', 'redo', 'wp_help', 'code' ), $editor_id ), 3 => apply_filters('mce_buttons_3', array(), $editor_id), 4 => apply_filters('mce_buttons_4', array(), $editor_id), ); // Basic $toolbars['Basic'] = array( 1 => apply_filters( 'teeny_mce_buttons', array('bold', 'italic', 'underline', 'blockquote', 'strikethrough', 'bullist', 'numlist', 'alignleft', 'aligncenter', 'alignright', 'undo', 'redo', 'link', 'unlink', 'fullscreen'), $editor_id ), ); } else { // Full $toolbars['Full'] = array( 1 => apply_filters( 'mce_buttons', array('bold', 'italic', 'strikethrough', 'bullist', 'numlist', 'blockquote', 'justifyleft', 'justifycenter', 'justifyright', 'link', 'unlink', 'wp_more', 'spellchecker', 'fullscreen', 'wp_adv' ), $editor_id ), 2 => apply_filters( 'mce_buttons_2', array( 'formatselect', 'underline', 'justifyfull', 'forecolor', 'pastetext', 'pasteword', 'removeformat', 'charmap', 'outdent', 'indent', 'undo', 'redo', 'wp_help', 'code' ), $editor_id ), 3 => apply_filters('mce_buttons_3', array(), $editor_id), 4 => apply_filters('mce_buttons_4', array(), $editor_id), ); // Basic $toolbars['Basic'] = array( 1 => apply_filters( 'teeny_mce_buttons', array('bold', 'italic', 'underline', 'blockquote', 'strikethrough', 'bullist', 'numlist', 'justifyleft', 'justifycenter', 'justifyright', 'undo', 'redo', 'link', 'unlink', 'fullscreen'), $editor_id ), ); } // Custom - can be added with acf/fields/wysiwyg/toolbars filter return $toolbars; } /* * input_admin_head() * * This action is called in the admin_head action on the edit screen where your field is created. * Use this action to add css and javascript to assist your create_field() action. * * @info http://codex.wordpress.org/Plugin_API/Action_Reference/admin_head * @type action * @since 3.6 * @date 23/01/13 */ function input_admin_head() { add_action( 'admin_footer', array( $this, 'admin_footer') ); } function admin_footer() { ?>
=' ) ) { add_filter( 'acf_the_editor_content', 'format_for_editor', 10, 2 ); // WP < 4.3 } else { $function = user_can_richedit() ? 'wp_richedit_pre' : 'wp_htmledit_pre'; add_filter('acf_the_editor_content', $function, 10, 1); } // filter $field['value'] = apply_filters( 'acf_the_editor_content', $field['value'], $default_editor ); ?>