Add button to insert shorcodes in Wordpress page construction menu

Asked

Viewed 357 times

1

I’m studying how to do things for Wordpress, I managed to make a plugin that creates a form with multiple screens and options fields and buttons.

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

The menu I am talking about is the one that is used to format the text of the page. The structure I saw is the one of the 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 passing the table name in the option "table", pass options of the type of user who has access to the form in the option "user", and if he wants the after submitting the answer he wants to be redirected to a specific page in the option "redirect".

Does anyone know how I can do that? What are the hook references? I’ve looked in Codex, but so far I have no idea how to look for it.

Thank you community!!!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.