Wordpress submit_button() not showing in custom plugin settings page - wordpress

I have a very small custom plugin that all of a sudden is not displaying the 'Save Changes' button at the bottom of the settings page being added via add_options_page function.
The rest of the form is there, and the button shows locally but for some reason it is not showing up on the live site (v4.1.1). I have tried removing the submit_button() function and adding the line below instead but no joy.
Also, I don't have any check thats says only certain users can see the button.
<input type="submit" name="submit" id="submit" class="button button-primary" value="Save Changes">
Any suggestions?

Related

After adding an item to the cart, sometimes it undesirably gets removed a second later

I have a weird bug which I can't reproduce easily. In 90% times everything works ok but sometimes when I add a new product, I can see that minicart shows higher product number but then after a second that number goes back to the previous item count. On the cart page I can also see that in that case product really wasn't added to cart.
So basically, after a product is added to the cart it gets removed a second later
In the WooCommerce settings Ajax functionality is turned on. It is a custom theme with quantity buttons added but adding a product into the cart is all on the WooCommerce end. I have also temporarely disabled all WC templates in my theme trying to find the problem. What can I do to inspect the problem further? I don't see any errors in the logs (both debug.log in wp-content, error log in the root or WC logs in uploads/wc-logs). Everything is updated to last version with only needed plugins active (like ACF). The same bug happens on stage hosting and localhost (Wampserver)
If I hook into "woocommerce_ajax_added_to_cart" action (which is triggered after a product is successfully added into the cart https://woocommerce.github.io/code-reference/files/woocommerce-includes-class-wc-ajax.html#source-view.419) and there I write to a log, I can see that it is correctly triggered each time, even in cases when a product is after for some reason removed from the cart.
add_action('woocommerce_ajax_added_to_cart', 'ms_woocommerce_ajax_added_to_cart');
function ms_woocommerce_ajax_added_to_cart() {
write_log('product is added to cart');
}
Also when I hook into their JS hook, it is triggered.
jQuery( document.body ).on('added_to_cart', function(e){
console.log('it worked')
});
Example of the form inside li.product:
<form action="?add-to-cart=4862" class="cart" method="post" enctype="multipart/form-data">
<div class="loop-increments">
<button type="button" class="btn-buyproduct btn-buyproduct--minus">-</button>
<div class="quantity">
<label class="screen-reader-text" for="quantity_63ac1f239e395">Product name</label>
<input type="number" id="quantity_63ac1f239e395" class="input-text qty text" name="quantity" value="1" title="Qty" size="4" min="0" max="" step="1" placeholder="" inputmode="numeric" autocomplete="off">
</div>
<button type="button" class="btn-buyproduct btn-buyproduct--plus">+</button>
</div>
Add to cart
</form>
What could be the problem?

Search Wordpress Site and External (Non-Wordpress) Site Search Form with Radio Buttons

I'm trying to duplicate the search box on this site : https:clearviewlibrary.org over on a Wordpress install here: https://news.clearviewlibrary.org
I was able to get the search box to execute a search on the external site with this code:
<div>
<form method="get" action="javascript:void(0)"
onsubmit="window.open('http://www.wsld.info/#section=search&term<%=Config%>#section=search&term='+this.term.value+'', '_blank');return true;">
<label>
<input type="text" class="searchform" name="term" placeholder="Search Our Catalog" /></label>
</form>
</div>
but I'm stumped on how to go about adding the additional search functionality and radio buttons.
I've tried taking the code from the clearviewlibrary.org site, but that didn't work. I also saw this, but would rather not have the two buttons : HTML form action search, one text box, 2 buttons, 2 possible results
Thanks,
Brad

Should I place a toggle form button outside of <form></form>?

I have a simple form on my main page. It needs to be toggle-able (is that a word?) between the simple version and the detailed version using a button. Where do I put the code for the button, inside or outside the form element? I read online that the submit button should be within the form, so I'm guessing a toggle button should also be there? But I'd rather ask more experienced people. Also, how would I make the forms retain the same content that the user typed when toggleing?
This is for a form I'm making on Wordpress.
I would recommend placing the toggle button outside of the <form> element and then use jQuery (or plain javascript) to handle the switching between the simple and detailed versions of the form. I'm not exactly clear what you had in mind for the simple and detailed versions of the form, but this approach should be easy to adapt to your purposes.
You can give the advanced form fields the same class (e.g. "detailed"), have them hidden by default in your CSS, and then have them appear when the toggle button is clicked using jQuery.
The values inputted into the detailed form fields won't get lost when the button is toggled; the values are still there, but just hidden. They'd still get submitted when the form submit button was clicked.
This is the toggle and <form> code.
<button id="form-toggle">Toggle Detailed Form Fields</button>
<form id="test-form" action="action_page.php">
<p>First name: <input type="text" name="firstname" value=""></p>
<p>Last name: <input type="text" name="lastname" value=""></p>
<p class="detailed">Email: <input type="email" name="email" value=""></p>
<p class="detailed">Phone: <input type="tel" name="phone" value=""></p>
<p><input type="submit" value="Submit"></p>
</form>
This is the CSS you should place in your stylesheet, it makes the detailed form fields hidden by default:
.detailed {
display: none;
}
This is the jQuery code that you could enqueue as an external .js file in your functions.php file or before the </body> of your footer.php file:
<script type="text/javascript">
jQuery(document).ready(function($){
$('#form-toggle').click(function() {
$('.detailed').toggle('fast');
});
});
</script>

Some WordPress page links redirectinf to home page

Links from the menu are directing correctly but links like the one in the page below are SUDDENLY not.
http://tazara.mwanawanga.com/?page_id=94
I gave searched on this topic. I have tried reseting permalinks and deactivating/activating plugins. Neither seems to work. I have also tried changing the theme. Still nothing.
Any helpful suggestions are welcome
You have a problem with the form that does the redirect on that button. See below
<form method="link" action=" http://tazara.mwanawanga.com/?page_id=389">
<input type="submit" value="View fare charts and train timetables">
</form>
If you can see, theres a space in the action field of the form which will error the form's action and go to the root.
Try changing it for this:
<form method="link" action="http://tazara.mwanawanga.com/?page_id=389">
<input type="submit" value="View fare charts and train timetables">
</form>
The same will probably go for many other buttons on the site doing the same thing. I would personally recommend not using forms though and just creating a class which has the same styling as a form submit button and using a tags to link. It will be more search engine friendly and easier to use and maintain.

Drupal WebForm With PinPointe--Avoid Confirmation Page

Our company uses PinPointe for email marketing and we have a Drupal 6 site with several language domains. I have created a web form except I did not create any fields in Drupal. Instead in the node Edit NOT THE NODE WEBFORM EDIT....in the node edit for the body section I added the HTML and the javascript for form. Everything works well and the data is captured to pinpointe. The problem lies in the fact that the page..upon clicking submit..actually redirects to PinPointe where I get a friendly message saying. Thanks for joining. Well I don't want this. I would like to just pop an alert saying thanks and leave the user on the page they were on. I tried this code for using jquery to do the post but it isn't loading and I suspect that's because I need it in the header not the body.
So all I want is to submit the data to pinpointe and not redirect the user. So here is where my limited Drupal knowledge runs out:
If I create the input fields in the node webform then how do I get the form to post to pinpointe?
If I create the fields dynamically in the node body (not node>>webform) I can direct the submission to PinPointe but then how do I stop the redirect?
FWIW here is the jquery I was trying to use but suspect has to go in the header http://jsfiddle.net/4xDFK/4/
FWIW here is the code for the dynamic creation:
<form action="http://na04.mypinpointe.com/...." id="webform-client-form-1375" method="post" onsubmit="return CheckForm257(this);">
<div>
<div id="webform-component-UsrEmail">
<div id="edit-submitted-UsrEmail-wrapper">
<input id="edit-submitted-UsrEmail" name="email" size="30" type="email" />
</div>
</div>
<div class="form-actions form-wrapper" id="edit-actions">
<input class="form-submit" id="edit-submit" name="op" type="submit" value=" " />
</div>
</div>
</form>
Create your custom confirmation page in Drupal. Then set up PinPointe to redirect to this confirmation page.
In the PinPointe form manager, there is a option under the 'Thank you page options' to send a signup user to a custom URL.

Resources