function product_metabox()
    {
        global $Premise;
        $lists = $Premise->getAweberLists();
        if (empty($lists)) {
            _e('No AWeber lists found.', 'premise');
            return;
        }
        ?>
		<p>
			<label for="accesspress_product_meta[_acp_product_aweber_list]"><strong><?php 
        _e('AWeber List', 'premise');
        ?>
</strong>:
			<select name="accesspress_product_meta[_acp_product_aweber_list]">
				<option value=""><?php 
        _e('None', 'premise');
        ?>
</option>
		<?php 
        foreach ($lists as $list) {
            printf('<option value="%s" %s>%s</option>', $list['id'], selected(accesspress_get_custom_field('_acp_product_aweber_list'), $list['id'], false), $list['name']);
        }
        ?>
			</select>
		</p>
		<?php 
    }
Exemple #2
0
    function access_metabox()
    {
        global $post;
        ?>
		<p>
			<?php 
        _e('Select Protection', 'premise');
        ?>
:
			<br />
			<label><input type="radio" name="accesspress_post_meta[_acp_protection]" id="accesspress_post_meta[_acp_protection]" value="" <?php 
        checked('' == accesspress_get_custom_field('_acp_protection'));
        ?>
 /> <?php 
        _e('No Membership Required', 'premise');
        ?>
</label>
			<br />
			<label><input type="radio" name="accesspress_post_meta[_acp_protection]" id="accesspress_post_meta[_acp_protection][member]" value="member" <?php 
        checked('member', accesspress_get_custom_field('_acp_protection'));
        ?>
 /> <?php 
        _e('Has Member Access to', 'premise');
        ?>
</label>
			<br />
			<label><input type="radio" name="accesspress_post_meta[_acp_protection]" id="accesspress_post_meta[_acp_protection][nonmember]" value="nonmember" <?php 
        checked('nonmember' == accesspress_get_custom_field('_acp_protection'));
        ?>
 /> <?php 
        _e('Does not have Member Access to', 'premise');
        ?>
</label>
		</p>

		<p><?php 
        _e('Choose the access level(s):', 'premise');
        ?>
</p>
		<p>
			<?php 
        echo accesspress_get_access_level_checklist(array('name' => 'accesspress_post_meta[_acp_access_levels][]', 'selected' => get_post_meta($post->ID, '_acp_access_levels', true), 'style' => 'style="width: auto;"'));
        ?>
		</p>

	<?php 
    }
Exemple #3
0
/**
 * Echo data from a custom field.
 *
 * Echo only the first value of custom field.
 *
 * @since 0.1.0
 *
 * @uses accesspress_get_custom_field()
 *
 * @param string $field Custom field key.
 */
function accesspress_custom_field($field, $default = '')
{
    echo accesspress_get_custom_field($field);
}
Exemple #4
0
function premise_has_content_access()
{
    global $post;
    if (!premise_is_protected_content()) {
        return true;
    }
    // if it's not published let WP handle permissions
    if ($post->post_status == 'draft' && 'true' == $_GET['preview']) {
        return true;
    }
    // don't let visitors access protected content
    if (!is_user_logged_in()) {
        return false;
    }
    $user = wp_get_current_user();
    $cap = 'edit_other_' . ('page' == $post->post_type ? 'post' : $post->post_type) . 's';
    if ($user->ID == $post->post_author || current_user_can($cap)) {
        return true;
    }
    $access_level = get_post_meta($post->ID, '_acp_access_levels', true);
    $protected = accesspress_get_custom_field('_acp_protection');
    if (member_has_access_level($access_level)) {
        if ('member' == $protected) {
            return true;
        }
    } elseif ('nonmember' == $protected) {
        return true;
    }
    return false;
}
    function product_metabox()
    {
        global $Premise;
        $lists = $Premise->getMailChimpLists();
        if (empty($lists)) {
            _e('No MailChimp lists found.', 'premise');
            return;
        }
        ?>
		<p>
			<label for="accesspress_product_meta[_acp_product_mailchimp_list]"><strong><?php 
        _e('MailChimp List', 'premise');
        ?>
</strong>:
			<select name="accesspress_product_meta[_acp_product_mailchimp_list]">
				<option value=""><?php 
        _e('None', 'premise');
        ?>
</option>
		<?php 
        foreach ($lists as $list) {
            printf('<option value="%s" %s>%s</option>', $list['id'], selected(accesspress_get_custom_field('_acp_product_mailchimp_list'), $list['id'], false), $list['name']);
        }
        ?>
			</select>
		</p>
		<?php 
        $args = array('title' => __('Add customers who purchase this product in MailChimp by identifying the fields.', 'premise'), 'field_format' => '%1$s : <input class="regular-text" type="text" name="accesspress_product_meta[_acp_product_mailchimp_%2$s]" id="accesspress_product_meta[_acp_product_mailchimp_%2$s]" value="%3$s" />', 'data' => array('email' => accesspress_get_custom_field('_acp_product_mailchimp_email'), 'first-name' => accesspress_get_custom_field('_acp_product_mailchimp_first-name'), 'last-name' => accesspress_get_custom_field('_acp_product_mailchimp_last-name')));
        $this->metabox_merge_fields($args);
    }
Exemple #6
0
 /**
  * Filter the data that shows up in the columns in the "Orders" screen, define our own.
  */
 function columns_data($column)
 {
     global $post;
     if ('acp-orders' != $post->post_type) {
         return;
     }
     switch ($column) {
         case "member_name":
             $member_id = accesspress_get_custom_field('_acp_order_member_id');
             $member = get_user_by('id', $member_id);
             if (!$member) {
                 break;
             }
             printf(__('<p><a href="%s">%s - %s %s</a></p>', 'premise'), add_query_arg(array('user_id' => $member->ID), admin_url('user-edit.php')), $member->user_login, $member->first_name, $member->last_name);
             break;
         case "member_product":
             $product_id = accesspress_get_custom_field('_acp_order_product_id');
             $product = get_post($product_id);
             if (!$product) {
                 break;
             }
             printf(__('<p><a href="%s">%s</a></p>', 'premise'), add_query_arg(array('post' => $product->ID, 'action' => 'edit'), admin_url('post.php')), $product->post_title);
             break;
         case "access_level":
             $product_id = accesspress_get_custom_field('_acp_order_product_id');
             $product = get_post($product_id);
             if (!$product) {
                 break;
             }
             echo get_the_term_list($product->ID, 'acp-access-level', '', '<br />', '');
             break;
     }
 }
Exemple #7
0
 /**
  * Filter the data that shows up in the columns in the "Orders" screen, define our own.
  */
 function columns_data($column)
 {
     global $post;
     if ('acp-products' != $post->post_type) {
         return;
     }
     switch ($column) {
         case "product_price":
             $price = accesspress_get_custom_field('_acp_product_price');
             if (!$price) {
                 break;
             }
             printf(__('<p>%.2f</p>', 'premise'), $price);
             break;
         case "access_level":
             echo get_the_term_list($post->ID, 'acp-access-level', '', '<br />', '');
             break;
     }
 }
Exemple #8
0
 /**
  * Filter the data that shows up in the columns in the "Orders" screen, define our own.
  */
 function columns_data($column)
 {
     global $post;
     if ('acp-orders' != $post->post_type) {
         return;
     }
     switch ($column) {
         case 'member_name':
             $member_id = accesspress_get_custom_field('_acp_order_member_id');
             $member = get_user_by('id', $member_id);
             if (!$member) {
                 break;
             }
             printf(__('<p><a href="%s">%s - %s %s</a></p>', 'premise'), add_query_arg(array('user_id' => $member->ID), admin_url('user-edit.php')), $member->user_login, $member->first_name, $member->last_name);
             break;
         case 'member_product':
             $product_id = accesspress_get_custom_field('_acp_order_product_id');
             $product = get_post($product_id);
             if (!$product) {
                 break;
             }
             printf(__('<p><a href="%s">%s</a></p>', 'premise'), add_query_arg(array('post' => $product->ID, 'action' => 'edit'), admin_url('post.php')), $product->post_title);
             break;
         case 'member_discount':
             $coupon_id = accesspress_get_custom_field('_acp_order_coupon_id');
             $coupon = get_post($coupon_id);
             if (!$coupon) {
                 break;
             }
             $percentage = 'percent' == get_post_meta($coupon_id, '_acp_coupon_type', true);
             $format = $percentage ? __('%d%%', 'premise') : __('$ %.2f', 'premise');
             $discount = get_post_meta($coupon_id, $percentage ? '_acp_coupon_percent' : '_acp_coupon_flat', true);
             printf(__('<p><a href="%s">' . $format . '</a></p>', 'premise'), add_query_arg(array('post' => $coupon->ID, 'action' => 'edit'), admin_url('post.php')), $discount);
             break;
         case 'access_level':
             $product_id = accesspress_get_custom_field('_acp_order_product_id');
             $product = get_post($product_id);
             if (!$product) {
                 break;
             }
             echo memberaccess_get_accesslevel_list($product->ID);
             break;
     }
 }
