예제 #1
0
function ml_post_published_notification($post_id)
{
    $post = get_post($post_id, OBJECT);
    $alert = $post->post_title;
    $custom_properties = array('post_id' => $post_id);
    //tags
    $tags = array();
    //subscriptions
    if (ml_subscriptions_enable()) {
        $tags[] = "all";
        $capabilities = ml_subscriptions_post_capabilities($post);
        foreach ($capabilities as $c) {
            $tags[] = $c;
        }
    } else {
        $tags[] = "all";
        $categories = wp_get_post_categories($post->ID);
        foreach ($categories as $c) {
            if ($c != NULL) {
                $tags[] = $c;
            }
        }
    }
    ml_send_notification($alert, true, NULL, $custom_properties, $tags, $post_id);
}
예제 #2
0
function ml_post_published_notification($new_status, $old_status = null, $post = null)
{
    if ($old_status === null || $post === null) {
        return;
    }
    if (ml_is_notified($post->ID) || !ml_check_post_notification_required($post->ID) || $post->post_type != 'post') {
        return;
    }
    if ($new_status == 'publish' && $old_status != 'publish') {
        // only send push if it's a new publish
        $alert = $post->post_title;
        $custom_properties = array('post_id' => $post->ID);
        //tags
        $tags = array();
        //subscriptions
        // if(ml_subscriptions_enable()) {
        // 	$tags[] = "all";
        // 	$capabilities = ml_subscriptions_post_capabilities($post);
        // 	foreach($capabilities as $c) {
        // 		$tags[] = $c;
        // 	}
        // } else {
        $tags[] = "all";
        $categories = wp_get_post_categories($post->ID);
        foreach ($categories as $c) {
            if ($c != NULL) {
                $tags[] = $c;
            }
        }
        // ml_send_notification($alert, true,NULL,$custom_properties,$tags,$post_id);
        ml_send_notification($alert, true, NULL, $custom_properties, NULL, strval($post->ID));
    }
}