Why are my settings not being saved on wordpress admin? - wordpress

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");

Few Things...
ISSUE - Your function name for registering settings fflRegisterSetting not ffl_register_setting as in your hook.
ISSUE - You are not outputting submit button by wp function
Reminder - facebook_url field has value wrong $opt["link_color"], but since checkboxes are not ready either so I'll consider this a WIP ;)
So your code should look something like this -
function fflOptionsMenuLink(){
add_options_page("Facebook Footer Link Options", "Facebook Footer Link","manage_options","ffl-options","fflOptionsContent" );
}
function fflOptionsContent(){
$opt = get_option("ffl_settings");
echo "<div class='wrap'>
<h2>Facebook footer link settings </h2>
<form method='post' action='options.php' id='ffl_settings_group'>";
settings_fields('ffl_settings_group');
echo "<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["facebook_url"]}' 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>
";
submit_button(); // Get the submit button from this function
echo "</form>";
echo "</div>";
}
add_action("admin_menu","fflOptionsMenuLink");
//Register Settings
function fflRegisterSetting(){
register_setting("ffl_settings_group","ffl_settings");
}
add_action("admin_init","fflRegisterSetting");

Related

how to get a table width to move in one of my media queries

I am trying to get one of my tables to be wider for my media query of 1024px but it isn't working. I have used width with px or em setting, even % but can't get it to work. I also added the !important tag. I am not sure what is overriding it. I am also having problems moving my span tag up or down and have been using either positioning, or margin-up, margin-down. Any other things I could do to make it move? I also try the display:flex but that doesn't help either.
I am not sure which code to put here because all my css code is too long for codepen
.admin_create_level1promo textarea {
width: 25em;
height:6em;
position: absolute;
font-size: 1em;
}
I tried to add margin-bottom and bottom but can't get my textarea to move
enter image description here
php code
echo '<form action="admin_create_level1promo_process.php" method="POST">';
echo '<table class="admin_create_level1promo">
<tr>
<th colspan="3" class="update_title">Welcome to the Create Level 1 Promo Competition\'s Section</th>
</tr>
<tr>
<th>Entry ID:</th><td><input type="text" name="entry_id" placeholder="Enter ID"></td>
</tr>
<tr>
<th>Name of Competition:</th><td><input type="text" name="name" placeholder="Enter Name"></td>
</tr>
<tr>
<th>Duration of Competition:</th><td><input type="duration" name="duration" placeholder="Enter Duration"></td>
</tr>
<tr>
<th>Describe Competition:</th><td><textarea name="describe" placeholder="Enter Description of Competition"></textarea></td>
</tr>
<tr>
<th>Opening Date:</th><td><input type="text" name="opening_date" placeholder="Enter Opening Date"></td>
</tr>
<tr>
<th>Closing Date:</th><td><input type="text" name="closing_date" placeholder="Enter Closing Date"></td>
</tr>
<tr>
<th>Points:</th><td><input type="text" name="points" placeholder="Enter Points"></td>
</tr>
<tr>
<th></th><td><input type="hidden" name="csrf" value="'.$_SESSION['token'].'"></td>
</tr>
<tr>
<th></th><td><input type="submit" name="submit" value="Create Level 1 promo Competition"></td>
</tr>
</table>
</form>';
}
}

get the index of a tal:repeat in another tal:repeat function

