Example #1
0
/**
 * Load Scripts
 *
 * Enqueues the required scripts.
 *
 * @since	1.3
 * @global	$post
 * @return	void
 */
function mdjm_load_scripts()
{
    $js_dir = MDJM_PLUGIN_URL . '/assets/js/';
    wp_register_script('mdjm-ajax', $js_dir . 'mdjm-ajax.js', array('jquery'), MDJM_VERSION_NUM);
    wp_enqueue_script('mdjm-ajax');
    wp_localize_script('mdjm-ajax', 'mdjm_vars', apply_filters('mdjm_script_vars', array('ajaxurl' => mdjm_get_ajax_url(), 'rest_url' => esc_url_raw(rest_url('mdjm/v1/')), 'ajax_loader' => MDJM_PLUGIN_URL . '/assets/images/loading.gif', 'required_date_message' => __('Please select a date', 'mobile-dj-manager'), 'availability_ajax' => mdjm_get_option('avail_ajax', false), 'available_redirect' => mdjm_get_option('availability_check_pass_page', 'text') != 'text' ? mdjm_get_formatted_url(mdjm_get_option('availability_check_pass_page')) : 'text', 'available_text' => mdjm_get_option('availability_check_pass_text', false), 'unavailable_redirect' => mdjm_get_option('availability_check_fail_page', 'text'), 'unavailable_text' => mdjm_get_option('availability_check_fail_text', false), 'is_payment' => mdjm_is_payment() ? '1' : '0', 'default_gateway' => mdjm_get_default_gateway(), 'payment_loading' => __('Please Wait...', 'mobile-dj-manager'), 'no_payment_amount' => __('Select Payment Amount', 'mobile-dj-manager'), 'no_card_name' => __('Enter the name printed on your card', 'mobile-dj-manager'), 'complete_payment' => mdjm_get_payment_button_text())));
    wp_register_script('jquery-validation-plugin', '//ajax.aspnetcdn.com/ajax/jquery.validate/1.14.0/jquery.validate.min.js', array('jquery'));
    wp_enqueue_script('jquery-validation-plugin');
    wp_enqueue_script('jquery-ui-datepicker', array('jquery'));
}
Example #2
0
/**
 * Send admin notice of payment.
 *
 * @since	1.3.8
 * @param
 * @return	void
 */
