PluginProbe ʕ •ᴥ•ʔ
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress / trunk
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress vtrunk
4.16.18 4.16.17 4.16.16 trunk 1.0 1.0.1 1.0.2 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.5a 1.1.6 1.1.7 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.4 1.4.1 1.4.2 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.7 1.7.1 1.7.2 1.8 1.8.1 1.8.10 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.1.9 2.2.10 2.2.11 2.2.12 2.2.13 2.2.14 2.2.15 2.2.16 2.2.2 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 3.0 3.1 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.14 3.2.15 3.2.16 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 4.0.0 4.0.1 4.0.2 4.0.3 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.10.0 4.10.1 4.10.2 4.10.3 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.13.3 4.13.4 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.15.0 4.15.1 4.15.10 4.15.11 4.15.12 4.15.13 4.15.14 4.15.15 4.15.16 4.15.17 4.15.18 4.15.19 4.15.2 4.15.20 4.15.20.1 4.15.21 4.15.22 4.15.23 4.15.24 4.15.25 4.15.3 4.15.4 4.15.5 4.15.6 4.15.7 4.15.8 4.15.9 4.16.0 4.16.1 4.16.10 4.16.11 4.16.12 4.16.13 4.16.14 4.16.15 4.16.2 4.16.3 4.16.4 4.16.5 4.16.6 4.16.7 4.16.8 4.16.9 4.2.0 4.3.0 4.3.1 4.3.2 4.4.0 4.4.1 4.5.0 4.5.1 4.5.2 4.5.3 4.5.4 4.5.5 4.6.0 4.7.0 4.8.0 4.9.0
wp-user-avatar / src / ShortcodeParser / MembershipShortcodes.php
wp-user-avatar / src / ShortcodeParser Last commit date
Builder 4 weeks ago MyAccount 4 weeks ago EditProfileTag.php 1 year ago FormProcessor.php 1 year ago FrontendProfileTag.php 1 year ago Init.php 3 years ago LoginFormTag.php 2 years ago MelangeTag.php 1 year ago MemberDirectoryTag.php 1 year ago MembershipShortcodes.php 1 year ago PasswordResetTag.php 4 weeks ago RegistrationFormTag.php 1 year ago index.php 5 years ago
MembershipShortcodes.php
203 lines
1 <?php
2
3 namespace ProfilePress\Core\ShortcodeParser;
4
5 use ProfilePress\Core\Membership\Controllers\CheckoutSessionData;
6 use ProfilePress\Core\Membership\Models\Coupon\CouponFactory;
7 use ProfilePress\Core\Membership\Models\Customer\CustomerFactory;
8 use ProfilePress\Core\Membership\Models\Group\GroupFactory;
9 use ProfilePress\Core\Membership\Models\Order\OrderFactory;
10 use ProfilePress\Core\Membership\Models\Order\OrderType;
11 use ProfilePress\Core\Membership\Models\Subscription\SubscriptionFactory;
12 use ProfilePress\Core\Membership\PaymentMethods\BankTransfer\BankTransfer;
13
14 class MembershipShortcodes
15 {
16 public function __construct()
17 {
18 add_shortcode('profilepress-checkout', [$this, 'checkout_page_wrapper']);
19 add_shortcode('profilepress-receipt', [$this, 'success_page']);
20
21 add_filter('the_content', [$this, 'filter_success_page_content'], 99999);
22
23 // Avada theme incompatibility fix
24 add_action('awb_remove_third_party_the_content_changes', function () {
25 remove_filter('the_content', [$this, 'filter_success_page_content'], 99999);
26 });
27
28 add_action('awb_readd_third_party_the_content_changes', function () {
29 add_filter('the_content', [$this, 'filter_success_page_content'], 99999);
30 });
31 }
32
33 function filter_success_page_content($content)
34 {
35 if (isset($_GET['order_key'], $_GET['payment_method']) && ppress_is_success_page()) {
36 $order = OrderFactory::fromOrderKey(sanitize_key($_GET['order_key']));
37 if ($order->exists() && $order->is_pending() && $_GET['payment_method'] != BankTransfer::get_instance()->get_id()) {
38 ob_start();
39 ppress_render_view('order-processing', [
40 'order_success_page' => ppress_get_success_url($order->order_key)
41 ]);
42
43 $content = ob_get_clean();
44 }
45 }
46
47 return $content;
48 }
49
50 public function checkout_page_wrapper()
51 {
52 if (ppress_is_redirect_to_referrer_after_checkout()) {
53
54 $referrer = wp_get_referer();
55
56 if ( ! empty($referrer)) {
57 ppress_session()->set('ppress_checkout_referrer', esc_url_raw($referrer));
58 }
59 }
60
61 ob_start();
62
63 echo '<div class="ppress-checkout__form">';
64 $this->checkout_page();
65 echo '</div>';
66
67 return ob_get_clean();
68 }
69
70 public function checkout_page()
71 {
72 if (
73 ( ! isset($_GET['plan']) || ! is_numeric($_GET['plan'])) &&
74 ( ! isset($_GET['group']) || ! is_numeric($_GET['group']))
75 ) {
76
77 do_action('ppress_membership_checkout_empty_cart');
78
79 echo '<p>';
80 printf(
81 __('Your cart is currently empty. Click <a href="%s">here</a> to get started.', 'wp-user-avatar'),
82 /** @todo add setting to set url to redirect to when cart is empty */
83 apply_filters('ppress_membership_checkout_empty_cart_url', home_url())
84 );
85 echo '</p>';
86
87 return;
88 }
89
90 $isGroupCheckout = ! empty($_GET['group']);
91
92 $isChangePlanCheckout = ! empty($_GET['change_plan']);
93
94 if ($isChangePlanCheckout) {
95
96 if ( ! is_user_logged_in()) {
97 echo '<p>';
98 esc_html_e('You must be logged in to switch to another plan.', 'wp-user-avatar');
99 echo '</p>';
100
101 return;
102 }
103
104 $sub = SubscriptionFactory::fromId(absint($_GET['change_plan']));
105
106 if ( ! $sub->exists() || ! ppress_get_plan($sub->plan_id)->get_group_id()) {
107
108 echo '<p>';
109 esc_html_e('You can not switch to another plan because this plan does not belong to any group.', 'wp-user-avatar');
110 echo '</p>';
111
112 return;
113 }
114 }
115
116 if ($isGroupCheckout) {
117
118 $group = GroupFactory::fromId(absint($_GET['group']));
119
120 if ( ! $group->exists()) {
121 esc_html_e('Invalid plan group.', 'wp-user-avatar');
122
123 return;
124 }
125
126 if (empty($group->get_plan_ids())) {
127 esc_html_e('Error: group has no membership plans.', 'wp-user-avatar');
128
129 return;
130 }
131 }
132
133 $planObj = ppress_get_plan(absint(ppressGET_var('plan', 0)));
134 $groupObj = GroupFactory::fromId(absint(ppressGET_var('group', 0)));
135
136 if (
137 is_user_logged_in() &&
138 ! $isGroupCheckout &&
139 ! $isChangePlanCheckout &&
140 CustomerFactory::fromUserId(get_current_user_id())->has_active_subscription($planObj->id)) {
141 echo '<p>';
142 printf(
143 esc_html__('You have an active subscription to this plan. Please go to %syour account%s to manage your subscription.', 'wp-user-avatar'),
144 '<a href="' . ppress_my_account_url() . '">', '</a>'
145 );
146 echo '</p>';
147
148 return;
149 }
150
151 if ( ! $planObj->is_active()) {
152 do_action('ppress_membership_checkout_invalid_plan');
153 echo '<p>' . esc_html__('Invalid membership plan.', 'wp-user-avatar') . '</p>';
154
155 return;
156 }
157
158 add_filter('ppress_logout_url_enable_redirect_get_query', '__return_true');
159
160 if ( ! empty($_GET['coupon'])) {
161
162 $coupon = CouponFactory::fromCode(sanitize_text_field($_GET['coupon']));
163
164 $order_type = CheckoutSessionData::get_order_type($planObj->get_id());
165
166 if ( ! $order_type) $order_type = OrderType::NEW_ORDER;
167
168 if ($coupon->exists() && $coupon->is_valid($planObj->get_id(), $order_type)) {
169
170 ppress_session()->set(CheckoutSessionData::COUPON_CODE, [
171 'plan_id' => $planObj->id,
172 'coupon_code' => $coupon->code,
173 ]);
174 }
175 }
176
177 ppress_render_view('checkout/form-checkout', [
178 'planObj' => $planObj,
179 'groupObj' => $groupObj,
180 'changePlanSubId' => absint(ppressGET_var('change_plan', 0)),
181 ]);
182 }
183
184 public function success_page()
185 {
186 ob_start();
187 require apply_filters('ppress_order_receipt_template', dirname(__FILE__) . '/MyAccount/view-order.tmpl.php');
188
189 return ob_get_clean();
190 }
191
192 public static function get_instance()
193 {
194 static $instance = null;
195
196 if (is_null($instance)) {
197 $instance = new self();
198 }
199
200 return $instance;
201 }
202 }
203