开发者

Adding content to tinyMCE in wordpress

My plugin create a buch of shortcodes, im wanting to have a little button above the MCE editor to add in these shorcodes ( aka gravity forms) the buttons are along the top where the "upload/insert" buttons are for adding开发者_如何学Go media ( or a gravity form ). Then i need to have a modal window ( i think wp uses jquery ui, im familiar with this ) to select options for the shortcode then insert the html/code via js im guessing into the editor... only i looked myself and could not figure it out. Im pretty ok with php and js so no need to dumb it down.

i think this would be a good question for the community !

thanks guys.


Theres a really good chance this is going to break (if it hasn't already) when you upgrade to WP 3.5. The media_buttons_context has been deprecated so you now need to be using media_buttons. Below should work in 3.5.

<?php
add_action('media_buttons', 'add_shortcode_button', 11));

function add_shortcode_button() {
    $image_btn = METAMAKER_URL . "/images/form-button.png";
    echo '<a href="#TB_inline?width=450&inlineId=select_form" class="thickbox" title="Add MetaMaker field"><img src="'.$image_btn.'" alt="Add MetaMaker field" /></a>';
}


ok guys so i worked it out.

you need to hook into an action called "'media_buttons_context'" it takes an argument called $context.

function add_shortcode_button( $context ) {

    $image_btn = METAMAKER_URL . "/images/form-button.png";
    $out = '<a href="#TB_inline?width=450&inlineId=select_form" class="thickbox" title="Add MetaMaker field"><img src="'.$image_btn.'" alt="Add MetaMaker field" /></a>';
    return $context . $out;
}
add_action('media_buttons_context', array( $this, 'add_shortcode_button'));

you would then need to add in some html and js for the modal window pop up


Hey man here is the best tutorial ever about adding button to wp editor. It shows all aspects of it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