Wp_localize_script( 'ajax_comment', 'misha_ajax_comment_params', array( let's pass ajaxurl here, you can do it directly in JavaScript but sometimes it can cause problems, so better is PHP Wp_register_script( 'ajax_comment', get_stylesheet_directory_uri(). just register for now, we will enqueue it below I think jQuery is already included in your theme, check it yourself htpasswd or by IP, please read this.Īdd_action( 'wp_enqueue_scripts', 'misha_ajax_comments_scripts' ) If you blocked your /wp-admin/ area with. Our task in this step is to include to our website pages jQuery, our custom script and print the URL of the WordPress AJAX. elements are the same like in depth-1 level -> You shouldn’t copy this code anywhere – just look if your theme comment structure is similar to it, if no – you should make changes either in your theme HTML structure or in Step 3 of this tutorial. In this post I will make the AJAX comments for WordPress default TwentySeventeen theme, but I can not even imagine what theme you will use. I begin with the words that each WordPress theme differs. If you do not have the advanced level of knowing such things as DOM traversal, please, be very careful at this step. Can not imagine that HTML could be the most difficult part? Surprise! Save in cookies the values of user Name and Email fields.Remove disallowed HTML tags from comment text.For simpleness I will do it with the JavaScript alert() function in this post. All the comment errors should be displayed properly.One of the most wanted functions – support of nested comments with comment-reply.js.I suggest you to overview the AJAX comment functionality we will create. By the way I redesigned my WordPress dashboard a little – the latest 30 comments are showing there now.īefore we begin coding there would be some more text to read. I decide how to filter them from spam, I decide what HTML tags to allow in comment body, I can force users to purchase a website membership before submitting a comment etc.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |