Esempio n. 1
0
 /**
  * Adds corresponding body classes when need be.
  *
  * @since 3.5
  * @filter body_class
  *
  * @param array $classes The array of body classes.
  * @return array The extended array of body classes.
  */
 public function add_body_classes($classes)
 {
     if (class_exists('BuddyPress') && filter_input(INPUT_GET, 'action') == 'registeruser' && membership_is_registration_page()) {
         add_filter('bp_is_blog_page', '__return_false');
         $this->_add_filter('bp_is_current_component', 'determine_bp_component', 10, 2);
         $classes = array_unique(bp_get_the_body_class($classes));
     }
     return $classes;
 }
Esempio n. 2
0
 function check_for_membership_pages($posts)
 {
     global $M_options;
     if (count($posts) != 1) {
         return $posts;
     }
     // We have only the one post, so check if it's one of our pages
     $post = $posts[0];
     if ($post->post_type != 'page') {
         return $posts;
     }
     if (membership_is_registration_page($post->ID, false) || M_contains_schortcode($post->post_content, 'subscriptionform')) {
         // Redirect members with subscriptions to the subscriptions page if it exists, else account page.
         global $member;
         $member = Membership_Plugin::current_member();
         if (!empty($member)) {
             if ($member->has_subscription() && $member->ID != 0 && !isset($_REQUEST['from_subscription'])) {
                 if (!empty($M_options['subscriptions_page'])) {
                     wp_redirect(get_permalink($M_options['subscriptions_page']));
                     exit;
                 } else {
                     wp_redirect(get_permalink($M_options['account_page']));
                     exit;
                 }
             }
         }
         add_action('template_redirect', array($this, 'process_subscription_form'), 1);
         if (strpos($post->post_content, '[subscriptionform]') !== false || strpos($post->post_content, '[renewform]') !== false) {
             // bail - shortcode found
             return $posts;
         }
         // registration page found - add in the styles
         if (!current_theme_supports('membership_subscription_form')) {
             wp_enqueue_style('membership-subscriptionformcss', MEMBERSHIP_ABSURL . 'css/subscriptionform.css', null, Membership_Plugin::VERSION);
             add_action('wp_head', array($this, 'enqueue_public_form_styles'), 99);
             $this->enqueue_fancybox_scripts();
         }
         do_action('membership_subscriptionbutton_onpage');
         // There is no shortcode content in there, so override
         remove_filter('the_content', 'wpautop');
     } elseif (membership_is_account_page($post->ID, false)) {
         // account page - check if page contains a shortcode
         if (strpos($post->post_content, '[accountform]') !== false || strpos($post->post_content, '[upgradeform]') !== false || strpos($post->post_content, '[renewform]') !== false) {
             // There is content in there with the shortcode so just return it
             return $posts;
         }
         // account page found - add in the styles
         if (!current_theme_supports('membership_account_form')) {
             wp_enqueue_style('membership-accountformcss', MEMBERSHIP_ABSURL . 'css/accountform.css', null, Membership_Plugin::VERSION);
             wp_enqueue_script('membership-accountformjs', MEMBERSHIP_ABSURL . 'js/accountform.js', array('jquery'), Membership_Plugin::VERSION);
             add_action('wp_head', array($this, 'enqueue_public_form_styles'), 99);
         }
         // There is no shortcode in there, so override
         remove_filter('the_content', 'wpautop');
     } elseif (membership_is_subscription_page($post->ID, false)) {
         // Handle any updates passed
         $page = isset($_REQUEST['action']) ? addslashes($_REQUEST['action']) : '';
         if (empty($page)) {
             $page = 'renewform';
         }
         if ($page == 'subscriptionsignup') {
             if (is_user_logged_in()) {
                 $member = current_member();
                 list($timestamp, $user_id, $sub_id, $key, $sublevel) = explode(':', $_POST['custom']);
                 if (wp_verify_nonce($_REQUEST['_wpnonce'], 'free-sub_' . $sub_id)) {
                     $gateway = $_POST['gateway'];
                     // Join the new subscription
                     $member->create_subscription($sub_id, $gateway);
                     do_action('membership_payment_subscr_signup', $user_id, $sub_id);
                     // Timestamp the update
                     update_user_meta($user_id, '_membership_last_upgraded', time());
                     // Added another redirect to the same url because the show_no_access filters
                     // have already run on the "parse_request" action (Cole)
                     wp_redirect(M_get_subscription_permalink());
                     exit;
                 }
             } else {
                 // check if a custom is posted and of so then process the user
                 if (isset($_POST['custom'])) {
                     list($timestamp, $user_id, $sub_id, $key, $sublevel) = explode(':', $_POST['custom']);
                     if (wp_verify_nonce($_REQUEST['_wpnonce'], 'free-sub_' . $sub_id)) {
                         $gateway = $_POST['gateway'];
                         // Join the new subscription
                         $member = Membership_Plugin::factory()->get_member($user_id);
                         $member->create_subscription($sub_id, $gateway);
                         do_action('membership_payment_subscr_signup', $user_id, $sub_id);
                         // Timestamp the update
                         update_user_meta($user_id, '_membership_last_upgraded', time());
                         // Added another redirect to the same url because the show_no_access filters
                         // have already run on the "parse_request" action (Cole)
                         wp_redirect(M_get_subscription_permalink());
                         exit;
                     }
                 }
             }
         }
         // account page - check if page contains a shortcode
         if (strstr($post->post_content, '[upgradeform]') !== false || strstr($post->post_content, '[renewform]') !== false) {
             // There is content in there with the shortcode so just return it
             if (!current_theme_supports('membership_subscription_form')) {
                 $this->enqueue_subscription_scripts();
             }
             return $posts;
         }
         // account page found - add in the styles
         if (!current_theme_supports('membership_account_form')) {
             $this->enqueue_subscription_scripts();
         }
         // There is no shortcode in there, so override
         remove_filter('the_content', 'wpautop');
     } elseif (membership_is_protected_page($post->ID, false)) {
         // no access page - we must return the content entered by the user so just return it
         return $posts;
     } elseif (membership_is_welcome_page($post->ID, false)) {
         // Registration complete page
         // Handle any updates passed
         $page = isset($_REQUEST['action']) && !empty($_REQUEST['action']) ? addslashes($_REQUEST['action']) : 'renewform';
         if ($page == 'subscriptionsignup') {
             if (is_user_logged_in() && isset($_POST['custom'])) {
                 list($timestamp, $user_id, $sub_id, $key, $sublevel) = explode(':', $_POST['custom']);
                 if (wp_verify_nonce($_REQUEST['_wpnonce'], 'free-sub_' . $sub_id)) {
                     $member = Membership_Plugin::factory()->get_member($user_id);
                     $member->create_subscription($sub_id, $_POST['gateway']);
                     do_action('membership_payment_subscr_signup', $user_id, $sub_id);
                     // Timestamp the update
                     update_user_meta($user_id, '_membership_last_upgraded', time());
                     // Added another redirect to the same url because the show_no_access filters
                     // have already run on the "parse_request" action (Cole)
                     wp_redirect(M_get_returnurl_permalink());
                     exit;
                 }
             } else {
                 // check if a custom is posted and of so then process the user
                 if (isset($_POST['custom'])) {
                     list($timestamp, $user_id, $sub_id, $key, $sublevel) = explode(':', $_POST['custom']);
                     if (wp_verify_nonce($_REQUEST['_wpnonce'], 'free-sub_' . $sub_id)) {
                         $member = Membership_Plugin::factory()->get_member($user_id);
                         $member->create_subscription($sub_id, $_POST['gateway']);
                         do_action('membership_payment_subscr_signup', $user_id, $sub_id);
                         // Timestamp the update
                         update_user_meta($user_id, '_membership_last_upgraded', time());
                         // Added another redirect to the same url because the show_no_access filters
                         // have already run on the "parse_request" action (Cole)
                         wp_redirect(M_get_returnurl_permalink());
                         exit;
                     }
                 }
             }
         }
         return $posts;
     }
     // If nothing else is hit, just return the content
     return $posts;
 }
