function set_global_sidebar_content()
 {
     ob_start();
     include_once membership_dir('membershipincludes/help/help.sidebar.php');
     $help = ob_get_clean();
     $this->screen->set_help_sidebar($help);
 }
    function handle_repair_panel()
    {
        global $action, $page, $M_options;
        wp_reset_vars(array('action', 'page'));
        ?>
		<div class='wrap nosubsub'>
			<div class="icon32" id="icon-tools"><br></div>
			<h2><?php 
        _e('Repair Membership', 'membership');
        ?>
</h2>

			<?php 
        if (isset($_GET['msg'])) {
            echo '<div id="message" class="updated fade"><p>' . $messages[(int) $_GET['msg']] . '</p></div>';
            $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
        }
        ?>

			<p><?php 
        _e('If you are having problems with your membership site, or have recently upgraded and are seeing strange behaviour then try the membership check below to see if there are any issues with your table structure. Click on the repair button if you want to repair any issues found (back up your database first).', 'membership');
        ?>
</p>
			<p>
			<?php 
        echo "<a href='" . wp_nonce_url("?page=" . $page . "&amp;tab=advanced&amp;verify=yes", 'verify-membership') . "' class='button'>" . __('Verify Membership Tables', 'membership') . "</a>&nbsp;&nbsp;";
        ?>
			<?php 
        echo "<a href='" . wp_nonce_url("?page=" . $page . "&amp;tab=advanced&amp;repair=yes", 'repair-membership') . "' class='button'>" . __('Repair Membership Tables', 'membership') . "</a>";
        ?>
			</p>

			<?php 
        if (isset($_GET['verify'])) {
            check_admin_referer('verify-membership');
            include_once membership_dir('membershipincludes/classes/upgrade.php');
            ?>
					<p><strong><?php 
            _e('Verifying', 'membership');
            ?>
</strong></p>
					<?php 
            M_verify_tables();
        }
        if (isset($_GET['repair'])) {
            check_admin_referer('repair-membership');
            include_once membership_dir('membershipincludes/classes/upgrade.php');
            ?>
					<p><strong><?php 
            _e('Verifying and Repairing', 'membership');
            ?>
</strong></p>
					<?php 
            M_repair_tables();
        }
        ?>
		</div> <!-- wrap -->
		<?php 
    }
 function __construct()
 {
     if (!class_exists('Pointer_Tutorial')) {
         require_once membership_dir('membershipincludes/includes/new-pointer-tutorials.php');
     }
     $this->_membership_tutorial = new Pointer_Tutorial('membership', __('Membership tutorial', 'membership'), false, false);
     $this->_membership_tutorial->add_icon(membership_url('membershipincludes/images/pointer-icon.png'));
     $this->_wizard_tutorial = new Pointer_Tutorial('membershipwizard', __('Membership tutorial', 'membership'), false, false);
     $this->_wizard_tutorial->add_icon(membership_url('membershipincludes/images/pointer-icon.png'));
 }
