0

I am trying to load content before the end body tag on admin pages that have a TinyMCE editor on them. To do this I am trying to leverage two action hooks 'before_wp_tiny_mce' and 'admin_footer' but it does not seem to be working as I expected. The following is a simplified version of my code:

add_action( 'before_wp_tiny_mce', 'before_wp_tiny_mce_action' );

function before_wp_tiny_mce_action() {
    add_action( 'admin_footer', 'admin_footer_action' );
}

function admin_footer_action() {
    echo "<p>I am in the footer of an admin page with a TinyMCE editor.</p>";
}

Why doesn't this work?

  • By all means it should. Do a echo 'xxx'; die; in each to make sure they are getting called properly. May have a typo in the something? – Eric Holmes Feb 27 '14 at 21:10
  • Fully tested. No typos... Both hooks work on their own but not when referenced inside the other one. – McShaman Feb 27 '14 at 21:17
  • 1
    Would you mind posting your actual code? The devil is in the details... – tfrommen Feb 27 '14 at 21:30
1

I think I worked out the problem.

before_wp_tiny_mce_action is not an action hook called before the actual TinyMCE editor in the DOM. It is called before the script that is loaded via the admin_print_footer_scripts action. So I think the admin_footer action hook is before the before_wp_tiny_mce_action action hook so I am calling my action too late.

I am going to have to find another way of detecting if a page has TinyMCE on it before it starts writing the script.

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.