function ml_push_notification_manual_send_callback() { if (isset($_POST['ml_push_notification_msg'])) { $platform = array(); switch ($_POST['ml_push_notification_os']) { case 'all': $platform = array(0, 1); break; case 'android': $platform = array(1); break; case 'ios': $platform = array(0); break; } $tags = array(); $tagNames = array(); $postId = null; if (strlen($_POST['ml_push_notification_data_id']) > 0) { if (strpos($_POST['ml_push_notification_data_id'], 'custom') !== false) { $postId = $_POST['ml_push_notification_post_id']; } else { $postId = substr($_POST['ml_push_notification_data_id'], 8); } } if ($postId != null) { $tags = ml_get_post_tag_ids($postId); $tagNames = ml_get_post_tags($postId); } $tags[] = 'all'; $tagNames[] = 'all'; $payload = array(); if ($postId !== null) { $image = wp_get_attachment_image_src(get_post_thumbnail_id($postId), 'single-post-thumbnail'); $payload = array('post_id' => $postId); if (is_array($image)) { $payload['featured_image'] = $image[0]; } } $data = array('platform' => $platform, 'msg' => trim($_POST['ml_push_notification_msg']), 'sound' => 'default', 'badge' => null, 'notags' => true, 'tags' => $tags, 'payload' => $payload); ml_pb_send_batch_notification($data, $tagNames); Mobiloud_Admin::track_user_event('push_notification'); } ml_push_notification_manual_send(); die; }
</div> <?php } else { ?> <form method="post" action="<?php echo admin_url('admin.php?page=wp2android_push&tab=notifications'); ?> "> <?php wp_nonce_field('form-push_notifications'); ?> <h3>Send manual message</h3> <div id="success-message" class="updated" style="display: none;">Your message has been sent!</div> <?php ml_push_notification_manual_send(); ?> <h3>Notification history</h3> <!-- NOTIFICATIONS LIST --> <div id="ml_push_notification_history"> <?php ml_push_notification_history_ajax_load(); ?> </div> </form> <?php } ?> </div>