I’ve some code in my features.php that, below a particular time situation, showes a popup that notices about some database replace routine. What is going on right here, is that when this situation occurs, I place html + script code in my footer by the wp_footer motion, that calls an ajax motion for beginning these updates. Due to this time situation and different stuffs, I’ve some variables that has the identical worth in wp_footer and in wp_ajax_update_db, so I wish to write these variables just one time for each the actions. That is my features.php like code
/**
* Popup for html to point out replace progress
*/
add_action('wp_footer', perform() {
$var1 = 'some worth';
$var2 = 'some worth';
$var3 = 'some worth';
if( $timeCondition ){
// My name to ajax update_db
// Rendered Html
}
}
/**
* Engine for the replace routine
*/
add_action('wp_ajax_update_db', 'update_db');
add_action('wp_ajax_nopriv_update_db','update_db');
perform update_db() {
$var1 = 'some worth';
$var2 = 'some worth';
$var3 = 'some worth';
// Code for updating the dbs
}
I used to be pondering that I might wrap the wp_ajax_update_db contained in the wp_footer motion and declare the variables solely at first, however I do not know if that is the appropriate approach, like this
/**
* Popup for html to point out replace progress
*/
add_action('wp_footer', perform() {
$var1 = 'some worth';
$var2 = 'some worth';
$var3 = 'some worth';
if( $timeCondition ){
// My name to ajax update_db
// Rendered Html
/**
* Engine for the replace routine
*/
add_action('wp_ajax_update_db', 'update_db');
add_action('wp_ajax_nopriv_update_db','update_db');
perform update_db() {
// Code for updating the dbs
}
}
}