Example #1
0
/**
 * API method to check if a user has access to a certain post.
 * Since v2.0
 */
function pmpro_xmlrpc_hasMembershipAccess($args)
{
    // Parse the arguments, assuming they're in the correct order
    $username = $args[0];
    $password = $args[1];
    $post_id = $args[2];
    //post id to check
    $user_id = $args[3];
    //optional user id passed in
    $return_membership_levels = $args[4];
    //option to also include an array of membership levels with access to the post
    global $wp_xmlrpc_server;
    // Let's run a check to see if credentials are okay
    if (!($user = $wp_xmlrpc_server->login($username, $password))) {
        return $wp_xmlrpc_server->error;
    }
    // The user passed should be an admin or have the pmpro_xmlprc capability
    if (!user_can($user->ID, "manage_options") && !user_can($user->ID, "pmpro_xmlrpc")) {
        return "ERROR: User does not have access to the PMPro XMLRPC methods.";
    }
    // Default to logged in user if no user_id is given.
    if (empty($user_id)) {
        $user_id = $user->ID;
    }
    $has_access = pmpro_has_membership_access($post_id, $user_id, $return_membership_levels);
    return $has_access;
}
Example #2
0
function pmprocpt_template_redirect()
{
    $selected_cpts = pmprocpt_getCPTs();
    $options = get_option('pmprocpt_options');
    $redirect_to = intval($options['redirect_to'][0]);
    if (!pmpro_has_membership_access() && is_singular($selected_cpts) && !empty($redirect_to)) {
        //wp_redirect(pmpro_url('levels');
        wp_redirect(get_permalink($redirect_to));
        exit;
    }
}
 /**
  * Paid Membership Pro
  * Show Builder contents only if user has access
  *
  * @return bool
  */
 public function pmpro_themify_builder_display($display, $post_id)
 {
     $hasaccess = pmpro_has_membership_access(NULL, NULL, true);
     if (is_array($hasaccess)) {
         //returned an array to give us the membership level values
         $post_membership_levels_ids = $hasaccess[1];
         $post_membership_levels_names = $hasaccess[2];
         $hasaccess = $hasaccess[0];
     }
     if (!$hasaccess) {
         return false;
     }
     return $display;
 }
