Exemple #1
0
function openbadger_admin_notices()
{
    global $openbadger_db_version;
    if (get_option('openbadger_db_version') != $openbadger_db_version && $_POST['openbadger_db_version'] != $openbadger_db_version) {
        $configlink = '<a href="' . admin_url('options-general.php?page=openbadger_configure_plugin') . '">';
        $configlink_end = '</a>';
        ?>
        <div class="updated">
            <p><?php 
        echo sprintf(__('openBadger has been updated! Please go to the %s configuration page %s and update the database', 'rpibadger'), $configlink, $configlink_end);
        ?>
.</p>
        </div>
        <?php 
    } elseif (!openbadger_configured()) {
        ?>
        <div class="error">
            <p><?php 
        echo sprintf(__('openBadger has been updated! Please go to the %s configuration page %s and update the database', 'rpibadger'), $configlink, $configlink_end);
        ?>
.</p>
        </div>
        <?php 
    }
}
Exemple #2
0
 function send_email($post_id)
 {
     // Verify that post has been published, and is an award
     if (get_post_type($post_id) != $this->get_post_type_name()) {
         return;
     }
     if (!get_post_meta($post_id, 'openbadger-award-valid', true)) {
         return;
     }
     if (get_post_meta($post_id, 'openbadger-award-status', true) != 'Awarded') {
         return;
     }
     if (!openbadger_configured()) {
         return;
     }
     $badge_id = (int) get_post_meta($post_id, 'openbadger-award-choose-badge', true);
     if (!$badge_id) {
         return;
     }
     $email_address = get_post_meta($post_id, 'openbadger-award-email-address', true);
     if (get_post_meta($post_id, 'openbadger-award-email-sent', true) == $email_address) {
         return;
     }
     $badge_title = get_the_title($badge_id);
     $badge_url = get_permalink($badge_id);
     $badge_image_id = get_post_thumbnail_id($badge_id);
     $badge_image_url = wp_get_attachment_url($badge_image_id);
     $badge_desc = get_post_meta($badge_id, 'openbadger-badge-description', true);
     $award = get_post($post_id);
     $award_title = get_the_title($post_id);
     $award_url = get_permalink($post_id);
     $award_evidence = $award->post_content;
     $subject = openbadger_template(get_option('openbadger_awarded_email_subject'), array('BADGE_TITLE' => $badge_title, 'AWARD_TITLE' => $award_title));
     $subject = apply_filters('openbadger_awarded_email_subject', $subject);
     $message = openbadger_template(get_option('openbadger_awarded_email_html'), array('BADGE_TITLE' => esc_html($badge_title), 'BADGE_URL' => $badge_url, 'BADGE_IMAGE_URL' => $badge_image_url, 'BADGE_DESCRIPTION' => esc_html($badge_desc), 'AWARD_TITLE' => esc_html($award_title), 'AWARD_URL' => $award_url, 'AWARD_ACCEPT_URL' => $award_url . '?awarded', 'EVIDENCE' => $award_evidence));
     add_filter('openbadger_awarded_email_html', 'wptexturize');
     add_filter('openbadger_awarded_email_html', 'convert_chars');
     add_filter('openbadger_awarded_email_html', 'wpautop');
     $message = apply_filters('openbadger_awarded_email_html', $message);
     wp_mail($email_address, $subject, $message, array('Content-Type: text/html'));
     update_post_meta($post_id, 'openbadger-award-email-sent', $email_address);
 }