/** * Get EDD details * * ## OPTIONS * * None. Returns basic info regarding your EDD instance. * * ## EXAMPLES * * wp edd details * * @access public * @param array $args * @param array $assoc_args * @return void */ public function details($args, $assoc_args) { $symlink_file_downloads = edd_get_option('symlink_file_downloads', false); $purchase_page = edd_get_option('purchase_page', ''); $success_page = edd_get_option('success_page', ''); $failure_page = edd_get_option('failure_page', ''); WP_CLI::line(sprintf(__('You are running EDD version: %s', 'easy-digital-downloads'), EDD_VERSION)); WP_CLI::line("\n" . sprintf(__('Test mode is: %s', 'easy-digital-downloads'), edd_is_test_mode() ? __('Enabled', 'easy-digital-downloads') : __('Disabled', 'easy-digital-downloads'))); WP_CLI::line(sprintf(__('Ajax is: %s', 'easy-digital-downloads'), edd_is_ajax_enabled() ? __('Enabled', 'easy-digital-downloads') : __('Disabled', 'easy-digital-downloads'))); WP_CLI::line(sprintf(__('Guest checkouts are: %s', 'easy-digital-downloads'), edd_no_guest_checkout() ? __('Disabled', 'easy-digital-downloads') : __('Enabled', 'easy-digital-downloads'))); WP_CLI::line(sprintf(__('Symlinks are: %s', 'easy-digital-downloads'), apply_filters('edd_symlink_file_downloads', isset($symlink_file_downloads)) && function_exists('symlink') ? __('Enabled', 'easy-digital-downloads') : __('Disabled', 'easy-digital-downloads'))); WP_CLI::line("\n" . sprintf(__('Checkout page is: %s', 'easy-digital-downloads'), !edd_get_option('purchase_page', false) ? __('Valid', 'easy-digital-downloads') : __('Invalid', 'easy-digital-downloads'))); WP_CLI::line(sprintf(__('Checkout URL is: %s', 'easy-digital-downloads'), !empty($purchase_page) ? get_permalink($purchase_page) : __('Undefined', 'easy-digital-downloads'))); WP_CLI::line(sprintf(__('Success URL is: %s', 'easy-digital-downloads'), !empty($success_page) ? get_permalink($success_page) : __('Undefined', 'easy-digital-downloads'))); WP_CLI::line(sprintf(__('Failure URL is: %s', 'easy-digital-downloads'), !empty($failure_page) ? get_permalink($failure_page) : __('Undefined', 'easy-digital-downloads'))); WP_CLI::line(sprintf(__('Downloads slug is: %s', 'easy-digital-downloads'), defined('EDD_SLUG') ? '/' . EDD_SLUG : '/downloads')); WP_CLI::line("\n" . sprintf(__('Taxes are: %s', 'easy-digital-downloads'), edd_use_taxes() ? __('Enabled', 'easy-digital-downloads') : __('Disabled', 'easy-digital-downloads'))); WP_CLI::line(sprintf(__('Tax rate is: %s', 'easy-digital-downloads'), edd_get_tax_rate() * 100 . '%')); $rates = edd_get_tax_rates(); if (!empty($rates)) { foreach ($rates as $rate) { WP_CLI::line(sprintf(__('Country: %s, State: %s, Rate: %s', 'easy-digital-downloads'), $rate['country'], $rate['state'], $rate['rate'])); } } }
/** * Gets the login fields for the login form on the checkout. This function hooks * on the edd_purchase_form_login_fields to display the login form if a user already * had an account. * * @since 1.0 * @return string */ function edd_get_login_fields() { $color = edd_get_option('checkout_color', 'gray'); $color = $color == 'inherit' ? '' : $color; $style = edd_get_option('button_style', 'button'); $show_register_form = edd_get_option('show_register_form', 'none'); ob_start(); ?> <fieldset id="edd_login_fields"> <?php if ($show_register_form == 'both') { ?> <p id="edd-new-account-wrap"> <?php _e('Need to create an account?', 'edd'); ?> <a href="<?php echo esc_url(remove_query_arg('login')); ?> " class="edd_checkout_register_login" data-action="checkout_register"> <?php _e('Register', 'edd'); if (!edd_no_guest_checkout()) { echo ' ' . __('or checkout as a guest.', 'edd'); } ?> </a> </p> <?php } ?> <?php do_action('edd_checkout_login_fields_before'); ?> <p id="edd-user-login-wrap"> <label class="edd-label" for="edd-username"><?php _e('Username', 'edd'); ?> </label> <input class="<?php if (edd_no_guest_checkout()) { echo 'required '; } ?> edd-input" type="text" name="edd_user_login" id="edd_user_login" value="" placeholder="<?php _e('Your username', 'edd'); ?> "/> </p> <p id="edd-user-pass-wrap" class="edd_login_password"> <label class="edd-label" for="edd-password"><?php _e('Password', 'edd'); ?> </label> <input class="<?php if (edd_no_guest_checkout()) { echo 'required '; } ?> edd-input" type="password" name="edd_user_pass" id="edd_user_pass" placeholder="<?php _e('Your password', 'edd'); ?> "/> <input type="hidden" name="edd-purchase-var" value="needs-to-login"/> </p> <p id="edd-user-login-submit"> <input type="submit" class="edd-submit button <?php echo $color; ?> " name="edd_login_submit" value="<?php _e('Login', 'edd'); ?> "/> </p> <?php do_action('edd_checkout_login_fields_after'); ?> </fieldset><!--end #edd_login_fields--> <?php echo ob_get_clean(); }
/** * Get Purchase Form User * * @param array $valid_data * * @access private * @since 1.0.8.1 * @return array */ function edd_get_purchase_form_user($valid_data = array()) { // Initialize user $user = false; $is_ajax = defined('DOING_AJAX') && DOING_AJAX; if ($is_ajax) { // Do not create or login the user during the ajax submission (check for errors only) return true; } else { if (is_user_logged_in()) { // Set the valid user as the logged in collected data $user = $valid_data['logged_in_user']; } else { if ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) { // New user registration if ($valid_data['need_new_user'] === true) { // Set user $user = $valid_data['new_user_data']; // Register and login new user $user['user_id'] = edd_register_and_login_new_user($user); // User login } else { if ($valid_data['need_user_login'] === true && !$is_ajax) { /* * The login form is now processed in the edd_process_purchase_login() function. * This is still here for backwards compatibility. * This also allows the old login process to still work if a user removes the * checkout login submit button. * * This also ensures that the customer is logged in correctly if they click "Purchase" * instead of submitting the login form, meaning the customer is logged in during the purchase process. */ // Set user $user = $valid_data['login_user_data']; // Login user edd_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']); } } } } } // Check guest checkout if (false === $user && false === edd_no_guest_checkout()) { // Set user $user = $valid_data['guest_user_data']; } // Verify we have an user if (false === $user || empty($user)) { // Return false return false; } // Get user first name if (!isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) { $user['user_first'] = isset($_POST["edd_first"]) ? strip_tags(trim($_POST["edd_first"])) : ''; } // Get user last name if (!isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) { $user['user_last'] = isset($_POST["edd_last"]) ? strip_tags(trim($_POST["edd_last"])) : ''; } // Get the user's billing address details $user['address'] = array(); $user['address']['line1'] = !empty($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : false; $user['address']['line2'] = !empty($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : false; $user['address']['city'] = !empty($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : false; $user['address']['state'] = !empty($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : false; $user['address']['country'] = !empty($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : false; $user['address']['zip'] = !empty($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : false; if (empty($user['address']['country'])) { $user['address'] = false; } // Country will always be set if address fields are present if (!empty($user['user_id']) && $user['user_id'] > 0 && !empty($user['address'])) { // Store the address in the user's meta so the cart can be pre-populated with it on return purchases update_user_meta($user['user_id'], '_edd_user_address', $user['address']); } // Return valid user return $user; }
/** * Change the registration form depending on a few conditions * * @since 1.3 */ public function remove_register_form($value, $key, $default) { // Guest purchasing disabled if (edd_no_guest_checkout()) { if (!is_user_logged_in()) { // Not logged in so force login $value = 'login'; } else { // No form if logged in $value = 'none'; } } elseif ('both' === $value || 'registration' === $value) { // Always remove registration form $value = 'none'; } return $value; }
/** * Look for errors during checkout * * This makes sure that only one recurring item is purchased per order. * * This checks to ensure a user is creating an account, logged/ing in if purchasing a subscription * * @since 1.0 * @return void */ public function checkout_errors($valid_data, $post_data) { // Retrieve the cart contents $cart_items = edd_get_cart_contents(); /********* Check for multiple recurring products *********/ // If less than 2 items in the cart, get out if (count($cart_items) < 2) { return; } $has_recurring = false; // Loops through each item to see if any of them are recurring foreach ($cart_items as $cart_item) { $item_id = $cart_item['id']; $options = $cart_item['options']; $price_id = isset($options['price_id']) ? intval($options['price_id']) : null; // Only one subscription can be purchased at a time. Throw an error is more than one. // This also throws an error if a recurring and non recurring product are purchased at once. if (!empty($price_id) && self::is_price_recurring($item_id, $price_id) || self::is_recurring($item_id)) { $has_recurring = true; edd_set_error('subscription_invalid', __('Sorry, you cannot purchase items in the same checkout session as subscriptions.', 'edd-recurring')); break; } } /********* Ensure users create an account *********/ // Only check if guest checkout is enabled if (!edd_no_guest_checkout() && $has_recurring && !is_user_logged_in()) { // If customer is purchasing as a guest, we must throw an error // TODO: this doesn't work yet if (isset($valid_data['new_user_data']) && ($valid_data['new_user_data'] = '-1')) { //edd_set_error( 'must_be_user', __( 'You must login or register to purchase a subscription.', 'edd-recurring') ); } } }
/** * Can checkout? * Prevents the form from being displayed when User must be logged in (Guest Checkout disabled), but "Show Register / Login Form?" is not * * @since 1.0 */ public function can_checkout($can_checkout) { if (edd_no_guest_checkout() && !edd_get_option('show_register_form') && !is_user_logged_in()) { return false; } return $can_checkout; }
/** * Get Register Fields * * @access private * @since 1.0 * @return string */ function vp_edd_fd_get_register_fields() { global $edd_options; global $user_ID; if (is_user_logged_in()) { $user_data = get_userdata($user_ID); } ob_start(); ?> <fieldset id="edd_register_fields"> <?php do_action('edd_register_account_fields_before'); ?> <p id="edd-user-login-wrap"> <label for="edd_user_login"><?php _e('Username', 'edd'); ?> </label> <input name="edd_user_login" id="edd_user_login" class="<?php if (edd_no_guest_checkout()) { echo 'required '; } ?> edd-input" type="text" placeholder="<?php _e('Username', 'edd'); ?> " title="<?php _e('Username', 'edd'); ?> "/> </p> <p id="edd-user-email-wrap"> <label for="edd-email"><?php _e('Email', 'edd'); ?> </label> <input name="edd_email" id="edd-email" class="required edd-input" type="email" placeholder="<?php _e('Email', 'edd'); ?> " title="<?php _e('Email', 'edd'); ?> "/> </p> <p id="edd-user-pass-wrap"> <label for="password"><?php _e('Password', 'edd'); ?> </label> <input name="edd_user_pass" id="edd_user_pass" class="<?php if (edd_no_guest_checkout()) { echo 'required '; } ?> edd-input" placeholder="<?php _e('Password', 'edd'); ?> " type="password"/> </p> <p id="edd-user-pass-confirm-wrap" class="edd_register_password"> <label for="password_again"><?php _e('Password Again', 'edd'); ?> </label> <input name="edd_user_pass_confirm" id="edd_user_pass_confirm" class="<?php if (edd_no_guest_checkout()) { echo 'required '; } ?> edd-input" placeholder="<?php _e('Confirm password', 'edd'); ?> " type="password"/> </p> <p id="edd-user-first-name-wrap"> <label class="edd-label" for="edd-first"><?php _e('First Name', 'edd'); ?> </label> <input class="edd-input required" type="text" name="edd_first" placeholder="<?php _e('First Name', 'edd'); ?> " id="edd-first" value="<?php echo is_user_logged_in() ? $user_data->user_firstname : ''; ?> "/> </p> <p id="edd-user-last-name-wrap"> <label class="edd-label" for="edd-last"><?php _e('Last Name', 'edd'); ?> </label> <input class="edd-input" type="text" name="edd_last" id="edd-last" placeholder="<?php _e('Last name', 'edd'); ?> " value="<?php echo is_user_logged_in() ? $user_data->user_lastname : ''; ?> "/> </p> <?php do_action('edd_register_account_fields_after'); ?> <?php do_action('edd_purchase_form_user_info'); ?> </fieldset> <?php echo ob_get_clean(); }
/** * Get system info * * @since 2.0 * @access public * @global object $wpdb Used to query the database using the WordPress Database API * @global array $edd_options Array of all EDD options * @return string $return A string containing the info to output */ function edd_tools_sysinfo_get() { global $wpdb, $edd_options; if (!class_exists('Browser')) { require_once EDD_PLUGIN_DIR . 'includes/libraries/browser.php'; } $browser = new Browser(); // Get theme info if (get_bloginfo('version') < '3.4') { $theme_data = get_theme_data(get_stylesheet_directory() . '/style.css'); $theme = $theme_data['Name'] . ' ' . $theme_data['Version']; } else { $theme_data = wp_get_theme(); $theme = $theme_data->Name . ' ' . $theme_data->Version; } // Try to identify the hosting provider $host = edd_get_host(); $return = '### Begin System Info ###' . "\n\n"; // Start with the basics... $return .= '-- Site Info' . "\n\n"; $return .= 'Site URL: ' . site_url() . "\n"; $return .= 'Home URL: ' . home_url() . "\n"; $return .= 'Multisite: ' . (is_multisite() ? 'Yes' : 'No') . "\n"; $return = apply_filters('edd_sysinfo_after_site_info', $return); // Can we determine the site's host? if ($host) { $return .= "\n" . '-- Hosting Provider' . "\n\n"; $return .= 'Host: ' . $host . "\n"; $return = apply_filters('edd_sysinfo_after_host_info', $return); } // The local users' browser information, handled by the Browser class $return .= "\n" . '-- User Browser' . "\n\n"; $return .= $browser; $return = apply_filters('edd_sysinfo_after_user_browser', $return); // WordPress configuration $return .= "\n" . '-- WordPress Configuration' . "\n\n"; $return .= 'Version: ' . get_bloginfo('version') . "\n"; $return .= 'Language: ' . (defined('WPLANG') && WPLANG ? WPLANG : 'en_US') . "\n"; $return .= 'Permalink Structure: ' . (get_option('permalink_structure') ? get_option('permalink_structure') : 'Default') . "\n"; $return .= 'Active Theme: ' . $theme . "\n"; $return .= 'Show On Front: ' . get_option('show_on_front') . "\n"; // Only show page specs if frontpage is set to 'page' if (get_option('show_on_front') == 'page') { $front_page_id = get_option('page_on_front'); $blog_page_id = get_option('page_for_posts'); $return .= 'Page On Front: ' . ($front_page_id != 0 ? get_the_title($front_page_id) . ' (#' . $front_page_id . ')' : 'Unset') . "\n"; $return .= 'Page For Posts: ' . ($blog_page_id != 0 ? get_the_title($blog_page_id) . ' (#' . $blog_page_id . ')' : 'Unset') . "\n"; } // Make sure wp_remote_post() is working $request['cmd'] = '_notify-validate'; $params = array('sslverify' => false, 'timeout' => 60, 'user-agent' => 'EDD/' . EDD_VERSION, 'body' => $request); $response = wp_remote_post('https://www.paypal.com/cgi-bin/webscr', $params); if (!is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300) { $WP_REMOTE_POST = 'wp_remote_post() works'; } else { $WP_REMOTE_POST = 'wp_remote_post() does not work'; } $return .= 'Remote Post: ' . $WP_REMOTE_POST . "\n"; $return .= 'Table Prefix: ' . 'Length: ' . strlen($wpdb->prefix) . ' Status: ' . (strlen($wpdb->prefix) > 16 ? 'ERROR: Too long' : 'Acceptable') . "\n"; $return .= 'WP_DEBUG: ' . (defined('WP_DEBUG') ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set') . "\n"; $return .= 'Memory Limit: ' . WP_MEMORY_LIMIT . "\n"; $return .= 'Registered Post Stati: ' . implode(', ', get_post_stati()) . "\n"; $return = apply_filters('edd_sysinfo_after_wordpress_config', $return); // EDD configuration $return .= "\n" . '-- EDD Configuration' . "\n\n"; $return .= 'Version: ' . EDD_VERSION . "\n"; $return .= 'Upgraded From: ' . get_option('edd_version_upgraded_from', 'None') . "\n"; $return .= 'Test Mode: ' . (edd_is_test_mode() ? "Enabled\n" : "Disabled\n"); $return .= 'Ajax: ' . (!edd_is_ajax_disabled() ? "Enabled\n" : "Disabled\n"); $return .= 'Guest Checkout: ' . (edd_no_guest_checkout() ? "Disabled\n" : "Enabled\n"); $return .= 'Symlinks: ' . (apply_filters('edd_symlink_file_downloads', isset($edd_options['symlink_file_downloads'])) && function_exists('symlink') ? "Enabled\n" : "Disabled\n"); $return .= 'Download Method: ' . ucfirst(edd_get_file_download_method()) . "\n"; $return .= 'Currency Code: ' . edd_get_currency() . "\n"; $return .= 'Currency Position: ' . edd_get_option('currency_position', 'before') . "\n"; $return .= 'Decimal Separator: ' . edd_get_option('decimal_separator', '.') . "\n"; $return .= 'Thousands Separator: ' . edd_get_option('thousands_separator', ',') . "\n"; $return = apply_filters('edd_sysinfo_after_edd_config', $return); // EDD pages $return .= "\n" . '-- EDD Page Configuration' . "\n\n"; $return .= 'Checkout: ' . (!empty($edd_options['purchase_page']) ? "Valid\n" : "Invalid\n"); $return .= 'Checkout Page: ' . (!empty($edd_options['purchase_page']) ? get_permalink($edd_options['purchase_page']) . "\n" : "Unset\n"); $return .= 'Success Page: ' . (!empty($edd_options['success_page']) ? get_permalink($edd_options['success_page']) . "\n" : "Unset\n"); $return .= 'Failure Page: ' . (!empty($edd_options['failure_page']) ? get_permalink($edd_options['failure_page']) . "\n" : "Unset\n"); $return .= 'Downloads Slug: ' . (defined('EDD_SLUG') ? '/' . EDD_SLUG . "\n" : "/downloads\n"); $return = apply_filters('edd_sysinfo_after_edd_pages', $return); // EDD gateways $return .= "\n" . '-- EDD Gateway Configuration' . "\n\n"; $active_gateways = edd_get_enabled_payment_gateways(); if ($active_gateways) { $default_gateway_is_active = edd_is_gateway_active(edd_get_default_gateway()); if ($default_gateway_is_active) { $default_gateway = edd_get_default_gateway(); $default_gateway = $active_gateways[$default_gateway]['admin_label']; } else { $default_gateway = 'Test Payment'; } $gateways = array(); foreach ($active_gateways as $gateway) { $gateways[] = $gateway['admin_label']; } $return .= 'Enabled Gateways: ' . implode(', ', $gateways) . "\n"; $return .= 'Default Gateway: ' . $default_gateway . "\n"; } else { $return .= 'Enabled Gateways: None' . "\n"; } $return = apply_filters('edd_sysinfo_after_edd_gateways', $return); // EDD Taxes $return .= "\n" . '-- EDD Tax Configuration' . "\n\n"; $return .= 'Taxes: ' . (edd_use_taxes() ? "Enabled\n" : "Disabled\n"); $return .= 'Tax Rate: ' . edd_get_tax_rate() * 100 . "\n"; $return .= 'Display On Checkout: ' . (!empty($edd_options['checkout_include_tax']) ? "Displayed\n" : "Not Displayed\n"); $return .= 'Prices Include Tax: ' . (edd_prices_include_tax() ? "Yes\n" : "No\n"); $rates = edd_get_tax_rates(); if (!empty($rates)) { $return .= 'Country / State Rates: ' . "\n"; foreach ($rates as $rate) { $return .= ' Country: ' . $rate['country'] . ', State: ' . $rate['state'] . ', Rate: ' . $rate['rate'] . "\n"; } } $return = apply_filters('edd_sysinfo_after_edd_taxes', $return); // EDD Templates $dir = get_stylesheet_directory() . '/edd_templates/*'; if (is_dir($dir) && count(glob("{$dir}/*")) !== 0) { $return .= "\n" . '-- EDD Template Overrides' . "\n\n"; foreach (glob($dir) as $file) { $return .= 'Filename: ' . basename($file) . "\n"; } $return = apply_filters('edd_sysinfo_after_edd_templates', $return); } // WordPress active plugins $return .= "\n" . '-- WordPress Active Plugins' . "\n\n"; $plugins = get_plugins(); $active_plugins = get_option('active_plugins', array()); foreach ($plugins as $plugin_path => $plugin) { if (!in_array($plugin_path, $active_plugins)) { continue; } $return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n"; } $return = apply_filters('edd_sysinfo_after_wordpress_plugins', $return); // WordPress inactive plugins $return .= "\n" . '-- WordPress Inactive Plugins' . "\n\n"; foreach ($plugins as $plugin_path => $plugin) { if (in_array($plugin_path, $active_plugins)) { continue; } $return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n"; } $return = apply_filters('edd_sysinfo_after_wordpress_plugins_inactive', $return); if (is_multisite()) { // WordPress Multisite active plugins $return .= "\n" . '-- Network Active Plugins' . "\n\n"; $plugins = wp_get_active_network_plugins(); $active_plugins = get_site_option('active_sitewide_plugins', array()); foreach ($plugins as $plugin_path) { $plugin_base = plugin_basename($plugin_path); if (!array_key_exists($plugin_base, $active_plugins)) { continue; } $plugin = get_plugin_data($plugin_path); $return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n"; } $return = apply_filters('edd_sysinfo_after_wordpress_ms_plugins', $return); } // Server configuration (really just versioning) $return .= "\n" . '-- Webserver Configuration' . "\n\n"; $return .= 'PHP Version: ' . PHP_VERSION . "\n"; $return .= 'MySQL Version: ' . $wpdb->db_version() . "\n"; $return .= 'Webserver Info: ' . $_SERVER['SERVER_SOFTWARE'] . "\n"; $return = apply_filters('edd_sysinfo_after_webserver_config', $return); // PHP configs... now we're getting to the important stuff $return .= "\n" . '-- PHP Configuration' . "\n\n"; $return .= 'Safe Mode: ' . (ini_get('safe_mode') ? 'Enabled' : 'Disabled' . "\n"); $return .= 'Memory Limit: ' . ini_get('memory_limit') . "\n"; $return .= 'Upload Max Size: ' . ini_get('upload_max_filesize') . "\n"; $return .= 'Post Max Size: ' . ini_get('post_max_size') . "\n"; $return .= 'Upload Max Filesize: ' . ini_get('upload_max_filesize') . "\n"; $return .= 'Time Limit: ' . ini_get('max_execution_time') . "\n"; $return .= 'Max Input Vars: ' . ini_get('max_input_vars') . "\n"; $return .= 'Display Errors: ' . (ini_get('display_errors') ? 'On (' . ini_get('display_errors') . ')' : 'N/A') . "\n"; $return = apply_filters('edd_sysinfo_after_php_config', $return); // PHP extensions and such $return .= "\n" . '-- PHP Extensions' . "\n\n"; $return .= 'cURL: ' . (function_exists('curl_init') ? 'Supported' : 'Not Supported') . "\n"; $return .= 'fsockopen: ' . (function_exists('fsockopen') ? 'Supported' : 'Not Supported') . "\n"; $return .= 'SOAP Client: ' . (class_exists('SoapClient') ? 'Installed' : 'Not Installed') . "\n"; $return .= 'Suhosin: ' . (extension_loaded('suhosin') ? 'Installed' : 'Not Installed') . "\n"; $return = apply_filters('edd_sysinfo_after_php_ext', $return); // Session stuff $return .= "\n" . '-- Session Configuration' . "\n\n"; $return .= 'EDD Use Sessions: ' . (defined('EDD_USE_PHP_SESSIONS') && EDD_USE_PHP_SESSIONS ? 'Enforced' : (EDD()->session->use_php_sessions() ? 'Enabled' : 'Disabled')) . "\n"; $return .= 'Session: ' . (isset($_SESSION) ? 'Enabled' : 'Disabled') . "\n"; // The rest of this is only relevant is session is enabled if (isset($_SESSION)) { $return .= 'Session Name: ' . esc_html(ini_get('session.name')) . "\n"; $return .= 'Cookie Path: ' . esc_html(ini_get('session.cookie_path')) . "\n"; $return .= 'Save Path: ' . esc_html(ini_get('session.save_path')) . "\n"; $return .= 'Use Cookies: ' . (ini_get('session.use_cookies') ? 'On' : 'Off') . "\n"; $return .= 'Use Only Cookies: ' . (ini_get('session.use_only_cookies') ? 'On' : 'Off') . "\n"; } $return = apply_filters('edd_sysinfo_after_session_config', $return); $return .= "\n" . '### End System Info ###'; return $return; }
/** * Get Purchase Form User * * @param array $valid_data * * @access private * @since 1.0.8.1 * @return array */ function edd_get_purchase_form_user($valid_data = array()) { // Initialize user $user = false; // Check if user is logged in if (is_user_logged_in()) { // set the valid user as the logged in collected data $user = $valid_data['logged_in_user']; } else { if ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) { // new user registration if ($valid_data['need_new_user'] === true) { // set user $user = $valid_data['new_user_data']; // register and login new user $user['user_id'] = edd_register_and_login_new_user($user); // user login } else { if ($valid_data['need_user_login'] === true) { // set user $user = $valid_data['login_user_data']; // login user edd_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']); } } } } // check guest checkout if (false === $user && false === edd_no_guest_checkout()) { // set user $user = $valid_data['guest_user_data']; } // verify we have an user if (false === $user || empty($user)) { // return false return false; } // get user first name if (!isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) { $user['user_first'] = isset($_POST["edd_first"]) ? strip_tags(trim($_POST["edd_first"])) : ''; } // get user last name if (!isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) { $user['user_last'] = isset($_POST["edd_last"]) ? strip_tags(trim($_POST["edd_last"])) : ''; } // return valid user return $user; }
/** * Gets the login fields for the login form on the checkout. This function hooks * on the edd_purchase_form_login_fields to display the login form if a user already * had an account. * * @since 1.0 * @return string */ function edd_get_login_fields() { ob_start(); ?> <fieldset id="edd_login_fields"> <legend><?php _e('Login to your account', 'edd'); ?> </legend> <?php do_action('edd_checkout_login_fields_before'); ?> <p id="edd-user-login-wrap"> <label class="edd-label" for="edd-username"><?php _e('Username', 'edd'); ?> </label> <input class="<?php if (edd_no_guest_checkout()) { echo 'required '; } ?> edd-input" type="text" name="edd_user_login" id="edd_user_login" value="" placeholder="<?php _e('Your username', 'edd'); ?> "/> </p> <p id="edd-user-pass-wrap" class="edd_login_password"> <label class="edd-label" for="edd-password"><?php _e('Password', 'edd'); ?> </label> <input class="<?php if (edd_no_guest_checkout()) { echo 'required '; } ?> edd-input" type="password" name="edd_user_pass" id="edd_user_pass" placeholder="<?php _e('Your password', 'edd'); ?> "/> <input type="hidden" name="edd-purchase-var" value="needs-to-login"/> </p> <?php do_action('edd_checkout_login_fields_after'); ?> </fieldset><!--end #edd_login_fields--> <p id="edd-new-account-wrap"> <?php _e('Need to create an account?', 'edd'); ?> <a href="<?php echo remove_query_arg('login'); ?> " class="edd_checkout_register_login" data-action="checkout_register"> <?php _e('Register', 'edd'); if (!edd_no_guest_checkout()) { echo ' ' . __('or checkout as a guest.', 'edd'); } ?> </a> </p> <?php echo ob_get_clean(); }
/** * System info * * Shows the system info panel which contains version data and debug info. * The data for the system info is generated by the Browser class. * * @since 1.4 * @global $wpdb * @global object $wpdb Used to query the database using the WordPress * Database API * @global $edd_options Array of all the EDD Options * @author Chris Christoff * @return void */ function edd_system_info() { global $wpdb, $edd_options; if (!class_exists('Browser')) { require_once EDD_PLUGIN_DIR . 'includes/libraries/browser.php'; } $browser = new Browser(); if (get_bloginfo('version') < '3.4') { $theme_data = get_theme_data(get_stylesheet_directory() . '/style.css'); $theme = $theme_data['Name'] . ' ' . $theme_data['Version']; } else { $theme_data = wp_get_theme(); $theme = $theme_data->Name . ' ' . $theme_data->Version; } // Try to identifty the hosting provider $host = false; if (defined('WPE_APIKEY')) { $host = 'WP Engine'; } elseif (defined('PAGELYBIN')) { $host = 'Pagely'; } ?> <div class="wrap"> <h2><?php _e('System Information', 'edd'); ?> </h2><br/> <form action="<?php echo esc_url(admin_url('edit.php?post_type=download&page=edd-system-info')); ?> " method="post" dir="ltr"> <textarea readonly="readonly" onclick="this.focus();this.select()" id="system-info-textarea" name="edd-sysinfo" title="<?php _e('To copy the system info, click below then press Ctrl + C (PC) or Cmd + C (Mac).', 'edd'); ?> "> ### Begin System Info ### ## Please include this information when posting support requests ## <?php do_action('edd_system_info_before'); ?> Multisite: <?php echo is_multisite() ? 'Yes' . "\n" : 'No' . "\n"; ?> SITE_URL: <?php echo site_url() . "\n"; ?> HOME_URL: <?php echo home_url() . "\n"; ?> EDD Version: <?php echo EDD_VERSION . "\n"; ?> Upgraded From: <?php echo get_option('edd_version_upgraded_from', 'None') . "\n"; ?> WordPress Version: <?php echo get_bloginfo('version') . "\n"; ?> Permalink Structure: <?php echo get_option('permalink_structure') . "\n"; ?> Active Theme: <?php echo $theme . "\n"; if ($host) { ?> Host: <?php echo $host . "\n"; } ?> Test Mode Enabled: <?php echo edd_is_test_mode() ? "Yes\n" : "No\n"; ?> Ajax Enabled: <?php echo edd_is_ajax_enabled() ? "Yes\n" : "No\n"; ?> Guest Checkout Enabled: <?php echo edd_no_guest_checkout() ? "No\n" : "Yes\n"; ?> Symlinks Enabled: <?php echo apply_filters('edd_symlink_file_downloads', isset($edd_options['symlink_file_downloads'])) && function_exists('symlink') ? "Yes\n" : "No\n"; ?> Checkout is: <?php echo !empty($edd_options['purchase_page']) ? "Valid\n" : "Invalid\n"; ?> Checkout Page: <?php echo !empty($edd_options['purchase_page']) ? get_permalink($edd_options['purchase_page']) . "\n" : "\n"; ?> Success Page: <?php echo !empty($edd_options['success_page']) ? get_permalink($edd_options['success_page']) . "\n" : "\n"; ?> Failure Page: <?php echo !empty($edd_options['failure_page']) ? get_permalink($edd_options['failure_page']) . "\n" : "\n"; ?> Downloads slug: <?php echo defined('EDD_SLUG') ? '/' . EDD_SLUG . "\n" : "/downloads\n"; ?> Taxes Enabled: <?php echo edd_use_taxes() ? "Yes\n" : "No\n"; ?> Taxes After Discounts: <?php echo edd_taxes_after_discounts() ? "Yes\n" : "No\n"; ?> Tax Rate: <?php echo edd_get_tax_rate() * 100; ?> % Country / State Rates: <?php $rates = edd_get_tax_rates(); if (!empty($rates)) { foreach ($rates as $rate) { echo 'Country: ' . $rate['country'] . ', State: ' . $rate['state'] . ', Rate: ' . $rate['rate'] . ' | '; } } ?> Registered Post Stati: <?php echo implode(', ', get_post_stati()) . "\n\n"; ?> <?php echo $browser; ?> PHP Version: <?php echo PHP_VERSION . "\n"; ?> MySQL Version: <?php echo mysql_get_server_info() . "\n"; ?> Web Server Info: <?php echo $_SERVER['SERVER_SOFTWARE'] . "\n"; ?> WordPress Memory Limit: <?php echo edd_let_to_num(WP_MEMORY_LIMIT) / 1024 . "MB"; echo "\n"; ?> PHP Safe Mode: <?php echo ini_get('safe_mode') ? "Yes" : "No\n"; ?> PHP Memory Limit: <?php echo ini_get('memory_limit') . "\n"; ?> PHP Upload Max Size: <?php echo ini_get('upload_max_filesize') . "\n"; ?> PHP Post Max Size: <?php echo ini_get('post_max_size') . "\n"; ?> PHP Upload Max Filesize: <?php echo ini_get('upload_max_filesize') . "\n"; ?> PHP Time Limit: <?php echo ini_get('max_execution_time') . "\n"; ?> PHP Max Input Vars: <?php echo ini_get('max_input_vars') . "\n"; ?> PHP Arg Separator: <?php echo ini_get('arg_separator.output') . "\n"; ?> PHP Allow URL File Open: <?php echo ini_get('allow_url_fopen') ? "Yes" : "No\n"; ?> WP_DEBUG: <?php echo defined('WP_DEBUG') ? WP_DEBUG ? 'Enabled' . "\n" : 'Disabled' . "\n" : 'Not set' . "\n"; ?> WP Table Prefix: <?php echo "Length: " . strlen($wpdb->prefix); echo " Status:"; if (strlen($wpdb->prefix) > 16) { echo " ERROR: Too Long"; } else { echo " Acceptable"; } echo "\n"; ?> Show On Front: <?php echo get_option('show_on_front') . "\n"; ?> Page On Front: <?php $id = get_option('page_on_front'); echo get_the_title($id) . ' (#' . $id . ')' . "\n"; ?> Page For Posts: <?php $id = get_option('page_for_posts'); echo get_the_title($id) . ' (#' . $id . ')' . "\n"; ?> <?php $request['cmd'] = '_notify-validate'; $params = array('sslverify' => false, 'timeout' => 60, 'user-agent' => 'EDD/' . EDD_VERSION, 'body' => $request); $response = wp_remote_post('https://www.paypal.com/cgi-bin/webscr', $params); if (!is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300) { $WP_REMOTE_POST = 'wp_remote_post() works' . "\n"; } else { $WP_REMOTE_POST = 'wp_remote_post() does not work' . "\n"; } ?> WP Remote Post: <?php echo $WP_REMOTE_POST; ?> Session: <?php echo isset($_SESSION) ? 'Enabled' : 'Disabled'; echo "\n"; ?> Session Name: <?php echo esc_html(ini_get('session.name')); echo "\n"; ?> Cookie Path: <?php echo esc_html(ini_get('session.cookie_path')); echo "\n"; ?> Save Path: <?php echo esc_html(ini_get('session.save_path')); echo "\n"; ?> Use Cookies: <?php echo ini_get('session.use_cookies') ? 'On' : 'Off'; echo "\n"; ?> Use Only Cookies: <?php echo ini_get('session.use_only_cookies') ? 'On' : 'Off'; echo "\n"; ?> DISPLAY ERRORS: <?php echo ini_get('display_errors') ? 'On (' . ini_get('display_errors') . ')' : 'N/A'; echo "\n"; ?> FSOCKOPEN: <?php echo function_exists('fsockopen') ? 'Your server supports fsockopen.' : 'Your server does not support fsockopen.'; echo "\n"; ?> cURL: <?php echo function_exists('curl_init') ? 'Your server supports cURL.' : 'Your server does not support cURL.'; echo "\n"; ?> SOAP Client: <?php echo class_exists('SoapClient') ? 'Your server has the SOAP Client enabled.' : 'Your server does not have the SOAP Client enabled.'; echo "\n"; ?> SUHOSIN: <?php echo extension_loaded('suhosin') ? 'Your server has SUHOSIN installed.' : 'Your server does not have SUHOSIN installed.'; echo "\n"; ?> TEMPLATES: <?php // Show templates that have been copied to the theme's edd_templates dir $dir = get_stylesheet_directory() . '/edd_templates/*'; if (!empty($dir)) { foreach (glob($dir) as $file) { echo "Filename: " . basename($file) . "\n"; } } else { echo 'No overrides found'; } ?> ACTIVE PLUGINS: <?php $plugins = get_plugins(); $active_plugins = get_option('active_plugins', array()); foreach ($plugins as $plugin_path => $plugin) { // If the plugin isn't active, don't show it. if (!in_array($plugin_path, $active_plugins)) { continue; } echo $plugin['Name'] . ': ' . $plugin['Version'] . "\n"; } if (is_multisite()) { ?> NETWORK ACTIVE PLUGINS: <?php $plugins = wp_get_active_network_plugins(); $active_plugins = get_site_option('active_sitewide_plugins', array()); foreach ($plugins as $plugin_path) { $plugin_base = plugin_basename($plugin_path); // If the plugin isn't active, don't show it. if (!array_key_exists($plugin_base, $active_plugins)) { continue; } $plugin = get_plugin_data($plugin_path); echo $plugin['Name'] . ' :' . $plugin['Version'] . "\n"; } } do_action('edd_system_info_after'); ?> ### End System Info ###</textarea> <p class="submit"> <input type="hidden" name="edd-action" value="download_sysinfo" /> <?php submit_button('Download System Info File', 'primary', 'edd-download-sysinfo', false); ?> </p> </form> </div> </div> <?php }
/** * Get Purchase Form User * * @param array $valid_data * * @access private * @since 1.0.8.1 * @return array */ function edd_get_purchase_form_user($valid_data = array()) { // Initialize user $user = false; $is_ajax = defined('DOING_AJAX') && DOING_AJAX; if ($is_ajax) { // Do not create or login the user during the ajax submission (check for errors only) return true; } else { if (is_user_logged_in()) { // Set the valid user as the logged in collected data $user = $valid_data['logged_in_user']; } else { if ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) { // New user registration if ($valid_data['need_new_user'] === true) { // Set user $user = $valid_data['new_user_data']; // Register and login new user $user['user_id'] = edd_register_and_login_new_user($user); // User login } else { if ($valid_data['need_user_login'] === true && !$is_ajax) { // Set user $user = $valid_data['login_user_data']; // Login user edd_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']); } } } } } // Check guest checkout if (false === $user && false === edd_no_guest_checkout()) { // Set user $user = $valid_data['guest_user_data']; } // Verify we have an user if (false === $user || empty($user)) { // Return false return false; } // Get user first name if (!isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) { $user['user_first'] = isset($_POST["edd_first"]) ? strip_tags(trim($_POST["edd_first"])) : ''; } // Get user last name if (!isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) { $user['user_last'] = isset($_POST["edd_last"]) ? strip_tags(trim($_POST["edd_last"])) : ''; } // Return valid user return $user; }
/** * System info * * Shows the system info panel which contains version data and debug info. * The data for the system info is generated by the Browser class. * * @since 1.4 * @global $wpdb * @global object $wpdb Used to query the database using the WordPress * Database API * @global $edd_options Array of all the EDD Options * @author Chris Christoff * @return void */ function edd_system_info() { global $wpdb, $edd_options; if (!class_exists('Browser')) { require_once EDD_PLUGIN_DIR . 'includes/libraries/browser.php'; } $browser = new Browser(); ?> <div class="wrap"> <h2><?php _e('System Information', 'edd'); ?> </h2><br/> <form action="<?php echo esc_url(admin_url('edit.php?post_type=download&page=edd-system-info')); ?> " method="post"> <textarea readonly="readonly" onclick="this.focus();this.select()" id="system-info-textarea" name="edd-sysinfo" title="<?php _e('To copy the system info, click below then press Ctrl + C (PC) or Cmd + C (Mac).', 'edd'); ?> "> ### Begin System Info ### ## Please include this information when posting support requests ## Multi-site: <?php echo is_multisite() ? 'Yes' . "\n" : 'No' . "\n"; ?> SITE_URL: <?php echo site_url() . "\n"; ?> HOME_URL: <?php echo home_url() . "\n"; ?> EDD Version: <?php echo EDD_VERSION . "\n"; ?> Upgraded From: <?php echo get_option('edd_version_upgraded_from', 'None') . "\n"; ?> WordPress Version: <?php echo get_bloginfo('version') . "\n"; ?> Test Mode Enabled: <?php echo edd_is_test_mode() ? "Yes\n" : "No\n"; ?> Ajax Enabled: <?php echo edd_is_ajax_enabled() ? "Yes\n" : "No\n"; ?> Guest Checkout Enabled: <?php echo edd_no_guest_checkout() ? "No\n" : "Yes\n"; ?> Symlinks Enabled: <?php echo apply_filters('edd_symlink_file_downloads', isset($edd_options['symlink_file_downloads'])) && function_exists('symlink') ? "Yes\n" : "No\n"; ?> Checkout: <?php echo !empty($edd_options['purchase_page']) ? "Valid\n" : "Invalid\n"; ?> Taxes Enabled: <?php echo edd_use_taxes() ? "Yes\n" : "No\n"; ?> Local Taxes Only: <?php echo edd_local_taxes_only() ? "Yes\n" : "No\n"; ?> Taxes After Discounts: <?php echo edd_taxes_after_discounts() ? "Yes\n" : "No\n"; ?> <?php echo $browser; ?> PHP Version: <?php echo PHP_VERSION . "\n"; ?> MySQL Version: <?php echo mysql_get_server_info() . "\n"; ?> Web Server Info: <?php echo $_SERVER['SERVER_SOFTWARE'] . "\n"; ?> PHP Safe Mode: <?php echo ini_get('safe_mode') ? "Yes" : "No\n"; ?> PHP Memory Limit: <?php echo ini_get('memory_limit') . "\n"; ?> PHP Post Max Size: <?php echo ini_get('post_max_size') . "\n"; ?> PHP Time Limit: <?php echo ini_get('max_execution_time') . "\n"; ?> WP_DEBUG: <?php echo defined('WP_DEBUG') ? WP_DEBUG ? 'Enabled' . "\n" : 'Disabled' . "\n" : 'Not set' . "\n"; ?> WP Table Prefix: <?php echo "Length: " . strlen($wpdb->prefix); echo " Status:"; if (strlen($wpdb->prefix) > 16) { echo " ERROR: Too Long"; } else { echo " Acceptable"; } echo "\n"; ?> Show On Front: <?php echo get_option('show_on_front') . "\n"; ?> Page On Front: <?php $id = get_option('page_on_front'); echo get_the_title($id) . ' #' . $id . "\n"; ?> Page For Posts: <?php $id = get_option('page_for_posts'); echo get_the_title($id) . ' #' . $id . "\n"; ?> Session: <?php echo isset($_SESSION) ? 'Enabled' : 'Disabled'; echo "\n"; ?> Session Name: <?php echo esc_html(ini_get('session.name')); echo "\n"; ?> Cookie Path: <?php echo esc_html(ini_get('session.cookie_path')); echo "\n"; ?> Save Path: <?php echo esc_html(ini_get('session.save_path')); echo "\n"; ?> Use Cookies: <?php echo ini_get('session.use_cookies') ? 'On' : 'Off'; echo "\n"; ?> Use Only Cookies: <?php echo ini_get('session.use_only_cookies') ? 'On' : 'Off'; echo "\n"; ?> UPLOAD_MAX_FILESIZE: <?php if (function_exists('phpversion')) { echo edd_let_to_num(ini_get('upload_max_filesize')) / (1024 * 1024) . "MB"; } echo "\n"; ?> POST_MAX_SIZE: <?php if (function_exists('phpversion')) { echo edd_let_to_num(ini_get('post_max_size')) / (1024 * 1024) . "MB"; } echo "\n"; ?> WordPress Memory Limit: <?php echo edd_let_to_num(WP_MEMORY_LIMIT) / (1024 * 1024) . "MB"; echo "\n"; ?> DISPLAY ERRORS: <?php echo ini_get('display_errors') ? 'On (' . ini_get('display_errors') . ')' : 'N/A'; echo "\n"; ?> FSOCKOPEN: <?php echo function_exists('fsockopen') ? __('Your server supports fsockopen.', 'edd') : __('Your server does not support fsockopen.', 'edd'); echo "\n"; ?> ACTIVE PLUGINS: <?php $plugins = get_plugins(); $active_plugins = get_option('active_plugins', array()); foreach ($plugins as $plugin_path => $plugin) { // If the plugin isn't active, don't show it. if (!in_array($plugin_path, $active_plugins)) { continue; } echo $plugin['Name']; ?> : <?php echo $plugin['Version'] . "\n"; } ?> CURRENT THEME: <?php if (get_bloginfo('version') < '3.4') { $theme_data = get_theme_data(get_stylesheet_directory() . '/style.css'); echo $theme_data['Name'] . ': ' . $theme_data['Version']; } else { $theme_data = wp_get_theme(); echo $theme_data->Name . ': ' . $theme_data->Version; } ?> ### End System Info ### </textarea> <p class="submit"> <input type="hidden" name="edd-action" value="download_sysinfo" /> <?php submit_button(__('Download System Info File', 'edd'), 'primary', 'edd-download-sysinfo', false); ?> </p> </form> </div> </div> <?php }