Category: Wordpress

DATABASE SEARCH AND REPLACE SCRIPT IN PHP outside wordpress

searchreplacedb21
search-replace-db-master

Database Importing error : utf8mb4_unicode_520_ci

find this
ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;

and change
ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

WP Rest API .htaccess settings

To fix “rest_user_cannot_view” error messsage in JWT Authentication for WP REST API

or to fix WP REST API RESPONSE

 

 

How to setup cron jobs in wordpress using right method?

Cron job is use for reminder related functionalities

Add this code in your wp-config.php

Add this this your cpanel command

Important part is url. You should set url in cron setup with ?doing_wp_cron
Suppose your url is http://yourdomain.com, then wordpress cron will be

http://yourdomain.com/wp-cron.php?doing_wp_cron

Add Pure Javascript Ajax in wordpress with preloader

<style type=”text/css”>
.rj_form{
position:relative;
}
.rj_form_preloader{
display:none;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(255,255,255,0.7);
text-align: center;
vertical-align: middle;
}
.rj_form_preloader span{

position: absolute;
top: 50%;
transform: translateY(-50%);
}
.rj_form[data-form-status=”submiting”]{

}
.rj_form[data-form-status=”submiting”] .rj_form_preloader{

display:block;
}
.rj_form[data-form-status=”submitted”] .rj_form_preloader{
display:none;
}
</style>
<script type=”text/javascript”>
var form = document.querySelector(‘.exam_questions_form’);
form.addEventListener(‘submit’,function(ev){
ev.preventDefault();
form.setAttribute(‘data-form-status’,’submiting’);
var formData = new FormData(form);

var r = new XMLHttpRequest();
r.open(“POST”, “<?php echo admin_url(‘admin-ajax.php’); ?>”, true);
r.onreadystatechange = function () {
if (r.readyState != 4 || r.status != 200) return;

form.setAttribute(‘data-form-status’,’submitted’);
console.log(r.responseText);
};
r.send(formData);
return false;
});

</script>

Add above code in your index.php file

<?php
add_action( ‘wp_ajax_get_course_result’, ‘my_action_callback’ );
add_action( ‘wp_ajax_nopriv_get_course_result’, ‘my_action_callback’ );
function my_action_callback(){
echo 1;
die(0);
}

Add above code in your functions.php file.