samedi 11 juin 2016

Why are my settings not being saved on wordpress admin?

I am new to wordpress, and I have build a plugin that just saves settings on the admin menu.

But when I click on the save button it just takes me to the options.php page and doesn't do anything. I have looked over my code a couple of times, and I can't seem to find why its not saving, and just stays at the options.php page.

Any help would be really appreciated!! Thanks

function fflOptionsMenuLink(){

    add_options_page("Facebook Footer Link Options", "Facebook Footer Link","manage_options","ffl-options","fflOptionsContent" );

}

function fflOptionsContent(){


    $opt = get_option("ffl_settings");

   $output = "<div class='wrap'>

        <h2>Facebook footer link settings </h2>

        <form method='post' action='options.php' id='ffl_settings_group'>";

      settings_fields('ffl_settings_group');

    $output .= "<table class='form-table'>
        <tbody>
            <tr>
                <th scope='row'><label for='ffl_settings[enable]'>Enable</label> </th>
                <td><input name='ffl_settings[enable]' type='checkbox' id='ffl_settings[enable]' value='1' ></td>
            </tr>


             <tr>
                <th scope='row'><label for='ffl_settings[facebook_url]'>Facebook Profile </label> </th>
                <td><input name='ffl_settings[facebook_url]' type='text' id='ffl_settings[facebook_url]' value='{$opt["ffl_settings"]}' class='regular-text' ></td>
            </tr>


              <tr>
                <th scope='row'><label for='ffl_settings[link_color]'>Enter color or hex value</label> </th>
                <td><input name='ffl_settings[link_color]' type='text' id='ffl_settings[link_color]' value='{$opt["link_color"]}' class='regular-text' ></td>
            </tr>

             <tr>
                <th scope='row'><label for='ffl_settings[show_in_feed]'>Show in feed</label> </th>
                <td><input name='ffl_settings[show_in_feed]' type='checkbox' id='ffl_settings[show_in_feed]' value='1' ></td>
            </tr>



        </tbody>


    </table>
    <p class='submit'><input type='submit' name='submit' id='submit' class='button button-primary' value='Submit'> </p>
        ";






    $output .= "</form>";

   $output.="</div>";

    echo $output;


}


add_action("admin_menu","fflOptionsMenuLink");

//Register Settings

function fflRegisterSetting(){

    register_setting("ffl_settings_group","ffl_settings");

}

add_action("admin_init","ffl_register_setting");



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire