我在下面有这个代码。它的作用是在发布新帖子时显示一个弹出框(wordpress)。
我想在显示(触发)弹出窗口时添加声音。
任何想法?
function siki_newposts_alert_ajax() {
if(!empty($_POST['lastPostID']) && is_numeric($_POST['lastPostID'])) {
$last = wp_get_recent_posts('1');
$last_id = $last['0']['ID'];
// Checks is opening links in new page is enabled
$this->new_page ? $target = "target=\'_blank\'" : null;
$this->color == 'notification' || $this->color == 'success' ? $colour = '#000' : $colour = '#FFF';
$args = array(
'numberposts' => 8,
'offset' => 0,
'category' => 0,
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'post',
'post_status' => 'publish',
'suppress_filters' => true );
$recent_posts = wp_get_recent_posts($args);
echo "<script>\n";
foreach( $recent_posts as $recent ) {
/* Checking If Post Is In The Selected Categories */
$cat_ids = get_the_category($recent['ID']);
$publish = null;
foreach($cat_ids as $cat_id) {
$pub = $cat_id->cat_ID;
if(in_array($pub, $this->categories) || in_array(0, $this->categories)) {
$publish = true;
}
}
/*****/
if($recent['ID'] > $_POST['lastPostID'] && $publish) {
echo "generate('{$this->position}', '<strong><a style=\'color: {$colour};\' {$target} href=\'". get_permalink($recent["ID"]) ."\'>". addslashes($recent['post_title']) ."</a></strong>', '{$this->color}');\n";
echo "jQuery('div#sikiPostNum').html('{$last_id}');\n";
}
}
echo "</script>\n";
}
/*
* Custom Message
*/
if(strlen($this->message) > 0 && $this->enable_cm && $this->cookie_set != 1) { // If message is set and enabled and new
echo "<script>generate('{$this->position_cm}', '" . addslashes($this->message) . "', '{$this->color_cm}');</script>\n";
}
}
这是弹出框的视图源代码
<div class="noty_bar" id="noty_121015168773080340"><div class="noty_message" style="font-size: 23px; line-height: 16px; text-align: justify; padding: 18px 30px 19px; width: auto; position: relative;"><span class="noty_text"><strong><a style="color: #FFF;" href="http://fortsatos.com/test-4/">test</a></strong></span><div class="siki_close" style="height: 16px; width: 16px; position: absolute; right: 7px; top: 7px; cursor: pointer; background: url("data:image/gif;base64,R0lGODlhEAAQANU0AP///4ODg4WFhXZ2dnd3d3Nzc3p6eomJiYiIiGpqaoGBgW1tbW5ubmlpaYaGhouLi3FxcY+Pj3R0dHBwcICAgJOTk5CQkG9vb2xsbI6OjpWVlWZmZnh4eHx8fH5+fmdnZ3l5eYyMjGtra5GRkYeHh4SEhJaWlmhoaHV1dXJyco2NjZKSkoqKipiYmIKCgpSUlH9/f319fXt7e5eXl////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAADQALAAAAAAQABAAAAabQFprZtJUVpaI6nFAOErC4qsysmRCTJIgoKBIV6PIleXcKmAxI1LJdJZcFE/HQLUCAAdt4C43cMJXdwBbgjIgBANsTYKCBocoBVh5hI0cAxIFEGQOZoyIEikTF25wjHeZEwwLZhSCloIXDBgiXGh3nyl3CxgJDXFzj6iqIr0nfZaYELGzvR8fhriiu8UfGxs0BJAQqQvEDSfV10EAOw==") 0px 0px no-repeat scroll transparent;"></div></div></div>