| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 3 |
/** |
| 4 |
* Function that creates the "Paid Accounts" submenu page |
| 5 |
* |
| 6 |
* @since v.2.0 |
| 7 |
* |
| 8 |
* @return void |
| 9 |
*/ |
| 10 |
function wppb_register_pms_cross_promo() { |
| 11 |
add_submenu_page( 'Profile Builder Paid Accounts', __( 'Paid Accounts', 'profile-builder' ), __( 'Paid Accounts', 'profile-builder' ), 'manage_options', 'profile-builder-pms-promo', 'wppb_pms_cross_promo' ); |
| 12 |
} |
| 13 |
add_action( 'admin_menu', 'wppb_register_pms_cross_promo', 2 ); |
| 14 |
|
| 15 |
|
| 16 |
function wppb_deactivate_pms_plugin() { |
| 17 |
check_ajax_referer( 'wppb-activate-addon', 'nonce' ); |
| 18 |
|
| 19 |
if ( current_user_can( 'activate_plugins' ) && !empty( $_POST['wppb_add_on_to_deactivate'] ) && !empty( $_POST['wppb_add_on_index'] ) ) { |
| 20 |
$plugin_path = str_replace(array("http://", "https://"), "", sanitize_text_field( $_POST['wppb_add_on_to_deactivate']) ); |
| 21 |
deactivate_plugins( $plugin_path ); |
| 22 |
echo esc_html( sanitize_text_field( $_POST['wppb_add_on_index'] ) ); |
| 23 |
} else { |
| 24 |
echo 'error'; |
| 25 |
} |
| 26 |
|
| 27 |
wp_die(); |
| 28 |
} |
| 29 |
add_action('wp_ajax_wppb_add_on_deactivate', 'wppb_deactivate_pms_plugin'); |
| 30 |
|
| 31 |
|
| 32 |
function wppb_activate_pms_plugin() { |
| 33 |
check_ajax_referer( 'wppb-activate-addon', 'nonce' ); |
| 34 |
|
| 35 |
if ( current_user_can( 'activate_plugins' ) && !empty( $_POST['wppb_add_on_to_activate'] ) && !empty( $_POST['wppb_add_on_index'] ) ) { |
| 36 |
$plugin_path = str_replace(array("http://", "https://"), "", sanitize_text_field( $_POST['wppb_add_on_to_activate']) ); |
| 37 |
activate_plugin( $plugin_path ); |
| 38 |
echo esc_html( sanitize_text_field( $_POST['wppb_add_on_index'] ) ); |
| 39 |
} else { |
| 40 |
echo 'error'; |
| 41 |
} |
| 42 |
|
| 43 |
wp_die(); |
| 44 |
} |
| 45 |
add_action('wp_ajax_wppb_add_on_activate', 'wppb_activate_pms_plugin'); |
| 46 |
|
| 47 |
|
| 48 |
/** |
| 49 |
* Function that adds content to the "Paid Accounts" submenu page |
| 50 |
* |
| 51 |
* @since v.2.0 |
| 52 |
* |
| 53 |
* @return string |
| 54 |
*/ |
| 55 |
function wppb_pms_cross_promo() { |
| 56 |
?> |
| 57 |
<div class="wrap wppb-wrap wppb-info-wrap cozmoslabs-wrap"> |
| 58 |
<div class="cozmoslabs-form-subsection-wrapper" id="pb-pms-cross-promo-header"> |
| 59 |
|
| 60 |
<div class="cozmoslabs-page-header"> |
| 61 |
<div> |
| 62 |
<h1 class="cozmoslabs-page-title"><?php esc_html_e( 'Users can pay for an account with', 'profile-builder' ); ?></h1> |
| 63 |
<h3><?php esc_html_e( 'Profile Builder and Paid Member Subscriptions', 'profile-builder' ); ?></h3> |
| 64 |
<p class="cozmoslabs-description"><?php esc_html_e( 'One of the most requested features in Profile Builder was for users to be able to pay for an account.', 'profile-builder' ); ?></p> |
| 65 |
<p class="cozmoslabs-description"> |
| 66 |
<?php esc_html_e( 'Now that is possible using the free WordPress plugin - ', 'profile-builder' ); ?> |
| 67 |
<a href="https://www.cozmoslabs.com/wordpress-paid-member-subscriptions/?utm_source=wpbackend&utm_medium=clientsite&utm_content=pb-pms-promo&utm_campaign=PBFree"><?php esc_html_e( 'Paid Member Subscriptions', 'profile-builder' ); ?></a> |
| 68 |
</p> |
| 69 |
</div> |
| 70 |
<div class="wppb-badge wppb-pb-pms"></div> |
| 71 |
</div> |
| 72 |
</div> |
| 73 |
|
| 74 |
<div class="cozmoslabs-form-subsection-wrapper"> |
| 75 |
<h2 class="cozmoslabs-subsection-title"><?php esc_html_e( 'Paid Member Subscriptions - a free WordPress plugin', 'profile-builder' ); ?></h2> |
| 76 |
<p class="cozmoslabs-description"><?php esc_html_e( 'With the new Subscriptions Field in Profile Builder, your registration forms will allow your users to sign up for paid accounts.', 'profile-builder' ); ?></p> |
| 77 |
|
| 78 |
<div id="pb-pms-cross-promo-pms-plugin"> |
| 79 |
|
| 80 |
<div id="pb-pms-cross-promo-pms-fetures" class="cozmoslabs-description"> |
| 81 |
<p><?php esc_html_e( 'Other features of Paid Member Subscriptions are:', 'profile-builder' ); ?></p> |
| 82 |
<ul> |
| 83 |
<li><?php esc_html_e( 'Paid & Free Subscriptions', 'profile-builder' ); ?></li> |
| 84 |
<li><?php esc_html_e( 'Restrict Content', 'profile-builder' ); ?></li> |
| 85 |
<li><?php esc_html_e( 'Member Management', 'profile-builder' ); ?></li> |
| 86 |
<li><?php esc_html_e( 'Email Templates', 'profile-builder' ); ?> </li> |
| 87 |
<li><?php esc_html_e( 'Account Management', 'profile-builder' ); ?> </li> |
| 88 |
<li><?php esc_html_e( 'Subscription Management', 'profile-builder' ); ?> </li> |
| 89 |
<li><?php esc_html_e( 'Payment Management', 'profile-builder' ); ?> </li> |
| 90 |
</ul> |
| 91 |
</div> |
| 92 |
|
| 93 |
<div> |
| 94 |
<?php |
| 95 |
$wppb_get_all_plugins = get_plugins(); |
| 96 |
$wppb_get_active_plugins = get_option('active_plugins'); |
| 97 |
|
| 98 |
$ajax_nonce = wp_create_nonce("wppb-activate-addon"); |
| 99 |
|
| 100 |
$pms_add_on_exists = 0; |
| 101 |
$pms_add_on_is_active = 0; |
| 102 |
$pms_add_on_is_network_active = 0; |
| 103 |
// Check to see if add-on is in the plugins folder |
| 104 |
foreach ($wppb_get_all_plugins as $wppb_plugin_key => $wppb_plugin) { |
| 105 |
if( strtolower($wppb_plugin['Name']) == strtolower( 'Paid Member Subscriptions' ) && strpos(strtolower($wppb_plugin['AuthorName']), strtolower('Cozmoslabs')) !== false) { |
| 106 |
$pms_add_on_exists = 1; |
| 107 |
if (in_array($wppb_plugin_key, $wppb_get_active_plugins)) { |
| 108 |
$pms_add_on_is_active = 1; |
| 109 |
} |
| 110 |
// Consider the add-on active if it's network active |
| 111 |
if (is_plugin_active_for_network($wppb_plugin_key)) { |
| 112 |
$pms_add_on_is_network_active = 1; |
| 113 |
$pms_add_on_is_active = 1; |
| 114 |
} |
| 115 |
$plugin_file = $wppb_plugin_key; |
| 116 |
} |
| 117 |
} |
| 118 |
?> |
| 119 |
|
| 120 |
<span id="wppb-add-on-activate-button-text" class="wppb-add-on-user-messages"><?php echo esc_html__( 'Activate', 'profile-builder' ); ?></span> |
| 121 |
|
| 122 |
<span id="wppb-add-on-downloading-message-text" class="wppb-add-on-user-messages"><?php echo esc_html__( 'Downloading and installing...', 'profile-builder' ); ?></span> |
| 123 |
<span id="wppb-add-on-download-finished-message-text" class="wppb-add-on-user-messages"><?php echo esc_html__( 'Installation complete', 'profile-builder' ); ?></span> |
| 124 |
|
| 125 |
<span id="wppb-add-on-activated-button-text" class="wppb-add-on-user-messages"><?php echo esc_html__( 'Plugin is Active', 'profile-builder' ); ?></span> |
| 126 |
<span id="wppb-add-on-activated-message-text" class="wppb-add-on-user-messages"><?php echo esc_html__( 'Plugin has been activated', 'profile-builder' ) ?></span> |
| 127 |
<span id="wppb-add-on-activated-error-button-text" class="wppb-add-on-user-messages"><?php echo esc_html__( 'Retry Install', 'profile-builder' ) ?></span> |
| 128 |
|
| 129 |
<span id="wppb-add-on-is-active-message-text" class="wppb-add-on-user-messages"><?php echo sprintf( wp_kses_post( __('Plugin is %1$s active %2$s', 'profile-builder') ), '<strong>', '</strong>' ); ?></span> |
| 130 |
<span id="wppb-add-on-is-active-message-text" class="wppb-add-on-user-messages"><?php echo sprintf( wp_kses_post( __('Plugin is %1$s inactive %2$s', 'profile-builder') ), '<strong>', '</strong>' ); ?></span> |
| 131 |
|
| 132 |
<span id="wppb-add-on-deactivate-button-text" class="wppb-add-on-user-messages"><?php echo esc_html__( 'Deactivate', 'profile-builder' ) ?></span> |
| 133 |
<span id="wppb-add-on-deactivated-message-text" class="wppb-add-on-user-messages"><?php echo esc_html__( 'Plugin has been deactivated.', 'profile-builder' ) ?></span> |
| 134 |
|
| 135 |
|
| 136 |
<div class="plugin-card wppb-recommended-plugin wppb-add-on"> |
| 137 |
<div class="plugin-card-top"> |
| 138 |
<div class="wppb-recommended-plugin-banner"> |
| 139 |
<a target="_blank" href="http://wordpress.org/plugins/paid-member-subscriptions/"> |
| 140 |
<img src="<?php echo esc_url( plugins_url( '../assets/images/pms-banner.png', __FILE__ ) ); ?>" width="100%"> |
| 141 |
</a> |
| 142 |
</div> |
| 143 |
<h3 class="wppb-add-on-title"> |
| 144 |
<a target="_blank" href="http://wordpress.org/plugins/paid-member-subscriptions/">Paid Member Subscriptions</a> |
| 145 |
</h3> |
| 146 |
<h3 class="wppb-add-on-price"><?php esc_html_e( 'Free', 'profile-builder' ) ?></h3> |
| 147 |
<p class="wppb-add-on-description"> |
| 148 |
<?php esc_html_e( 'Accept user payments, create subscription plans and restrict content on your website.', 'profile-builder' ) ?> |
| 149 |
<a href="<?php esc_url( admin_url() );?>plugin-install.php?tab=plugin-information&plugin=paid-member-subscriptions&TB_iframe=true&width=772&height=875" class="thickbox" aria-label="More information about Paid Member Subscriptions - membership & content restriction" data-title="Paid Member Subscriptions - membership & content restriction"><?php esc_html_e( 'More Details', 'profile-builder' ); ?></a> |
| 150 |
</p> |
| 151 |
</div> |
| 152 |
<div class="plugin-card-bottom wppb-add-on-compatible"> |
| 153 |
<?php |
| 154 |
if ($pms_add_on_exists) { |
| 155 |
|
| 156 |
// Display activate/deactivate buttons |
| 157 |
if (!$pms_add_on_is_active) { |
| 158 |
echo '<a class="wppb-add-on-activate right button button-primary" href="' . esc_url( $plugin_file ) . '" data-nonce="' . esc_attr( $ajax_nonce ) . '">' . esc_html__('Activate', 'profile-builder') . '</a>'; |
| 159 |
|
| 160 |
// If add-on is network activated don't allow deactivation |
| 161 |
} elseif (!$pms_add_on_is_network_active) { |
| 162 |
echo '<a class="wppb-add-on-deactivate right button button-secondary" href="' . esc_url( $plugin_file ) . '" data-nonce="' . esc_attr( $ajax_nonce ) . '">' . esc_html__('Deactivate', 'profile-builder') . '</a>'; |
| 163 |
} |
| 164 |
|
| 165 |
// Display message to the user |
| 166 |
if( !$pms_add_on_is_active ){ |
| 167 |
echo '<span class="dashicons dashicons-yes"></span><span class="wppb-add-on-message">' . sprintf( wp_kses_post( __( 'Plugin is %1$s inactive %2$s', 'profile-builder' ) ), '<strong>', '</strong>' ) . '</span>'; |
| 168 |
} else { |
| 169 |
echo '<span class="dashicons dashicons-yes"></span><span class="wppb-add-on-message">' . sprintf( wp_kses_post( __( 'Plugin is %1$s active %2$s', 'profile-builder' ) ), '<strong>', '</strong>' ) . '</span>'; |
| 170 |
} |
| 171 |
|
| 172 |
} else { |
| 173 |
|
| 174 |
// If we're on a multisite don't add the wpp-add-on-download class to the button so we don't fire the js that |
| 175 |
// handles the in-page download |
| 176 |
if (is_multisite()) { |
| 177 |
$wppb_paid_link_class = 'button-primary'; |
| 178 |
$wppb_paid_link_text = esc_html__('Download Now', 'profile-builder' ); |
| 179 |
} else { |
| 180 |
$wppb_paid_link_class = 'button-primary wppb-add-on-download'; |
| 181 |
$wppb_paid_link_text = esc_html__('Install Now', 'profile-builder'); |
| 182 |
} |
| 183 |
|
| 184 |
echo '<a target="_blank" class="right button ' . esc_attr( $wppb_paid_link_class ) . '" href="https://downloads.wordpress.org/plugin/paid-member-subscriptions.zip" data-add-on-slug="paid-member-subscriptions" data-add-on-name="Paid Member Subscriptions" data-nonce="' . esc_attr( $ajax_nonce ) . '">' . esc_html( $wppb_paid_link_text ) . '</a>'; |
| 185 |
echo '<span class="dashicons dashicons-yes"></span><span class="wppb-add-on-message">' . esc_html__('Compatible with your version of Profile Builder.', 'profile-builder') . '</span>'; |
| 186 |
|
| 187 |
} |
| 188 |
?> |
| 189 |
<div class="spinner"></div> |
| 190 |
<span class="wppb-add-on-user-messages wppb-error-manual-install"><?php printf(esc_html__('Could not install plugin. Retry or <a href="%s" target="_blank">install manually</a>.', 'profile-builder'), esc_url( 'http://www.wordpress.org/plugins/paid-member-subscriptions' )) ?></a>.</span> |
| 191 |
</div> |
| 192 |
</div> |
| 193 |
</div> |
| 194 |
</div> |
| 195 |
</div> |
| 196 |
|
| 197 |
<div class="cozmoslabs-form-subsection-wrapper"> |
| 198 |
<h2 class="cozmoslabs-subsection-title"><?php esc_html_e( 'Step by Step Quick Setup', 'profile-builder' ); ?></h2> |
| 199 |
<p class="cozmoslabs-description"><?php esc_html_e( 'Setting up Paid Member Subscriptions opens the door to paid user accounts.', 'profile-builder' ); ?></p> |
| 200 |
|
| 201 |
<div class="cozmoslabs-form-subsection-wrapper"> |
| 202 |
<h3 class="cozmoslabs-subsection-title"><?php esc_html_e( 'Create Subscription Plans', 'profile-builder' ); ?></h3> |
| 203 |
<p class="cozmoslabs-description"><?php esc_html_e( 'With Paid Member Subscriptions it’s fairly easy to create tiered subscription plans for your users.', 'profile-builder' ); ?></p> |
| 204 |
<p class="cozmoslabs-description"><?php esc_html_e( 'Adding a new subscription gives you access to the following options to set up: subscription name, description, duration, the price, status and user role.', 'profile-builder' ); ?></p> |
| 205 |
<div class="cozmoslabs-subsection-image"> |
| 206 |
<a href="<?php echo esc_url( WPPB_PLUGIN_URL ); ?>assets/images/pms_all_subscriptions.jpg" target="_blank"> |
| 207 |
<img src="<?php echo esc_url( WPPB_PLUGIN_URL ); ?>assets/images/pms_all_subscriptions.jpg" alt="paid subscription plans"/> |
| 208 |
</a> |
| 209 |
</div> |
| 210 |
</div> |
| 211 |
|
| 212 |
<div class="cozmoslabs-form-subsection-wrapper"> |
| 213 |
<h3 class="cozmoslabs-subsection-title"><?php esc_html_e( 'Add Subscriptions field to Profile Builder -> Manage Fields', 'profile-builder' ); ?></h3> |
| 214 |
<p class="cozmoslabs-description"><?php esc_html_e( 'The new Subscription Plans field will add a list of radio buttons with membership details to Profile Builder registration forms.', 'profile-builder' ); ?></p> |
| 215 |
<div class="cozmoslabs-subsection-image"> |
| 216 |
<a href="<?php echo esc_url( WPPB_PLUGIN_URL ); ?>assets/images/pms_pb_add_subscription.jpg" target="_blank"> |
| 217 |
<img src="<?php echo esc_url( WPPB_PLUGIN_URL ); ?>assets/images/pms_pb_add_subscription.jpg" alt="manage fields subscription plans"/> |
| 218 |
</a> |
| 219 |
</div> |
| 220 |
</div> |
| 221 |
|
| 222 |
<div class="cozmoslabs-form-subsection-wrapper"> |
| 223 |
<h3 class="cozmoslabs-subsection-title"><?php esc_html_e( 'Start getting user payments', 'profile-builder' ); ?></h3> |
| 224 |
<p class="cozmoslabs-description"><?php esc_html_e( 'To finalize registration for a paid account, users will need to complete the payment.', 'profile-builder' ); ?></p> |
| 225 |
<p class="cozmoslabs-description"><?php esc_html_e( 'Members created with Profile Builder registration form will have the user role of the selected subscription.', 'profile-builder' ); ?></p> |
| 226 |
<div class="cozmoslabs-subsection-image"> |
| 227 |
<a href="<?php echo esc_url( WPPB_PLUGIN_URL ); ?>assets/images/pms_pb_register_page.jpg" target="_blank"> |
| 228 |
<img src="<?php echo esc_url( WPPB_PLUGIN_URL ); ?>assets/images/pms_pb_register_page.jpg" alt="register payed accounts"/> |
| 229 |
</a> |
| 230 |
</div> |
| 231 |
</div> |
| 232 |
|
| 233 |
</div> |
| 234 |
|
| 235 |
|
| 236 |
<div id="pms-bottom-install" class="wppb-add-on"> |
| 237 |
<div class="plugin-card-bottom wppb-add-on-compatible"> |
| 238 |
<?php |
| 239 |
if ($pms_add_on_exists) { |
| 240 |
|
| 241 |
// Display activate/deactivate buttons |
| 242 |
if (!$pms_add_on_is_active) { |
| 243 |
echo '<a class="wppb-add-on-activate right button button-primary" href="' . esc_url( $plugin_file ) . '" data-nonce="' . esc_attr( $ajax_nonce ) . '">' . esc_html__('Activate', 'profile-builder') . '</a>'; |
| 244 |
|
| 245 |
// If add-on is network activated don't allow deactivation |
| 246 |
} elseif (!$pms_add_on_is_network_active) { |
| 247 |
echo '<a class="wppb-add-on-deactivate right button button-secondary" href="' . esc_url( $plugin_file ) . '" data-nonce="' . esc_attr( $ajax_nonce ) . '">' . esc_html__('Deactivate', 'profile-builder') . '</a>'; |
| 248 |
} |
| 249 |
|
| 250 |
// Display message to the user |
| 251 |
if( !$pms_add_on_is_active ){ |
| 252 |
echo '<span class="dashicons dashicons-no-alt"></span><span class="wppb-add-on-message">' . sprintf( wp_kses_post( __( 'Plugin is %1$s inactive %2$s', 'profile-builder' ) ), '<strong>', '</strong>' ) . '</span>'; |
| 253 |
} else { |
| 254 |
echo '<span class="dashicons dashicons-yes"></span><span class="wppb-add-on-message">' . sprintf( wp_kses_post( __( 'Plugin is %1$s active %2$s', 'profile-builder' ) ), '<strong>', '</strong>' ) . '</span>'; |
| 255 |
} |
| 256 |
|
| 257 |
} else { |
| 258 |
|
| 259 |
// If we're on a multisite don't add the wpp-add-on-download class to the button so we don't fire the js that |
| 260 |
// handles the in-page download |
| 261 |
if (is_multisite()) { |
| 262 |
$wppb_paid_link_class = 'button-secondary'; |
| 263 |
$wppb_paid_link_text = __('Download Now', 'profile-builder' ); |
| 264 |
} else { |
| 265 |
$wppb_paid_link_class = 'button-secondary wppb-add-on-download'; |
| 266 |
$wppb_paid_link_text = __('Install Now', 'profile-builder'); |
| 267 |
} |
| 268 |
|
| 269 |
echo '<a target="_blank" class="right button ' . esc_attr( $wppb_paid_link_class ) . '" href="https://downloads.wordpress.org/plugin/paid-member-subscriptions.zip" data-add-on-slug="paid-member-subscriptions" data-add-on-name="Paid Member Subscriptions" data-nonce="' . esc_attr( $ajax_nonce ) . '">' . esc_html( $wppb_paid_link_text ) . '</a>'; |
| 270 |
echo '<span class="dashicons dashicons-yes"></span><span class="wppb-add-on-message">' . esc_html__('Compatible with your version of Profile Builder.', 'profile-builder') . '</span>'; |
| 271 |
} |
| 272 |
?> |
| 273 |
<div class="spinner"></div> |
| 274 |
<?php /* <span class="wppb-add-on-user-messages wppb-error-manual-install"><?php printf(__('Could not install plugin. Retry or <a href="%s" target="_blank">install manually</a>.', 'profile-builder'), esc_url( 'http://www.wordpress.org/plugins/paid-member-subscriptions' )) ?></a>.</span> */ ?> |
| 275 |
</div> |
| 276 |
</div> |
| 277 |
|
| 278 |
|
| 279 |
</div> |
| 280 |
<?php |
| 281 |
} |
| 282 |
/* |
| 283 |
* Instantiate a new notification for the PMS cross Promotion |
| 284 |
* |
| 285 |
* @Since 2.2.5 |
| 286 |
*/ |
| 287 |
add_action('init', function() |
| 288 |
{ |
| 289 |
$is_pms_promo_page = isset( $_GET['page'] ) && $_GET['page'] === 'profile-builder-pms-promo'; |
| 290 |
$is_setup_wizard = isset( $_GET['subpage'] ) && $_GET['subpage'] === 'wppb-setup'; |
| 291 |
|
| 292 |
if ( $is_pms_promo_page || $is_setup_wizard ) { |
| 293 |
return; |
| 294 |
} |
| 295 |
|
| 296 |
if ( ! function_exists( 'is_plugin_active' ) || is_plugin_active( 'paid-member-subscriptions/index.php' ) ) { |
| 297 |
return; |
| 298 |
} |
| 299 |
|
| 300 |
if ( ! wppb_should_show_marketing_notice() ) { |
| 301 |
return; |
| 302 |
} |
| 303 |
|
| 304 |
new WPPB_Add_General_Notices('wppb_pms_cross_promo', |
| 305 |
sprintf(__('Allow your users to have <strong>paid accounts with Profile Builder</strong>. %1$sFind out how >%2$s %3$sDismiss%4$s', 'profile-builder'), "<a href='" . esc_url( admin_url('options.php?page=profile-builder-pms-promo') ) . "'>", "</a>", "<a class='wppb-dismiss-notification' href='" . esc_url( wp_nonce_url( add_query_arg( 'wppb_pms_cross_promo_dismiss_notification', '0' ), 'wppb_general_notice_dismiss' ) ) . "'>", "</a>"), |
| 306 |
'pms-cross-promo'); |
| 307 |
}); |
| 308 |
|