function membership_okay()
{
    if (function_exists("pmpro_membership_content_filter")) {
        $hasaccess = pmpro_has_membership_access(NULL, NULL, true);
        if (is_array($hasaccess)) {
            //returned an array to give us the membership level values
            $post_membership_levels_ids = $hasaccess[1];
            $post_membership_levels_names = $hasaccess[2];
            $hasaccess = $hasaccess[0];
        }
        return $hasaccess;
    }
    return true;
    // default to a true return if membership pro is not installed
}
function acceptance_videos_func($atts)
{
    global $wpdb, $pmpro_msg, $pmpro_msgt, $pmpro_levels, $current_user, $levels;
    $type = 'video';
    $max_count = 0;
    /*
     +===================================+
     | BEGIN 'Acceptance'                |
     +===================================+
    */
    $acceptance = array();
    $empty_acceptance = true;
    $args = array('post_type' => array($type), 'post_status' => 'publish', 'caller_get_posts' => 1, 'tax_query' => array(array('taxonomy' => 'categories', 'field' => 'slug', 'terms' => 'acceptance')));
    $acceptance_query = null;
    $acceptance_query = new WP_Query($args);
    if ($acceptance_query->have_posts()) {
        while ($acceptance_query->have_posts()) {
            $acceptance_query->the_post();
            $thumbnail = "";
            $video_thumbnail_url = get_field('video_thumbnail', $post_id = $post->ID);
            if (!empty($video_thumbnail_url)) {
                $thumbnail = '<img src="' . $video_thumbnail_url . '" alt="" class="img-responsive">';
            }
            $col = '<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">' . '<a class="dashboard-stat acceptance dashboard-stat-light blue-soft" href="' . get_the_permalink($post_id = $post->ID) . '">' . '<div class="visual">' . '<div class="overlay"></div>' . $thumbnail . '</div>' . '<div class="details">' . '<div class="number">' . the_title($before = '', $after = '', $echo = false) . '</div>' . '</div>' . '<span class="caption-helper">' . '<ul class="post-meta clr">' . '<li class="meta-date">' . 'Posted on <span class="meta-date-text">' . get_the_date() . '</span>' . '</li>' . '</ul><!-- .post-meta -->' . '</span>' . '</a>' . '</div>';
            $hasaccess = pmpro_has_membership_access($post_id = $post->ID, $user_id = $current_user->ID, $return_membership_levels = false);
            if ($hasaccess) {
                $acceptance[] = $col;
            }
        }
    }
    $tmp = count($acceptance);
    if ($tmp > $max_count) {
        $max_count = $tmp;
    }
    wp_reset_query();
    ?>
    <!-- BEGIN VIDEOS MENU-->
    <div class="row top-category">
        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
            <div class="easy-pie-chart">
                <div class="number bounce" data-percent="46">
                    <img src="<?php 
    echo get_template_directory_uri();
    ?>
/assets/global/img/acceptance-color.png" alt="" class=""/>
                </div>
                <a class="title" href="#">
                    Acceptance
                </a>
            </div>
        </div>
    </div>
    <div class="clearfix">
    </div>
    <div class="page-bar" style="height: 16px; width: 80%; text-align: center; margin: auto auto 75px auto;padding-top: 7px;">
        <div class="line" style="width: 100%; color: #1977ba; border-top: 2px dotted #1977ba; margin: auto;"></div>

        <div class="line-left" style=" padding: 0px 0px 0px 7px; background-color: #ffffff; height: 45px;width: 16px; margin-top: -2px;  float: left;">
            <div class="line" style="color: #1977ba;  border-left: 2px dotted #1977ba;   margin: auto; height: 100%; position: relative; display: block;">
                <div class="arrow-down" style=" width: 0px;   height: 0px;   border-left: 20px solid transparent;   border-right: 20px solid transparent;  border-top: 20px solid #FFF; bottom: -18px;position: absolute; left: -21px;">
                </div>
            </div>
        </div>

        <div class="middle-container-left" style="display: block; position: relative; width: 47%; float: left; margin: auto; text-align: center;">
            <div class="line-middle" style="padding: 0px 0px 0px 7px;   background-color: #ffffff; height: 45px; width: 16px; margin-top: -2px; margin:-2px 29% auto auto; text-align: center;">
                <div class="line" style="color: #1977ba; border-left: 2px dotted #1977ba;  margin: auto; height: 100%; position: relative; display: block;">
                    <div class="arrow-down" style="width: 0px;   height: 0px;   border-left: 20px solid transparent; border-right: 20px solid transparent; border-top: 20px solid #FFF; bottom: -18px; position: absolute; left: -21px;">
                    </div>
                </div>
            </div>
        </div>          
        <div class="middle-container-right" style="display: block; position: relative; width: 48%; float: left; margin: auto; text-align: center;">
            <div class="line-middle-right" style="padding: 0px 0px 0px 7px; background-color: #ffffff; height: 45px; width: 16px; margin-top: -2px; margin: -2px auto auto 35%; text-align: center;">
                <div class="line" style="color: #1977ba; border-left: 2px dotted #1977ba; margin: auto;  height: 100%; position: relative; display: block;">
                    <div class="arrow-down" style="width: 0px; height: 0px;  border-left: 20px solid transparent; border-right: 20px solid transparent; border-top: 20px solid #FFF; bottom: -18px; position: absolute; left: -21px; ">
                    </div>
                </div>
            </div>
        </div>
        <div class="line-right" style="padding: 0px 0px 0px 7px;   background-color: #ffffff; height: 45px; width: 16px; margin-top: -2px; float: right; ">
            <div class="line" style="color: #1977ba; border-left: 2px dotted #1977ba; margin: auto; height: 100%; position: relative; display: block;">
                <div class="arrow-down" style="width: 0px;   height: 0px;   border-left: 20px solid transparent;   border-right: 20px solid transparent; border-top: 20px solid #FFF; bottom: -18px; position: absolute; left: -21px;">
                </div>   
            </div>
        </div>
    </div>
    <div class="clearfix">
    </div>
    <!-- END VIDEOS MENU-->
    <!-- BEGIN VIDEO LIST-->
    <div class="row init-row">
        <?php 
    for ($i = 0; $i <= $max_count; $i++) {
        ?>

            <?php 
        if (isset($acceptance[$i])) {
            echo $acceptance[$i];
        } else {
            echo '<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12"></div>';
        }
        ?>

        <?php 
    }
    ?>
    </div>
    <div class="clearfix">
    </div>
    <!-- END VIDEOS LIST-->
    <?php 
}
 /**
  * Hook to content filter to show builder output
  * @param $content
  * @return string
  */
 function builder_show_on_front($content)
 {
     global $post, $wp_query;
     if (is_admin()) {
         return $content;
     }
     // Disable builder on admin post list
     if (is_post_type_archive() && !is_post_type_archive('product') || post_password_required() || isset($wp_query->query_vars['product_cat']) || is_tax('product_tag')) {
         return $content;
     }
     if (is_singular('product') && 'product' == get_post_type()) {
         return $content;
     }
     // dont show builder on product single description
     if (is_post_type_archive('product') && get_query_var('paged') == 0 && $this->builder_is_plugin_active('woocommerce/woocommerce.php')) {
         $post = get_post(woocommerce_get_page_id('shop'));
     }
     if (!is_object($post)) {
         return $content;
     }
     // Paid Membership Pro
     if (defined('PMPRO_VERSION')) {
         $hasaccess = pmpro_has_membership_access(NULL, NULL, true);
         if (is_array($hasaccess)) {
             //returned an array to give us the membership level values
             $post_membership_levels_ids = $hasaccess[1];
             $post_membership_levels_names = $hasaccess[2];
             $hasaccess = $hasaccess[0];
         }
         if (!$hasaccess) {
             return $content;
         }
     }
     // Members
     if (class_exists('Members_Load')) {
         if (!members_can_current_user_view_post(get_the_ID())) {
             return $content;
         }
     }
     // Infinite-loop prevention
     if (empty($this->post_ids)) {
         $this->post_ids[] = $post->ID;
     } elseif (in_array($post->ID, $this->post_ids)) {
         // we have already rendered this, go back.
         return $content;
     }
     $this->post_ids[] = $post->ID;
     $builder_data = $this->get_builder_data($post->ID);
     if (!is_array($builder_data) || strpos($content, '#more-')) {
         $builder_data = array();
     }
     if ($this->in_the_loop) {
         $content .= $this->retrieve_template('builder-output-in-the-loop.php', array('builder_output' => $builder_data, 'builder_id' => $post->ID), '', '', false);
     } else {
         $content .= $this->retrieve_template('builder-output.php', array('builder_output' => $builder_data, 'builder_id' => $post->ID), '', '', false);
     }
     if (array_shift($this->post_ids) == $post->ID) {
         // the loop is finished, reset the ID list
         $this->post_ids = array();
     }
     return $content;
 }