Esempio n. 3
0
    /**
     * Renders special page notice messages.
     *
     * @since 3.5
     *
     * @access private
     * @param int $page_id Current page ID.
     * @return boolean TRUE if it is special page, otherwise FALSE.
     */
    private function _render_special_page_message($page_id)
    {
        if (membership_is_registration_page($page_id, false)) {
            ?>
<div class="membership-access-info">
				<p><?php 
            esc_html_e('This is the page a new user will be redirected to when they want to register on your site.', 'membership');
            ?>
</p>
				<p><?php 
            _e('You can include an introduction on the page, for more advanced content around the registration form then you <b>should</b> include the <code>[subscriptionform]</code> shortcode in some location on that page. Alternatively leave the page blank for the standard Membership subscription forms.', 'membership');
            ?>
</p>
			</div><?php 
            return true;
        }
        if (membership_is_account_page($page_id, false)) {
            ?>
<div class="membership-access-info">
				<p><?php 
            esc_html_e('This is the page a user will be redirected to when they want to view their account or make a payment on their account.', 'membership');
            ?>
</p>
				<p><?php 
            _e('It can be left blank to use the standard Membership interface, otherwise it can contain any content you want but <b>should</b> contain the <code>[accountform]</code> shortcode in some location.', 'membership');
            ?>
</p>
			</div><?php 
            return true;
        }
        if (membership_is_subscription_page($page_id, false)) {
            ?>
<div class="membership-access-info">
				<p><?php 
            esc_html_e('This is the page a user will be redirected to when they want to view their subscription details and upgrade / renew them.', 'membership');
            ?>
</p>
				<p><?php 
            _e('It can be left blank to use the standard Membership interface, otherwise it can contain any content you want but <b>should</b> contain the <code>[renewform]</code> shortcode in some location.', 'membership');
            ?>
</p>
			</div><?php 
            return true;
        }
        if (membership_is_welcome_page($page_id, false)) {
            ?>
<div class="membership-access-info">
				<p><?php 
            esc_html_e('When a user has signed up for membership and completed any payments required, they will be redirected to this page.', 'membership');
            ?>
</p>
				<p><?php 
            _e('You should include a welcome message on this page and some details on what to do next.', 'membership');
            ?>
</p>
			</div><?php 
            return true;
        }
        if (membership_is_protected_page($page_id, false)) {
            ?>
<div class="membership-access-info">
				<p><?php 
            esc_html_e('If a post / page / content is not available to a user, this is the page that they user will be directed to.', 'membership');
            ?>
</p>
				<p><?php 
            _e('This page will only be displayed if the user has tried to access the post / page / content directly or via a link.', 'membership');
            ?>
</p>
			</div><?php 
            return true;
        }
        return false;
    }
Esempio n. 4
0
 /**
  * Enqueues scripts.
  *
  * @since  3.5
  * @action wp_enqueue_scripts
  *
  * @access public
  */
 public function enqueue_scripts()
 {
     if (membership_is_registration_page() || membership_is_subscription_page()) {
         wp_enqueue_script('membership-authorize', MEMBERSHIP_ABSURL . 'js/authorizenet.js', array('jquery'), Membership_Plugin::VERSION, true);
         wp_localize_script('membership-authorize', 'membership_authorize', array('return_url' => esc_url(add_query_arg('action', 'processpurchase_' . $this->gateway, admin_url('admin-ajax.php', 'https'))), 'payment_error_msg' => __('There was an unknown error encountered with your payment. Please contact the site administrator.', 'membership'), 'stylesheet_url' => MEMBERSHIP_ABSURL . 'css/authorizenet.css'));
     }
 }