Ejemplo n.º 1
0
/**
 * Display a list of possible alert types
 *
 * @since 0.1.0
 */
function wp_user_alerts_methods_picker()
{
    // Query for users
    $methods = wp_user_alerts_get_alert_methods();
    $long = wp_filter_object_list($methods, array('type' => 'long'));
    $short = wp_filter_object_list($methods, array('type' => 'short'));
    // Start a buffer
    ob_start();
    // Output methods
    ?>
<h4><?php 
    esc_html_e('Delivery Methods', 'wp-user-alerts');
    ?>
</h4>
	<p><?php 
    esc_html_e('Pick from several different communication methods, or leave empty to not alert anyone.', 'wp-user-alerts');
    ?>
</p>
	<div id="alert-methods" class="tabs-panel"><?php 
    // User Dashboard
    if (!empty($long)) {
        ?>
<div><h4><?php 
        esc_html_e('Full Text', 'wp-user-alerts');
        ?>
</h4><?php 
        wp_user_alert_methods_items($long);
        ?>
</div><?php 
    }
    // Direct
    if (!empty($short)) {
        ?>
<div><h4><?php 
        esc_html_e('Short Message (100 characters)', 'wp-user-alerts');
        ?>
</h4><?php 
        wp_user_alert_methods_items($short);
        ?>
</div><?php 
    }
    ?>
</div><div class="clear"></div><?php 
    // Send the buffer
    ob_flush();
}
Ejemplo n.º 2
0
/**
 * Return text to use as the message body, based on the alert method
 *
 * @since 0.1.0
 *
 * @param mixed $post
 */
function wp_user_alerts_get_alert_message_body($post = 0, $method = '')
{
    // Get the post
    $post = get_post($post);
    // Message
    $content = wp_kses($post->post_content, array());
    $message = wp_html_excerpt($post->post_content, 100);
    $excerpt = get_post_meta($post->ID, 'wp_user_alerts_message', true);
    // Override the message
    if (!empty($excerpt)) {
        $message = $excerpt;
    }
    // Get methods to check for override
    $methods = wp_user_alerts_get_alert_methods();
    // Use message
    $use_message = isset($methods[$method]->type) && 'short' === $methods[$method]->type;
    // Force the message
    if (!empty($message) && true === $use_message) {
        $content = $message;
    }
    return $content;
}