/**
 * Adds custom classes to the array of body classes.
 * Same as the above, but acts on the "queried object" instead of the post global.
 *
 * pmpro-body-level-required = this post requires at least one level
 * pmpro-body-level-1 = this post requires level 1
 * pmpro-body-has-access = this post is usually locked, but the current user has access to this post
 *
 * @param array $classes Classes for the body element.
 * @return array
 *
 * @since 1.8.6.1
 */
function pmpro_body_classes($classes)
{
    $post = get_queried_object();
    if (empty($post) || !is_singular()) {
        return $classes;
    }
    $post_levels = array();
    $post_levels = pmpro_has_membership_access($post->ID, NULL, true);
    if (!empty($post_levels)) {
        if (!empty($post_levels[1])) {
            $classes[] = 'pmpro-body-level-required';
            foreach ($post_levels[1] as $post_level) {
                $classes[] = 'pmpro-body-level-' . $post_level[0];
            }
        }
        if (!empty($post_levels[0]) && $post_levels[0] == true) {
            $classes[] = 'pmpro-body-has-access';
        }
    }
    return $classes;
}
Example #8
0
/**
 * Adds custom classes to the array of post classes.
 *
 * pmpro-level-required = this post requires at least one level
 * pmpro-level-1 = this post requires level 1
 * pmpro-has-access = this post is usually locked, but the current user has access to this post
 *
 * @param array $classes Classes for the post element.
 * @return array
 *
 * @since 1.8.5.4
 */
