add_action(\'wp_ajax_nopriv_updating_heat_value\',\'updating_heat_value\');
add_action(\'wp_ajax_updating_heat_value\',\'updating_heat_value\');
add_action(\'wp_ajax_update_reading_history\',\'update_reading_history\');
function update_reading_history() {
global $post;
if(is_normal_post()) {
$postiddx2 = get_the_ID();
$thepost = get_post($postiddx2);
if(!(wp_is_post_revision($thepost)))
{
$userid1 = get_current_user_id();
$loggedreadinghistory = get_user_meta($userid1, \'readinghistory\', true);
if($loggedreadinghistory == \'\') {
$readinghistory = $postiddx2;
update_user_meta($userid1, \'readinghistory\', $readinghistory);
}
else
{
$readinghistory = $loggedreadinghistory;
$readinghistory = $readinghistory.\',\'.$postiddx2;
update_user_meta($userid1, \'readinghistory\', $readinghistory);
}
}
}
exit();
}
function updating_heat_value()
{
global $post;
if(is_single())
{
$postiddx = get_the_ID();
$timenow = time();
$heatvaluedate = get_post_meta($postiddx, \'heatvaluedate\');
if((get_post_meta($postiddx, \'heatvalue\') == \'\') || $heatvaluedate == \'\')
{
update_post_heat_value($postiddx);
}
elseif(($timenow - $heatvaluedate) >= 600)
{
update_post_heat_value($postiddx);
}
}
exit();
}
我想将此PHP代码添加到wp\\U ajax挂钩中,但我不知道这些函数是如何执行的。有什么问题吗?这是这样做的最佳方式吗?