<div class='ml-col-half'>
                <div class="ml-form-row ml-checkbox-wrap">
                    <input type="checkbox" id="ml_push_notification_enabled" name="ml_push_notification_enabled" value="true" <?php 
echo wp2android::get_option('ml_push_notification_enabled') ? 'checked' : '';
?>
/>
                    <label for="ml_push_notification_enabled">Send notifications automatically</label>
                </div>
                <p>Select which categories will generate a push notification (leave empty for all)</p>
                <select id="ml_push_notification_categories" name='ml_push_notification_categories[]' data-placeholder="Select Categories..." style="width:350px;" multiple class="chosen-select">
                    <option></option>
                    <?php 
$categories = get_categories();
?>
                    <?php 
$pushCategories = ml_get_push_notification_categories();
?>
                    <?php 
foreach ($categories as $c) {
    $selected = '';
    if (is_array($pushCategories) && count($pushCategories) > 0) {
        foreach ($pushCategories as $pushCategory) {
            if ($pushCategory->cat_ID == $c->cat_ID) {
                $selected = 'selected';
            }
        }
    }
    echo "<option value='{$c->cat_ID}' {$selected}>{$c->cat_name}</option>";
}
?>
                </select>
Beispiel #2
0
function ml_check_post_notification_required($postId)
{
    $notification_categories = ml_get_push_notification_categories();
    if (is_array($notification_categories) && count($notification_categories) > 0) {
        $post_categories = wp_get_post_categories($postId);
        $found = false;
        if (is_array($post_categories) && count($post_categories) > 0) {
            foreach ($post_categories as $post_category_id) {
                foreach ($notification_categories as $notification_category) {
                    if ($notification_category->cat_ID == $post_category_id) {
                        $found = true;
                    }
                }
            }
        }
        return $found;
    }
    return true;
}