I have added shortcode buttons to the WordPress tinyMCE text editor using the WordPress quicktags function.

This works fine when in functions.php, however I need it to be in an external functions file which I am including in functions.php. For some reason it does not work in my external functions file.

The external function file definitely works, sinceother functions work fine within it.

I have also removed all code from the external file except the quicktags function to see if there is a conflict but it still does not work.

Any ideas on how i can get this to work?

function appthemes_add_quicktags() {
    <script type="text/javascript">
        QTags.addButton( 'eg_builderEmail', 'Email Link', '[getBuilderData name="domainPleskEmail"]@[getBuilderData name="domainName"]', '', 'builderEmail', 'builderEmail', 1 );
        QTags.addButton( 'eg_builderCompanyName', 'Company Name', '[getBuilderData name="domainTradingName"]', '', 'builderCompanyName', 'builderCompanyName', 1 );
        QTags.addButton( 'eg_builderMainNumber', 'Main Number', '[getBuilderData name="domainMainPhoneNumber"]', '', 'MainNumber', 'MainNumber', 1 );
        QTags.addButton( 'eg_builderMobileNumber', 'Mobile Number', '[getBuilderData name="domainBusinessMobile"]', '', 'MobileNumber', 'MobileNumber', 1 );
        QTags.addButton( 'eg_builderDomainName', 'Domain Name', '[getBuilderData name="domainName"]', '', 'DomainName', 'DomainName', 1 );
        QTags.addButton( 'eg_builderTown', 'Town', '[getBuilderData name="domainWebTown"]', '', 'builderTown', 'builderTown', 1 );
        QTags.addButton( 'eg_builderCounty', 'County', '[getBuilderData name="domainWebCounty"]', '', 'builderCounty', 'builderCounty', 1 );
add_action( 'admin_print_footer_scripts', 'appthemes_add_quicktags' );
  • Please post that external quicktag adding function so we can see if everything's alright with it. – jimihenrik Mar 23 '15 at 15:38
  • @jimihenrik i have edited my question with the function – Alicia C Mar 23 '15 at 16:31
  • Worth noting it works fine when in functions.php – Alicia C Mar 23 '15 at 16:32
  • Well that's strange. I copy-pasted your code to my external writer_editor_cleanup.php and it works fine. And for me it's even more than one external file away, I have require_once( 'library/admin.php' ); in functions.php, and in my admin.php I have require_once( 'includes/SU_Writer_Editor_Cleanup.php' ); so doesn't seem like the file being external is the problem. You do have <?php in the front of the file and ?> at the end right? – jimihenrik Mar 23 '15 at 16:41
  • And by the way, you probably noticed, but I'll say anyway; that this adds the quicktag buttons only to the text-editor, not to the visual editor. – jimihenrik Mar 23 '15 at 16:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.