admin_post hook not firing function inside class
admin_post hook not firing function inside class
admin_post hook not firing function inside class
Here’s what I think is happening. I’ve added comments to the relevant sections of your code. // You use the $_FILES superglobal to get the uploaded files. if (isset($_FILES[‘file_metabox’])) { $file_metabox = $_FILES[‘file_metabox’]; foreach ($file_metabox[‘name’] as $key => $value) { if ($file_metabox[‘name’][$key]) { // … // Here you **overwrite** the $_FILES superglobal. $_FILES = array(“file_metabox” … Read more
In ACF for Authors, you need to supply the author in ‘user_’.$user_id format. Which would be this: echo get_field( ‘students_no_class’, ‘user_’. get_queried_object()->ID ); or this: the_field( ‘students_no_class’, ‘user_’. get_queried_object()->ID );
This code will call your function every hour. // The ‘if’ condition is needed to make sure the scheduler runs only once if ( ! wp_next_scheduled( ‘my_custom_action’ ) ){ wp_schedule_event( time(), ‘hourly’, ‘my_custom_action’ ); } // Here we create our own action to attach to the scheduler add_action( ‘my_custom_action’, ‘update_content’ ); It is also recommended … Read more
You can change the sort order on a category archive page to show posts by title (A-Z) by adding this code to your child theme’s functions.php: /* Sort posts by title for a specific category */ function change_category_order( $query ) { //Sort all posts from category with id=3 by title if($query->is_category(‘3’) && $query->is_main_query()){ $query->query_vars[‘orderby’] = … Read more
Is there a way to prevent user from entering script tag to the form? Yes, escaping. It is one of the fundamental cornerstones of web security, and completely missing from the code in the question. Take this example: <a href=”<?php echo $foo; ?>”> How do we know it’s actually a URL? Your colleague has said … Read more
Because you want to run JS code, using WordPress post action handler will not give you the solution. You will need to use ajax for that. I have created a small example you can copy/paste. <form method=”post” class=”myform”> <input type=”hidden” name=”action” value=”add_foobar”> <input type=”hidden” name=”data” value=”foobarid”> <input type=”submit” value=”Submit”> </form> For our form I removed … Read more
To answer my own question, WordPress does not appear to make any changes to the database after a post “Update” that contained no changes. Any changes that happen should be the result of a theme or plugin. However, the Advanced Custom Fields (ACF) plugin does. Specifically, if ACF fields are set (such as through WP … Read more
@wordpress/scripts advanced usage
wordpress plugin add page when activate