As you can see I have 3 lists: Procedur_Headers, Diagnoses and List_Procedur.
Procedur_headers gives the headers of my tabels,
Diagnoses gives the specific id of a procedure and
List_Procedur is a list of lists (query’s) where all the data that I need is contained.
Now what I want to do is to have the index of the Diagnoses page in the
tal:repeat="list_procedur List_Procedur[index]"
that I can get my data in my table.
I already can get the index:
tal:content="python:repeat['diagnoses'].index"
but I can't do this at the place of index.
Does anybody have a solution for something like this?
<table id="tableIngrepen" class="table">
<thead class="header">
<tr>
<th>Code Diagnose vast</th>
<th tal:repeat="procedur_headers Procedur_Headers" tal:content="procedur_headers" > </th>
</tr>
</thead>
<tr tal:repeat="diagnoses Diagnoses">
<td tal:content="python:repeat['diagnoses'].index"></td>
<td ><input type='text' id="dz_code" class="input-mini" value="${diagnoses.code_diagnose}" onchange="voegrijtoe_Ingrepen(this.value,this);logging(this,'Code','2')" placeholder="Code"></input></td> <!-- onfocus="rijencolom($(this).parent().children().index($(this)),$(this).parent().parent().children().index($(this).parent()))" -->
<td colspan="6">
<table id="tableIngrepen" class="table table-hover" style="border-style:none">
<thead class="header">
<tr>
<th tal:repeat="procedur_headers Procedur_Headers" tal:content="procedur_headers" > </th> <!-- style="display:none"-->
</tr>
</thead>
<tr tal:repeat="list_procedur List_Procedur[index]">
<td style="max-width: 60px; word-wrap: break-word" >Uitleg over de Code van deze diagnose in maximaal 200 karakters</td>
<td ><input type='text' id="dz_Datum" class="input-small2" value="${list_procedur.code_diagnose}" onchange="logging(this,'Datum','2');datumvalidate(this)" placeholder="yyyy-mm-dd"></input></td>
<td><input type='text' id="dz_dir" class="input-mini1" onchange="logging(this,'Dir','2')" ></input></td>
<td><input type='text' id="dz_aan" class="input-mini1" onchange="logging(this,'Aan','2')" ></input></td>
<td><input type='text' id="dz_uit" class="input-mini1" onchange="logging(this,'Dz','2')" ></input></td>
</tr>
<tr>
<td style="max-width: 60px; word-wrap: break-word" >Uitleg over de Code van deze diagnose in maximaal 200 karakters</td>
<td ><input type='text' id="dz_Datum" class="input-small2" onchange="logging(this,'Datum','2');datumvalidate(this)" placeholder="yyyy-mm-dd"></input></td>
<td><input type='text' id="dz_dir" class="input-mini1" onchange="logging(this,'Dir','2')" ></input></td>
<td><input type='text' id="dz_aan" class="input-mini1" onchange="logging(this,'Aan','2')" ></input></td>
<td><input type='text' id="dz_uit" class="input-mini1" onchange="logging(this,'Dz','2')" ></input></td>
</tr>
</table>
</td>
</tr>
</table>
The solution is:
<tr tal:repeat="diagnoses Diagnoses"> <div tal:omit-tag="" tal:define="myindex python:repeat['diagnoses'].index"> ..use the myindex.. </div> </tr>

WordPress Plugin: How to add a separate page for editing a form

OK so i have a plugin which has its own settings page and all. In the settings i have a form that will display data from a custom table. It looks like this:
<form method="post" action="">
<table>
<tbody>
<tr>
<th>StringVal1</th>
<th>Checked</th>
<th>StringVal2</th>
<th>StringVal3</th>
<th>Configurations</th>
</tr>
<tr>
<td>
<?php echo "Value from table"; ?>
</td>
<td>
<?php
if ($row["Checked"] == 1) {
$checked = ' checked="checked" ';
}
echo "<input name='Checked' type='checkbox' " . $checked . " />";
?>
</td>
<td>
<?php echo "Another value from table"; ?>
</td>
<td>
<?php echo "More value from table"; ?>
</td>
<th>
<div align="center">
<input name="EditButton" type="submit" class="edit-secondary" value="Edit">
</div>
</th>
</tr>
</tbody>
</table>
</form>
When the "Edit" Button is clicked i want to link to another page (for ex. /wp-admin/plugins.php?page=myplugin-settings/edit-form) in order to edit and insert delete rows from the table. So how can i add that extra page i need?

Why does $_POST return multi array

