/** * Retrieve page permalink * * @package Social Deals Engine * @since 2.1.9 */ function wps_get_page_permalink($page) { $page_id = wps_deals_get_page_id($page); $permalink = $page_id ? get_permalink($page_id) : ''; return apply_filters('wps_get_' . $page . '_page_permalink', $permalink); }
/** * Add the "Deals Store" link in admin bar main menu * * @package Social Deals Engine * @since 2.0.6 */ public function wps_deals_admin_bar_menus($wps_admin_bar) { global $wps_deals_public; // Return if filter false if (!apply_filters('wps_show_admin_bar_visit_deals_shop', true)) { return; } // Returen if user is not admin or logged in if (!is_admin() || !is_user_logged_in()) { return; } // Show only when the user is a member of this site, or they're a super admin if (!is_user_member_of_blog() && !is_super_admin()) { return; } // Don't display when shop page is the same of the page on front if (get_option('page_on_front') == wps_deals_get_page_id('shop_page')) { return; } $page_url = $wps_deals_public->wps_get_page_permalink('shop_page'); if (!empty($page_url)) { // Add an option to visit the store $wps_admin_bar->add_node(array('parent' => 'site-name', 'id' => 'deals-store', 'title' => __('Deals Store', 'wpsdeals'), 'href' => $wps_deals_public->wps_get_page_permalink('shop_page'))); } // End of if condition }
/** * Loads the buy now button template. * * @package Social Deals Engine * @since 1.0.0 */ function wps_deals_buy_now_button() { global $post, $wps_deals_options, $wps_deals_price; $prefix = WPS_DEALS_META_PREFIX; $dealurl = get_permalink($post->ID); // get the product price $productprice = $wps_deals_price->wps_deals_get_price($post->ID); //get the display price $displayprice = $wps_deals_price->get_display_price($productprice, $post->ID); // get the buy now button text $buynowtext = get_post_meta($post->ID, $prefix . 'buy_now', true); // get the color scheme from the settings $button_color = $wps_deals_options['deals_btn_color']; $btncolor = isset($button_color) && !empty($button_color) ? $button_color : 'blue'; // Check user is not logged in and disable guest checkout from misc settings if (!is_user_logged_in() && !empty($wps_deals_options['disable_guest_checkout'])) { if (isset($wps_deals_options['create_account_page']) && !empty($wps_deals_options['create_account_page'])) { // Check create an account page id is not empty $create_account_page_id = wps_deals_get_page_id('create_account_page'); $payurl = get_permalink($create_account_page_id); } else { $payurl = wp_login_url($dealurl); } } else { $payurl = add_query_arg(array('dealsaction' => 'buynow', 'dealid' => $post->ID), $dealurl); } $args = array('payurl' => $payurl, 'displayprice' => $displayprice, 'dealid' => $post->ID, 'buynowtext' => !empty($buynowtext) ? $buynowtext : __('Buy Now', 'wpsdeals'), 'btncolor' => $btncolor); // get the template wps_deals_get_template('single-deal/buy-now-button.php', $args); }
/** * Fix active class in wp_list_pages for deals shop page. * * @package Social Deals Engine * @since 2.1.0 * @param string $pages * @return string */ function wps_deals_list_pages($pages) { $shop_page = 'page-item-' . wps_deals_get_page_id('shop_page'); // find shop_page_id through deals options if (is_page(wps_deals_get_page_id('shop_page')) || is_post_type_archive(WPS_DEALS_POST_TYPE)) { $pages = str_replace($shop_page, $shop_page . ' current_page_item', $pages); } // add current_page_item class to shop page return $pages; }
<?php /** * My Account Top Content Template * * Override this template by copying it to yourtheme/deals-engine/my-account/top-content.php * * @author Social Deals Engine * @package Deals-Engine/Includes/Templates * @version 1.0.0 */ if (!defined('ABSPATH')) { exit; } // Exit if accessed directly //$changepasswordlinkhtml = '<a href="' . $changepasswordlink . '">' . __( 'change your password', 'wpsdeals' ) . '</a>'; $changepasswordlinkhtml = '<a href="' . $changepasswordlink . '">' . __('edit your password and account details', 'wpsdeals') . '</a>'; ?> <p class="deals-account-top deals-clearfix"> <?php printf(__('Hello <strong>%1$s</strong> (not %1$s? <a href="%2$s">Sign out</a>).', 'wpsdeals') . ' ', $username, wp_logout_url(get_permalink(wps_deals_get_page_id('my_account_page')))); printf(__('From your account dashboard you can view your recent orders, manage your shipping and billing addresses and %s.', 'wpsdeals'), $changepasswordlinkhtml); ?> </p>