Esempio n. 1
0
/**
 * Display a list of possible alert types
 *
 * @since 0.1.0
 */
function wp_user_alerts_priority_picker()
{
    // Get the post type
    $post_type = get_post_type();
    // Query for users
    $priorities = wp_user_alerts_get_alert_priorities();
    // Get meta data
    $post = get_post();
    $_meta = get_post_meta($post->ID, 'wp_user_alerts_priority');
    ?>

	<h4><?php 
    esc_html_e('Delivery Priority', 'wp-user-alerts');
    ?>
</h4>
	<p><?php 
    esc_html_e('The color of each priority will be used to convey urgency to your members. It will also be prefixed on email subjects so your members can filter their inboxes appropriately.', 'wp-user-alerts');
    ?>
</p>
	<div id="alert-priorities" class="tabs-panel">
		<ul id="<?php 
    echo esc_attr($post_type);
    ?>
-checklist" data-wp-lists="list:<?php 
    echo esc_attr($post_type);
    ?>
" class="categorychecklist form-no-clear">

			<?php 
    foreach ($priorities as $priority_id => $priority) {
        ?>

				<li class="alert-priority-<?php 
        echo esc_attr($priority_id);
        ?>
">
					<label class="selectit">
						<input value="<?php 
        echo esc_attr($priority_id);
        ?>
" type="radio" name="wp_user_alerts_priorities[]" class="alert-priority" data-priority="<?php 
        echo esc_attr($priority_id);
        ?>
" id="" <?php 
        checked(in_array($priority_id, $_meta, true) || 'info' === $priority_id);
        ?>
 />
						<?php 
        echo esc_html($priority->name);
        ?>
					</label>
				</li>

			<?php 
    }
    ?>

		</ul>
	</div>

	<?php 
}
Esempio n. 2
0
/**
 * Get the priority of a post
 *
 * @since 0.1.0
 *
 * @param  int  $post_id
 *
 * @return object
 */
function wp_user_alerts_get_alert_priority($post_id = 0)
{
    // Get priority for alert
    $priority = get_post_meta($post_id, 'wp_user_alerts_priority', true);
    $priorities = wp_user_alerts_get_alert_priorities();
    // Use priority
    if (isset($priorities[$priority])) {
        return $priorities[$priority];
        // Fallback to "Info"
    } elseif (isset($priorities['info'])) {
        return $priorities['info'];
        // "Info" is broken, so force it
    } else {
        return (object) array('id' => 'info', 'name' => esc_html__('Info', 'wp-user-alerts'), 'callback' => '');
    }
}