I have the following HTML form
<form id="form2" name="form2" method="post" action="process.php">
<table width="271" border="1">
<tr>
<td width="5"><input name="txtIdone2" type="text" id="txtIdone2" value="Richard" /></td>
<td width="250">
<label for="txtIdone"></label>
<input name="txtIdone" type="text" id="txtIdone" value="Hopes" />
</td>
</tr>
<tr>
<td><input name="txtIdone3" type="text" id="txtIdone3" value="Testing" /></td>
<td><input name="txtIdone4" type="text" id="txtIdone4" value="this" /></td>
</tr>
<tr>
<td><input name="txtIdone5" type="text" id="txtIdone5" value="it" /></td>
<td><input name="txtIdone6" type="text" id="txtIdone6" value="works" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="btnTest" id="btnTest" value="Submit" />
</td>
</tr>
</table>
</form>
That submits to process.php that has the following code:
$data = array($_POST);
print_r ($data);
Simple. However, instead of a regular array being returned, i'm receiving a multi array. Here is an example:
Array
(
[0] => Array
(
[txtIdone2] => Richard
[txtIdone] => Hopes
[txtIdone3] => Testing
[txtIdone4] => this
[txtIdone5] => it
[txtIdone6] => works
)
)
I just want a regular array returned. What am I doing wrong?
Thanks.
$_POST is already an array.
By doing $data = array($_POST); you are making the array multidimensional.
Try doing simply:
print_r($_POST);

Cannot respond to radio button change in partial view

I loaded a partial view containing some radiobuttons on it in my view, but when I try to respond to events from the radio button, through some jquery calls, I can't. Is it impossible to do this, or am I placing the code in the wrong place. I placed the jquery codes in the View and the partial view classes, but neither works. Can anyone help..any advice? Or code samples or links?
Code below:
Sorry...Here's the partial view
#model IEnumerable<Tuda.Models.PriceModel>
<table class="planTable">
<thead>
<tr>
<th></th>
<th scope="col" abbr="Premium">PREMIUM</th>
<th scope="col" abbr="Deluxe">DELUXE</th>
<th scope="col" abbr="Utlmate">ULTIMATE</th>
</tr>
</thead>
<tfoot>
<tr>
<th scope="row" style="font-weight:bold">Select Plan</th>
<td><input type="radio" name="planRadio" value="1"></td>
<td><input type="radio" name="planRadio" value="2"></td>
<td><input type="radio" name="planRadio" value="3"></td>
</tr>
</tfoot>
<tbody>
<tr>
<th scope="row">Library Use (Includes Questions & Answers Only)</th>
<td>Unlimited</td>
<td>Unlimited</td>
<td>Unlimited</td>
</tr>
<tr>
<th scope="row">Interview Tips & Guides</th>
<td><span ><img src="../../Images/check0.png" /></span></td>
<td><span ><img src="../../Images/check0.png" /></span></td>
<td><span ><img src="../../Images/check0.png" /></span></td>
</tr>
<tr>
<th scope="row">Problem Areas Detection</th>
<td><span ><img src="../../Images/check0.png" /></span></td>
<td><span ><img src="../../Images/check0.png" /></span></td>
<td><span ><img src="../../Images/check0.png" /></span></td>
</tr>
<tr>
<th scope="row">Relevant Concepts & Terminology</th>
<td> - </td>
<td> - </td>
<td><span ><img src="../../Images/check0.png" /></span></td>
</tr>
<tr>
<th scope="row">User Recommended</th>
<td></td>
<td><span><img src="../../Images/check0.png" /></span></td>
<td><span><img src="../../Images/check0.png" /></span></td>
</tr>
<tr>
<th scope="row">Validity</th>
<td>1 Month</td>
<td>3 Months</td>
<td>12 Months</td>
</tr>
</tbody>
</table>
<script type="text/javascript">
$(document).ready(function () {
$("input[name='planRadio']").change(function(){
var planse = $("input[name='planRadio']:checked").val();
$.get('#Url.Action(MVC.Account.AddToCartPartial())',
{ id: planse }, function (data) {
$('#plan').html('<p><strong>Adding to cart...</strong> <img src="#Url.Content("~/images/ajax-loader1.gif")" width="54" height="55" /></p>');
$("#plan").html(data);
});
});
</script>
The call to the controller isn't made
$(":radio").live("click", function () {
var inputValue = $('input:radio:checked').val();
});
or to keep the value of the selected Radiobutton on to hidden field
<input type="radio" id="SelectedPlanType" rel="1" name="Plan1" value='1' onClick="document.getElementById('hiddenfield').value=this.value" checked="checked">
<input type="hidden" name="SelectedPlanType" value="" id="hiddenfield" />

Resources