Exemple #9
0
    function details_metabox($post)
    {
        ?>

		<input type="hidden" name="accesspress-link-nonce" value="<?php 
        echo wp_create_nonce(plugin_basename(__FILE__));
        ?>
" />

		<table class="form-table">
		<tbody>
			
			<tr>
				<th scope="row"><p><?php 
        _e('Link URI', 'premise');
        ?>
</p></th>
				
				<td>
					<?php 
        if (!accesspress_get_custom_field('_acp_link_id')) {
            ?>
					<p class="description"><?php 
            _e('Save link to generate URI', 'premise');
            ?>
</p>
					<?php 
        } else {
            ?>
					<input type="hidden" name="accesspress_link_meta[_acp_link_id]" value="<?php 
            accesspress_custom_field('_acp_link_id');
            ?>
" />
					<p class="description"><?php 
            echo esc_url(sprintf(home_url('/?download_id=%s'), accesspress_get_custom_field('_acp_link_id')));
            ?>
</p>
					<?php 
        }
        ?>
				</td>
			</tr>
			
			<tr>
				<th scope="row">
					<label for="accesspress_link_meta[_acp_link_filename]"><?php 
        _e('Filename', 'premise');
        ?>
</label>
				</th>
				
				<td>
					<input type="text" placeholder="" id="accesspress_link_meta[_acp_link_filename]" autocomplete="off" name="accesspress_link_meta[_acp_link_filename]" value="<?php 
        accesspress_custom_field('_acp_link_filename');
        ?>
" class="large-text ui-autocomplete-input" role="textbox" aria-autocomplete="list" aria-haspopup="true"/>
					<p><span class="description"><?php 
        _e('Type the filename (file must exist) you wish to link to.', 'premise');
        ?>
</span></p>
				</td>
			</tr>
			
			<tr>
				<th scope="row">
					<label for="accesspress_link_meta[_acp_link_delay]"><?php 
        _e('Delay Access', 'premise');
        ?>
</label>
				</th>
				
				<td>
					<input type="text" placeholder="" id="accesspress_link_meta[_acp_link_delay]" autocomplete="off" name="accesspress_link_meta[_acp_link_delay]" value="<?php 
        accesspress_custom_field('_acp_link_delay');
        ?>
" class="small-text ui-autocomplete-input" role="textbox" aria-autocomplete="list" aria-haspopup="true"/> <?php 
        _e('Days', 'premise');
        ?>
					<p><span class="description"><?php 
        _e('Delay access to this file by X days after signup.', 'premise');
        ?>
</span></p>
				</td>
			</tr>
			
			<?php 
        do_action('premise_memberaccess_link_details_metabox_rows');
        ?>
			
		</tbody>
		</table>

	<?php 
    }
 function post_content_filter($content)
 {
     global $post;
     $protected = accesspress_get_custom_field('_acp_protection');
     if (!$protected) {
         return $content;
     }
     // close comments on protected content
     add_filter('comments_open', '__return_false', 99);
     if ($post->post_status == 'draft' && 'true' == $_GET['preview']) {
         return $content;
     }
     if (!is_user_logged_in()) {
         return sprintf(__('Please <a href="%s">Log in</a> to view this content.', 'premise'), memberaccess_login_redirect(get_permalink()));
     }
     $user = wp_get_current_user();
     $cap = 'edit_other_' . ('page' == $post->post_type ? 'post' : $post->post_type) . 's';
     if ($user->ID == $post->post_author || current_user_can($cap)) {
         return $content;
     }
     $access_level = get_post_meta($post->ID, '_acp_access_levels', true);
     if (member_has_access_level($access_level)) {
         if ('member' == $protected) {
             return $content;
         }
     } elseif ('nonmember' == $protected) {
         return $content;
     }
     return '';
 }