function new_user_notification_mail($userid, $userpassword)
{
    global $M_options;
    $users = get_userdata($userid);
    $template = '';
    include_once membership_dir('membershipincludes/templates/email.php');
    $emailoptions = array('from_email' => $M_options['sendername'], 'from_name' => $M_options['senderemail'], 'template' => $template);
    $to_replace = array('content' => wpautop(wptexturize($M_options['messagemail'])), 'username' => $users->user_login, 'password' => $userpassword, 'blog_url' => get_option('siteurl'), 'home_url' => get_option('home'), 'login_url' => wp_login_url(), 'blog_name' => get_option('blogname'), 'blog_description' => get_option('blogdescription'), 'admin_email' => get_option('admin_email'), 'date' => date_i18n(get_option('date_format')), 'time' => date_i18n(get_option('time_format')));
    $to_replace = apply_filters('membership_email_tags', $to_replace);
    foreach ($to_replace as $tag => $var) {
        $emailoptions['template'] = str_replace('%' . $tag . '%', $var, $emailoptions['template']);
    }
    add_filter('wp_mail_content_type', create_function('', 'return "text/html"; '));
    $headers = apply_filters('memebership_email_headers', "From: " . $emailoptions['from_name'] . " <" . $emailoptions['from_email'] . ">  \r\n");
    wp_mail($users->user_email, 'New User Registration Login Details', $emailoptions['template'], $headers);
}
Exemple #5
0
function membership_newsstreamcreatetables($installed = false)
{
    global $wpdb;
    require_once membership_dir('membershipincludes/classes/upgrade.php');
    $charset_collate = M_get_charset_collate();
    $table = 'membership_news';
    $row = $wpdb->get_results($wpdb->prepare("SELECT * FROM INFORMATION_SCHEMA.COLUMNS\n\t\tWHERE table_name = %s and column_name='id' LIMIT 1", membership_db_prefix($wpdb, $table, false)));
    if (!empty($row)) {
        $sql = $wpdb->prepare("RENAME TABLE %s TO %s;", membership_db_prefix($wpdb, $table, false), membership_db_prefix($wpdb, $table));
        $sql = str_replace("'", '`', $sql);
        $wpdb->query($sql);
    } else {
        // Added for RC
        $sql = "CREATE TABLE IF NOT EXISTS `" . membership_db_prefix($wpdb, 'membership_news') . "` (\n\t\t\t  `id` bigint(11) NOT NULL auto_increment,\n\t\t\t  `newsitem` text,\n\t\t\t  `newsdate` datetime default NULL,\n\t\t\t  PRIMARY KEY  (`id`)\n\t\t\t) {$charset_collate};";
        $wpdb->query($sql);
    }
}
function load_membership_plugins()
{
    if (is_dir(membership_dir('membershipincludes/plugins'))) {
        if ($dh = opendir(membership_dir('membershipincludes/plugins'))) {
            $mem_plugins = array();
            while (($plugin = readdir($dh)) !== false) {
                if (substr($plugin, -4) == '.php') {
                    $mem_plugins[] = $plugin;
                }
            }
            closedir($dh);
            sort($mem_plugins);
            foreach ($mem_plugins as $mem_plugin) {
                include_once membership_dir('membershipincludes/plugins/' . $mem_plugin);
            }
        }
    }
    do_action('membership_plugins_loaded');
}
 function set_membership_coupon_cookie()
 {
     if (!defined('DOING_AJAX') || DOING_AJAX == FALSE) {
         die('NOT DOING AJAX?');
     }
     $this->start_membership_session();
     if (isset($_POST['coupon_code'])) {
         $_SESSION['m_coupon_code'] = esc_attr($_POST['coupon_code']);
         include membership_dir('membershipincludes/includes/coupon.form.php');
         die;
     } else {
         die(0);
     }
 }
 function output_paymentpage($user_id = false)
 {
     global $wp_query, $M_options;
     $subscription = (int) $_REQUEST['subscription'];
     if (!$user_id) {
         $user = wp_get_current_user();
         if (!empty($user->ID) && is_numeric($user->ID)) {
             $member = new M_Membership($user->ID);
         } else {
             $member = current_member();
         }
     } else {
         $member = new M_Membership($user_id);
     }
     if (empty($error)) {
         $error = '';
     }
     $content = apply_filters('membership_subscription_form_payment_before_content', '', $error);
     ob_start();
     if (defined('MEMBERSHIP_PAYMENT_FORM') && file_exists(MEMBERSHIP_PAYMENT_FORM)) {
         include_once MEMBERSHIP_PAYMENT_FORM;
     } elseif (file_exists(apply_filters('membership_override_payment_form', membership_dir('membershipincludes/includes/payment.form.php'), $error))) {
         include_once apply_filters('membership_override_payment_form', membership_dir('membershipincludes/includes/payment.form.php'), $error);
     }
     $content .= ob_get_contents();
     ob_end_clean();
     $content = apply_filters('membership_subscription_form_payment_after_content', $content, $error);
     return $content;
 }
                    }
                    ?>
					<input type="radio" id="subyearlypayment" name="paypalpayment" onclick="javascript:selectyearlypayment();">
					<label for="subyearlypayment"></label>					
					</div>
				</div>
			</div>
			<?php 
                }
                ?>
			</div>

			<?php 
                if (!defined('MEMBERSHIP_HIDE_COUPON_FORM')) {
                    if (!isset($M_options['show_coupons_form']) || $M_options['show_coupons_form'] == 'yes') {
                        include_once membership_dir('membershipincludes/includes/coupon.form.php');
                    }
                }
                ?>
			<span class='buynowcolumn'>
				<?php 
                if (!empty($pricing)) {
                    do_action('membership_purchase_button', $sub, $pricing, $member->ID);
                }
                ?>
			</span>
             
             
