/**
  * Pluggable function to render social login "link your account" buttons
  *
  * @since 1.1.0
  * @param string $return_url Return url, defaults my account page
  */
 function woocommerce_social_login_link_account_buttons($return_url = null)
 {
     if (!is_user_logged_in()) {
         return;
     }
     // If no return_url, use the my account page
     if (!$return_url) {
         $return_url = SV_WC_Plugin_Compatibility::wc_get_page_permalink('myaccount');
     }
     // Enqueue styles and scripts
     wc_social_login()->frontend->load_styles_scripts();
     $available_providers = array();
     // determine available providers for user
     foreach (wc_social_login()->get_available_providers() as $provider) {
         if (!get_user_meta(get_current_user_id(), '_wc_social_login_' . $provider->get_id() . '_profile', true)) {
             $available_providers[] = $provider;
         }
     }
     // load the template
     wc_get_template('global/social-login-link-account.php', array('available_providers' => $available_providers, 'return_url' => $return_url), '', wc_social_login()->get_plugin_path() . '/templates/');
 }
 /**
  * Entry method for the Add Payment Method feature flow. Note this is *not*
  * stubbed in the WC_Payment_Gateway abstract class, but is called if the
  * gateway declares support for it.
  *
  * @since 4.0.0
  */
 public function add_payment_method()
 {
     assert($this->supports_add_payment_method());
     $order = $this->get_order_for_add_payment_method();
     try {
         $result = $this->do_add_payment_method_transaction($order);
     } catch (SV_WC_Plugin_Exception $e) {
         $result = array('message' => sprintf(__('Oops, adding your new payment method failed: %s', $this->text_domain), $e->getMessage()), 'success' => false);
     }
     SV_WC_Helper::wc_add_notice($result['message'], $result['success'] ? 'success' : 'error');
     // redirect to my account on success, or back to Add Payment Method screen on failure so user can try again
     wp_safe_redirect($result['success'] ? SV_WC_Plugin_Compatibility::wc_get_page_permalink('myaccount') : wc_get_endpoint_url('add-payment-method'));
     exit;
 }
 /**
  * Get renew membership URL for frontend
  *
  * @since 1.0
  * @return string Renew URL
  */
 public function get_renew_membership_url()
 {
     $renew_endpoint = SV_WC_Plugin_Compatibility::wc_get_page_permalink('myaccount');
     if (false === strpos($renew_endpoint, '?')) {
         $renew_endpoint = trailingslashit($renew_endpoint);
     }
     /**
      * Filter the renew membership URL
      *
      * @since 1.0.0
      * @param string $url
      * @param WC_Memberships_User_Membership $user_membership
      */
     return apply_filters('wc_memberships_get_renew_membership_url', wp_nonce_url(add_query_arg(array('renew_membership' => 'true', 'user_membership_id' => $this->get_id()), $renew_endpoint), 'wc_memberships-renew_membership'), $this);
 }
 /**
  * Redirect back to the My Account page
  *
  * @since 4.0.0
  */
 protected function redirect_to_my_account()
 {
     wp_redirect(SV_WC_Plugin_Compatibility::wc_get_page_permalink('myaccount'));
     exit;
 }
 /**
  * Get the "Manage Payment Methods" button HTML
  *
  * @since 4.0.0
  * @return string manage payment methods button html
  */
 protected function get_manage_payment_methods_button_html()
 {
     $html = sprintf('<a class="button" style="float:right;" href="%s">%s</a>', esc_url(SV_WC_Plugin_Compatibility::wc_get_page_permalink('myaccount') . '#wc-' . $this->get_gateway()->get_plugin()->get_id_dasherized() . '-my-payment-methods'), wp_kses_post(apply_filters('wc_' . $this->get_gateway()->get_id() . '_manage_payment_methods_text', __("Manage Payment Methods", $this->get_gateway()->get_text_domain()))));
     /**
      * Payment Gateway Payment Form Manage Payment Methods Button HTML.
      *
      * Filters the HTML rendered for the "Manage Payment Methods" button.
      *
      * @since 4.0.0
      * @param string $html
      * @param \SV_WC_Payment_Gateway_Payment_Form $this payment form instance
      */
     return apply_filters('wc_' . $this->get_gateway()->get_id() . '_payment_form_manage_payment_methods_button_html', $html, $this);
 }
 /**
  * Add social login buttons to Sensei
  *
  * @since 1.1.0
  */
 public function add_buttons_to_sensei_login()
 {
     global $woothemes_sensei;
     if (isset($woothemes_sensei->settings->settings['my_course_page'])) {
         $return_url = get_permalink(absint($woothemes_sensei->settings->settings['my_course_page']));
     } else {
         $return_url = SV_WC_Plugin_Compatibility::wc_get_page_permalink('myaccount');
     }
     woocommerce_social_login_buttons($return_url);
 }
 /**
  * Get and parse a restriction message
  *
  * General wrapper around different types of restriction messages
  *
  * @since 1.0.0
  * @param string $type Restriction type
  * @param int $post_id Post ID that is being restricted
  * @param array $products List of product IDs that grant access. Optional
  * @return string Restriction message
  */
 private function get_restriction_message($type, $post_id, $products = null)
 {
     if (!$type) {
         return false;
     }
     if (!empty($products)) {
         foreach ($products as $key => $product_id) {
             $product = wc_get_product($product_id);
             $link = $product->get_permalink();
             $title = $product->get_title();
             // Special handling for variations
             if ($product->is_type('variation')) {
                 $attributes = $product->get_variation_attributes();
                 foreach ($attributes as $attr_key => $attribute) {
                     $attributes[$attr_key] = ucfirst($attribute);
                 }
                 $title .= ' &ndash; ' . implode(', ', $attributes);
             }
             $products[$key] = sprintf('<a href="%s">%s</a>', esc_url($link), wp_kses_post($title));
         }
         // Check that the message type is valid for custom messages.
         // For example, purchasing_discount messages cannot be customized per-product
         // so we must leave them out
         if (in_array($type, wc_memberships_get_valid_restriction_message_types()) && 'yes' === get_post_meta($post_id, "_wc_memberships_use_custom_{$type}_message", true)) {
             $message = get_post_meta($post_id, "_wc_memberships_{$type}_message", true);
         } else {
             $message = get_option('wc_memberships_' . $type . '_message');
         }
         $message = str_replace('{products}', '<span class="wc-memberships-products-grant-access">' . wc_memberships()->list_items($products) . '</span>', $message);
         $message = str_replace('{login_url}', esc_url(SV_WC_Plugin_Compatibility::wc_get_page_permalink('myaccount')), $message);
     } else {
         $message = get_option('wc_memberships_' . $type . '_message_no_products');
     }
     return $message;
 }
 /**
  * Redirect back to the provided return_url
  *
  * @since 1.2.0
  * @param string $redirect_location
  * @param string $redirect_location
  * @return string URL
  */
 public function redirect_after_save_account_details($redirect_location)
 {
     $safe_redirect_location = SV_WC_Plugin_Compatibility::wc_get_page_permalink('myaccount');
     $safe_redirect_location = wp_sanitize_redirect($safe_redirect_location);
     $safe_redirect_location = wp_validate_redirect($safe_redirect_location, admin_url());
     if ($redirect_location === $safe_redirect_location && ($new_location = get_transient('wcsl_' . md5($_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT'])))) {
         $redirect_location = $new_location;
         delete_transient('wcsl_' . md5($_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT']));
     }
     return $redirect_location;
 }
            ?>
						</td>
					</tr>

				<?php 
        }
        ?>

			<?php 
    }
    ?>

			</tbody>

		</table>

	<?php 
} else {
    ?>

		<p><?php 
    echo sprintf(__('You have not added any %s yet. %sAdd one now%s', WC_Product_Reviews_Pro::TEXT_DOMAIN), wc_product_reviews_pro_get_enabled_types_name(), '<a href="' . esc_url(SV_WC_Plugin_Compatibility::wc_get_page_permalink('shop')) . '">', '</a>');
    ?>
</p>

	<?php 
}
?>

</div>