/** * Set the payment mode to sandbox or live * * @since 0.8 */ function set_mode() { if (wpuf_get_option('sandbox_mode') == 'on') { $this->gateway_url = 'https://www.sandbox.paypal.com/webscr/'; $this->test_mode = true; } }
public static function attach_html($attach_id, $type = NULL) { if (!$type) { $type = isset($_GET['type']) ? $_GET['type'] : 'image'; } $attachment = get_post($attach_id); if (!$attachment) { return; } if (wp_attachment_is_image($attach_id)) { $image = wp_get_attachment_image_src($attach_id, 'thumbnail'); $image = $image[0]; } else { $image = wp_mime_type_icon($attach_id); } $html = '<li class="wpuf-image-wrap thumbnail">'; $html .= sprintf('<div class="attachment-name"><img src="%s" alt="%s" /></div>', $image, esc_attr($attachment->post_title)); if (wpuf_get_option('image_caption', 'wpuf_general', 'off') == 'on') { $html .= '<div class="wpuf-file-input-wrap">'; $html .= sprintf('<input type="text" name="wpuf_files_data[%d][title]" value="%s" placeholder="%s">', $attach_id, esc_attr($attachment->post_title), __('Title', 'wpuf')); $html .= sprintf('<textarea name="wpuf_files_data[%d][caption]" placeholder="%s">%s</textarea>', $attach_id, __('Caption', 'wpuf'), esc_textarea($attachment->post_excerpt)); $html .= sprintf('<textarea name="wpuf_files_data[%d][desc]" placeholder="%s">%s</textarea>', $attach_id, __('Description', 'wpuf'), esc_textarea($attachment->post_content)); $html .= '</div>'; } $html .= sprintf('<input type="hidden" name="wpuf_files[%s][]" value="%d">', $type, $attach_id); $html .= sprintf('<div class="caption"><a href="#" class="btn btn-danger btn-small attachment-delete" data-attach_id="%d">%s</a></div>', $attach_id, __('Delete', 'wpuf')); $html .= '</li>'; return $html; }
/** * Coupon list table column values * * @param string $column_name * @param int $post_ID * @return void */ function coupon_columns_content($column_name, $post_ID) { switch ($column_name) { case 'coupon_type': $price = get_post_meta($post_ID, '_type', true); if ($price == 'amount') { _e('Fixed Price', 'wpuf'); } else { _e('Percentage', 'wpuf'); } break; case 'amount': $type = get_post_meta($post_ID, '_type', true); $currency = $type != 'percent' ? wpuf_get_option('currency_symbol', 'wpuf_payment') : ''; $symbol = $type == 'percent' ? '%' : ''; echo $currency . get_post_meta($post_ID, '_amount', true) . $symbol; break; case 'usage_limit': $usage_limit = get_post_meta($post_ID, '_usage_limit', true); if (intval($usage_limit) == 0) { $usage_limit = __('∞', 'wpuf'); } $use = intval(get_post_meta($post_ID, '_coupon_used', true)); echo $use . '/' . $usage_limit; break; case 'expire_date': $start_date = get_post_meta($post_ID, '_start_date', true); $end_date = get_post_meta($post_ID, '_end_date', true); $start_date = !empty($start_date) ? date_i18n('M j, Y', strtotime($start_date)) : ''; $end_date = !empty($end_date) ? date_i18n('M j, Y', strtotime($end_date)) : ''; echo $start_date . ' to ' . $end_date; break; } }
function add_form_button_style() { global $pagenow, $post_type; if (!in_array($post_type, array('wpuf_forms', 'wpuf_profile'))) { return; } $fixed_sidebar = wpuf_get_option('fixed_form_element', 'wpuf_general'); ?> <style type="text/css"> .wrap .add-new-h2, .wrap .add-new-h2:active { background: #21759b; color: #fff; text-shadow: 0 1px 1px #446E81; } <?php if ($fixed_sidebar == 'on') { ?> #wpuf-metabox-fields{ position: fixed; bottom: 10px; } <?php } ?> </style> <?php }
/** * Show user info on dashboard */ function user_info() { global $userdata; if (wpuf_get_option('show_user_bio', 'wpuf_dashboard', 'on') == 'on') { ?> <div class="wpuf-author"> <h3><?php _e('Author Info', 'wpuf'); ?> </h3> <div class="wpuf-author-inside odd"> <div class="wpuf-user-image"><?php echo get_avatar($userdata->user_email, 80); ?> </div> <div class="wpuf-author-body"> <p class="wpuf-user-name"><a href="<?php echo get_author_posts_url($userdata->ID); ?> "><?php printf(esc_attr__('%s', 'wpuf'), $userdata->display_name); ?> </a></p> <p class="wpuf-author-info"><?php echo $userdata->description; ?> </p> </div> </div> </div><!-- .author --> <?php } }
/** * reCaptcha Validation * * @return void */ function validate_re_captcha() { $recap_challenge = isset($_POST['recaptcha_challenge_field']) ? $_POST['recaptcha_challenge_field'] : ''; $recap_response = isset($_POST['recaptcha_response_field']) ? $_POST['recaptcha_response_field'] : ''; $private_key = wpuf_get_option('recaptcha_private', 'wpuf_general'); $resp = recaptcha_check_answer($private_key, $_SERVER["REMOTE_ADDR"], $recap_challenge, $recap_response); if (!$resp->is_valid) { $this->send_error(__('reCAPTCHA validation failed', 'wpuf')); } }
/** * Prepare the payment form and send to paypal * * @since 0.8 * @param array $data payment info */ function prepare_to_send($data) { $order_id = wp_insert_post(array('post_type' => 'wpuf_order', 'post_status' => 'publish', 'post_title' => 'WPUF Bank Order')); if ($order_id) { update_post_meta($order_id, '_data', $data); } do_action('wpuf_gateway_bank_order_submit', $data, $order_id); $success = get_permalink(wpuf_get_option('bank_success', 'wpuf_payment')); wp_redirect($success); exit; }
/** * Add post shortcode handler * * @param array $atts * @return string */ function shortcode_handler($atts) { extract(shortcode_atts(array('id' => 0, 'type' => 'registration'), $atts)); //registration time redirect to subscription if ($type == 'registration') { $is_fource_pack = wpuf_get_option('register_subscription', 'wpuf_payment'); if ($is_fource_pack == 'on' && !isset($_GET['type']) || $is_fource_pack == 'on' && $_GET['type'] != 'wpuf_sub') { $subscription_page_id = wpuf_get_option('subscription_page', 'wpuf_payment'); if (empty($subscription_page_id)) { _e('Please select subscription page', 'wpuf'); return; } else { wp_redirect(get_permalink($subscription_page_id)); exit; } } } ob_start(); $form_vars = wpuf_get_form_fields($id); //get_post_meta( $id, self::$meta_key, true ); $form_settings = wpuf_get_form_settings($id); if (!$form_vars) { return; } if ($type == 'profile') { if (is_user_logged_in()) { if (isset($_GET['msg']) && $_GET['msg'] == 'profile_update') { echo '<div class="wpuf-success">'; echo $form_settings['update_message']; echo '</div>'; } $this->profile_edit($id, $form_vars, $form_settings); } else { echo '<div class="wpuf-info">' . __('Please login to update your profile!', 'wpuf') . '</div>'; } } elseif ($type == 'registration') { if (is_user_logged_in()) { echo '<div class="wpuf-info">' . __('You are already logged in!', 'wpuf') . '</div>'; } else { if (get_option('users_can_register') != '1') { echo '<div class="wpuf-info">'; _e('User registration is currently not allowed.'); echo '</div>'; return; } $this->profile_edit($id, $form_vars, $form_settings); } } // var_dump( $id, $type, $form_vars, $form_settings ); $content = ob_get_contents(); ob_end_clean(); return $content; }
/** * reCaptcha Validation * * @return void */ function validate_re_captcha($no_captcha = '') { $private_key = wpuf_get_option('recaptcha_private', 'wpuf_general'); if ($no_captcha == 1) { $response = null; $reCaptcha = new ReCaptcha($private_key); $resp = $reCaptcha->verifyResponse($_SERVER["REMOTE_ADDR"], $_POST["g-recaptcha-response"]); if (!$resp->success) { $this->send_error(__('reCAPTCHA validation failed', 'wpuf')); } } elseif ($no_captcha == 0) { $recap_challenge = isset($_POST['recaptcha_challenge_field']) ? $_POST['recaptcha_challenge_field'] : ''; $recap_response = isset($_POST['recaptcha_response_field']) ? $_POST['recaptcha_response_field'] : ''; $resp = recaptcha_check_answer($private_key, $_SERVER["REMOTE_ADDR"], $recap_challenge, $recap_response); if (!$resp->is_valid) { $this->send_error(__('reCAPTCHA validation failed', 'wpuf')); } } }
function add_post_fields($post_type, $post_obj = null) { //var_dump($post_type, $post_obj); $attachments = array(); if ($post_obj) { $attachments = wpfu_get_attachments($post_obj->ID); } ?> <li> <label><?php echo wpuf_get_option('attachment_label', 'wpuf_labels', 'Attachments'); ?> </label> <div class="clear"></div> </li> <li> <div id="wpuf-attachment-upload-container"> <div id="wpuf-attachment-upload-filelist"> <ul class="wpuf-attachment-list"> <script>window.wpufFileCount = 0;</script> <?php if ($attachments) { foreach ($attachments as $attach) { echo $this->attach_html($attach['id']); echo '<script>window.wpufFileCount += 1;</script>'; } } ?> </ul> </div> <a id="wpuf-attachment-upload-pickfiles" class="button" href="#"><?php echo wpuf_get_option('attachment_btn_label', 'wpuf_labels', 'Add another'); ?> </a> </div> <div class="clear"></div> </li> <?php }
/** * Set the payment mode to sandbox or live * * @since 0.8 */ function set_mode() { if (wpuf_get_option('sandbox_mode', 'wpuf_payment') == 'on') { $this->gateway_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr/?'; $this->gateway_cancel_url = 'https://api-3t.sandbox.paypal.com/nvp'; $this->test_mode = true; } }
/** * Send payment handler to the gateway * * This function sends the payment handler mechanism to the selected * gateway. If 'paypal' is selected, then a particular action is being * called. A listener function can be invoked for that gateway to handle * the request and send it to the gateway. * * Need to use `wpuf_gateway_{$gateway_name} */ function send_to_gateway() { if (isset($_POST['wpuf_payment_submit']) && $_POST['action'] == 'wpuf_pay' && wp_verify_nonce($_POST['_wpnonce'], 'wpuf_payment_gateway')) { $post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0; $pack_id = isset($_REQUEST['pack_id']) ? intval($_REQUEST['pack_id']) : 0; $gateway = $_POST['wpuf_payment_method']; $type = $_POST['type']; if (is_user_logged_in()) { $userdata = wp_get_current_user(); } else { $user_id = isset($_REQUEST['user_id']) ? $_REQUEST['user_id'] : 0; if ($user_id) { $userdata = get_userdata($user_id); } else { $userdata = new stdClass(); $userdata->ID = 0; $userdata->user_email = ''; $userdata->first_name = ''; $userdata->last_name = ''; } } switch ($type) { case 'post': $post = get_post($post_id); $amount = wpuf_get_option('cost_per_post', 'wpuf_payment'); $item_number = get_post_meta($post_id, '_wpuf_order_id', true); $item_name = $post->post_title; break; case 'pack': $pack = WPUF_Subscription::init()->get_subscription($pack_id); $custom = $pack->meta_value; $amount = $this->coupon_discount($_POST['coupon_code'], $pack->meta_value['billing_amount'], $pack_id); $item_name = $pack->post_title; $item_number = $pack->ID; break; } $payment_vars = array('currency' => wpuf_get_option('currency', 'wpuf_payment'), 'price' => $amount, 'item_number' => $item_number, 'item_name' => $item_name, 'type' => $type, 'user_info' => array('id' => $userdata->ID, 'email' => $userdata->user_email, 'first_name' => $userdata->first_name, 'last_name' => $userdata->last_name), 'date' => date('Y-m-d H:i:s'), 'post_data' => $_POST, 'custom' => isset($custom) ? $custom : ''); do_action('wpuf_gateway_' . $gateway, $payment_vars); } }
/** * Show a info message when posting if payment is enabled */ function add_post_info() { if ($this->has_post_error()) { ?> <div class="info"> <?php printf(__('This will cost you <strong>%s</strong>. to add a new post. You may buy some bulk package too. ', 'wpuf'), wpuf_get_option('currency_symbol') . wpuf_get_option('cost_per_post')); ?> </div> <?php } }
/** * Send payment handler to the gateway * * This function sends the payment handler mechanism to the selected * gateway. If 'paypal' is selected, then a particular action is being * called. A listener function can be invoked for that gateway to handle * the request and send it to the gateway. * * Need to use `wpuf_gateway_{$gateway_name} */ function send_to_gateway() { if (isset($_POST['wpuf_payment_submit']) && $_POST['action'] == 'wpuf_pay' && wp_verify_nonce($_POST['_wpnonce'], 'wpuf_payment_gateway')) { $post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0; $pack_id = isset($_REQUEST['pack_id']) ? intval($_REQUEST['pack_id']) : 0; $gateway = $_POST['wpuf_payment_method']; $type = $_POST['type']; $userdata = wp_get_current_user(); switch ($type) { case 'post': $post = get_post($post_id); $amount = wpuf_get_option('cost_per_post'); $item_number = get_post_meta($post_id, 'wpuf_order_id', true); $item_name = $post->post_title; break; case 'pack': $subscription = new WPUF_Subscription(); $pack = $subscription->get_subscription($pack_id); $amount = $pack->cost; $item_name = $pack->name; $item_number = $pack->id; break; } $payment_vars = array('currency' => wpuf_get_option('currency'), 'price' => $amount, 'item_number' => $item_number, 'item_name' => $item_name, 'type' => $type, 'user_info' => array('id' => $userdata->ID, 'email' => $userdata->user_email, 'first_name' => $userdata->first_name, 'last_name' => $userdata->last_name), 'date' => date('Y-m-d H:i:s'), 'post_data' => $_POST); do_action('wpuf_gateway_' . $gateway, $payment_vars); } }
function user_register() { check_ajax_referer('wpuf_form_add'); @header('Content-Type: application/json; charset=' . get_option('blog_charset')); $form_id = isset($_POST['form_id']) ? intval($_POST['form_id']) : 0; $form_vars = $this->get_input_fields($form_id); $form_settings = wpuf_get_form_settings($form_id); list($user_vars, $taxonomy_vars, $meta_vars) = $form_vars; // search if rs captcha is there if ($this->search($user_vars, 'input_type', 'really_simple_captcha')) { $this->validate_rs_captcha(); } // check recaptcha if ($this->search($user_vars, 'input_type', 'recaptcha')) { $this->validate_re_captcha(); } $has_username_field = false; $username = ''; $user_email = ''; $firstname = ''; $lastname = ''; // don't let to be registered if no email address given if (!isset($_POST['user_email'])) { $this->send_error(__('An Email address is required', 'wpuf')); } // if any username given, check if it exists if ($this->search($user_vars, 'name', 'user_login')) { $has_username_field = true; $username = sanitize_user(trim($_POST['user_login'])); if (username_exists($username)) { $this->send_error(__('Username already exists.', 'wpuf')); } } // if any email address given, check if it exists if ($this->search($user_vars, 'name', 'user_email')) { $user_email = trim($_POST['user_email']); if (email_exists($user_email)) { $this->send_error(__('E-mail address already exists.', 'wpuf')); } } // if there isn't any username field in the form, lets guess a username if (!$has_username_field) { $username = $this->guess_username($user_email); } if (!validate_username($username)) { $this->send_error(__('Username is not valid', 'wpuf')); } // verify password if ($pass_element = $this->search($user_vars, 'name', 'password')) { $pass_element = current($pass_element); $password = $_POST['pass1']; $password_repeat = isset($_POST['pass2']) ? $_POST['pass2'] : false; // min length check if (strlen($password) < intval($pass_element['min_length'])) { $this->send_error(sprintf(__('Password must be %s character long', 'wpuf'), $pass_element['min_length'])); } // repeat password check if ($password != $password_repeat && $password_repeat !== false) { $this->send_error(__('Password didn\'t match', 'wpuf')); } } else { $password = wp_generate_password(); } // default WP registration hook $errors = new WP_Error(); do_action('register_post', $username, $user_email, $errors); $errors = apply_filters('registration_errors', $errors, $username, $user_email); if ($errors->get_error_code()) { $this->send_error($errors->get_error_message()); } // seems like we don't have any error. Lets register the user $user_id = wp_create_user($username, $password, $user_email); if (is_wp_error($user_id)) { $this->send_error($user_id->get_error_message()); } else { $userdata = array('ID' => $user_id, 'first_name' => $this->search($user_vars, 'name', 'first_name') ? $_POST['first_name'] : '', 'last_name' => $this->search($user_vars, 'name', 'last_name') ? $_POST['last_name'] : '', 'nickname' => $this->search($user_vars, 'name', 'nickname') ? $_POST['nickname'] : '', 'user_url' => $this->search($user_vars, 'name', 'user_url') ? $_POST['user_url'] : '', 'description' => $this->search($user_vars, 'name', 'description') ? $_POST['description'] : '', 'role' => $form_settings['role']); $user_id = wp_update_user(apply_filters('wpuf_register_user_args', $userdata)); if ($user_id) { // update meta fields $this->update_user_meta($meta_vars, $user_id); // send user notification or email verification if (isset($form_settings['enable_email_verification']) && $form_settings['enable_email_verification'] != 'yes') { wp_send_new_user_notifications($user_id); } else { $this->send_verification_mail($user_id, $user_email); } do_action('wpuf_after_register', $user_id, $userdata, $form_id, $form_settings); //redirect URL $show_message = false; $redirect_to = ''; if ($form_settings['redirect_to'] == 'page') { $redirect_to = get_permalink($form_settings['page_id']); } elseif ($form_settings['redirect_to'] == 'url') { $redirect_to = $form_settings['url']; } elseif ($form_settings['redirect_to'] == 'same') { $show_message = true; } else { $redirect_to = get_permalink($post_id); } // send the response $response = array('success' => true, 'post_id' => $user_id, 'redirect_to' => $redirect_to, 'show_message' => $show_message, 'message' => isset($form_settings['enable_email_verification']) && $form_settings['enable_email_verification'] == 'yes' ? __('Please check your email for activation link', 'wpuf') : $form_settings['message']); $autologin_after_registration = wpuf_get_option('autologin_after_registration', 'wpuf_profile'); if ($autologin_after_registration == 'on') { wp_set_current_user($user_id); wp_set_auth_cookie($user_id); } $response = apply_filters('wpuf_user_register_redirect', $response, $user_id, $userdata, $form_id, $form_settings); wpuf_clear_buffer(); echo json_encode($response); exit; } // endif } wpuf_clear_buffer(); echo json_encode(array('success' => false, 'error' => __('Something went wrong', 'wpuf'))); exit; }
/** * Checks against the user, if he is valid for posting new post * * @global object $userdata * @return bool */ public static function has_user_error($form_settings = null) { global $userdata; $user_id = isset($userdata->ID) ? $userdata->ID : ''; // bail out if charging is not enabled if (wpuf_get_option('charge_posting', 'wpuf_payment') != 'yes') { return false; } // check form if subscription is disabled if (isset($form_settings['subscription_disabled']) && $form_settings['subscription_disabled'] == 'yes') { return false; } $user_sub_meta = self::get_user_pack($user_id); $form_post_type = isset($form_settings['post_type']) ? $form_settings['post_type'] : 'post'; $post_count = isset($user_sub_meta['posts'][$form_post_type]) ? $user_sub_meta['posts'][$form_post_type] : 0; if (isset($user_sub_meta['recurring']) && $user_sub_meta['recurring'] == 'yes') { // user has recurring subscription if ($post_count > 0 || $post_count == '-1') { return false; } else { return true; } } else { $expire = isset($user_sub_meta['expire']) ? $user_sub_meta['expire'] : 0; if (strtolower($expire) == 'unlimited' || empty($expire)) { $expire_status = false; } else { if (strtotime(date('Y-m-d', strtotime($expire))) >= strtotime(date('Y-m-d', time())) && ($post_count > 0 || $post_count == '-1')) { $expire_status = false; } else { $expire_status = true; } } if ($post_count > 0 || $post_count == '-1') { $post_count_status = false; } else { $post_count_status = true; } if ($expire_status || $post_count_status) { return true; } } return false; }
/** * Adds the postlock form in users profile * * @param object $profileuser */ function profile_subscription_details($profileuser) { if (!current_user_can('edit_users')) { return; } if (wpuf_get_option('charge_posting', 'wpuf_payment') != 'yes') { return; } $userdata = get_userdata($profileuser->ID); //wp 3.3 fix $packs = WPUF_Subscription::init()->get_subscriptions(); $user_sub = WPUF_Subscription::get_user_pack($userdata->ID); $pack_id = isset($user_sub['pack_id']) ? $user_sub['pack_id'] : ''; ?> <div class="wpuf-user-subscription"> <h3><?php _e('WPUF Subscription', 'wpuf'); ?> </h3> <?php if (isset($user_sub['pack_id'])) { $pack = WPUF_Subscription::get_subscription($user_sub['pack_id']); $details_meta = WPUF_Subscription::init()->get_details_meta_value(); $billing_amount = intval($pack->meta_value['billing_amount']) > 0 ? $details_meta['symbol'] . $pack->meta_value['billing_amount'] : __('Free', 'wpuf'); if ($billing_amount && $pack->meta_value['recurring_pay'] == 'yes') { $recurring_des = sprintf('For each %s %s', $pack->meta_value['billing_cycle_number'], $pack->meta_value['cycle_period'], $pack->meta_value['trial_duration_type']); $recurring_des .= !empty($pack->meta_value['billing_limit']) ? sprintf(', for %s installments', $pack->meta_value['billing_limit']) : ''; $recurring_des = $recurring_des; } else { $recurring_des = ''; } ?> <div class="wpuf-user-sub-info"> <h3><?php _e('Subscription Details', 'wpuf'); ?> </h3> <?php if (isset($user_sub['recurring']) && $user_sub['recurring'] == 'yes') { ?> <div class="updated"> <p><?php _e('This user is using recurring subscription pack', 'wpuf'); ?> </p> </div> <?php } ?> <div class="wpuf-text"> <div><strong><?php _e('Subcription Name: ', 'wpuf'); ?> </strong><?php echo $pack->post_title; ?> </div> <div> <strong><?php _e('Package billing details: '); ?> </strong> <div class="wpuf-pricing-wrap"> <div class="wpuf-sub-amount"> <?php echo $billing_amount; ?> <?php echo $recurring_des; ?> </div> </div> </div> <strong><?php _e('Remaining post: ', 'wpuf'); ?> </strong> <table class="form-table"> <?php foreach ($user_sub['posts'] as $key => $value) { ?> <tr> <th><label><?php echo $key; ?> </label></th> <td><input type="text" value="<?php echo $value; ?> " name="<?php echo $key; ?> " ></td> </tr> <?php } ?> <?php if ($user_sub['recurring'] != 'yes') { if (!empty($user_sub['expire'])) { $expire = $user_sub['expire'] == 'unlimited' ? ucfirst('unlimited') : wpuf_date2mysql($user_sub['expire']); ?> <tr> <th><label><?php echo _e('Expire date:'); ?> </label></th> <td><input type="text" class="wpuf-date-picker" name="expire" value="<?php echo wpuf_get_date($expire); ?> "></td> </tr> <?php } } ?> <?php $is_post_exp_selected = isset($user_sub['_enable_post_expiration']) ? 'checked' : ''; $_post_expiration_time = explode(' ', isset($user_sub['_post_expiration_time']) ? $user_sub['_post_expiration_time'] : ' '); $time_value = isset($_post_expiration_time[0]) && !empty($_post_expiration_time[0]) ? $_post_expiration_time[0] : '1'; $time_type = isset($_post_expiration_time[1]) && !empty($_post_expiration_time[1]) ? $_post_expiration_time[1] : 'day'; ?> <tr> <th><label><?php echo _e('Post Expiration Enabled'); ?> </label></th> <td><input type="checkbox" name="is_post_expiration_enabled" value="on" <?php echo $is_post_exp_selected; ?> ></td> </tr> <tr> <?php $timeType_array = array('year' => 100, 'month' => 12, 'day' => 30); ?> <th><?php _e('Post Expiration Time', 'wpuf'); ?> </th> <td> <select name="post_expiration_settings[expiration_time_value]" id="wpuf-expiration_time_value"> <?php for ($i = 1; $i <= $timeType_array[$time_type]; $i++) { ?> <option value="<?php echo $i; ?> " <?php echo $i == $time_value ? 'selected' : ''; ?> ><?php echo $i; ?> </option> <?php } ?> </select> <select name="post_expiration_settings[expiration_time_type]" id="wpuf-expiration_time_type"> <?php foreach ($timeType_array as $each_time_type => $each_time_type_val) { ?> <option value="<?php echo $each_time_type; ?> " <?php echo $each_time_type == $time_type ? 'selected' : ''; ?> ><?php echo ucfirst($each_time_type); ?> </option> <?php } ?> </select> </td> </tr> </table> </div> </div> <?php } ?> <?php if (!isset($user_sub['recurring']) || $user_sub['recurring'] != 'yes') { ?> <a class="btn button-primary wpuf-assing-pack-btn wpuf-add-pack" href="#"><?php _e('Assign Package', 'wpuf'); ?> </a> <a class="btn button-primary wpuf-assing-pack-btn wpuf-cancel-pack" style="display:none;" href="#"><?php _e('Show Package', 'wpuf'); ?> </a> <table class="form-table wpuf-pack-dropdown" disabled="disabled" style="display: none;"> <tr> <th><label for="wpuf_sub_pack"><?php _e('Pack:', 'wpuf'); ?> </label></th> <td> <select name="pack_id" id="wpuf_sub_pack"> <option value="-1"><?php _e('--Select--', 'wpuf'); ?> </option> <?php $this->packdropdown_without_recurring($packs, $pack_id); //WPUF_Subscription::init()->packdropdown( $packs, $selected = '' ); ?> </select> </td> </tr> </table> <?php } ?> <?php if (!empty($user_sub)) { ?> <a class="btn button-primary wpuf-delete-pack-btn" href="javascript:" data-userid = "<?php echo $userdata->ID; ?> "><?php _e('Delete Package', 'wpuf'); ?> </a> <?php } ?> </div> <?php }
function submit_post() { global $userdata; $errors = array(); $title = trim($_POST['wpuf_post_title']); $content = trim($_POST['wpuf_post_content']); $tags = ''; $cat = ''; if (isset($_POST['wpuf_post_tags'])) { $tags = wpuf_clean_tags($_POST['wpuf_post_tags']); } //if there is some attachement, validate them if (!empty($_FILES['wpuf_post_attachments'])) { $errors = wpuf_check_upload(); } if (empty($title)) { $errors[] = __('Empty post title', 'wpuf'); } else { $title = trim(strip_tags($title)); } //validate cat $cat_type = wpuf_get_option('cat_type'); if (!isset($_POST['category'])) { $errors[] = __('Please choose a category', 'wpuf'); } else { if ($cat_type == 'normal' && $_POST['category'][0] == '-1') { $errors[] = __('Please choose a category', 'wpuf'); } else { if (count($_POST['category']) < 1) { $errors[] = __('Please choose a category', 'wpuf'); } } } if (empty($content)) { $errors[] = __('Empty post content', 'wpuf'); } else { $content = trim($content); } if (!empty($tags)) { $tags = explode(',', $tags); } //process the custom fields $custom_fields = array(); $fields = wpuf_get_custom_fields(); if (is_array($fields)) { foreach ($fields as $cf) { if (array_key_exists($cf['field'], $_POST)) { $temp = trim(strip_tags($_POST[$cf['field']])); //var_dump($temp, $cf); if ($cf['type'] == 'yes' && !$temp) { $errors[] = sprintf(__('%s is missing', 'wpuf'), $cf['label']); } else { $custom_fields[$cf['field']] = $temp; } } //array_key_exists } //foreach } //is_array //post attachment $attach_id = isset($_POST['wpuf_featured_img']) ? intval($_POST['wpuf_featured_img']) : 0; $errors = apply_filters('wpuf_edit_post_validation', $errors); if (!$errors) { //users are allowed to choose category if (wpuf_get_option('allow_cats') == 'on') { $post_category = $_POST['category']; } else { $post_category = array(get_option('wpuf_default_cat')); } $post_update = array('ID' => trim($_POST['post_id']), 'post_title' => $title, 'post_content' => $content, 'post_category' => $post_category, 'tags_input' => $tags); //plugin API to extend the functionality $post_update = apply_filters('wpuf_edit_post_args', $post_update); $post_id = wp_update_post($post_update); if ($post_id) { echo '<div class="success">' . __('Post updated succesfully.', 'wpuf') . '</div>'; //upload attachment to the post wpuf_upload_attachment($post_id); //set post thumbnail if has any if ($attach_id) { set_post_thumbnail($post_id, $attach_id); } //add the custom fields if ($custom_fields) { foreach ($custom_fields as $key => $val) { update_post_meta($post_id, $key, $val, false); } } do_action('wpuf_edit_post_after_update', $post_id); } } else { echo wpuf_error_msg($errors); } }
/** * Adds the postlock form in users profile * * @param object $profileuser */ function profile_subscription_details($profileuser) { if (!is_admin() && !current_user_can('edit_users')) { return; } if (wpuf_get_option('charge_posting', 'wpuf_payment') != 'yes') { return; } $userdata = get_userdata($profileuser->ID); //wp 3.3 fix $packs = WPUF_Subscription::init()->get_subscriptions(); $user_sub = WPUF_Subscription::get_user_pack($userdata->ID); $pack_id = isset($user_sub['pack_id']) ? $user_sub['pack_id'] : ''; ?> <div class="wpuf-user-subscription"> <h3><?php _e('WPUF Subscription', 'wpuf'); ?> </h3> <a class="btn button-primary wpuf-assing-pack-btn wpuf-add-pack" href="#"><?php _e('Assign Package', 'wpuf'); ?> </a> <a class="btn button-primary wpuf-assing-pack-btn wpuf-cancel-pack" style="display:none;" href="#"><?php _e('Show Package', 'wpuf'); ?> </a> <table class="form-table wpuf-pack-dropdown" disabled="disabled" style="display: none;"> <tr> <th><label for="wpuf_sub_pack"><?php _e('Pack:', 'wpuf'); ?> </label></th> <td> <select name="pack_id" id="wpuf_sub_pack"> <option value="-1"><?php _e('--Select--', 'wpuf'); ?> </option> <?php $this->packdropdown_without_recurring($packs, $pack_id); //WPUF_Subscription::init()->packdropdown( $packs, $selected = '' ); ?> </select> </td> </tr> </table> <?php if (!isset($user_sub['pack_id'])) { return; } $pack = WPUF_Subscription::get_subscription($user_sub['pack_id']); $details_meta = WPUF_Subscription::init()->get_details_meta_value(); $billing_amount = intval($pack->meta_value['billing_amount']) > 0 ? $details_meta['symbol'] . $pack->meta_value['billing_amount'] : __('Free', 'wpuf'); if ($billing_amount && $pack->meta_value['recurring_pay'] == 'yes') { $recurring_des = sprintf('For each %s %s', $pack->meta_value['billing_cycle_number'], $pack->meta_value['cycle_period'], $pack->meta_value['trial_duration_type']); $recurring_des .= !empty($pack->meta_value['billing_limit']) ? sprintf(', for %s installments', $pack->meta_value['billing_limit']) : ''; $recurring_des = $recurring_des; } else { $recurring_des = ''; } ?> <div class="wpuf-user-sub-info"> <h3><?php _e('Subscription Details', 'wpuf'); ?> </h3> <div class="wpuf-text"> <div><strong><?php _e('Subcription Name: ', 'wpuf'); ?> </strong><?php echo $pack->post_title; ?> </div> <div> <strong><?php _e('Package billing details: '); ?> </strong> <div class="wpuf-pricing-wrap"> <div class="wpuf-sub-amount"> <?php echo $billing_amount; ?> <?php echo $recurring_des; ?> </div> </div> </div> <strong><?php _e('Remaining post: ', 'wpuf'); ?> </strong> <table class="form-table"> <?php foreach ($user_sub['posts'] as $key => $value) { ?> <tr> <th><label><?php echo $key; ?> </label></th> <td><input type="text" value="<?php echo $value; ?> " name="<?php echo $key; ?> " ></td> </tr> <?php } ?> <?php if ($user_sub['recurring'] != 'yes') { if (!empty($user_sub['expire'])) { $expire = $user_sub['expire'] == 'unlimited' ? ucfirst('unlimited') : wpuf_date2mysql($user_sub['expire']); ?> <tr> <th><label><?php echo _e('Expire date:'); ?> </label></th> <td><input type="text" class="wpuf-date-picker" name="expire" value="<?php echo wpuf_get_date($expire); ?> "></td> </tr> <?php } } ?> </table> </div> </div> </div> <?php }
function wpuf_transaction() { global $wpdb; $date = date('d-m-Y H:i:s', time()); $month = date('m', time()); $year = date('Y', time()); //var_dump( $date, $month, $year); $total_income = $wpdb->get_var("SELECT SUM(cost) FROM {$wpdb->prefix}wpuf_transaction"); $month_income = $wpdb->get_var("SELECT SUM(cost) FROM {$wpdb->prefix}wpuf_transaction WHERE YEAR(`created`) = YEAR(NOW()) AND MONTH(`created`) = MONTH(NOW())"); $fields = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}wpuf_transaction ORDER BY `created` DESC LIMIT 0, 60", OBJECT); ?> <div class="wrap"> <div id="icon-options-general" class="icon32"><br></div> <h2>WP User Frontend: Payments Received</h2> Total Income: <?php echo wpuf_get_option('currency', 'wpuf_payment') . $total_income; ?> <br /> This Month: <?php echo wpuf_get_option('currency', 'wpuf_payment') . $month_income; ?> <hr /> <table class="widefat meta" style="margin-bottom: 20px;"> <thead> <tr> <th scope="col">ID</th> <th scope="col">User ID</th> <th scope="col">Status</th> <th scope="col">Cost</th> <th scope="col">Post ID</th> <th scope="col">Pack ID</th> <th scope="col">Payer</th> <th scope="col">Email</th> <th scope="col">Type</th> <th scope="col">Transaction ID</th> <th scope="col">Created</th> </tr> </thead> <?php if ($wpdb->num_rows > 0) { $count = 0; foreach ($fields as $row) { //var_dump( $row ); ?> <tr valign="top" <?php echo $count % 2 == 0 ? 'class="alternate"' : ''; ?> > <td><?php echo stripslashes(htmlspecialchars($row->id)); ?> </td> <td><?php echo stripslashes(htmlspecialchars($row->user_id)); ?> </td> <td><?php echo stripslashes(htmlspecialchars($row->status)); ?> </td> <td><?php echo stripslashes(htmlspecialchars($row->cost)); ?> </td> <td><?php echo stripslashes(htmlspecialchars($row->post_id)); ?> </td> <td><?php echo stripslashes(htmlspecialchars($row->pack_id)); ?> </td> <td><?php echo $row->payer_first_name . ' ' . $row->payer_last_name; ?> </td> <td><?php echo stripslashes(htmlspecialchars($row->payer_email)); ?> </td> <td><?php echo stripslashes(htmlspecialchars($row->payment_type)); ?> </td> <td><?php echo stripslashes(htmlspecialchars($row->transaction_id)); ?> </td> <td><?php echo stripslashes(htmlspecialchars($row->created)); ?> </td> </tr> <?php $count++; } ?> <?php } else { ?> <tr> <td colspan="5">Nothing Found</td> </tr> <?php } ?> </table> </div> <?php }
} else { ?> <a href="<?php echo wp_nonce_url($url, 'wpuf_edit'); ?> "><?php _e('Edit', 'wpuf'); ?> </a> <?php } } ?> <?php if (wpuf_get_option('enable_post_del', 'wpuf_dashboard', 'yes') == 'yes') { $del_url = add_query_arg(array('action' => 'del', 'pid' => $post->ID)); ?> <a href="<?php echo wp_nonce_url($del_url, 'wpuf_del'); ?> " onclick="return confirm('Are you sure to delete?');"><span style="color: red;"><?php _e('Delete', 'wpuf'); ?> </span></a> <?php } ?> </td> </tr> <?php
/** * New/Edit post submit handler * * @return void */ function submit_post() { check_ajax_referer('wpuf_form_add'); @header('Content-Type: application/json; charset=' . get_option('blog_charset')); $form_id = isset($_POST['form_id']) ? intval($_POST['form_id']) : 0; $form_vars = $this->get_input_fields($form_id); $form_settings = wpuf_get_form_settings($form_id); list($post_vars, $taxonomy_vars, $meta_vars) = $form_vars; // don't check captcha on post edit if (!isset($_POST['post_id'])) { // search if rs captcha is there if ($this->search($post_vars, 'input_type', 'really_simple_captcha')) { $this->validate_rs_captcha(); } // check recaptcha if ($this->search($post_vars, 'input_type', 'recaptcha')) { $this->validate_re_captcha(); } } $is_update = false; $post_author = null; $default_post_author = wpuf_get_option('default_post_owner', 'wpuf_general', 1); // Guest Stuffs: check for guest post if (!is_user_logged_in()) { if ($form_settings['guest_post'] == 'true' && $form_settings['guest_details'] == 'true') { $guest_name = trim($_POST['guest_name']); $guest_email = trim($_POST['guest_email']); // is valid email? if (!is_email($guest_email)) { $this->send_error(__('Invalid email address.', 'wpuf')); } // check if the user email already exists $user = get_user_by('email', $guest_email); if ($user) { // $post_author = $user->ID; echo json_encode(array('success' => false, 'error' => __("You already have an account in our site. Please login to continue.\n\nClicking 'OK' will redirect you to the login page and you will lost the form data.\nClick 'Cancel' to stay at this page.", 'wpuf'), 'type' => 'login', 'redirect_to' => wp_login_url(get_permalink($_POST['page_id'])))); exit; } else { // user not found, lets register him // username from email address $username = $this->guess_username($guest_email); $user_pass = wp_generate_password(12, false); $errors = new WP_Error(); do_action('register_post', $username, $guest_email, $errors); $user_id = wp_create_user($username, $user_pass, $guest_email); // if its a success and no errors found if ($user_id && !is_wp_error($user_id)) { update_user_option($user_id, 'default_password_nag', true, true); //Set up the Password change nag. if (class_exists('Theme_My_Login_Custom_Email')) { do_action('tml_new_user_registered', $user_id, $user_pass); } else { wp_new_user_notification($user_id, $user_pass); } // update display name to full name wp_update_user(array('ID' => $user_id, 'display_name' => $guest_name)); $post_author = $user_id; } else { //something went wrong creating the user, set post author to the default author $post_author = $default_post_author; } } // guest post is enabled and details are off } elseif ($form_settings['guest_post'] == 'true' && $form_settings['guest_details'] == 'false') { $post_author = $default_post_author; } // the user must be logged in already } else { $post_author = get_current_user_id(); } $postarr = array('post_type' => $form_settings['post_type'], 'post_status' => isset($form_settings['post_status']) ? $form_settings['post_status'] : 'publish', 'post_author' => $post_author, 'post_title' => isset($_POST['post_title']) ? trim($_POST['post_title']) : '', 'post_content' => isset($_POST['post_content']) ? trim($_POST['post_content']) : '', 'post_excerpt' => isset($_POST['post_excerpt']) ? trim($_POST['post_excerpt']) : ''); if (isset($_POST['category'])) { $category = $_POST['category']; $postarr['post_category'] = is_array($category) ? $category : array($category); } if (isset($_POST['tags'])) { $postarr['tags_input'] = explode(',', $_POST['tags']); } // if post_id is passed, we update the post if (isset($_POST['post_id'])) { $is_update = true; $postarr['ID'] = $_POST['post_id']; $postarr['post_date'] = $_POST['post_date']; $postarr['comment_status'] = $_POST['comment_status']; $postarr['post_author'] = $_POST['post_author']; $postarr['post_parent'] = get_post_field('post_parent', $_POST['post_id']); if ($form_settings['edit_post_status'] == '_nochange') { $postarr['post_status'] = get_post_field('post_status', $_POST['post_id']); } else { $postarr['post_status'] = $form_settings['edit_post_status']; } } else { if (isset($form_settings['comment_status'])) { $postarr['comment_status'] = $form_settings['comment_status']; } } // check the form status, it might be already a draft // in that case, it already has the post_id field // so, WPUF's add post action/filters won't work for new posts if (isset($_POST['wpuf_form_status']) && $_POST['wpuf_form_status'] == 'new') { $is_update = false; } // set default post category if it's not been set yet and if post type supports if (!isset($postarr['post_category']) && isset($form_settings['default_cat']) && is_object_in_taxonomy($form_settings['post_type'], 'category')) { $postarr['post_category'] = array($form_settings['default_cat']); } // validation filter if ($is_update) { $error = apply_filters('wpuf_update_post_validate', ''); } else { $error = apply_filters('wpuf_add_post_validate', ''); } if (!empty($error)) { $this->send_error($error); } // ############ It's Time to Save the World ############### if ($is_update) { $postarr = apply_filters('wpuf_update_post_args', $postarr, $form_id, $form_settings, $form_vars); } else { $postarr = apply_filters('wpuf_add_post_args', $postarr, $form_id, $form_settings, $form_vars); } $post_id = wp_insert_post($postarr); if ($post_id) { self::update_post_meta($meta_vars, $post_id); // if user has a subscription pack $user_wpuf_subscription_pack = get_user_meta(get_current_user_id(), '_wpuf_subscription_pack', true); if (!empty($user_wpuf_subscription_pack) && isset($user_wpuf_subscription_pack['_enable_post_expiration']) && isset($user_wpuf_subscription_pack['expire']) && strtotime($user_wpuf_subscription_pack['expire']) >= time()) { $expire_date = date('Y-m-d', strtotime("+" . $user_wpuf_subscription_pack['_post_expiration_time'])); update_post_meta($post_id, $this->post_expiration_date, $expire_date); // save post status after expiration $expired_post_status = $user_wpuf_subscription_pack['_expired_post_status']; update_post_meta($post_id, $this->expired_post_status, $expired_post_status); // if mail active if (isset($user_wpuf_subscription_pack['_enable_mail_after_expired']) && $user_wpuf_subscription_pack['_enable_mail_after_expired'] == 'on') { $post_expiration_message = $user_wpuf_subscription_pack['_post_expiration_message']; update_post_meta($post_id, $this->post_expiration_message, $post_expiration_message); } } elseif (!empty($user_wpuf_subscription_pack) && isset($user_wpuf_subscription_pack['expire']) && strtotime($user_wpuf_subscription_pack['expire']) <= time()) { if (isset($form_settings['expiration_settings']['enable_post_expiration'])) { $expire_date = date('Y-m-d', strtotime("+" . $form_settings['expiration_settings']['expiration_time_value'] . ' ' . $form_settings['expiration_settings']['expiration_time_type'] . "")); update_post_meta($post_id, $this->post_expiration_date, $expire_date); // save post status after expiration $expired_post_status = $form_settings['expiration_settings']['expired_post_status']; update_post_meta($post_id, $this->expired_post_status, $expired_post_status); // if mail active if (isset($form_settings['expiration_settings']['enable_mail_after_expired']) && $form_settings['expiration_settings']['enable_mail_after_expired'] == 'on') { $post_expiration_message = $form_settings['expiration_settings']['post_expiration_message']; update_post_meta($post_id, $this->post_expiration_message, $post_expiration_message); } } } elseif (empty($user_wpuf_subscription_pack)) { if (isset($form_settings['expiration_settings']['enable_post_expiration'])) { $expire_date = date('Y-m-d', strtotime("+" . $form_settings['expiration_settings']['expiration_time_value'] . ' ' . $form_settings['expiration_settings']['expiration_time_type'] . "")); update_post_meta($post_id, $this->post_expiration_date, $expire_date); // save post status after expiration $expired_post_status = $form_settings['expiration_settings']['expired_post_status']; update_post_meta($post_id, $this->expired_post_status, $expired_post_status); // if mail active if (isset($form_settings['expiration_settings']['enable_mail_after_expired']) && $form_settings['expiration_settings']['enable_mail_after_expired'] == 'on') { $post_expiration_message = $form_settings['expiration_settings']['post_expiration_message']; update_post_meta($post_id, $this->post_expiration_message, $post_expiration_message); } } } // set the post form_id for later usage update_post_meta($post_id, self::$config_id, $form_id); // save post formats if have any if (isset($form_settings['post_format']) && $form_settings['post_format'] != '0') { if (post_type_supports($form_settings['post_type'], 'post-formats')) { set_post_format($post_id, $form_settings['post_format']); } } // find our if any images in post content and associate them if (!empty($postarr['post_content'])) { $dom = new DOMDocument(); @$dom->loadHTML($postarr['post_content']); $images = $dom->getElementsByTagName('img'); if ($images->length) { foreach ($images as $img) { $url = $img->getAttribute('src'); $url = str_replace(array('"', "'", "\\"), '', $url); $attachment_id = wpuf_get_attachment_id_from_url($url); if ($attachment_id) { wpuf_associate_attachment($attachment_id, $post_id); } } } } // save any custom taxonomies $woo_attr = array(); foreach ($taxonomy_vars as $taxonomy) { if (isset($_POST[$taxonomy['name']])) { if (is_object_in_taxonomy($form_settings['post_type'], $taxonomy['name'])) { $tax = $_POST[$taxonomy['name']]; // if it's not an array, make it one if (!is_array($tax)) { $tax = array($tax); } if ($taxonomy['type'] == 'text') { $hierarchical = array_map('trim', array_map('strip_tags', explode(',', $_POST[$taxonomy['name']]))); wp_set_object_terms($post_id, $hierarchical, $taxonomy['name']); // woocommerce check if (isset($taxonomy['woo_attr']) && $taxonomy['woo_attr'] == 'yes') { $woo_attr[sanitize_title($taxonomy['name'])] = $this->woo_attribute($taxonomy); } } else { if (is_taxonomy_hierarchical($taxonomy['name'])) { wp_set_post_terms($post_id, $_POST[$taxonomy['name']], $taxonomy['name']); // woocommerce check if (isset($taxonomy['woo_attr']) && $taxonomy['woo_attr'] == 'yes') { $woo_attr[sanitize_title($taxonomy['name'])] = $this->woo_attribute($taxonomy); } } else { if ($tax) { $non_hierarchical = array(); foreach ($tax as $value) { $term = get_term_by('id', $value, $taxonomy['name']); if ($term && !is_wp_error($term)) { $non_hierarchical[] = $term->name; } } wp_set_post_terms($post_id, $non_hierarchical, $taxonomy['name']); } } // hierarchical } // is text } // is object tax } // isset tax } // if a woocommerce attribute if ($woo_attr) { update_post_meta($post_id, '_product_attributes', $woo_attr); } if ($is_update) { // plugin API to extend the functionality do_action('wpuf_edit_post_after_update', $post_id, $form_id, $form_settings, $form_vars); //send mail notification if (isset($form_settings['notification']) && $form_settings['notification']['edit'] == 'on') { $mail_body = $this->prepare_mail_body($form_settings['notification']['edit_body'], $post_author, $post_id); wp_mail($form_settings['notification']['edit_to'], $form_settings['notification']['edit_subject'], $mail_body); } } else { // plugin API to extend the functionality do_action('wpuf_add_post_after_insert', $post_id, $form_id, $form_settings, $form_vars); // send mail notification if (isset($form_settings['notification']) && $form_settings['notification']['new'] == 'on') { $mail_body = $this->prepare_mail_body($form_settings['notification']['new_body'], $post_author, $post_id); wp_mail($form_settings['notification']['new_to'], $form_settings['notification']['new_subject'], $mail_body); } } //redirect URL $show_message = false; $redirect_to = false; if ($is_update) { if ($form_settings['edit_redirect_to'] == 'page') { $redirect_to = get_permalink($form_settings['edit_page_id']); } elseif ($form_settings['edit_redirect_to'] == 'url') { $redirect_to = $form_settings['edit_url']; } elseif ($form_settings['edit_redirect_to'] == 'same') { $redirect_to = add_query_arg(array('pid' => $post_id, '_wpnonce' => wp_create_nonce('wpuf_edit'), 'msg' => 'post_updated'), get_permalink($_POST['page_id'])); } else { $redirect_to = get_permalink($post_id); } } else { if ($form_settings['redirect_to'] == 'page') { $redirect_to = get_permalink($form_settings['page_id']); } elseif ($form_settings['redirect_to'] == 'url') { $redirect_to = $form_settings['url']; } elseif ($form_settings['redirect_to'] == 'same') { $show_message = true; } else { $redirect_to = get_permalink($post_id); } } // send the response $response = array('success' => true, 'redirect_to' => $redirect_to, 'show_message' => $show_message, 'message' => $form_settings['message']); if ($is_update) { $response = apply_filters('wpuf_edit_post_redirect', $response, $post_id, $form_id, $form_settings); } else { $response = apply_filters('wpuf_add_post_redirect', $response, $post_id, $form_id, $form_settings); } wpuf_clear_buffer(); echo json_encode($response); exit; } $this->send_error(__('Something went wrong', 'wpuf')); }
/** * Prints recaptcha field * * @param array $attr */ function recaptcha($attr, $post_id, $form_id) { if ($post_id) { return; } ?> <div class="wpuf-fields <?php echo ' wpuf_' . $attr['name'] . '_' . $form_id; ?> "> <?php echo recaptcha_get_html(wpuf_get_option('recaptcha_public', 'wpuf_general')); ?> </div> <?php }
/** * Show/hide admin bar to the permitted user level * * @since 2.2.3 * @return void */ function show_admin_bar() { $access_level = wpuf_get_option('admin_access', 'wpuf_general', 'read'); return current_user_can($access_level); }
public static function add_subscription_element($sub_meta, $hidden_recurring_class, $hidden_trial_class, $obj) { ?> <tr valign="top"> <th><label><?php _e('Recurring', 'wpuf'); ?> </label></th> <td> <label for="wpuf-recuring-pay"> <input type="checkbox" <?php checked($sub_meta['recurring_pay'], 'yes'); ?> size="20" style="" id="wpuf-recuring-pay" value="yes" name="recurring_pay" /> <?php _e('Enable Recurring Payment', 'wpuf'); ?> </label> </td> </tr> <tr valign="top" class="wpuf-recurring-child" style="display: <?php echo $hidden_recurring_class; ?> ;"> <th><label for="wpuf-billing-cycle-number"><?php _e('Billing cycle:', 'wpuf'); ?> </label></th> <td> <select id="wpuf-billing-cycle-number" name="billing_cycle_number"> <?php echo $obj->lenght_type_option($sub_meta['billing_cycle_number']); ?> </select> <select id="cycle_period" name="cycle_period"> <?php echo $obj->option_field($sub_meta['cycle_period']); ?> </select> <div><span class="description"></span></div> </td> </tr> <tr valign="top" class="wpuf-recurring-child" style="display: <?php echo $hidden_recurring_class; ?> ;"> <th><label for="wpuf-billing-limit"><?php _e('Billing cycle stop', 'wpuf'); ?> </label></td> <td> <select id="wpuf-billing-limit" name="billing_limit"> <option value=""><?php _e('Never', 'wpuf'); ?> </option> <?php echo $obj->lenght_type_option($sub_meta['billing_limit']); ?> </select> <div><span class="description"><?php _e('After how many cycles should billing stop?', 'wpuf'); ?> </span></div> </td> </th> </tr> <tr valign="top" class="wpuf-recurring-child" style="display: <?php echo $hidden_recurring_class; ?> ;"> <th><label for="wpuf-trial-status"><?php _e('Trial', 'wpuf'); ?> </label></th> <td> <label for="wpuf-trial-status"> <input type="checkbox" size="20" style="" id="wpuf-trial-status" <?php checked($sub_meta['trial_status'], 'yes'); ?> value="yes" name="trial_status" /> <?php _e('Enable trial period', 'wpuf'); ?> </label> </td> </tr> <tr class="wpuf-trial-child" style="display: <?php echo $hidden_trial_class; ?> ;"> <th><label for="wpuf-trial-cost"><?php _e('Trial amount', 'wpuf'); ?> </label></th> <td> <?php echo wpuf_get_option('currency_symbol', 'wpuf_payment', '$'); ?> <input type="text" size="20" class="small-text" id="wpuf-trial-cost" value="<?php echo esc_attr($sub_meta['trial_cost']); ?> " name="trial_cost" /> <span class="description"><?php _e('Amount to bill for the trial period', 'wpuf'); ?> </span> </td> </tr> <tr class="wpuf-trial-child" style="display: <?php echo $hidden_trial_class; ?> ;"> <th><label for="wpuf-trial-duration"><?php _e('Trial period', 'wpuf'); ?> </label></th> <td> <select id="wpuf-trial-duration" name="trial_duration"> <?php echo $obj->lenght_type_option($sub_meta['trial_duration']); ?> </select> <select id="trial-duration-type" name="trial_duration_type"> <?php echo $obj->option_field($sub_meta['trial_duration_type']); ?> </select> <span class="description"><?php _e('Define the trial period', 'wpuf'); ?> </span> </td> </tr> <?php }
/** * Get the subscription page url * * @return string */ function wpuf_get_subscription_page_url() { $page_id = wpuf_get_option('subscription_page', 'wpuf_payment'); return get_permalink($page_id); }
function after_apply_coupon($pack) { ob_start(); $currency = wpuf_get_option('currency_symbol', 'wpuf_payment'); ?> <div><?php _e('Selected Pack ', 'wpuf'); ?> : <strong><?php echo $pack->post_title; ?> </strong></div> <?php _e('Pack Price ', 'wpuf'); ?> : <strong><?php echo $currency . $pack->meta_value['billing_amount']; ?> </strong> <?php return ob_get_clean(); }
function wp_login_page_redirect() { global $pagenow; if (!is_admin() && $pagenow == 'wp-login.php' && isset($_GET['action']) && $_GET['action'] == 'register') { if (wpuf_get_option('register_link_override', 'wpuf_profile') != 'on') { return; } $reg_page = get_permalink(wpuf_get_option('reg_override_page', 'wpuf_profile')); wp_redirect($reg_page); exit; } }
function wpuf_header_css() { $css = wpuf_get_option('custom_css'); ?> <style type="text/css"> ul.wpuf-attachments{ list-style: none; overflow: hidden;} ul.wpuf-attachments li {float: left; margin: 0 10px 10px 0;} <?php echo $css; ?> </style> <?php }
function upload_file($image_only = false) { $upload = array('name' => $_FILES['wpuf_file']['name'], 'type' => $_FILES['wpuf_file']['type'], 'tmp_name' => $_FILES['wpuf_file']['tmp_name'], 'error' => $_FILES['wpuf_file']['error'], 'size' => $_FILES['wpuf_file']['size']); header('Content-Type: text/html; charset=' . get_option('blog_charset')); $attach = $this->handle_upload($upload); if ($attach['success']) { $response = array('success' => true); if ($image_only) { $image_size = wpuf_get_option('insert_photo_size', 'wpuf_general', 'thumbnail'); $image_type = wpuf_get_option('insert_photo_type', 'wpuf_general', 'link'); if ($image_type == 'link') { $response['html'] = wp_get_attachment_link($attach['attach_id'], $image_size); } else { $response['html'] = wp_get_attachment_image($attach['attach_id'], $image_size); } } else { $response['html'] = $this->attach_html($attach['attach_id']); } echo $response['html']; } else { echo 'error'; } // $response = array('success' => false, 'message' => $attach['error']); // echo json_encode( $response ); exit; }