<div class="payment_note"><b>PLEASE NOTE:</b> Coupon codes should NOT have spaces.  If you received a coupon code with a space, simply remove it and it should work fine.  Thank you and sorry for any confusion or inconvenience.</div>
		</div>
	</div>
    }
    // take care of new users
    Membership_Plugin::factory()->hook_new_user_registration();
    do_action('membership_loaded', $plugin);
}
// register autoloader function
spl_autoload_register('membership_autoloader');
// launch the plugin
membership_launch();
// Load secondary plugins
load_all_membership_addons();
load_membership_gateways();
// Use preset colors
// Remove the indicated lines below to override buttons with a preset color.
// This will override your theme colors and is here for legacy usage. It is not recommended.
/*  --- Remove this line ----

add_filter( 'membership_subscription_button_color', 'add_primary_button_color' );

function add_primary_button_color( $color ) {
	// Replace the color below with other color choices: black, white, gray, orange, red, green, rosy, pink, blue
	$color = 'blue';
	return $color;
}

--- And, remove this line */
// Cron processing moved to the end to ensure tables exist.
require_once membership_dir('membershipincludes/classes/membershipcron.php');
// Update assistant for M2 plugin
require_once membership_dir('membershipincludes/classes/class-m2-migration-handler.php');
Exemple #11
0
 function addons_help()
 {
     ob_start();
     include_once membership_dir('membershipincludes/help/help.addons.php');
     $help = ob_get_clean();
     $this->screen->add_help_tab(array('id' => 'addons', 'title' => __('Add-ons', 'membership'), 'content' => $help));
 }
        function show_dripped_wizard_step($nextsteplink = false)
        {
            global $page, $action, $step;
            $deactivateurl = wp_nonce_url("admin.php?page=" . $page . "&amp;action=deactivatewelcome", 'deactivate-welcome');
            ob_start();
            ?>
				<h3><?php 
            _e('Create your levels', 'membership');
            ?>
</h3>
				<p class="about-description">
					<?php 
            _e('A level controls what parts of your website a user has access to, so we will need to set some initial ones up. ', 'membership');
            _e('Select the number of levels you think you will need to get started (you can add or remove them later).', 'membership');
            ?>
				</p>
				<form action='<?php 
            echo $nextsteplink;
            ?>
' method='post' name='wizardform' id='wizardform'>
					<input type='hidden' name='action' value='processwizard' />
					<input type='hidden' name='from' value='steptwo' />
					<input type='hidden' name='nonce' value='<?php 
            echo wp_create_nonce('membership_wizard');
            ?>
' />
					<input type='hidden' name='wizardtype' value='dripped' />
					<p class="about-description createsteps">
					<?php 
            _e('Create ', 'membership');
            ?>
					<select name='numberoflevels' id='wizardnumberoflevels'>
					<?php 
            for ($n = 1; $n <= 2; $n++) {
                if ($n == 2) {
                    ?>
									<option value='<?php 
                    echo $n;
                    ?>
' selected='selected'><?php 
                    echo $n;
                    ?>
</option>
								<?php 
                } else {
                    ?>
									<option value='<?php 
                    echo $n;
                    ?>
'><?php 
                    echo $n;
                    ?>
</option>
								<?php 
                }
            }
            ?>
					</select>
					<?php 
            _e(' levels and give them the following names:', 'membership');
            ?>
					</p>
						<ul class='wizardlevelnames'>
							<li><input type='text' name='levelname[]' value='<?php 
            _e('Level 1', 'membership');
            ?>
' class='wizardlevelname' /></li>
							<li><input type='text' name='levelname[]' value='<?php 
            _e('Level 2', 'membership');
            ?>
' class='wizardlevelname' /></li>
						</ul>
					<p class="about-description createsteps">
					<input type='checkbox' name='creatavisitorlevel' value='yes' checked='checked' />&nbsp;<?php 
            _e('also create a level to control what non-members can see?', 'membership');
            ?>
					<br/><br/>
					<?php 
            _e('Finally, I would like to use the ', 'membership');
            ?>
					<select name='wizardgateway' >
						<option value=''><?php 
            _e('Select a gateway...', 'membership');
            ?>
</option>
						<?php 
            $gateways = get_membership_gateways();
            if (!empty($gateways)) {
                foreach ($gateways as $key => $gateway) {
                    $default_headers = array('Name' => 'Addon Name', 'Author' => 'Author', 'Description' => 'Description', 'AuthorURI' => 'Author URI', 'gateway_id' => 'Gateway ID');
                    $gateway_data = get_file_data(membership_dir('membershipincludes/gateways/' . $gateway), $default_headers, 'plugin');
                    if (empty($gateway_data['Name'])) {
                        continue;
                    }
                    ?>
										<option value='<?php 
                    echo $gateway_data['gateway_id'];
                    ?>
'><?php 
                    echo $gateway_data['Name'];
                    ?>
</option>
										<?php 
                }
            }
            ?>
					</select>
					<?php 
            _e(' gateway to receive payments.', 'membership');
            ?>
				</p>
				<p class="about-description">
					<input type='submit' name='submit' class='button-primary alignright' value='<?php 
            _e('Finish', 'membership');
            ?>
' />
				</p>
				</form>

				<p class="welcome-panel-dismiss"><?php 
            _e('Already know what you\'re doing?', 'membership');
            ?>
 <a href="<?php 
            echo $deactivateurl;
            ?>
"><?php 
            _e('Dismiss this message', 'membership');
            ?>
</a>.</p>

			<?php 
            return ob_get_clean();
        }
 function dashboard_members()
 {
     global $page, $action;
     $plugin = get_plugin_data(membership_dir('membership.php'));
     $membershipactive = get_option('membership_active', 'no');
     echo __('The membership plugin version ', 'membership') . "<strong>" . $plugin['Version'] . '</strong>';
     echo __(' is ', 'membership');
     // Membership active toggle
     if ($membershipactive == 'no') {
         echo '<strong>' . __('disabled', 'membership') . '</strong> <a href="' . nxt_nonce_url("?page=" . $page . "&amp;action=activate", 'toggle-plugin') . '" title="' . __('Click here to enable the plugin', 'membership') . '">' . __('[Enable it]', 'membership') . '</a>';
     } else {
         echo '<strong>' . __('enabled', 'membership') . '</strong> <a href="' . nxt_nonce_url("?page=" . $page . "&amp;action=deactivate", 'toggle-plugin') . '" title="' . __('Click here to enable the plugin', 'membership') . '">' . __('[Disable it]', 'membership') . '</a>';
     }
     echo '<br/><br/>';
     echo "<strong>" . __('Member counts', 'membership') . "</strong><br/>";
     $detail = $this->get_subscriptions_and_levels(array('sub_status' => 'active'));
     $subs = $this->get_subscriptions(array('sub_status' => 'active'));
     $levels = $this->get_membership_levels(array('level_id' => 'active'));
     echo "<table style='width: 100%;'>";
     echo "<tbody>";
     echo "<tr>";
     echo "<td style='width: 48%' valign='top'>";
     if ($levels) {
         $levelcount = 0;
         echo "<table style='width: 100%;'>";
         echo "<tbody>";
         echo "<tr>";
         echo "<td colspan='2'><strong>" . __('Levels', 'membership') . "</strong></td>";
         echo "</tr>";
         foreach ($levels as $key => $level) {
             echo "<tr>";
             echo "<td><a href='" . admin_url('admin.php?page=membershiplevels&action=edit&level_id=') . $level->id . "'>" . esc_html($level->level_title) . "</a></td>";
             // find out how many people are in this level
             $thiscount = $this->count_on_level($level->id);
             echo "<td style='text-align: right;'>" . (int) $thiscount . "</td>";
             $levelcount += (int) $thiscount;
             echo "</tr>";
         }
         echo "<tr>";
         echo "<td>" . __('Total', 'membership') . "</td>";
         echo "<td style='text-align: right;'><strong>" . (int) $levelcount . "</strong></td>";
         echo "</tr>";
         echo "</tbody>";
         echo "</table>";
     }
     echo "</td>";
     echo "<td style='width: 48%' valign='top'>";
     if ($subs) {
         $subcount = 0;
         echo "<table style='width: 100%;'>";
         echo "<tbody>";
         echo "<tr>";
         echo "<td colspan='2'><strong>" . __('Subscriptions', 'membership') . "</strong></td>";
         echo "</tr>";
         foreach ($subs as $key => $sub) {
             echo "<tr>";
             echo "<td><a href='" . admin_url('admin.php?page=membershipsubs&action=edit&sub_id=') . $sub->id . "'>" . $sub->sub_name . "</a></td>";
             // find out how many people are in this sub
             $thiscount = $this->count_on_sub($sub->id);
             echo "<td style='text-align: right;'>" . (int) $thiscount . "</td>";
             $subcount += (int) $thiscount;
             echo "</tr>";
         }
         echo "<tr>";
         echo "<td>" . __('Total', 'membership') . "</td>";
         echo "<td style='text-align: right;'><strong>" . (int) $subcount . "</strong></td>";
         echo "</tr>";
         echo "</tbody>";
         echo "</table>";
     }
     echo "</td>";
     echo "</tr>";
     echo "</tbody>";
     echo "</table>";
     echo "<br/><strong>" . __('User counts', 'membership') . "</strong><br/>";
     echo "<table style='width: 100%;'>";
     echo "<tbody>";
     echo "<tr>";
     echo "<td style='width: 48%' valign='top'>";
     echo "<table style='width: 100%;'>";
     echo "<tbody>";
     $usercount = $this->db->get_var($this->db->prepare("SELECT count(*) FROM {$this->db->users} INNER JOIN {$this->db->usermeta} ON {$this->db->users}.ID = {$this->db->usermeta}.user_id WHERE {$this->db->usermeta}.meta_key = '{$this->db->prefix}capabilities'"));
     echo "<tr>";
     echo "<td>" . __('Total Users', 'membership') . "</td>";
     echo "<td style='text-align: right;'>" . $usercount . "</td>";
     echo "</tr>";
     $deactivecount = $this->db->get_var($this->db->prepare("SELECT count(*) FROM {$this->db->usermeta} WHERE meta_key = %s AND meta_value = %s", $this->db->prefix . 'membership_active', 'no'));
     echo "<tr>";
     echo "<td>" . __('Deactivated Users', 'membership') . "</td>";
     echo "<td style='text-align: right;'>" . $deactivecount . "</td>";
     echo "</tr>";
     echo "</tbody>";
     echo "</table>";
     echo "</td>";
     echo "<td style='width: 48%' valign='top'></td>";
     echo "</tr>";
     echo "</tbody>";
     echo "</table>";
 }
