$html = $header; $html .= ym_get_additional_registration_form_page($another_page_needed, $page); $html .= $footer; } else { if (isset($_GET['ud']) && $_GET['ud'] == 1) { $html = $header; $user_id = false; if ($username = ym_get('username')) { $user_id = ym_get_user_id_by_username($username); } else { if ($email = ym_get('email')) { $user_id = ym_get_user_id_by_email($email); } } $pack_id = ym_post('ym_subscription', FALSE); $html .= ym_upgrade_buttons(true, $pack_id, $user_id); $html .= $footer; } else { if (ym_request('username')) { $errors = false; $html = $header; if ($page > 1) { $wp_error = new WP_Error(); ym_register_post(ym_request('username'), '', $wp_error, $page); //error checking if ($wp_error->get_error_code()) { $errors = true; $additional_page_needed = $page + 1; $html .= ym_get_additional_registration_form_page($additional_page_needed, $page); } }
function ym_shortcode_parse($args, $content, $tag) { global $ym_sys; get_currentuserinfo(); global $current_user; $arg_zero = isset($args[0]) ? $args[0] : false; if ($tag == 'private') { if (!$ym_sys->protect_mode || ym_post_is_purchasable()) { $return = ym_replace_tag($tag, $content, $args); } else { //just removes the private tags as the query joins hide the posts $return = $content; $return = ''; } } else { if ($tag == 'ym_login') { $return = ym_replace_tag($tag, $content, $args); } else { if ($tag == 'ym_register') { $return = ym_replace_tag($tag, $content, $args); } else { if ($tag == 'private_or') { $account = str_replace('#', '', $arg_zero); $return = ym_replace_tag($tag, $content, $account); } else { if ($tag == 'private_and') { $account = str_replace('#', '', $arg_zero); $return = ym_replace_tag($tag, $content, $account); } else { if ($tag == 'ym_packs') { $return = ym_upgrade_links('page', $args['id'], $args['hide_pack_string'], true); } else { if ($tag == 'ym_upgrade') { if (is_user_logged_in()) { $args['id'] = isset($args['id']) ? $args['id'] : ''; if ($args['id'] == 'get') { $args['id'] = ym_request('id', FALSE); } if ($args['id']) { $return = ym_upgrade_buttons(true, $args['id']); } else { $return = ym_available_modules($current_user->user_login, true, 1); //pass a 1 for coupon type 1 upgrade } } else { $return = ''; } } else { if ($tag == 'ym_drip_date') { $return = ym_drip_date($tag, $content, $args); } else { $args = str_replace('#', '', $arg_zero); $return = ym_replace_tag($tag, $content, $args); } } } } } } } } return do_shortcode(stripslashes($return)); }
function ym_upgrade_buttons($return = false, $pack_id = false, $user_id = false) { global $wpdb, $duration_str, $current_user, $ym_res, $ym_sys, $ym_packs; get_currentuserinfo(); if (!$user_id) { $user_id = $current_user->ID; } if ($pack_id == 'all') { global $ym_packs; $html = ''; foreach ($ym_packs->packs as $pack) { if (!$pack['hide_subscription']) { $html .= ym_upgrade_buttons(TRUE, $pack['id']); } } if ($return) { return $html; } else { echo $html; return; } } $html = ''; $ym_home = get_option('siteurl'); if (!$user_id) { $html = $ym_res->msg_header . __('Sorry but you must be logged in to upgrade your account', 'ym') . $ym_res->msg_footer; } else { $user_data = new YourMember_User($user_id); $account_type = ym_get_user_account_type(false, true); $packs = $ym_packs->packs; $trial_taken = get_user_meta($user_id, 'ym_trial_taken', TRUE); $active_modules = get_option('ym_modules'); $modules_dir = YM_MODULES_DIR; $base = add_query_arg(array('ym_subscribe' => 1, 'ud' => 1, 'username' => $current_user->user_login), $ym_home); if ((!isset($_POST['submit']) || !isset($_POST['subs_opt'])) && !$pack_id) { // TODO: Does this code even run? $html = '<p class="message register">' . __('Choose an Account Type', 'ym') . '</p>'; $html .= '<form action="" method="post" class="ym"><div style="clear: both; overflow: auto; padding-bottom: 10px;">'; // RENDER2 $packs_shown = 0; if ($existing_data = ym_request('ym_subscription')) { $default = $existing_data; } else { // $default = ym_get_default_pack(); $default = $user_data->pack_id; } $did_checked = FALSE; foreach ($packs as $pack) { if (!$pack['hide_subscription']) { $html .= '<div class="ym_register_form_subs_row"> <div class="ym_reg_form_pack_radio"> <input type="radio" '; if ($pack['id'] == $default && !$did_checked) { $html .= 'checked="checked"'; $did_checked = TRUE; } $packs_shown++; $html .= ' class="checkbox" id="ym_subscription_' . $pack['id'] . '" name="ym_subscription" value="' . $pack['id'] . '" /> </div> <label for="ym_subscription_' . $pack['id'] . '" class="ym_subs_opt_label ym_reg_form_pack_name">' . ym_get_pack_label($pack['id']) . '</label> </div>'; } } if (!$packs_shown) { $hide_label = true; } else { if (isset($entry['caption']) && $entry['caption']) { $html .= '<div class="ym_clear"> </div><div class="ym_register_form_caption">' . $entry['caption'] . '</div>' . $row; } } // END RENDER2 if ($packs_shown) { // $html .= '</div><input type="hidden" name="ref" value="'. md5($user_data->amount .'_'. $user_data->duration .'_'. $user_data->duration_type .'_'. $user_data->account_type) .'" />'; $html .= '<p class="submit"><input type="submit" name="submit" value="' . __('Next »', 'ym') . '" /></p>'; } else { $html .= '<p>' . __('Sorry there are currently no upgrade/downgrade options available to you.', 'ym') . '</p>'; } $html .= '</form>'; } else { if (!ym_post('subs_opt') && $pack_id != ym_post('ym_subscription')) { global $ym_res; $html = '<form action="" method="post" class="ym_upgrade_shortcode">'; $html .= '<input type="hidden" name="ym_subscription" value="' . $pack_id . '" />'; // $html .= '<input type="hidden" name="ref" value="'. md5($user_data->amount .'_'. $user_data->duration .'_'. $user_data->duration_type .'_'. $user_data->account_type) .'" />'; $html .= ym_get_pack_label($pack_id); $html .= ' <a href="#nowhere" onClick="jQuery(this).parents(\'form\').submit();">Upgrade</a>'; $html .= '</form>'; return $html; } else { $pack = ym_get_pack_by_id($pack_id); $cost = $pack['cost']; if (!$pack_id) { $html .= '<br /><table width="100%" cellpadding="3" cellspacing="0" border="0" align="center" class="form-table">'; if ($cost == 0 || $account_type == 'free') { $html .= '<tr><th>' . __('Create a free account: ', 'ym') . ucwords($account_type) . '</th></tr>'; } else { $html .= '<tr><th>' . __('Select Payment Gateway', 'ym') . '</th></tr>'; $html .= '<tr><th>' . ym_get_pack_label($pack['id']) . '</th></tr>'; } } if (count($active_modules)) { $buttons_shown = array(); foreach ($active_modules as $module) { if ($module == 'ym_free' && $pack['cost'] > 0) { continue; } require_once $modules_dir . $module . '.php'; $obj = new $module(); $string = $obj->getButton($pack['id']); if ($string) { $buttons_shown[] = $module; $html .= $string; } $string = false; $obj = null; } if (count($buttons_shown) == 1) { $module = array_pop($buttons_shown); $form_code = '<div style="display:none;">' . $html . '</div>'; $js = 'document.forms["' . $module . '_form"].submit();'; $html = ' <html> <head> <title>Redirecting...</title> <script type="text/javascript"> function load() { ' . $js . ' } </script> </head> <body onload="load();">'; $html .= ' <div style="color: #333333; font-size: 14px; margin: 30px 10px; font-family: tahoma; text-align: center; padding: 50px; border: 1px solid silver;">'; $html .= ' <div>' . __('You are being redirected. If this page does not refresh in 5 seconds then click', 'ym') . ' <a onclick="document.forms[\'' . $module . '_form\'].submit();">here</a>.</div> <div style="margin-top: 10px;"><img alt="" src="' . YM_IMAGES_DIR_URL . 'loading.gif" /></div>'; $html .= ' </div>'; $html .= $form_code; $html .= ' </body> </html>'; echo $html; die; } } else { $html .= __('There are no gateways available at this time.', 'ym'); } } } } if ($return) { return $html; } else { echo $html; } }