Plugin settings page checkbox not saving - one options array with sub array

I'm driving myself crazy here trying to get a checkbox to save on a plugin settings page. Right now, as a template, I'm working through the excellent example given here: Settings API with arrays example I'm also referring to a very useful tutorial at https://www.smashingmagazine.com/2016/04/three-approaches-to-adding-configurable-fields-to-your-plugin/ with a detailed git at https://github.com/rayman813/smashing-custom-fields/blob/master/smashing-fields-approach-1/smashing-fields.php I've also read about a half dozen posts with similar questions but none have my answer, at least that I can find and understand. I think I'm stumbling on …
Category: Web

Refresh page after update_post_meta

I have created a input field on a front-page where the value of the database is on the same page as the input-field. If a value is passed to the database I have to reload the page for it to show on the page. Is there a way where I can automatically refresh the page after the value is passed to the database, so it is shows instantly? My guess would be JQuery but I don't know how! M.
Category: Web

Live search in admin page

I'm building a plugin that works only in admin. I've a page where the user choose some posts, the script generate a pdf file from this data and then it save in a specif folder. To help the user to choose the posts I would to do an input text with a "live search". The user select the post from the list result and the script add it in a list (and the post_id in a hidden input). I've searched …
Category: Web

input data and output table

I need a solution to do this with WP. In admin: I need to input data into database (name, surname, certification, level, date of issue). In Frontend: client can use a specific search field to search within the inserted data and get a table with the results. (name, surname, certification, level, date of issue). Any module can do this please.
Category: Web

Sanitizing comments or escaping comment_text()

I'm creating a template for comments on my WordPress site. I noticed that a simple <script>alert(1);</script> slips through the default WP codex implementation of comments, using the comment_text() function to display my comments. No bueno. How can i properly sanitize and/or escape WordPress comments? The esc_html() function, seems to do nothing in this case.
Category: Web

How to add "on change" to a text input in contact form7?

I am converting a static theme to a wp-theme and I am working on forms with wpcf7 plugin. I am wondering how can I write this code with wpcf7 text tag. <input type="text" name="name" id="name" value="" onchange="this.setAttribute('value',this.value);" required/> All what I could do is this [text* name id:name] my question is how can I add onchange to this text input ?
Category: Web

Adding text box with add_meta_box

