Add button to insert shorcodes in the Wordpress page build menu

2

I am studying how to do things for Wordpress, I was able to make a plugin that creates a form with multiple screens and field options and buttons.

So far the options I pass in shortcodes is necessary to know the code to know what options to place and what the key words of the options. What I want is to add a button that opens a modal where the user will set the options, then click insert and generate the shortcode on the page.

The menu I am talking about is what is used to format the text on the page. The structure I saw is that of the div with class="mce-toolbar-grp mce-container mce-panel mce-stack-layout-item mce-first" .

To understand what I want to do, this is an excerpt from my plugin:

function mf_container($atts, $content = null) {
    extract( shortcode_atts( array (
        "table" => false,
        "user" => false,
        "redirect" => false,
    ), $atts ) );
    if($user && !is_user_logged_in()){
        return  'É necessario estar logado';
    }

    $content = do_shortcode($content);
    $content = str_replace("<br />","",$content);
    $content = str_replace("<p>","",$content);
    $content = str_replace("</p>","",$content);

    $header = "<form action='' method='post'>
            <input type='hidden' name='action' value='mult_form_submited'/>";

    if ($table){
        $header .= "<input type='hidden' name='table' value='".$table."'/>";
    }

    if ($redirect){
        $header .= "<input type='hidden' name='redirect' value='".$redirect."'/>";
    }

    if($user == "logged"){
        $header .= "<input type='hidden' name='user' value='".$user."'/>";
    }

    return $header . $content . "</form>";
}

add_shortcode('mult_form','mf_container');

In this code the user can pass by parameter, the options to generate a table by passing the table name in the "table" option, pass options of the user type that has access to the form in the "user" option, and if he wants that after submitting the answer he wants to be redirected to a specific page in the "redirect" option.

Does anyone know how I can do this? What are hook references? I searched the codex, but so far I have no idea how to look for it.

Thank you community !!!

    
asked by anonymous 31.03.2016 / 18:09

0 answers