php 提供短代码以在任何页面中添加Pro Site结帐表单
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 提供短代码以在任何页面中添加Pro Site结帐表单相关的知识,希望对你有一定的参考价值。
<?php
/*
Plugin Name: Pro Sites - Checkout Shortcode
Plugin URI: https://premium.wpmudev.org/
Description: Provides a shortcode to add the Pro Sites checkout form in any page
Author: Panos Lyrakis @ WPMUDEV
Author URI: https://premium.wpmudev.org/
License: GPLv2 or later
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'PS_Checkout_Shortcode' ) ) {
class PS_Checkout_Shortcode {
private static $_instance = null;
public static function get_instance() {
if( is_null( self::$_instance ) ){
self::$_instance = new PS_Checkout_Shortcode();
}
return self::$_instance;
}
private function __construct() {
if( ! class_exists('ProSites') ){
return;
}
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
add_shortcode( 'pro_checkout', array( $this, 'load_checkout_form' ) );
}
public function load_checkout_form( $atts, $content = null ){
global $psts;
return $psts->checkout_output($content);
}
public function enqueue_scripts(){
global $psts, $post;
if ( ! $post instanceof WP_POST || ! has_shortcode( $post->post_content, 'pro_checkout' ) ){
return;
}
$stripe_secret_key = $psts->get_setting( 'stripe_secret_key' );
$stripe_publishable_key = $psts->get_setting( 'stripe_publishable_key' );
wp_enqueue_script( 'jquery-ui-tabs' );
wp_enqueue_style( 'proSite-custom-checkout', get_site_url().'/wp-content/plugins/pro-sites/pro-sites-files/css/checkout.css' );
wp_enqueue_style( 'proSite-option-1', get_site_url().'/wp-content/plugins/pro-sites/pro-sites-files/css/pricing-tables/option1.css' );
wp_enqueue_style( 'proSite-custom', get_site_url().'/wp-content/plugins/pro-sites/pro-sites-files/css/plans-pricing.css' );
wp_enqueue_script( 'psts-checkout', $psts->plugin_url . 'js/checkout.js', array( 'jquery' ), $psts->version );
wp_localize_script( 'psts-checkout', 'prosites_checkout', array(
'ajax_url' => ProSites_Helper_ProSite::admin_ajax_url(),
'confirm_cancel' => __( "Please note that if you cancel your subscription you will not be immune to future price increases. The price of un-canceled subscriptions will never go up!\n\nAre you sure you really want to cancel your subscription?\nThis action cannot be undone!", 'psts'),
'button_signup' => __( "Sign Up", 'psts' ),
'button_choose' => __( "Choose Plan", 'psts' ),
'button_chosen' => __( "Chosen Plan", 'psts' ),
'logged_in' => is_user_logged_in(),
'new_blog' => ProSites_Helper_ProSite::allow_new_blog() ? 'true' : 'false'
) );
wp_enqueue_script( 'psts-checkout-2', get_site_url() . '/wp-content/plugins/pro-sites/pro-sites-files/js/tax.js', array( 'jquery' ), time() );
wp_enqueue_script( 'js-stripe', 'https://js.stripe.com/v2/', array( 'jquery' ) );
wp_enqueue_script( 'stripe-token', $psts->plugin_url . 'gateways/gateway-stripe-files/stripe_token.js', array(
'js-stripe',
'jquery'
) );
wp_localize_script( 'stripe-token', 'stripe', array(
'publisher_key' => $stripe_publishable_key,
'name' => __( 'Please enter the full Cardholder Name.', 'psts' ),
'number' => __( 'Please enter a valid Credit Card Number.', 'psts' ),
'expiration' => __( 'Please choose a valid expiration date.', 'psts' ),
'cvv2' => __( 'Please enter a valid card security code. This is the 3 digits on the signature panel, or 4 digits on the front of Amex cards.', 'psts' )
) );
add_action( 'wp_head', array( 'ProSites_Gateway_Stripe', 'checkout_js' ) );
}
}
add_action( 'plugins_loaded', function(){
$GLOBALS['PS_Checkout_Shortcode'] = PS_Checkout_Shortcode::get_instance();
}, 10 );
}
以上是关于php 提供短代码以在任何页面中添加Pro Site结帐表单的主要内容,如果未能解决你的问题,请参考以下文章
css 扩展动画 - 使用animate.css。提供数据属性以在页面上的任何元素中添加动画。触发sc上的动画
php 事件日历PRO:将{pro_addl_fields}变量添加到tribe_event_inline短代码中。