Home › Forums › Backend Issues (wp-admin) › WYSIWYG shortcode button not visible within flexible content › Reply To: WYSIWYG shortcode button not visible within flexible content
Hi John,
Thanks for your reply! I figured out that there was something wrong with initializing the shortcodes button. Everything is working fine now and this is the optimized code:
add_action( 'after_setup_theme', 'shortcodes_button_setup' );
if ( ! function_exists( 'shortcodes_button_setup' ) ) {
function shortcodes_button_setup() {
add_action( 'init', 'shortcodes_button' );
}
}
if ( ! function_exists( 'shortcodes_button' ) ) {
function shortcodes_button() {
if ( ! current_user_can( 'edit_posts' ) && ! current_user_can( 'edit_pages' ) ) {
return;
}
if ( get_user_option( 'rich_editing' ) !== 'true' ) {
return;
}
add_filter( 'mce_external_plugins', 'add_shortcodes_button' );
add_filter( 'mce_buttons', 'register_shortcodes_button' );
}
}
if ( ! function_exists( 'add_shortcodes_button' ) ) {
function add_shortcodes_button( $plugin_array ) {
$plugin_array['shortcodes_button'] = get_template_directory_uri().'/includes/shortcodes/js/shortcodes.js';
return $plugin_array;
}
}
if ( ! function_exists( 'register_shortcodes_button' ) ) {
function register_shortcodes_button( $buttons ) {
array_push( $buttons, 'shortcodes_button' );
return $buttons;
}
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.