Add WordPay integration
This commit is contained in:
@@ -155,6 +155,9 @@
|
||||
.sp-icon-user-scores:before {
|
||||
content: "\f101";
|
||||
}
|
||||
.sp-icon-wordpay:before {
|
||||
content: "\f526";
|
||||
}
|
||||
|
||||
/* Performance Icons */
|
||||
.sp-icon-card:before {
|
||||
|
||||
Binary file not shown.
@@ -60,4 +60,5 @@
|
||||
<glyph unicode="" glyph-name="availability" d="M384 435.2h-51.2v-51.2h51.2v51.2zM435.2 435.2h-25.6v-76.8h-102.4v76.8h-102.4v-76.8h-102.4v76.8h-25.6c-14.16 0-25.6-11.44-25.6-25.6v-358.4c0-14.16 11.44-25.6 25.6-25.6h358.4c14.16 0 25.6 11.44 25.6 25.6v358.4c0 14.16-11.44 25.6-25.6 25.6zM409.6 76.8h-307.2v230.4h307.2v-230.4zM179.2 435.2h-51.2v-51.2h51.2v51.2zM230.4 115.2l-76.4 76.4 29.12 29.12 47.28-47.28 98.8 98.8 29.2-29.040-128-128z" />
|
||||
<glyph unicode="" glyph-name="scoreboard" d="M435.2 25.6h-358.4c-14.16 0-25.6 11.44-25.6 25.6v358.4c0 14.16 11.44 25.6 25.6 25.6h358.4c14.16 0 25.6-11.44 25.6-25.6v-358.4c0-14.16-11.44-25.6-25.6-25.6zM409.6 384h-307.2v-307.2h307.2v307.2zM217.6 307.2l12.8-12.8v-51.2l-12.8-12.8 12.8-12.8v-51.2l-12.8-12.8h-64l-12.8 12.8v51.2l12.8 12.8-12.8 12.8v51.2l12.8 12.8h64zM166.4 179.2h38.4v38.4h-38.4v-38.4zM166.4 243.2h38.4v38.4h-38.4v-38.4zM256 268.8c7.040 0 12.8-5.76 12.8-12.8s-5.76-12.8-12.8-12.8-12.8 5.76-12.8 12.8 5.76 12.8 12.8 12.8zM256 217.6c7.040 0 12.8-5.76 12.8-12.8s-5.76-12.8-12.8-12.8-12.8 5.76-12.8 12.8 5.76 12.8 12.8 12.8zM358.4 307.2l12.8-12.8v-51.2l-12.8-12.8 12.8-12.8v-51.2l-12.8-12.8h-64l-12.8 12.8v51.2l12.8 12.8-12.8 12.8v51.2l12.8 12.8h64zM307.2 179.2h38.4v38.4h-38.4v-38.4zM307.2 243.2h38.4v38.4h-38.4v-38.4z" />
|
||||
<glyph unicode="" glyph-name="ticket" d="M125.6 190.96l90.96-90.96 166.8 166.88-90.96 90.88-166.8-166.8zM489.12 315.84l-38.72 38.64c-7.36-4-15.76-6.32-24.8-6.32-28.56 0-51.76 23.2-51.76 51.84 0 8.96 2.24 17.44 6.32 24.8l-38.72 38.72c-10.080 10.080-26.56 10.080-36.64 0l-281.92-281.84c-10.080-10.080-10.080-26.56 0-36.64l38.72-38.72c7.36 4 15.84 6.32 24.8 6.32 28.64 0 51.84-23.2 51.84-51.76 0-8.96-2.24-17.44-6.32-24.8l38.72-38.72c10.080-10.080 26.56-10.080 36.64 0l281.84 281.76c10 10.16 10 26.64 0 36.72v0zM216.56 58.4l-132.56 132.56 208.48 208.4 132.48-132.48-208.4-208.48z" />
|
||||
<glyph unicode="" glyph-name="wordpay" d="M491.84 260.88v0l-82.32-142.56c-14.24-24.56-40.8-41.12-71.28-41.12-27.84 0-52.4 13.84-67.28 35.040l78.48 135.84c19.28 33.36 19.28 74.72 0.080 108-6.32 10.88-14.4 20.4-23.76 28.32h94.96c28.4 0 56-14.72 71.28-41.12 15.2-26.48 14.080-57.76-0.16-82.4zM327.28 260.88v0l-71.28-123.44v-0.080l-71.28 123.44c-14.24 24.64-15.28 55.92-0.080 82.4 15.2 26.4 42.88 41.12 71.28 41.12v0h0.16c28.4 0 56-14.72 71.28-41.12 15.2-26.4 14.16-57.68-0.080-82.32zM162.56 248.080l78.4-135.84c-14.88-21.2-39.44-35.040-67.28-35.040-30.48 0-57.12 16.56-71.28 41.2v0l-82.24 142.4c-14.24 24.72-15.36 56-0.080 82.4 15.2 26.4 42.88 41.12 71.28 41.12v0h94.88c-9.36-7.92-17.44-17.44-23.76-28.32-19.2-33.28-19.2-74.64 0.080-107.92z" />
|
||||
</font></defs></svg>
|
||||
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 49 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
assets/images/modules/wordpay.png
Normal file
BIN
assets/images/modules/wordpay.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.3 KiB |
@@ -59,7 +59,7 @@ class SP_Settings_Modules extends SP_Settings_Page {
|
||||
<table class="widefat" cellspacing="0">
|
||||
<thead>
|
||||
<tr><th>
|
||||
<img src="<?php echo plugin_dir_url( SP_PLUGIN_FILE ); ?>/assets/images/modules/sportspress-pro-sidebar.png" alt="<?php _e( 'SportsPress Pro', 'sportspress' ); ?>">
|
||||
<a href="<?php echo apply_filters( 'sportspress_pro_url', 'http://tboy.co/pro' ); ?>" target="_blank"><img src="<?php echo plugin_dir_url( SP_PLUGIN_FILE ); ?>/assets/images/modules/sportspress-pro.png" alt="<?php _e( 'SportsPress Pro', 'sportspress' ); ?>" width="174"></a>
|
||||
</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -74,6 +74,25 @@ class SP_Settings_Modules extends SP_Settings_Page {
|
||||
</table>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ( ! class_exists( 'WordPay' ) ) { ?>
|
||||
<table class="widefat" cellspacing="0">
|
||||
<thead>
|
||||
<tr><th>
|
||||
<a href="https://wordpay.org" target="_blank"><img src="<?php echo plugin_dir_url( SP_PLUGIN_FILE ); ?>/assets/images/modules/wordpay.png" alt="<?php _e( 'WordPay', 'sportspress' ); ?>" width="150"></a>
|
||||
</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr><td>
|
||||
<p><?php _e( 'Start collecting club membership payments with WordPay.','sportspress' ); ?></p>
|
||||
<p class="sp-module-actions">
|
||||
<span><?php _e( 'Premium', 'sportspress' ); ?></span>
|
||||
<a class="button" href="https://wordpay.org" target="_blank"><?php _e( 'Get WordPay', 'sportspress' ); ?></a>
|
||||
</p>
|
||||
</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ( ! class_exists( 'SportsPress_Twitter' ) || ! class_exists( 'SportsPress_Facebook' ) ) { ?>
|
||||
<table class="widefat" cellspacing="0">
|
||||
<thead>
|
||||
|
||||
@@ -152,6 +152,14 @@ class SP_Modules {
|
||||
'link' => 'https://www.themeboy.com/sportspress-extensions/sponsors/',
|
||||
'desc' => __( 'Attract sponsors by offering them advertising space on your website.', 'sportspress' ),
|
||||
),
|
||||
'wordpay' => array(
|
||||
'label' => __( 'WordPay', 'sportspress' ),
|
||||
'class' => 'WordPay',
|
||||
'icon' => 'sp-icon-wordpay',
|
||||
'link' => 'https://wordpay.org/',
|
||||
'desc' => __( 'Start collecting club membership payments with WordPay.', 'sportspress' ),
|
||||
'tip' => __( 'Get WordPay', 'sportspress' ),
|
||||
),
|
||||
),
|
||||
));
|
||||
|
||||
|
||||
@@ -64,6 +64,22 @@ class SportsPress_User_Registration {
|
||||
'checkboxgroup' => 'start',
|
||||
),
|
||||
|
||||
array(
|
||||
'desc' => __( 'Add a team name field to signup form', 'sportspress' ),
|
||||
'id' => 'sportspress_registration_team_input',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => '',
|
||||
),
|
||||
|
||||
array(
|
||||
'desc' => __( 'Add a team selector to signup form', 'sportspress' ),
|
||||
'id' => 'sportspress_registration_team_select',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => '',
|
||||
),
|
||||
|
||||
array(
|
||||
'desc' => __( 'Create player profiles for new users', 'sportspress' ),
|
||||
'id' => 'sportspress_registration_add_player',
|
||||
@@ -85,16 +101,35 @@ class SportsPress_User_Registration {
|
||||
$last_name = ( ! empty( $_POST['last_name'] ) ) ? trim( $_POST['last_name'] ) : '';
|
||||
?>
|
||||
<p>
|
||||
<label for="first_name"><?php _e( 'First Name', 'themeboy' ) ?><br />
|
||||
<input type="text" name="first_name" id="first_name" class="input" value="<?php echo esc_attr( wp_unslash( $first_name ) ); ?>" size="25" /></label>
|
||||
<label for="first_name"><?php _e( 'First Name', 'sportspress' ) ?><br />
|
||||
<input type="text" name="first_name" id="first_name" class="input" value="<?php echo esc_attr( wp_unslash( $first_name ) ); ?>" size="25" /></label>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label for="last_name"><?php _e( 'Last Name', 'themeboy' ) ?><br />
|
||||
<input type="text" name="last_name" id="last_name" class="input" value="<?php echo esc_attr( wp_unslash( $last_name ) ); ?>" size="25" /></label>
|
||||
<label for="last_name"><?php _e( 'Last Name', 'sportspress' ) ?><br />
|
||||
<input type="text" name="last_name" id="last_name" class="input" value="<?php echo esc_attr( wp_unslash( $last_name ) ); ?>" size="25" /></label>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
|
||||
if ( 'yes' === get_option( 'sportspress_registration_team_select', 'no' ) ) {
|
||||
?>
|
||||
<p>
|
||||
<label for="sp_team"><?php _e( 'Team', 'sportspress' ) ?><br />
|
||||
<?php
|
||||
$args = array(
|
||||
'post_type' => 'sp_team',
|
||||
'name' => 'sp_team',
|
||||
'values' => 'ID',
|
||||
'show_option_none' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Team', 'sportspress' ) ),
|
||||
'property' => 'style="width:100%;height:36px;margin-bottom:16px"',
|
||||
);
|
||||
sp_dropdown_pages( $args );
|
||||
?>
|
||||
</p>
|
||||
<?php
|
||||
wp_nonce_field( 'submit_team', 'sp_register_form_player' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,6 +153,27 @@ class SportsPress_User_Registration {
|
||||
}
|
||||
}
|
||||
|
||||
// Add team from team name
|
||||
if ( isset( $_POST['sp_register_form_team'] ) && wp_verify_nonce( $_POST['sp_register_form_team'], 'submit_team_name' ) ) {
|
||||
if ( ! empty( $_POST['team_name'] ) ) {
|
||||
$team_name = trim( $_POST['team_name'] );
|
||||
$post['post_type'] = 'sp_team';
|
||||
$post['post_title'] = $team_name;
|
||||
$post['post_author'] = $user_id;
|
||||
$post['post_status'] = 'draft';
|
||||
$id = wp_insert_post( $post );
|
||||
}
|
||||
}
|
||||
|
||||
// Save team
|
||||
if ( isset( $_POST['sp_register_form_player'] ) && wp_verify_nonce( $_POST['sp_register_form_player'], 'submit_team' ) ) {
|
||||
if ( ! empty( $_POST['sp_team'] ) ) {
|
||||
$team = trim( $_POST['sp_team'] );
|
||||
if ( $team <= 0 ) $team = 0;
|
||||
update_user_meta( $user_id, 'sp_team', $team );
|
||||
}
|
||||
}
|
||||
|
||||
// Add player
|
||||
if ( 'yes' === get_option( 'sportspress_registration_add_player', 'no' ) ) {
|
||||
if ( ! sizeof( $parts ) && ! empty( $_POST['user_login'] ) ) {
|
||||
@@ -129,8 +185,13 @@ class SportsPress_User_Registration {
|
||||
$post['post_type'] = 'sp_player';
|
||||
$post['post_title'] = trim( $name );
|
||||
$post['post_author'] = $user_id;
|
||||
$post['post_status'] = 'publish';
|
||||
$post['post_status'] = 'draft';
|
||||
$id = wp_insert_post( $post );
|
||||
|
||||
if ( isset( $team ) && $team ) {
|
||||
update_post_meta( $id, 'sp_team', $team );
|
||||
update_post_meta( $id, 'sp_current_team', $team );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
239
modules/sportspress-wordpay.php
Normal file
239
modules/sportspress-wordpay.php
Normal file
@@ -0,0 +1,239 @@
|
||||
<?php
|
||||
/*
|
||||
Plugin Name: SportsPress WordPay
|
||||
Plugin URI: http://themeboy.com/
|
||||
Description: Add team and player registration shortcodes to WordPay.
|
||||
Author: ThemeBoy
|
||||
Author URI: http://themeboy.com/
|
||||
Version: 2.3
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
if ( ! class_exists( 'SportsPress_WordPay' ) ) :
|
||||
|
||||
/**
|
||||
* Main SportsPress WordPay Class
|
||||
*
|
||||
* @class SportsPress_WordPay
|
||||
* @version 2.3
|
||||
*/
|
||||
class SportsPress_WordPay {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
// Shortcode
|
||||
add_action( 'init', array( $this, 'add_shortcodes' ) );
|
||||
add_action( 'wpay_register_form_after_fields', array( $this, 'form_field' ) );
|
||||
|
||||
// Editor
|
||||
add_filter( 'wordpay_shortcodes', array( $this, 'editor_shortcodes' ) );
|
||||
add_filter( 'wordpay_tinymce_strings', array( $this, 'editor_strings' ) );
|
||||
|
||||
// Widgets
|
||||
add_action( 'wordpay_after_widget_register_form', array( $this, 'widget_form' ), 10, 2 );
|
||||
add_filter( 'wordpay_widget_register_update', array( $this, 'widget_update' ), 10, 2 );
|
||||
add_filter( 'wordpay_widget_register_shortcode', array( $this, 'widget_shortcode' ), 10, 2 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( !defined( 'SP_WORDPAY_VERSION' ) )
|
||||
define( 'SP_WORDPAY_VERSION', '2.3' );
|
||||
|
||||
if ( !defined( 'SP_WORDPAY_URL' ) )
|
||||
define( 'SP_WORDPAY_URL', plugin_dir_url( __FILE__ ) );
|
||||
|
||||
if ( !defined( 'SP_WORDPAY_DIR' ) )
|
||||
define( 'SP_WORDPAY_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
/**
|
||||
* Add team and player registration shortcodes.
|
||||
*/
|
||||
public static function add_shortcodes() {
|
||||
add_shortcode( 'wpay-register-team', array( $this, 'register_team' ) );
|
||||
add_shortcode( 'wpay-register-player', array( $this, 'register_player' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Team registration shortcode.
|
||||
*/
|
||||
public static function register_team( $atts = array() ) {
|
||||
$args = array(
|
||||
'post_type' => 'wpay-subscription',
|
||||
'post_status' => 'active',
|
||||
'posts_per_page' => 500,
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'key' => 'wpay_subscription_plan_user_role',
|
||||
'value' => 'sp_team_manager',
|
||||
),
|
||||
),
|
||||
'fields' => 'ids',
|
||||
);
|
||||
|
||||
$plans = get_posts( $args );
|
||||
|
||||
if ( empty( $plans ) ) {
|
||||
_e( 'There are no plans associated with the Team Manager role.', 'sportspress' );
|
||||
return;
|
||||
}
|
||||
|
||||
return self::register_form( $atts, 'team', $plans );
|
||||
}
|
||||
|
||||
/**
|
||||
* Player registration shortcode.
|
||||
*/
|
||||
public static function register_player( $atts = array() ) {
|
||||
$args = array(
|
||||
'post_type' => 'wpay-subscription',
|
||||
'post_status' => 'active',
|
||||
'posts_per_page' => 500,
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'key' => 'wpay_subscription_plan_user_role',
|
||||
'value' => 'sp_player',
|
||||
),
|
||||
),
|
||||
'fields' => 'ids',
|
||||
);
|
||||
|
||||
$plans = get_posts( $args );
|
||||
|
||||
if ( empty( $plans ) ) {
|
||||
_e( 'There are no plans associated with the Player role.', 'sportspress' );
|
||||
return;
|
||||
}
|
||||
|
||||
return self::register_form( $atts, 'player', $plans );
|
||||
}
|
||||
|
||||
/**
|
||||
* Registration form template.
|
||||
*/
|
||||
public static function register_form( $atts = array(), $context = '', $plans = array() ) {
|
||||
|
||||
$atts = shortcode_atts( array(
|
||||
'plans_position' => 'bottom',
|
||||
'selected' => '',
|
||||
), $atts );
|
||||
|
||||
$atts['subscription_plans'] = implode( ',', $plans );
|
||||
|
||||
$atts['context'] = $context;
|
||||
|
||||
$shortcode = '[wpay-register';
|
||||
|
||||
foreach ( $atts as $key => $value ) {
|
||||
$shortcode .= ' ' . $key . '="' . esc_attr( $value ) . '"';
|
||||
}
|
||||
|
||||
$shortcode .= ']';
|
||||
|
||||
return do_shortcode( $shortcode );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add field to registration form.
|
||||
*/
|
||||
public static function form_field( $atts = array() ) {
|
||||
if ( 'team' == $atts['context'] ) {
|
||||
?>
|
||||
<li class="wpay-field">
|
||||
<label for="wpay_team_name"><?php _e( 'Team Name', 'sportspress' ); ?></label>
|
||||
<input id="wpay_team_name" name="team_name" type="text" value="">
|
||||
</li>
|
||||
<?php
|
||||
wp_nonce_field( 'submit_team_name', 'sp_register_form_team' );
|
||||
} elseif ( 'player' == $atts['context'] ) {
|
||||
?>
|
||||
<li class="wpay-field">
|
||||
<label for="sp_team"><?php _e( 'Team', 'sportspress' ); ?></label>
|
||||
<?php
|
||||
$args = array(
|
||||
'post_type' => 'sp_team',
|
||||
'name' => 'sp_team',
|
||||
'values' => 'ID',
|
||||
'show_option_none' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Team', 'sportspress' ) ),
|
||||
'class' => 'widefat',
|
||||
);
|
||||
sp_dropdown_pages( $args );
|
||||
?>
|
||||
</li>
|
||||
<?php
|
||||
wp_nonce_field( 'submit_team', 'sp_register_form_player' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add shortcodes to editor.
|
||||
*/
|
||||
public static function editor_shortcodes( $shortcodes = array() ) {
|
||||
$shortcodes[] = 'register_team';
|
||||
$shortcodes[] = 'register_player';
|
||||
return $shortcodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add strings to editor.
|
||||
*/
|
||||
public static function editor_strings( $strings = array() ) {
|
||||
$strings['register_team'] = __( 'Register Team', 'sportspress' );
|
||||
$strings['register_player'] = __( 'Register Player', 'sportspress' );
|
||||
return $strings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add selector to widget form.
|
||||
*/
|
||||
public static function widget_form( $widget, $instance = array() ) {
|
||||
$contexts = array(
|
||||
'' => __( 'Members', 'sportspress' ),
|
||||
'team' => __( 'Teams', 'sportspress' ),
|
||||
'player' => __( 'Players', 'sportspress' ),
|
||||
);
|
||||
?>
|
||||
<p>
|
||||
<label for="<?php echo $widget->get_field_id('context'); ?>"><?php _e( 'For:', 'sportspress' ); ?></label>
|
||||
<select id="<?php echo $widget->get_field_id('context'); ?>" name="<?php echo $widget->get_field_name('context'); ?>">
|
||||
<?php foreach ( $contexts as $value => $label ) { ?>
|
||||
<option value="<?php echo $value; ?>" <?php selected( $value, sp_array_value( $instance, 'context' ) ); ?>><?php echo $label; ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Update widget form.
|
||||
*/
|
||||
public static function widget_update( $instance = array(), $new_instance = array() ) {
|
||||
$instance['context'] = strip_tags($new_instance['context']);
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify widget shortcode.
|
||||
*/
|
||||
public static function widget_shortcode( $shortcode = '[wpay-register]', $instance = array() ) {
|
||||
if ( ! empty( $instance['context'] ) && in_array( $instance['context'], array( 'team', 'player' ) ) ) {
|
||||
$shortcode = str_replace( 'wpay-register', 'wpay-register-' . $instance['context'], $shortcode );
|
||||
}
|
||||
return $shortcode;
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
if ( get_option( 'sportspress_load_wordpay_module', 'yes' ) == 'yes' ) {
|
||||
new SportsPress_WordPay();
|
||||
}
|
||||
Reference in New Issue
Block a user