Full Front End, AJAX comment system and comment reply script

<script> var addComment = { settings: function( parentId, postId ) { var t = $(this), commentDivName = $(‘#comment-‘+parentId), formDivName = $(‘#commentForm-‘+postId), formReplyDivName = $(‘#commentReplyForm-‘+parentId), postDivName = $(‘#post-‘+postId), theform = formDivName.find(‘form.comment-form’); if( !t.length || !commentDivName.length || !formDivName.length || !postDivName.length ) { return; } if(!theform.length){ $(postDivName).find(‘[id^=commentReplyForm-]’).each(function(){ if($(this).find(‘form.comment-form’).length){ formDivName = $(‘#’+$(this).attr(‘id’)); } }); theform = formDivName.find(‘form.comment-form’); } theform.find(‘input[name=parent]’).val(parentId); … Read more

How to change the text of the “You are about to permanently delete these items…” alert message when deleting media from the media library?

You could use the gettext filter. See the examples here https://codex.wordpress.org/Plugin_API/Filter_Reference/gettext. In your filter you will add code to check IF it’s the exact text you want to change then if the users meta value is what you are looking for the return the revised text. Else return the passed text unchanged.

Output multi-steps form results in same page

You will need a function that will handle the sent data from the form. Then you have to attach this function to the wp_ajax_nopriv_[your_action_name] hook. function process_form() { // process $_POST data, prepare $output to return // // send: array( ‘success’ => true, ‘data’ => $data ) wp_send_json_success( $data ); wp_die(); } // add_action( ‘wp_ajax_my_action’, … Read more

Get post content and show it in a div

OK, I managed to make it work, here’s how i did : Jquery part : jQuery(“.post-link”).click(function(){ var post_id = jQuery(this).data(‘id’); jQuery.post( ajaxurl, { ‘action’: ‘load_post_content’, ‘the_ID’: post_id }, function(response){ jQuery(‘#the-post-content’).html(response); } ); return false; }); And the function.php part : add_action( ‘wp_ajax_load_post_content’, ‘load_post_content’ ); add_action( ‘wp_ajax_nopriv_load_post_content’, ‘load_post_content’ ); function load_post_content() { $the_post_id = $_POST[‘the_ID’]; $args … Read more

jquery in wordpress plugin with depdendency

You will have to load jquery.formstyler first to use it in your ajax.js. You can add it as another dependancie like jquery itself. wp_enqueue_script( ‘my-ajax-handle’, plugin_dir_url( _FILE_ ) . ‘guards_search/js/ajax.js’, array( ‘jquery’, ‘jquery.formstyler’ ) ); Also you have a little syntax issue in: wp_register_style(‘jquery.formstyler’, plugin_dir_url( _FILE_ ) . ‘guards_search/js/jquery.formstyler.min.js’); It should be register script, not … Read more

How to disable a jQuery plugin on WordPress plugin page

Sure there is. https://codex.wordpress.org/Function_Reference/wp_dequeue_script /** * Dequeue the jQuery UI script. * * Hooked to the wp_print_scripts action, with a late priority (100), * so that it is after the script was enqueued. */ function wpdocs_dequeue_script() { wp_dequeue_script( ‘jquery-ui-core’ ); } add_action( ‘wp_print_scripts’, ‘wpdocs_dequeue_script’, 100 ); Obviously replace jquery-ui-core with the handler of the script … Read more

How to add plugin with jQuery to custom theme?

It should be said, that WordPress comes with jQuery out-of-the-box. You can check it, if you slap this in your page-template (based on this post): window.onload = function() { if (window.jQuery) { // jQuery is loaded alert(“Yeah!”); } else { // jQuery is not loaded alert(“Doesn’t Work”); } } In case you need other scripts, … Read more