function pmprodon_getPriceComponents($order)
{
    $r = array("price" => $order->total, "donation" => "");
    if (!empty($order->notes) && strpos($order->notes, "Donation:") !== false) {
        $donation = pmpro_getMatches("/Donation\\:([0-9\\.]+)/", $order->notes, true);
        $r['donation'] = $donation;
        if ($donation > 0) {
            $r['price'] = $order->total - $donation;
        }
    }
    //filter added .2
    $r = apply_filters('pmpro_donations_get_price_components', $r, $order);
    return $r;
}
示例#2
0
function pmpro_init()
{
    require_once PMPRO_DIR . "/includes/countries.php";
    require_once PMPRO_DIR . "/includes/states.php";
    require_once PMPRO_DIR . "/includes/currencies.php";
    wp_enqueue_script('ssmemberships_js', plugins_url('js/paid-memberships-pro.js', dirname(__FILE__)), array('jquery'));
    if (is_admin()) {
        $admin_css_rtl = false;
        if (file_exists(get_stylesheet_directory() . "/paid-memberships-pro/css/admin.css")) {
            $admin_css = get_stylesheet_directory_uri() . "/paid-memberships-pro/css/admin.css";
            if (is_rtl() && file_exists(get_stylesheet_directory() . "/paid-memberships-pro/css/admin-rtl.css")) {
                $admin_css_rtl = get_stylesheet_directory_uri() . "/paid-memberships-pro/css/admin-rtl.css";
            }
        } elseif (file_exists(get_template_directory() . "/paid-memberships-pro/admin.css")) {
            $admin_css = get_template_directory_uri() . "/paid-memberships-pro/admin.css";
            if (is_rtl() && file_exists(get_template_directory() . "/paid-memberships-pro/css/admin-rtl.css")) {
                $admin_css_rtl = get_template_directory_uri() . "/paid-memberships-pro/css/admin-rtl.css";
            }
        } else {
            $admin_css = plugins_url('css/admin.css', dirname(__FILE__));
            if (is_rtl()) {
                $admin_css_rtl = plugins_url('css/admin-rtl.css', dirname(__FILE__));
            }
        }
        wp_enqueue_style('pmpro_admin', $admin_css, array(), PMPRO_VERSION, "screen");
        if ($admin_css_rtl) {
            wp_enqueue_style('pmpro_admin_rtl', $admin_css_rtl, array(), PMPRO_VERSION, "screen");
        }
        wp_enqueue_script('jquery-ui-sortable');
    } else {
        $frontend_css_rtl = false;
        if (file_exists(get_stylesheet_directory() . "/paid-memberships-pro/css/frontend.css")) {
            $frontend_css = get_stylesheet_directory_uri() . "/paid-memberships-pro/css/frontend.css";
            if (is_rtl() && file_exists(get_stylesheet_directory() . "/paid-memberships-pro/css/frontend-rtl.css")) {
                $frontend_css_rtl = get_stylesheet_directory_uri() . "/paid-memberships-pro/css/frontend-rtl.css";
            }
        } elseif (file_exists(get_template_directory() . "/paid-memberships-pro/frontend.css")) {
            $frontend_css = get_template_directory_uri() . "/paid-memberships-pro/frontend.css";
            if (is_rtl() && file_exists(get_template_directory() . "/paid-memberships-pro/css/frontend-rtl.css")) {
                $frontend_css_rtl = get_template_directory_uri() . "/paid-memberships-pro/css/frontend-rtl.css";
            }
        } else {
            $frontend_css = plugins_url('css/frontend.css', dirname(__FILE__));
            if (is_rtl()) {
                $frontend_css_rtl = plugins_url('css/frontend-rtl.css', dirname(__FILE__));
            }
        }
        wp_enqueue_style('pmpro_frontend', $frontend_css, array(), PMPRO_VERSION, "screen");
        if ($frontend_css_rtl) {
            wp_enqueue_style('pmpro_frontend_rtl', $frontend_css_rtl, array(), PMPRO_VERSION, "screen");
        }
        if (file_exists(get_stylesheet_directory() . "/paid-memberships-pro/css/print.css")) {
            $print_css = get_stylesheet_directory_uri() . "/paid-memberships-pro/css/print.css";
        } elseif (file_exists(get_template_directory() . "/paid-memberships-pro/print.css")) {
            $print_css = get_template_directory_uri() . "/paid-memberships-pro/print.css";
        } else {
            $print_css = plugins_url('css/print.css', dirname(__FILE__));
        }
        wp_enqueue_style('pmpro_print', $print_css, array(), PMPRO_VERSION, "print");
    }
    global $pmpro_pages, $pmpro_ready, $pmpro_currencies, $pmpro_currency, $pmpro_currency_symbol;
    $pmpro_pages = array();
    $pmpro_pages["account"] = pmpro_getOption("account_page_id");
    $pmpro_pages["billing"] = pmpro_getOption("billing_page_id");
    $pmpro_pages["cancel"] = pmpro_getOption("cancel_page_id");
    $pmpro_pages["checkout"] = pmpro_getOption("checkout_page_id");
    $pmpro_pages["confirmation"] = pmpro_getOption("confirmation_page_id");
    $pmpro_pages["invoice"] = pmpro_getOption("invoice_page_id");
    $pmpro_pages["levels"] = pmpro_getOption("levels_page_id");
    $pmpro_ready = pmpro_is_ready();
    //set currency
    $pmpro_currency = pmpro_getOption("currency");
    if (!$pmpro_currency) {
        global $pmpro_default_currency;
        $pmpro_currency = $pmpro_default_currency;
    }
    //figure out what symbol to show for currency
    if (!empty($pmpro_currencies[$pmpro_currency]) && is_array($pmpro_currencies[$pmpro_currency])) {
        $pmpro_currency_symbol = $pmpro_currencies[$pmpro_currency]['symbol'];
    } elseif (!empty($pmpro_currencies[$pmpro_currency]) && strpos($pmpro_currencies[$pmpro_currency], "(") !== false) {
        $pmpro_currency_symbol = pmpro_getMatches("/\\((.*)\\)/", $pmpro_currencies[$pmpro_currency], true);
    } else {
        $pmpro_currency_symbol = $pmpro_currency . " ";
    }
    //just use the code
}
function pmpromd_profile_preheader()
{
    global $post, $pmpro_pages, $current_user;
    if (!empty($post->ID) && $post->ID == $pmpro_pages['profile']) {
        /*
        	Preheader operations here.
        */
        global $main_post_id;
        $main_post_id = $post->ID;
        //Get the profile user
        if (!empty($_REQUEST['pu']) && is_numeric($_REQUEST['pu'])) {
            $pu = get_user_by('id', $_REQUEST['pu']);
        } elseif (!empty($_REQUEST['pu'])) {
            $pu = get_user_by('slug', $_REQUEST['pu']);
        } elseif (!empty($current_user->ID)) {
            $pu = $current_user;
        } else {
            $pu = false;
        }
        //If no profile user, go to directory or home
        if (empty($pu) || empty($pu->ID)) {
            if (!empty($pmpro_pages['directory'])) {
                wp_redirect(get_permalink($pmpro_pages['directory']));
            } else {
                wp_redirect(home_url());
            }
            exit;
        }
        /*
        	If a level is required for the profile page, make sure the profile user has it.
        */
        //check is levels are required
        $levels = pmpro_getMatches("/ levels?=[\"']([^\"^']*)[\"']/", $post->post_content, true);
        if (!empty($levels) && !pmpro_hasMembershipLevel(explode(",", $levels), $pu->ID)) {
            if (!empty($pmpro_pages['directory'])) {
                wp_redirect(get_permalink($pmpro_pages['directory']));
            } else {
                wp_redirect(home_url());
            }
            exit;
        }
        /*
        	Update the head title and H1
        */
        function pmpromd_the_title($title, $post_id = NULL)
        {
            global $main_post_id, $current_user;
            if ($post_id == $main_post_id) {
                if (!empty($_REQUEST['pu'])) {
                    global $wpdb;
                    $user_nicename = $_REQUEST['pu'];
                    $display_name = $wpdb->get_var("SELECT display_name FROM {$wpdb->users} WHERE user_nicename = '" . esc_sql($user_nicename) . "' LIMIT 1");
                } elseif (!empty($current_user)) {
                    $display_name = $current_user->display_name;
                }
                if (!empty($display_name)) {
                    $title = $display_name;
                }
            }
            return $title;
        }
        add_filter("the_title", "pmpromd_the_title", 10, 2);
        function pmpromd_wp_title($title, $sep)
        {
            global $wpdb, $main_post_id, $post, $current_user;
            if ($post->ID == $main_post_id) {
                if (!empty($_REQUEST['pu'])) {
                    $user_nicename = $_REQUEST['pu'];
                    $display_name = $wpdb->get_var("SELECT display_name FROM {$wpdb->users} WHERE user_nicename = '" . esc_sql($user_nicename) . "' LIMIT 1");
                } elseif (!empty($current_user)) {
                    $display_name = $current_user->display_name;
                }
                if (!empty($display_name)) {
                    $title = $display_name . ' ' . $sep . ' ';
                }
                $title .= get_bloginfo('name');
            }
            return $title;
        }
        add_filter("wp_title", "pmpromd_wp_title", 10, 2);
    }
}