function mdjm_admin_payment_notice($txn_data)
{
    if (isset($txn_data['gateway'])) {
        $gateway = mdjm_get_gateway_admin_label($txn_data['gateway']);
    } else {
        $gateway = mdjm_get_gateway_admin_label(mdjm_get_default_gateway());
    }
    $subject = sprintf(__('%s Payment received via %s', 'mobile-dj-manager'), mdjm_get_label_singular(), $gateway);
    $subject = apply_filters('mdjm_admin_payment_notice_subject', $subject);
    $content = '<!DOCTYPE html>' . "\n";
    $content .= '<html>' . "\n" . '<body>' . "\n";
    $content .= '<p>' . __('Hi there', 'mobile-dj-manager') . ',</p>' . "\n";
    $content .= '<p>' . __('A payment has just been received via MDJM Event Management', 'mobile-dj-manager') . '</p>' . "\n";
    $content .= '<hr />' . "\n";
    $content .= '<h4>' . sprintf(__('%s ID', 'mobile-dj-manager'), mdjm_get_label_singular()) . ': ' . mdjm_get_event_contract_id($txn_data['event_id']) . '</a></h4>' . "\n";
    $content .= '<p>' . "\n";
    $content .= __('Date', 'mobile-dj-manager') . ': {event_date}<br />' . "\n";
    $content .= __('Status', 'mobile-dj-manager') . ': {event_status}<br />' . "\n";
    $content .= __('Client', 'mobile-dj-manager') . ': {client_fullname}<br />' . "\n";
    $content .= __('Payment Date', 'mobile-dj-manager') . ': {payment_date}<br />' . "\n";
    $content .= __('For', 'mobile-dj-manager') . ': {payment_for}<br />' . "\n";
    $content .= __('Amount', 'mobile-dj-manager') . ': {payment_amount}<br />' . "\n";
    $content .= __('Merchant', 'mobile-dj-manager') . ': ' . $gateway . '<br />' . "\n";
    if (!empty($txn_data['fee'])) {
        $content .= __('Transaction Fee', 'mobile-dj-manager') . ': ' . mdjm_currency_filter(mdjm_format_amount($txn_data['fee'])) . '</span><br />' . "\n";
        $content .= '<strong>' . __('Total Received', 'mobile-dj-manager') . ': ' . mdjm_currency_filter(mdjm_format_amount($txn_data['total'] - $txn_data['fee'])) . '</strong><br />' . "\n";
    }
    $content .= __('Outstanding Balance', 'mobile-dj-manager') . ': {balance}</p>' . "\n";
    $content .= sprintf(__('<a href="%s">View %s</a>', 'mobile-dj-manager'), admin_url('post.php?post=' . $txn_data['event_id'] . '&action=edit'), mdjm_get_label_singular()) . '</p>' . "\n";
    $content .= '<hr />' . "\n";
    $content .= '<p>' . __('Regards', 'mobile-dj-manager') . '<br />' . "\n";
    $content .= '{company_name}</p>' . "\n";
    $content .= '</body>' . "\n";
    $content .= '</html>' . "\n";
    $content = apply_filters('mdjm_admin_payment_notice_content', $content);
    mdjm_send_email_content(array('to_email' => mdjm_get_option('system_email'), 'from_name' => mdjm_get_option('company_name'), 'from_email' => mdjm_get_option('system_email'), 'event_id' => $txn_data['event_id'], 'client_id' => mdjm_get_event_client_id($txn_data['event_id']), 'subject' => $subject, 'message' => $content, 'copy_to' => 'disable', 'source' => __('Automated Payment Received', 'mobile-dj-manager')));
}
/**
 * Payment Form Validate Gateway
 *
 * @since	1.3.8
 * @return	string
 */
function mdjm_payment_form_validate_gateway()
{
    $gateway = mdjm_get_default_gateway();
    // Check if a gateway value is present
    if (!empty($_REQUEST['mdjm_gateway'])) {
        $gateway = sanitize_text_field($_REQUEST['mdjm_gateway']);
    }
    return $gateway;
}
Example #4
0
/**
 * Get system info
 *
 * @since	1.4
 * @global	obj	$wpdb	Used to query the database using the WordPress Database API
 * @return	str	$return	A string containing the info to output
 */