function pmpro_post_classes($classes)
{
    global $post;
    $post_levels = array();
    $post_levels = pmpro_has_membership_access($post->ID, NULL, true);
    if (!empty($post_levels)) {
        if (!empty($post_levels[1])) {
            $classes[] = 'pmpro-level-required';
            foreach ($post_levels[1] as $post_level) {
                $classes[] = 'pmpro-level-' . $post_level[0];
            }
        }
        if (!empty($post_levels[0]) && $post_levels[0] == true) {
            $classes[] = 'pmpro-has-access';
        }
    }
    return $classes;
}
<?php

/**
 * The Template for displaying all single posts.
 *
 * @package WordPress
 * @subpackage Elegant WPExplorer Theme
 * @since Elegant 1.0
 */
get_header("dashboard");
global $wpdb, $pmpro_msg, $pmpro_msgt, $pmpro_levels, $current_user, $levels;
$return_membership_levels = pmpro_has_membership_access($post_id = $post->ID, $user_id = $current_user->ID, $return_membership_levels = true);
if (empty($return_membership_levels[2]) && $return_membership_levels[0]) {
    $hasaccess = FALSE;
} else {
    $hasaccess = $return_membership_levels[0];
}
if ($hasaccess) {
    ?>
    <!-- BEGIN CONTENT -->
    <div class="page-content-wrapper">
        <div class="page-content">
            <div class="row">
                <div class="col-md-8 col-sm-8 col-sm-offset-2 col-md-offset-2">
                    <!-- BEGIN PORTLET-->
                    <?php 
    while (have_posts()) {
        the_post();
        ?>
                        <?php 
        $term_list = wp_get_post_terms($post->ID, 'categories', array("fields" => "all"));
function pmproap_getLevelIDForCheckoutLink($post_id = NULL, $user_id = NULL)
{
    global $current_user, $post;
    //default to current user
    if (empty($user_id) && !empty($current_user) && !empty($current_user->ID)) {
        $user_id = $current_user->ID;
    }
    //default to current post
    if (empty($post_id) && !empty($post) && !empty($post->ID)) {
        $post_id = $post->ID;
    }
    //no post, we bail
    if (empty($post_id)) {
        return false;
    }
    //no user id? make sure it's null
    if (empty($user_id)) {
        $user_id = NULL;
    }
    //use current level or offer a free level checkout
    $has_access = pmpro_has_membership_access($post_id, $user_id, true);
    $post_levels = $has_access[1];
    //make sure membership_level obj is populated
    if (is_user_logged_in()) {
        $current_user->membership_level = pmpro_getMembershipLevelForUser($current_user->ID);
    }
    if (!empty($current_user->membership_level) && in_array($current_user->membership_level->ID, $post_levels)) {
        $text_level_id = $current_user->membership_level->id;
    } elseif (!empty($post_levels)) {
        //find a free level to checkout with
        foreach ($post_levels as $post_level_id) {
            $post_level = pmpro_getLevel($post_level_id);
            if (pmpro_isLevelFree($post_level)) {
                $text_level_id = $post_level->id;
                break;
            }
        }
    }
    //didn't find a level id to use yet? return false and user's will be linked to the levels page.
    if (empty($text_level_id)) {
        $text_level_id = false;
    }
    return $text_level_id;
}
Example #11
0
function pmpro_hide_pages_redirect()
{
    global $post;
    if (!is_admin() && !empty($post->ID)) {
        if ($post->post_type == "attachment") {
            //check if the user has access to the parent
            if (!pmpro_has_membership_access($post->ID)) {
                wp_redirect(pmpro_url("levels"));
                exit;
            }
        }
    }
}
<?php

/**
 * PMPro custom template output for a download via the [download] shortcode
 */
if (!defined('ABSPATH')) {
    exit;
}
// Exit if accessed directly
global $current_user;
if (function_exists('pmpro_hasMembershipLevel')) {
    if (!pmpro_has_membership_access($dlm_download->id)) {
        $download_membership_levels = pmprodlm_getDownloadLevels($dlm_download);
        if ($dlm_download->exists()) {
            ?>
			<a class="download-link" href="
			<?php 
            if (count($download_membership_levels[0]) > 1) {
                echo pmpro_url('levels');
            } else {
                echo pmpro_url("checkout", "?level=" . $download_membership_levels[0][0], "https");
            }
            ?>
"><?php 
            echo $dlm_download->get_the_title();
            ?>
</a>
			<?php 
            _e('Membership Required', 'pmprodlm');
            ?>
: <?php 
function pmprodlm_dlm_no_access_after_message($download)
{
    global $current_user;
    if (function_exists('pmpro_hasMembershipLevel')) {
        if (!pmpro_has_membership_access($download->id)) {
            $hasaccess = pmpro_has_membership_access($download->id, NULL, true);
            if (is_array($hasaccess)) {
                //returned an array to give us the membership level values
                $post_membership_levels_ids = $hasaccess[1];
                $post_membership_levels_names = $hasaccess[2];
                $hasaccess = $hasaccess[0];
            }
            if (empty($post_membership_levels_ids)) {
                $post_membership_levels_ids = array();
            }
            if (empty($post_membership_levels_names)) {
                $post_membership_levels_names = array();
            }
            //hide levels which don't allow signups by default
            if (!apply_filters("pmpro_membership_content_filter_disallowed_levels", false, $post_membership_levels_ids, $post_membership_levels_names)) {
                foreach ($post_membership_levels_ids as $key => $id) {
                    //does this level allow registrations?
                    $level_obj = pmpro_getLevel($id);
                    if (!$level_obj->allow_signups) {
                        unset($post_membership_levels_ids[$key]);
                        unset($post_membership_levels_names[$key]);
                    }
                }
            }
            $pmpro_content_message_pre = '<div class="pmpro_content_message">';
            $pmpro_content_message_post = '</div>';
            $content = '';
            $sr_search = array("!!levels!!", "!!referrer!!");
            $sr_replace = array(pmpro_implodeToEnglish($post_membership_levels_names), urlencode(site_url($_SERVER['REQUEST_URI'])));
            //get the correct message to show at the bottom
            if ($current_user->ID) {
                //not a member
                $newcontent = apply_filters("pmpro_non_member_text_filter", stripslashes(pmpro_getOption("nonmembertext")));
                $content .= $pmpro_content_message_pre . str_replace($sr_search, $sr_replace, $newcontent) . $pmpro_content_message_post;
            } else {
                //not logged in!
                $newcontent = apply_filters("pmpro_not_logged_in_text_filter", stripslashes(pmpro_getOption("notloggedintext")));
                $content .= $pmpro_content_message_pre . str_replace($sr_search, $sr_replace, $newcontent) . $pmpro_content_message_post;
            }
        }
    }
    echo $content;
}
function pmpros_pmpro_text_filter($text)
{
    global $wpdb, $current_user, $post;
    if (!empty($current_user) && !empty($post)) {
        if (!pmpros_hasAccess($current_user->ID, $post->ID)) {
            //Update text. The either have to wait or sign up.
            $post_series = get_post_meta($post->ID, "_post_series", true);
            $inseries = false;
            foreach ($post_series as $ps) {
                if (pmpro_has_membership_access($ps)) {
                    $inseries = $ps;
                    break;
                }
            }
            if ($inseries) {
                //user has one of the series levels, find out which one and tell him how many days left
                $series = new PMProSeries($inseries);
                $day = $series->getDelayForPost($post->ID);
                $member_days = pmpro_getMemberDays($current_user->ID);
                $days_left = ceil($day - $member_days);
                $date = date(get_option("date_format"), strtotime("+ {$days_left} Days", current_time("timestamp")));
                $text = "This content is part of the <a href='" . get_permalink($inseries) . "'>" . get_the_title($inseries) . "</a> series. You will gain access on " . $date . ".";
            } else {
                //user has to sign up for one of the series
                if (count($post_series) == 1) {
                    $text = "This content is part of the <a href='" . get_permalink($post_series[0]) . "'>" . get_the_title($post_series[0]) . "</a> series.";
                } else {
                    $text = "This content is part of the following series: ";
                    $series = array();
                    foreach ($post_series as $series_id) {
                        $series[] = "<a href='" . get_permalink($series_id) . "'>" . get_the_title($series_id) . "</a>";
                    }
                    $text .= implode(", ", $series) . ".";
                }
            }
        }
    }
    return $text;
}
 /**
  * Builder integration with Paid Mambership Pro
  * Display the Builder contents only if user has permission to view the post contents
  *
  * @since 1.2.0
  * @return string $content
  */
 function paidmembershippro_builder_show_on_front($content)
 {
     global $ThemifyBuilder;
     $hasaccess = pmpro_has_membership_access(NULL, NULL, true);
     if (is_array($hasaccess)) {
         //returned an array to give us the membership level values
         $post_membership_levels_ids = $hasaccess[1];
         $post_membership_levels_names = $hasaccess[2];
         $hasaccess = $hasaccess[0];
     }
     if ($hasaccess) {
         $content = $ThemifyBuilder->builder_show_on_front($content);
     }
     return $content;
 }
}
$filename = ABSPATH . $new_uri;
$pathParts = pathinfo($filename);
//only checking if the image is pulled from outside the admin
if (!is_admin()) {
    //get some info to use
    $upload_dir = wp_upload_dir();
    //wp upload dir
    $filename_small = substr($filename, strlen($upload_dir['basedir']) + 1, strlen($filename) - strlen($upload_dir['basedir']) - 1);
    //just the part wp saves
    //look the file up in the db
    $sqlQuery = "SELECT post_parent FROM {$wpdb->posts} WHERE ID = (SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = '_wp_attached_file' AND meta_value = '" . esc_sql($filename_small) . "' LIMIT 1) LIMIT 1";
    $file_post_parent = $wpdb->get_var($sqlQuery);
    //has access?
    if ($file_post_parent) {
        if (!pmpro_has_membership_access($file_post_parent)) {
            //hook for users without access
            do_action("pmpro_getfile_before_error", $filename, $file_post_parent);
            //nope
            header('HTTP/1.1 503 Service Unavailable', true, 503);
            echo "HTTP/1.1 503 Service Unavailable";
            exit;
        }
    }
}
//get mimetype
$mimetype = new pmpro_mimetype();
$file_mimetype = $mimetype->getType($filename);
//in case we want to do something else with the file
do_action("pmpro_getfile_before_readfile", $filename, $file_mimetype);
//if file is not found, die
function pmpro_lpv_wp()
{
    if (function_exists("pmpro_has_membership_access")) {
        /*
        	If we're viewing a page that the user doesn't have access to...
        	Could add extra checks here.
        */
        if (!pmpro_has_membership_access()) {
            //ignore non-posts
            $queried_object = get_queried_object();
            if (empty($queried_object) || empty($queried_object->post_type) || $queried_object->post_type != "post") {
                return;
            }
            $hasaccess = apply_filters('pmprolpv_has_membership_access', true, $queried_object);
            if (false === $hasaccess) {
                pmpro_lpv_redirect();
            }
            //if we're using javascript, just give them access and let JS redirect them
            if (PMPRO_LPV_USE_JAVASCRIPT) {
                wp_enqueue_script('wp-utils', includes_url('/js/utils.js'));
                add_action("wp_footer", "pmpro_lpv_wp_footer");
                add_filter("pmpro_has_membership_access_filter", "__return_true");
                return;
            }
            //PHP is going to handle cookie check and redirect
            $thismonth = date("n");
            //check for past views
            if (!empty($_COOKIE['pmpro_lpv_count'])) {
                $parts = explode(",", $_COOKIE['pmpro_lpv_count']);
                $month = $parts[1];
                if ($month == $thismonth) {
                    $count = intval($parts[0]) + 1;
                } else {
                    $count = 1;
                    //new month
                    $month = $thismonth;
                }
            } else {
                //new user
                $count = 1;
                $month = $thismonth;
            }
            //if count is above limit, redirect, otherwise update cookie
            if ($count > PMPRO_LPV_LIMIT) {
                pmpro_lpv_redirect();
            } else {
                //give them access and track the view
                add_filter("pmpro_has_membership_access_filter", "__return_true");
                if (defined('PMPRO_LPV_LIMIT_PERIOD')) {
                    switch (PMPRO_LPV_LIMIT_PERIOD) {
                        case 'hour':
                            $expires = current_time('timestamp') + HOUR_IN_SECONDS;
                            break;
                        case 'day':
                            $expires = current_time('timestamp') + DAY_IN_SECONDS;
                            break;
                        case 'week':
                            $expires = current_time('timestamp') + WEEK_IN_SECONDS;
                            break;
                        case 'month':
                            $expires = current_time('timestamp') + DAY_IN_SECONDS * 30;
                    }
                } else {
                    $expires = current_time('timestamp') + DAY_IN_SECONDS * 30;
                }
                setcookie('pmpro_lpv_count', $count . ',' . $month, $expires, '/');
            }
        }
    }
}
function bundlesandbonuses_videos_func($atts)
{
    //-> ONLY premium.
    if (pmpro_hasMembershipLevel(array(6, 7, 12, 14))) {
        global $wpdb, $pmpro_msg, $pmpro_msgt, $pmpro_levels, $current_user, $levels;
        $type = 'video';
        $max_count = 0;
        /*
         +===================================+
         | BEGIN 'Mandarin'                  |
         +===================================+
        */
        $bundlesandbonuses = array();
        $empty_bundlesandbonuses = true;
        $args = array('post_type' => array($type), 'post_status' => 'publish', 'posts_per_page' => '-1', 'caller_get_posts' => 1, 'tax_query' => array(array('taxonomy' => 'categories', 'field' => 'id', 'terms' => 20)));
        $bundlesandbonuses_query = null;
        $bundlesandbonuses_query = new WP_Query($args);
        if ($bundlesandbonuses_query->have_posts()) {
            while ($bundlesandbonuses_query->have_posts()) {
                $bundlesandbonuses_query->the_post();
                $thumbnail = "";
                $video_custom_thumbnail = get_field('video_custom_thumbnail', $post_id = $post->ID);
                if (!empty($video_custom_thumbnail)) {
                    $video_thumbnail_url = $video_custom_thumbnail;
                } else {
                    $video_thumbnail_url = get_field('video_thumbnail', $post_id = $post->ID);
                }
                if (!empty($video_thumbnail_url)) {
                    $thumbnail = '<img src="' . $video_thumbnail_url . '" alt="" class="img-responsive">';
                }
                $col = '<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">' . '<a class="dashboard-stat bundlesandbonuses dashboard-stat-light blue-soft" href="' . get_the_permalink($post_id = $post->ID) . '">' . '<div class="visual">' . '<div class="overlay"></div>' . $thumbnail . '</div>' . '<div class="details">' . '<div class="number">' . the_title($before = '', $after = '', $echo = false) . '</div>' . '</div>' . '<span class="caption-helper">' . '<ul class="post-meta clr">' . '<li class="meta-date">' . 'Posted on <span class="meta-date-text">' . get_the_date() . '</span>' . '</li>' . '</ul><!-- .post-meta -->' . '</span>' . '</a>' . '</div>';
                $return_membership_levels = pmpro_has_membership_access($post_id = $post->ID, $user_id = $current_user->ID, $return_membership_levels = true);
                if (empty($return_membership_levels[2]) && $return_membership_levels[0]) {
                    $hasaccess = FALSE;
                } else {
                    $hasaccess = $return_membership_levels[0];
                }
                if ($hasaccess) {
                    $bundlesandbonuses[] = $col;
                }
            }
        }
        $tmp = count($bundlesandbonuses);
        if ($tmp > $max_count) {
            $max_count = $tmp;
        }
        wp_reset_query();
        ?>
        <!-- BEGIN VIDEOS MENU-->
        <div class="row top-category">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <div class="easy-pie-chart">
                    <div class="number transactions" data-percent="55">
                        <img src="<?php 
        echo get_template_directory_uri();
        ?>
/assets/global/img/AR_bundles_icon.png" alt="" class=""/>
                    </div>
                    <a class="title" href="#">
                        Bundles & Bonuses
                    </a>
                </div>
            </div>
        </div>
        <div class="clearfix">
        </div>
        <div class="dashboard-page-bar" >
            <div class="line-full-width" ></div>

            <div class="line-container-left" >
                <div class="line" >
                    <div class="arrow-down" >
                    </div>
                </div>
            </div>

            <div class="middle-container-left" >
                <div class="line-middle" >
                    <div class="line" >
                        <div class="arrow-down" >
                        </div>
                    </div>
                </div>
            </div>          
            <div class="middle-container-right" >
                <div class="line-middle-right" >
                    <div class="line" >
                        <div class="arrow-down" >
                        </div>
                    </div>
                </div>
            </div>
            <div class="line-container-right" >
                <div class="line" >
                    <div class="arrow-down" >
                    </div>   
                </div>
            </div>
        </div>
        <div class="clearfix">
        </div>
        <!-- END VIDEOS MENU-->
        <!-- BEGIN VIDEO LIST-->
        <div class="row init-row">
            <?php 
        if ($max_count > 0) {
            ?>
                <?php 
            $row = 1;
            ?>
                <?php 
            for ($i = 0; $i <= $max_count; $i++) {
                ?>
                    <?php 
                if (isset($bundlesandbonuses[$i])) {
                    if ($row == 1) {
                        echo '<div class="row">';
                    }
                    echo $bundlesandbonuses[$i];
                    if ($row >= 4 || $i == $max_count) {
                        echo '</div>';
                        $row = 0;
                    }
                    $row = $row + 1;
                }
                ?>
                <?php 
            }
            ?>
 
            <?php 
        } else {
            ?>
                <div class="col-lg-12 col-md-12 col-sm-6 col-xs-12">
                    <a class="dashboard-stat bundlesandbonuses dashboard-stat-light blue-soft" href="javascript:void(0);">
                        <p> 
                            There are no videos yet for this Subscription plan on this category. <span class="meta-date-text">Check back soon!</span> 
                        </p>
                    </a>
                </div>
            <?php 
        }
        ?>
        </div>
    <?php 
    } else {
        ?>
        <br>
        <div class="row top-category no-allow">
            <div class="col-lg-12 col-md-12 col-sm-6 col-xs-12">
                <p> 
                    This content is for <span class="meta-date-text">Premium</span> members only. Visit the site and log in/register.
                </p>
            </div>
        </div>
    <?php 
    }
    ?>
    <div class="clearfix">
    </div>
    <div class="row">
        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
            <p class="notice">
                <?php 
    wpex_copyright_dashboard();
    ?>
            </p>
        </div>
    </div>
    <!-- END VIDEOS LIST-->
    <?php 
}