Exemple #11
0
 function process_coupon()
 {
     if (is_admin() || !is_singular('acp-coupons')) {
         return;
     }
     // check for authorization
     $object = get_queried_object();
     $product_id = str_replace('/', '', get_query_var('attachment'));
     if (!accesspress_get_custom_field('_acp_coupon_auth_key') || !accesspress_get_custom_field('_acp_coupon_auth_key_base') || isset($_REQUEST['auth']) && $this->get_authorization_key($object->ID, $product_id) == $_REQUEST['auth']) {
         $coupon_products = accesspress_get_custom_field('_acp_coupon_products');
         $cookie_name = 'premise-coupon-' . $object->ID . ($product_id && !empty($coupon_products) ? '-' . $product_id : '');
         $value = isset($_REQUEST['auth']) ? $_REQUEST['auth'] : md5($cookie_name);
         $now = time();
         $expiry = accesspress_get_custom_field('_acp_coupon_lifetime') > 0 ? $now + accesspress_get_custom_field('_acp_coupon_lifetime') * 86400 : 0;
         // clear conflicting coupons
         foreach ($this->get_member_coupons() as $key => $coupon) {
             if ($key != $cookie_name && (empty($coupon_products) || !isset($coupon[2]) || $coupon[2] == $product_id)) {
                 setcookie($key, '', $now, COOKIEPATH, COOKIE_DOMAIN);
             }
         }
         // store the coupon in a cookie
         setcookie($cookie_name, $value, $expiry, COOKIEPATH, COOKIE_DOMAIN);
     }
     if (isset($_REQUEST['redir'])) {
         wp_redirect(urldecode($_REQUEST['redir']));
         exit;
     }
     $checkout_page = accesspress_get_option('checkout_page');
     if (!$product_id || !$checkout_page) {
         if (accesspress_get_custom_field('_acp_coupon_redirect')) {
             wp_redirect(accesspress_get_custom_field('_acp_coupon_redirect'));
         } else {
             wp_safe_redirect(home_url('/'));
         }
         exit;
     }
     wp_safe_redirect(add_query_arg(array('product_id' => $product_id), get_permalink($checkout_page)));
     exit;
 }
Exemple #12
0
 /**
  * Filter the data that shows up in the columns in the "Orders" screen, define our own.
  */
 function columns_data($column)
 {
     global $post;
     if ('acp-products' != $post->post_type) {
         return;
     }
     switch ($column) {
         case "product_price":
             $free = accesspress_get_custom_field('_acp_product_free_product');
             if ($free) {
                 _e('<p>Free Product</p>', 'premise');
                 break;
             }
             $price = accesspress_get_custom_field('_acp_product_price');
             if (!$price) {
                 break;
             }
             printf(__('<p>%.2f</p>', 'premise'), $price);
             break;
         case "access_level":
             echo memberaccess_get_accesslevel_list($post->ID);
             break;
     }
 }
Exemple #13
0
    function product_metabox()
    {
        ?>
		<p>
			<label for="accesspress_product_meta[_acp_product_vbulletin_group]"><strong><?php 
        _e('vBulletin User Group', 'premise');
        ?>
</strong>:
			<br />
			</label><input type="text" name="accesspress_product_meta[_acp_product_vbulletin_group]" id="accesspress_product_meta[_acp_product_vbulletin_group]" value="<?php 
        echo esc_attr(accesspress_get_custom_field('_acp_product_vbulletin_group'));
        ?>
" />
			<br />
			<span class="description"><?php 
        _e('Choose the vBulletin user group that Premise Members will be added to for this product.', 'premise');
        ?>
</span>
		</p>

		<?php 
    }