コード例 #1
0
ファイル: crons.php プロジェクト: greathmaster/pmpro-series
function pmpros_check_for_new_content()
{
    global $wpdb;
    //get all members
    $users = $wpdb->get_results("\r\n        SELECT *\r\n        FROM {$wpdb->pmpro_memberships_users}\r\n        WHERE status = 'active'\r\n\t");
    //get all series
    $series = $wpdb->get_results("\r\n        SELECT *\r\n        FROM {$wpdb->posts}\r\n        WHERE post_type = 'pmpro_series'\r\n    ");
    //store emails to send
    $emails = array();
    //search through series looking for emails to send
    foreach ($series as $s) {
        $series = new PMProSeries($s->ID);
        $series_posts = $series->getPosts();
        if (empty($series_posts)) {
            continue;
        }
        foreach ($series_posts as $series_post) {
            foreach ($users as $user) {
                $notified = get_user_meta($user->user_id, 'pmpros_notified', true);
                if (empty($notified)) {
                    $notified = array();
                }
                if (pmpros_hasAccess($user->user_id, $series_post->id) && !in_array($series_post->id, $notified)) {
                    //add email to array to send
                    if (empty($emails[$user->user_id])) {
                        $emails[$user->user_id] = array();
                    }
                    $emails[$user->user_id][] = $series_post->id;
                    //$series->sendEmail($series_post->id, $user->user_id);
                }
            }
        }
    }
    //send emails
    foreach ($emails as $user_id => $posts) {
        //send email
        $series->sendEmail($posts, $user_id);
        //remember that we emailed about these posts
        $notified = get_user_meta($user_id, "pmpros_notified", true);
        if (!is_array($notified)) {
            $notified = array();
        }
        $notified = array_unique(array_merge($posts, $notified));
        update_user_meta($user_id, "pmpros_notified", $notified);
    }
}
コード例 #2
0
    static function seriesMetaBox()
    {
        global $post;
        $series = new PMProSeries($post->ID);
        ?>
		<div id="pmpros_series_posts">
		<?php 
        $series->getPostListForMetaBox();
        ?>
		</div>				
		<?php 
    }
コード例 #3
0
function pmpros_member_links_bottom()
{
    global $wpdb, $current_user;
    //get all series
    $all_series = $wpdb->get_results("\n        SELECT *\n        FROM {$wpdb->posts}\n        WHERE post_type = 'pmpro_series'\n    ");
    if (empty($all_series)) {
        return;
    }
    foreach ($all_series as $s) {
        $series = new PMProSeries($s->ID);
        $series_posts = $series->getPosts();
        if (!empty($series_posts)) {
            foreach ($series_posts as $series_post) {
                if (pmpros_hasAccess($current_user->user_id, $series_post->id)) {
                    ?>
					<li><a href="<?php 
                    echo get_permalink($series_post->id);
                    ?>
" title="<?php 
                    echo get_the_title($series_post->id);
                    ?>
"><?php 
                    echo get_the_title($series_post->id);
                    ?>
</a></li>
					<?php 
                }
            }
        }
    }
}