Exemple #14
0
function load_all_membership_gateways()
{
    if (is_dir(membership_dir('membershipincludes/gateways'))) {
        if ($dh = opendir(membership_dir('membershipincludes/gateways'))) {
            $mem_gateways = array();
            while (($gateway = readdir($dh)) !== false) {
                if (substr($gateway, -4) == '.php') {
                    $mem_gateways[] = $gateway;
                }
            }
            closedir($dh);
            sort($mem_gateways);
            $mem_gateways = apply_filters('membership_available_gateways', $mem_gateways);
            foreach ($mem_gateways as $mem_gateway) {
                include_once membership_dir('membershipincludes/gateways/' . $mem_gateway);
            }
        }
    }
    do_action('membership_gateways_loaded');
}
 function popover_extra_payment_form($user_id = false)
 {
     $content = '';
     $content = apply_filters('membership_popover_extraform_before_content', $content);
     ob_start();
     if (defined('MEMBERSHIP_POPOVER_SENDPAYMENT_FORM') && file_exists(MEMBERSHIP_POPOVER_SENDPAYMENT_FORM)) {
         include_once MEMBERSHIP_POPOVER_SENDPAYMENT_FORM;
     } elseif (file_exists(apply_filters('membership_override_popover_sendpayment_form', membership_dir('membershipincludes/includes/popover_payment.form.php')))) {
         include_once apply_filters('membership_override_popover_sendpayment_form', membership_dir('membershipincludes/includes/popover_payment.form.php'));
     }
     $content .= ob_get_contents();
     ob_end_clean();
     $content = apply_filters('membership_popover_extraform_after_content', $content);
     echo $content;
     exit;
 }
 function membershipsubtext()
 {
     $locale = apply_filters('membership_locale', get_locale());
     $mofile = membership_dir("membershipincludes/languages/membership-{$locale}.mo");
     if (file_exists($mofile)) {
         load_textdomain('membership', $mofile);
     }
     $widget_ops = array('classname' => 'membershipsubtext', 'description' => __('Membership Subscription Text', 'membership'));
     $control_ops = array('width' => 400, 'height' => 350, 'id_base' => 'membershipsubtext');
     $this->WP_Widget('membershipsubtext', __('Membership Subscription Text', 'membership'), $widget_ops, $control_ops);
 }
 function show_renew_page()
 {
     global $M_options;
     $content = '';
     $content = apply_filters('membership_renew_form_member_before_content', $content, $user_id);
     ob_start();
     if (defined('MEMBERSHIP_RENEW_FORM') && file_exists(MEMBERSHIP_RENEW_FORM)) {
         include_once MEMBERSHIP_RENEW_FORM;
     } elseif (file_exists(apply_filters('membership_override_renew_form', membership_dir('membershipincludes/includes/renew.form.php')))) {
         include_once apply_filters('membership_override_renew_form', membership_dir('membershipincludes/includes/renew.form.php'));
     }
     $content .= ob_get_contents();
     ob_end_clean();
     $content = apply_filters('membership_renew_form_member_after_content', $content, $user_id);
     return $content;
 }