function mdjm_tools_sysinfo_get()
{
    global $wpdb;
    // Get theme info
    $theme_data = wp_get_theme();
    $theme = $theme_data->Name . ' ' . $theme_data->Version;
    $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('mdjm_sysinfo_after_site_info', $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";
    }
    $return .= 'ABSPATH:                  ' . ABSPATH . "\n";
    // Make sure wp_remote_post() is working
    $request['cmd'] = '_notify-validate';
    $params = array('sslverify' => false, 'timeout' => 60, 'user-agent' => 'MDJM/' . MDJM_VERSION_NUM, '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('mdjm_sysinfo_after_wordpress_config', $return);
    // MDJM configuration
    $employer = mdjm_is_employer();
    $packages = mdjm_packages_enabled();
    $debug = MDJM_DEBUG;
    $return .= "\n" . '-- MDJM Configuration' . "\n\n";
    $return .= 'Version:                  ' . MDJM_VERSION_NUM . "\n";
    $return .= 'Upgraded From:            ' . get_option('mdjm_version_upgraded_from', 'None') . "\n";
    $return .= 'Debugging Status:         ' . (!empty($debug) ? "Enabled\n" : "Disabled\n");
    $return .= 'Multiple Employees:       ' . (!empty($employer) ? "Enabled\n" : "Disabled\n");
    $return .= 'Packages Enabled:         ' . (!empty($packages) ? "Enabled\n" : "Disabled\n");
    $return .= 'Currency Code:            ' . mdjm_get_currency() . "\n";
    $return .= 'Currency Position:        ' . mdjm_get_option('currency_format', 'before') . "\n";
    $return .= 'Decimal Separator:        ' . mdjm_get_option('decimal', '.') . "\n";
    $return .= 'Thousands Separator:      ' . mdjm_get_option('thousands_separator', ',') . "\n";
    $return = apply_filters('mdjm_sysinfo_after_mdjm_config', $return);
    // MDJM pages
    $clientzone_page = mdjm_get_option('app_home_page', '');
    $contact_page = mdjm_get_option('contact_page', '');
    $contracts_page = mdjm_get_option('contracts_page', '');
    $payments_page = mdjm_get_option('payments_page', '');
    $playlist_page = mdjm_get_option('playlist_page', '');
    $profile_page = mdjm_get_option('profile_page', '');
    $quotes_page = mdjm_get_option('quotes_page', '');
    $return .= "\n" . '-- MDJM Page Configuration' . "\n\n";
    $return .= 'Client Zone Page:         ' . (!empty($clientzone_page) ? get_permalink($clientzone_page) . "\n" : "Unset\n");
    $return .= 'Contact Page:             ' . (!empty($contact_page) ? get_permalink($contact_page) . "\n" : "Unset\n");
    $return .= 'Contracts Page:           ' . (!empty($contracts_page) ? get_permalink($contracts_page) . "\n" : "Unset\n");
    $return .= 'Payments Page:            ' . (!empty($payments_page) ? get_permalink($payments_page) . "\n" : "Unset\n");
    $return .= 'Playlist Page:            ' . (!empty($playlist_page) ? get_permalink($playlist_page) . "\n" : "Unset\n");
    $return .= 'Profile Page:             ' . (!empty($profile_page) ? get_permalink($profile_page) . "\n" : "Unset\n");
    $return .= 'Quotes Page:              ' . (!empty($quotes_page) ? get_permalink($quotes_page) . "\n" : "Unset\n");
    $return = apply_filters('mdjm_sysinfo_after_mdjm_pages', $return);
    // MDJM email templates
    $quote_template = mdjm_get_option('enquiry', '');
    $online_quote = mdjm_get_option('online_enquiry', '');
    $unavailable_template = mdjm_get_option('unavailable', '');
    $contract_template = mdjm_get_option('contract', '');
    $booking_conf_template = mdjm_get_option('booking_conf_client', '');
    $auto_payment_template = mdjm_get_option('payment_cfm_template', '');
    $manual_payment_template = mdjm_get_option('manual_payment_cfm_template', '');
    $return .= "\n" . '-- MDJM Email Templates' . "\n\n";
    $return .= 'Quote:                    ' . (!empty($quote_template) ? get_the_title($quote_template) . ' (' . $quote_template . ')' . "\n" : "Unset\n");
    $return .= 'Online Quote:             ' . (!empty($online_quote) ? get_the_title($online_quote) . ' (' . $online_quote . ')' . "\n" : "Unset\n");
    $return .= 'Unavailable:              ' . (!empty($unavailable_template) ? get_the_title($unavailable_template) . ' (' . $unavailable_template . ')' . "\n" : "Unset\n");
    $return .= 'Awaiting Contract:        ' . (!empty($contract_template) ? get_the_title($quote_template) . ' (' . $quote_template . ')' . "\n" : "Unset\n");
    $return .= 'Booking Confirmation:     ' . (!empty($booking_conf_template) ? get_the_title($booking_conf_template) . ' (' . $booking_conf_template . ')' . "\n" : "Unset\n");
    $return .= 'Gateway Payment:          ' . (!empty($auto_payment_template) ? get_the_title($auto_payment_template) . ' (' . $auto_payment_template . ')' . "\n" : "Unset\n");
    $return .= 'Manual Payment:           ' . (!empty($manual_payment_template) ? get_the_title($manual_payment_template) . ' (' . $manual_payment_template . ')' . "\n" : "Unset\n");
    $return = apply_filters('mdjm_sysinfo_after_mdjm_pages', $return);
    // MDJM Payment Gateways
    $return .= "\n" . '-- MDJM Gateway Configuration' . "\n\n";
    $active_gateways = mdjm_get_enabled_payment_gateways();
    if ($active_gateways) {
        $default_gateway_is_active = mdjm_is_gateway_active(mdjm_get_default_gateway());
        if ($default_gateway_is_active) {
            $default_gateway = mdjm_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('mdjm_sysinfo_after_mdjm_gateways', $return);
    // MDJM Templates
    $dir = get_stylesheet_directory() . '/mdjm-templates/*';
    if (is_dir($dir) && count(glob("{$dir}/*")) !== 0) {
        $return .= "\n" . '-- MDJM Template Overrides' . "\n\n";
        foreach (glob($dir) as $file) {
            $return .= 'Filename:                 ' . basename($file) . "\n";
        }
        $return = apply_filters('mdjm_sysinfo_after_mdjm_templates', $return);
    }
    // Get plugins that have an update
    $updates = get_plugin_updates();
    // Must-use plugins
    // NOTE: MU plugins can't show updates!
    $muplugins = get_mu_plugins();
    if (count($muplugins > 0)) {
        $return .= "\n" . '-- Must-Use Plugins' . "\n\n";
        foreach ($muplugins as $plugin => $plugin_data) {
            $return .= $plugin_data['Name'] . ': ' . $plugin_data['Version'] . "\n";
        }
        $return = apply_filters('mdjm_sysinfo_after_wordpress_mu_plugins', $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;
        }
        $update = array_key_exists($plugin_path, $updates) ? ' (needs update - ' . $updates[$plugin_path]->update->new_version . ')' : '';
        $return .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n";
    }
    $return = apply_filters('mdjm_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;
        }
        $update = array_key_exists($plugin_path, $updates) ? ' (needs update - ' . $updates[$plugin_path]->update->new_version . ')' : '';
        $return .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n";
    }
    $return = apply_filters('mdjm_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;
            }
            $update = array_key_exists($plugin_path, $updates) ? ' (needs update - ' . $updates[$plugin_path]->update->new_version . ')' : '';
            $plugin = get_plugin_data($plugin_path);
            $return .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n";
        }
        $return = apply_filters('mdjm_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('mdjm_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('mdjm_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('mdjm_sysinfo_after_php_ext', $return);
    $return .= "\n" . '### End System Info ###';
    return $return;
}
Example #5
0
/**
 * Renders the payment mode form by getting all the enabled payment gateways and
 * outputting them as radio buttons for the user to choose the payment gateway. If
 * a default payment gateway has been chosen from the MDJM Settings, it will be
 * automatically selected.
 *
 * @since 	1.3.8
 * @return	void
 */
function mdjm_payment_mode_select()
{
    $gateways = mdjm_get_enabled_payment_gateways(true);
    $page_URL = mdjm_get_current_page_url();
    do_action('mdjm_payment_mode_top');
    ?>
		<fieldset id="mdjm_payment_mode_select">
        	<legend><?php 
    _e('Select Payment Method', 'mobile-dj-manager');
    ?>
</legend>
			<?php 
    do_action('mdjm_payment_mode_before_gateways_wrap');
    ?>
			<div id="mdjm-payment-mode-wrap">
				<?php 
    do_action('mdjm_payment_mode_before_gateways');
    foreach ($gateways as $gateway_id => $gateway) {
        $checked = checked($gateway_id, mdjm_get_default_gateway(), false);
        $checked_class = $checked ? ' mdjm-gateway-option-selected' : '';
        echo '<label for="mdjm-gateway-' . esc_attr($gateway_id) . '" class="mdjm-gateway-option' . $checked_class . '" id="mdjm-gateway-option-' . esc_attr($gateway_id) . '">';
        echo '<input type="radio" name="payment-mode" class="mdjm-gateway" id="mdjm-gateway-' . esc_attr($gateway_id) . '" value="' . esc_attr($gateway_id) . '"' . $checked . '>' . esc_html($gateway['payment_label']);
        echo '</label>';
    }
    do_action('mdjm_payment_mode_after_gateways');
    ?>
			</div>
			<?php 
    do_action('mdjm_payment_mode_after_gateways_wrap');
    ?>
		</fieldset>
	<div id="mdjm_payment_form_wrap"></div><!-- the fields are loaded into this-->
	<?php 
    do_action('mdjm_payment_mode_bottom');
}