This is my code: $configuracoes = register_post_type( 'configuracoes', $args ); $configuracoes->add_meta_box( 'dados', 'Personalize os dados de impressão', array( 'tabs', array( 'Dados Pessoais' => array( array( 'name' => 'Série', 'label'=> 'Série', 'type' => 'text', 'underscore' => false ) ), 'Dados Profissionais' => array( array( 'name' => 'Tempo de Profissão', 'label'=> 'Tempo de Profissão', 'type' => 'text', 'underscore' => false ), ) ) ) This code generates this form: How can I put in place of the input, a text box similar …
Category: Web

how to upload a image from frontend with wp_insert_post and also update_post_meta?

I am using cmb2 for frontend form submission with custom post type name 'form'. But can not upload image with that. the first step is: array( 'name' => 'Image', 'type' => 'file', 'id' => '_first_image', 'options' => array( 'url' => true, // Hide the text input for the url ), 'text' => array( 'add_upload_file_text' => 'Upload your image image', // Change upload button text. Default: "Add or Upload File" ), ), my form is: <form method="post" action="" id="form"> <div class="student-image"> …
Category: Web

$_POST field value gets altered after "init"

I'm new to wordpress development. I'm trying to develop a simple plugin for practice. It involves a form submission from the frontend. The form has an input with the following code. <input type='hidden' name='test' value='{"id": 1}'/> When I submit the form, the value of 'test' field gets altered after the "init" hook. My plugin code looks like the following add_action('init', [$this, 'init']); function init() { printe_r($_POST); } Output: Array ( [test] => {\"id\":1} ) The problem is that json_decode errors …
Category: Web

Add a second rich text input to post editor, and make that content available in post template

As per title, I want to add a second rich text editor (or whatever that's called now?) to the Post edit page, and then allow the content from that to be easily insertable inside any Post template page. I've found a couple of references of how to do this, this one particularly is the same question, but from a long time ago with now outdated answers. Thanks!
Category: Web

How to use jQuery(...).material_chip inside WordPress?

Although I have imported materialize.js (v1.0.0) inside my plugin in WordPress with $pluginpath = dirname (plugin_dir_url( __DIR__ )); $pluginpath = str_replace('\\','/',$pluginpath); $thepath = $pluginpath . '/js_libs/materialize.js'; wp_enqueue_script('wpunity_materialize_jslib', $thepath); and in my main function wp_register_script( 'wpunity_materialize_jslib', plugin_dir_url( __FILE__ ) . 'js_libs/materialize.js', null, null, false); I keep getting jQuery(...).material_chip is not a function for this code <div id="textarea-collaborators" class="chips-autocomplete"></div> <script> jQuery( document ).ready(function() { jQuery('.chips-autocomplete').material_chip({ secondaryPlaceholder: 'Your collaborator email', placeholder: 'Your collaborator email' }); }); </script>
Category: Web

Enter name and email on the Product page and keep the input data on the Checkout page

I developed a custom Product page where I have to place the form with the Name field and Email address field. When I click a Purchase button Woocommerce links me to the Checkout Page (I avoided the Cart page). How can enter name and email on the Product page and keep the input data on the Checkout page? I broke my head trying to find an appropriate solution, but unfortunately can't get how I can do that. Much appreciate any …
Category: Web

Custom Formdata matching with user table

I am writing a code to match form input data with user table in wp, but its not working proper, either condition is true or false, its giving same message. please help me to resolve it. function email_form_code() { echo '<form action="' . esc_url( $_SERVER['REQUEST_URI'] ) . '" method="post">'; echo '<p>'; echo '<p>'; echo 'Your Email (required) <br />'; echo '<input type="email" name="email" value="' . ( isset( $_POST["email"] ) ? esc_attr( $_POST["email"] ) : '' ) . '" size="40" />'; …
Category: Web

Sanitizing integer input for update_post_meta

When updating a post meta where the input will be always an integer, should I use (int) or is there a WordPress function for that (eg. sanitize_text_field)? For example: if(isset($_POST['category_id'])){ update_post_meta($post->ID, 'category_id', (int)($_POST['category_id'])); }
Category: Web

Wordpress search with more input fields?

I have this example of working search: <form action="<?php echo esc_url(site_url('/')) ; ?>" method="get"> <input type="search" name"s"> <input type="submit" value="search"> </form> and this works great, but what I want to archive is to make this search work with two more select boxes: <form action="<?php echo esc_url(site_url('/')) ; ?>" method="get"> <select name=""> <option>Option one</option> <option>Option one</option> </select> <select name=""> <option>Option A</option> <option>Option B</option> </select> <input type="search" name"s"> <input type="submit" value="search"> </form> How do I go around to make this post do …
Category: Web

Redirect when user clicks on an image

I want to make it so that when a user clicks on an image in my site, they are redirected to a specific page. I WAS using a submit button for the redirect, but I want to replace it with a custom-designed icon which I have saved as a png. Here's what I used to have: <form method='post' id='back_button' action=''> <p class='form-submit'> <input name='back_button' type='submit' id='back_button' class='submit button' value= 'Go Back' /> </p> </form> In functions.php, I have this hooked …
Category: Web

Desktop is class List and Mobile is class Grid

<input type="radio" class="list" checked> <!-- checked, desktop --> <input type="radio" class="grid"> <!-- checked, mobile --> Here class list is desktop and mobile. I know it is css media screen. How can I change the mobile is class grid and desktop is class list? Now it is only list on the first, both desktop and mobile.
Category: Web

Send attachments via wp_mail from temporary folder

Is it possible to send attachment via wp_mail, using temporary file, instad of uploading them to any actual folder on server? For example: <input type="file" name="file"> $attachment[] = $_FILES['file']['name']; wp_mail(....,$attachment); Documentation: The filenames in the $attachments attribute have to be filesystem paths. How can i get the path for temporary file (if this is possible)?
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.