Clean up spaces, tabs, indentation, and bracket formatting
This commit is contained in:
@@ -9,57 +9,64 @@
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SportsPress_Admin_Bar' ) ) :
|
||||
|
||||
/**
|
||||
* Main SportsPress Admin Bar Class
|
||||
*
|
||||
* @class SportsPress_Admin_Bar
|
||||
* @version 2.2
|
||||
*/
|
||||
class SportsPress_Admin_Bar {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Main SportsPress Admin Bar Class
|
||||
*
|
||||
* @class SportsPress_Admin_Bar
|
||||
* @version 2.2
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
class SportsPress_Admin_Bar {
|
||||
|
||||
add_action( 'admin_bar_menu', array( $this, 'add_node' ), 40 );
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
add_action( 'admin_bar_menu', array( $this, 'add_node' ), 40 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( ! defined( 'SP_ADMIN_BAR_VERSION' ) ) {
|
||||
define( 'SP_ADMIN_BAR_VERSION', '2.2' );
|
||||
}
|
||||
|
||||
if ( ! defined( 'SP_ADMIN_BAR_URL' ) ) {
|
||||
define( 'SP_ADMIN_BAR_URL', plugin_dir_url( __FILE__ ) );
|
||||
}
|
||||
|
||||
if ( ! defined( 'SP_ADMIN_BAR_DIR' ) ) {
|
||||
define( 'SP_ADMIN_BAR_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add node to admin bar menu.
|
||||
*/
|
||||
public function add_node( $wp_admin_bar ) {
|
||||
if ( is_admin() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$args = array(
|
||||
'id' => 'sportspress',
|
||||
'title' => __( 'SportsPress', 'sportspress' ),
|
||||
'href' => add_query_arg( 'page', 'sportspress', admin_url( 'admin.php' ) ),
|
||||
);
|
||||
$wp_admin_bar->add_node( $args );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( !defined( 'SP_ADMIN_BAR_VERSION' ) )
|
||||
define( 'SP_ADMIN_BAR_VERSION', '2.2' );
|
||||
|
||||
if ( !defined( 'SP_ADMIN_BAR_URL' ) )
|
||||
define( 'SP_ADMIN_BAR_URL', plugin_dir_url( __FILE__ ) );
|
||||
|
||||
if ( !defined( 'SP_ADMIN_BAR_DIR' ) )
|
||||
define( 'SP_ADMIN_BAR_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add node to admin bar menu.
|
||||
*/
|
||||
public function add_node( $wp_admin_bar ) {
|
||||
if ( is_admin() ) return;
|
||||
|
||||
$args = array(
|
||||
'id' => 'sportspress',
|
||||
'title' => __( 'SportsPress', 'sportspress' ),
|
||||
'href' => add_query_arg( 'page', 'sportspress', admin_url( 'admin.php' ) ),
|
||||
);
|
||||
$wp_admin_bar->add_node( $args );
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
new SportsPress_Admin_Bar();
|
||||
|
||||
@@ -9,191 +9,207 @@
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SportsPress_Birthdays' ) ) :
|
||||
|
||||
/**
|
||||
* Main SportsPress Birthdays Class
|
||||
*
|
||||
* @class SportsPress_Birthdays
|
||||
* @version 2.7.1
|
||||
*/
|
||||
class SportsPress_Birthdays {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
add_filter( 'gettext', array( $this, 'gettext' ), 20, 3 );
|
||||
add_filter( 'sportspress_text', array( $this, 'add_text_options' ) );
|
||||
add_filter( 'sportspress_player_options', array( $this, 'add_player_options' ) );
|
||||
add_filter( 'sportspress_staff_options', array( $this, 'add_staff_options' ) );
|
||||
add_filter( 'sportspress_player_details', array( $this, 'add_player_details' ), 20, 2 );
|
||||
add_filter( 'sportspress_staff_details', array( $this, 'add_staff_details' ), 20, 2 );
|
||||
|
||||
add_action( 'sportspress_widgets', array( $this, 'widgets' ) );
|
||||
add_action( 'sportspress_list_general_columns', array( $this, 'columns' ), 10, 1 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( !defined( 'SP_BIRTHDAYS_VERSION' ) )
|
||||
define( 'SP_BIRTHDAYS_VERSION', '2.7.1' );
|
||||
|
||||
if ( !defined( 'SP_BIRTHDAYS_URL' ) )
|
||||
define( 'SP_BIRTHDAYS_URL', plugin_dir_url( __FILE__ ) );
|
||||
|
||||
if ( !defined( 'SP_BIRTHDAYS_DIR' ) )
|
||||
define( 'SP_BIRTHDAYS_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Text filter.
|
||||
*/
|
||||
public function gettext( $translated_text, $untranslated_text, $domain ) {
|
||||
if ( ! is_admin() ) return $translated_text;
|
||||
|
||||
global $typenow;
|
||||
|
||||
if ( 'default' == $domain && in_array( $typenow, array( 'sp_player', 'sp_staff', 'sp_official' ) ) ):
|
||||
switch ( $untranslated_text ):
|
||||
case 'Scheduled for: <b>%1$s</b>':
|
||||
case 'Published on: <b>%1$s</b>':
|
||||
case 'Schedule for: <b>%1$s</b>':
|
||||
case 'Publish on: <b>%1$s</b>':
|
||||
return __( 'Birthday: <b>%1$s</b>', 'sportspress' );
|
||||
case 'Publish <b>immediately</b>':
|
||||
return __( 'Birthday', 'sportspress' );
|
||||
case 'M j, Y @ G:i':
|
||||
return 'M j, Y';
|
||||
case '%1$s %2$s, %3$s @ %4$s : %5$s':
|
||||
$hour = '<input type="hidden" id="hh" name="hh" value="00" readonly />';
|
||||
$minute = '<input type="hidden" id="mn" name="mn" value="00" readonly />';
|
||||
return '%1$s %2$s, %3$s' . $hour . $minute;
|
||||
endswitch;
|
||||
endif;
|
||||
|
||||
return $translated_text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add text options
|
||||
*/
|
||||
public function add_text_options( $options = array() ) {
|
||||
return array_merge( $options, array(
|
||||
__( 'Age', 'sportspress' ),
|
||||
__( 'Birthday', 'sportspress' ),
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add options to player settings page.
|
||||
* Main SportsPress Birthdays Class
|
||||
*
|
||||
* @return array
|
||||
* @class SportsPress_Birthdays
|
||||
* @version 2.7.1
|
||||
*/
|
||||
public function add_player_options( $options ) {
|
||||
$options = array_merge( $options, array(
|
||||
array(
|
||||
'title' => __( 'Birthday', 'sportspress' ),
|
||||
'desc' => __( 'Display birthday', 'sportspress' ),
|
||||
'id' => 'sportspress_player_show_birthday',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'start',
|
||||
),
|
||||
class SportsPress_Birthdays {
|
||||
|
||||
array(
|
||||
'desc' => __( 'Display age', 'sportspress' ),
|
||||
'id' => 'sportspress_player_show_age',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'end',
|
||||
),
|
||||
) );
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
return $options;
|
||||
}
|
||||
add_filter( 'gettext', array( $this, 'gettext' ), 20, 3 );
|
||||
add_filter( 'sportspress_text', array( $this, 'add_text_options' ) );
|
||||
add_filter( 'sportspress_player_options', array( $this, 'add_player_options' ) );
|
||||
add_filter( 'sportspress_staff_options', array( $this, 'add_staff_options' ) );
|
||||
add_filter( 'sportspress_player_details', array( $this, 'add_player_details' ), 20, 2 );
|
||||
add_filter( 'sportspress_staff_details', array( $this, 'add_staff_details' ), 20, 2 );
|
||||
|
||||
/**
|
||||
* Add options to staff settings page.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_staff_options( $options ) {
|
||||
$options = array_merge( $options, array(
|
||||
array(
|
||||
'title' => __( 'Birthday', 'sportspress' ),
|
||||
'desc' => __( 'Display birthday', 'sportspress' ),
|
||||
'id' => 'sportspress_staff_show_birthday',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'start',
|
||||
),
|
||||
|
||||
array(
|
||||
'desc' => __( 'Display age', 'sportspress' ),
|
||||
'id' => 'sportspress_staff_show_age',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'end',
|
||||
),
|
||||
) );
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add data to player details template.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_player_details( $data, $post_id ) {
|
||||
if ( 'yes' == get_option( 'sportspress_player_show_birthday', 'no' ) ) {
|
||||
$data[ __( 'Birthday', 'sportspress' ) ] = get_the_date( get_option( 'date_format' ), $post_id );
|
||||
add_action( 'sportspress_widgets', array( $this, 'widgets' ) );
|
||||
add_action( 'sportspress_list_general_columns', array( $this, 'columns' ), 10, 1 );
|
||||
}
|
||||
|
||||
if ( 'yes' == get_option( 'sportspress_player_show_age', 'no' ) ) {
|
||||
$data[ __( 'Age', 'sportspress' ) ] = $this->get_age( get_the_date( 'm-d-Y', $post_id ) );
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( ! defined( 'SP_BIRTHDAYS_VERSION' ) ) {
|
||||
define( 'SP_BIRTHDAYS_VERSION', '2.7.1' );
|
||||
}
|
||||
|
||||
if ( ! defined( 'SP_BIRTHDAYS_URL' ) ) {
|
||||
define( 'SP_BIRTHDAYS_URL', plugin_dir_url( __FILE__ ) );
|
||||
}
|
||||
|
||||
if ( ! defined( 'SP_BIRTHDAYS_DIR' ) ) {
|
||||
define( 'SP_BIRTHDAYS_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
/**
|
||||
* Text filter.
|
||||
*/
|
||||
public function gettext( $translated_text, $untranslated_text, $domain ) {
|
||||
if ( ! is_admin() ) {
|
||||
return $translated_text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add data to staff details template.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_staff_details( $data, $post_id ) {
|
||||
if ( 'yes' == get_option( 'sportspress_staff_show_birthday', 'no' ) ) {
|
||||
$data[ __( 'Birthday', 'sportspress' ) ] = get_the_date( get_option( 'date_format' ), $post_id );
|
||||
global $typenow;
|
||||
|
||||
if ( 'default' == $domain && in_array( $typenow, array( 'sp_player', 'sp_staff', 'sp_official' ) ) ) :
|
||||
switch ( $untranslated_text ) :
|
||||
case 'Scheduled for: <b>%1$s</b>':
|
||||
case 'Published on: <b>%1$s</b>':
|
||||
case 'Schedule for: <b>%1$s</b>':
|
||||
case 'Publish on: <b>%1$s</b>':
|
||||
return __( 'Birthday: <b>%1$s</b>', 'sportspress' );
|
||||
case 'Publish <b>immediately</b>':
|
||||
return __( 'Birthday', 'sportspress' );
|
||||
case 'M j, Y @ G:i':
|
||||
return 'M j, Y';
|
||||
case '%1$s %2$s, %3$s @ %4$s : %5$s':
|
||||
$hour = '<input type="hidden" id="hh" name="hh" value="00" readonly />';
|
||||
$minute = '<input type="hidden" id="mn" name="mn" value="00" readonly />';
|
||||
return '%1$s %2$s, %3$s' . $hour . $minute;
|
||||
endswitch;
|
||||
endif;
|
||||
|
||||
return $translated_text;
|
||||
}
|
||||
|
||||
if ( 'yes' == get_option( 'sportspress_staff_show_age', 'no' ) ) {
|
||||
$data[ __( 'Age', 'sportspress' ) ] = $this->get_age( get_the_date( 'm-d-Y', $post_id ) );
|
||||
/**
|
||||
* Add text options
|
||||
*/
|
||||
public function add_text_options( $options = array() ) {
|
||||
return array_merge(
|
||||
$options,
|
||||
array(
|
||||
__( 'Age', 'sportspress' ),
|
||||
__( 'Birthday', 'sportspress' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
/**
|
||||
* Add options to player settings page.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_player_options( $options ) {
|
||||
$options = array_merge(
|
||||
$options,
|
||||
array(
|
||||
array(
|
||||
'title' => __( 'Birthday', 'sportspress' ),
|
||||
'desc' => __( 'Display birthday', 'sportspress' ),
|
||||
'id' => 'sportspress_player_show_birthday',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'start',
|
||||
),
|
||||
|
||||
/**
|
||||
* Register widgets
|
||||
*/
|
||||
public static function widgets() {
|
||||
include_once( SP()->plugin_path() . '/includes/widgets/class-sp-widget-birthdays.php' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add more General Columns at Player Lists
|
||||
*/
|
||||
public static function columns( $selected ) {
|
||||
?>
|
||||
array(
|
||||
'desc' => __( 'Display age', 'sportspress' ),
|
||||
'id' => 'sportspress_player_show_age',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'end',
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add options to staff settings page.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_staff_options( $options ) {
|
||||
$options = array_merge(
|
||||
$options,
|
||||
array(
|
||||
array(
|
||||
'title' => __( 'Birthday', 'sportspress' ),
|
||||
'desc' => __( 'Display birthday', 'sportspress' ),
|
||||
'id' => 'sportspress_staff_show_birthday',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'start',
|
||||
),
|
||||
|
||||
array(
|
||||
'desc' => __( 'Display age', 'sportspress' ),
|
||||
'id' => 'sportspress_staff_show_age',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'end',
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add data to player details template.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_player_details( $data, $post_id ) {
|
||||
if ( 'yes' == get_option( 'sportspress_player_show_birthday', 'no' ) ) {
|
||||
$data[ __( 'Birthday', 'sportspress' ) ] = get_the_date( get_option( 'date_format' ), $post_id );
|
||||
}
|
||||
|
||||
if ( 'yes' == get_option( 'sportspress_player_show_age', 'no' ) ) {
|
||||
$data[ __( 'Age', 'sportspress' ) ] = $this->get_age( get_the_date( 'm-d-Y', $post_id ) );
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add data to staff details template.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_staff_details( $data, $post_id ) {
|
||||
if ( 'yes' == get_option( 'sportspress_staff_show_birthday', 'no' ) ) {
|
||||
$data[ __( 'Birthday', 'sportspress' ) ] = get_the_date( get_option( 'date_format' ), $post_id );
|
||||
}
|
||||
|
||||
if ( 'yes' == get_option( 'sportspress_staff_show_age', 'no' ) ) {
|
||||
$data[ __( 'Age', 'sportspress' ) ] = $this->get_age( get_the_date( 'm-d-Y', $post_id ) );
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register widgets
|
||||
*/
|
||||
public static function widgets() {
|
||||
include_once SP()->plugin_path() . '/includes/widgets/class-sp-widget-birthdays.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Add more General Columns at Player Lists
|
||||
*/
|
||||
public static function columns( $selected ) {
|
||||
?>
|
||||
<li>
|
||||
<label class="selectit">
|
||||
<input value="dob" type="checkbox" name="sp_columns[]" id="sp_columns_dob" <?php checked( in_array( 'dob', $selected ) ); ?>>
|
||||
@@ -206,23 +222,23 @@ class SportsPress_Birthdays {
|
||||
<?php _e( 'Age', 'sportspress' ); ?>
|
||||
</label>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Get age from date.
|
||||
* Adapted from http://stackoverflow.com/questions/3776682/php-calculate-age.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function get_age( $date ) {
|
||||
$date = explode( '-', $date );
|
||||
$age = ( date( 'md', date( 'U', mktime( 0, 0, 0, $date[0], $date[1], $date[2] ) ) ) > date('md')
|
||||
/**
|
||||
* Get age from date.
|
||||
* Adapted from http://stackoverflow.com/questions/3776682/php-calculate-age.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function get_age( $date ) {
|
||||
$date = explode( '-', $date );
|
||||
$age = ( date( 'md', date( 'U', mktime( 0, 0, 0, $date[0], $date[1], $date[2] ) ) ) > date( 'md' )
|
||||
? ( ( date( 'Y' ) - $date[2] ) - 1 )
|
||||
: ( date( 'Y' ) - $date[2] ) );
|
||||
return $age;
|
||||
return $age;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
@@ -9,170 +9,191 @@
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SportsPress_Bulk_Actions' ) ) :
|
||||
|
||||
/**
|
||||
* Main SportsPress Bulk Actions Class
|
||||
*
|
||||
* @class SportsPress_Bulk_Actions
|
||||
* @version 2.7.6
|
||||
*/
|
||||
class SportsPress_Bulk_Actions {
|
||||
/**
|
||||
* Main SportsPress Bulk Actions Class
|
||||
*
|
||||
* @class SportsPress_Bulk_Actions
|
||||
* @version 2.7.6
|
||||
*/
|
||||
class SportsPress_Bulk_Actions {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
// Teams
|
||||
add_filter( 'bulk_actions-edit-sp_team', array( $this, 'team_actions' ) );
|
||||
add_filter( 'handle_bulk_actions-edit-sp_team', array( $this, 'team_actions_handler' ), 10, 3 );
|
||||
// Teams
|
||||
add_filter( 'bulk_actions-edit-sp_team', array( $this, 'team_actions' ) );
|
||||
add_filter( 'handle_bulk_actions-edit-sp_team', array( $this, 'team_actions_handler' ), 10, 3 );
|
||||
|
||||
// Events
|
||||
add_filter( 'bulk_actions-edit-sp_event', array( $this, 'event_actions' ) );
|
||||
add_filter( 'handle_bulk_actions-edit-sp_event', array( $this, 'event_actions_handler' ), 10, 3 );
|
||||
// Events
|
||||
add_filter( 'bulk_actions-edit-sp_event', array( $this, 'event_actions' ) );
|
||||
add_filter( 'handle_bulk_actions-edit-sp_event', array( $this, 'event_actions_handler' ), 10, 3 );
|
||||
|
||||
// Notices
|
||||
add_action( 'admin_notices', array( $this, 'admin_notices' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( !defined( 'SP_BULK_ACTIONS_VERSION' ) )
|
||||
define( 'SP_BULK_ACTIONS_VERSION', '2.7.6' );
|
||||
|
||||
if ( !defined( 'SP_BULK_ACTIONS_URL' ) )
|
||||
define( 'SP_BULK_ACTIONS_URL', plugin_dir_url( __FILE__ ) );
|
||||
|
||||
if ( !defined( 'SP_BULK_ACTIONS_DIR' ) )
|
||||
define( 'SP_BULK_ACTIONS_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add option to the team bulk actions dropdown.
|
||||
*/
|
||||
public function team_actions( $bulk_actions ) {
|
||||
$bulk_actions['sp_calendar'] = __( 'Generate Calendars', 'sportspress' );
|
||||
return $bulk_actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle form submission for team bulk actions.
|
||||
*/
|
||||
public function team_actions_handler( $redirect_to, $doaction, $post_ids ) {
|
||||
if ( $doaction !== 'sp_calendar' ) {
|
||||
return $redirect_to;
|
||||
}
|
||||
|
||||
foreach ( $post_ids as $post_id ) {
|
||||
$post = array();
|
||||
$post['post_title'] = get_the_title( $post_id ) . ' ' . __( 'Calendar', 'sportspress' );
|
||||
$post['post_type'] = 'sp_calendar';
|
||||
$post['post_status'] = 'publish';
|
||||
|
||||
// Insert post
|
||||
$id = wp_insert_post( $post );
|
||||
|
||||
// Flag as bulk
|
||||
update_post_meta( $id, '_sp_bulk', 1 );
|
||||
|
||||
// Update meta
|
||||
update_post_meta( $id, 'sp_team', $post_id );
|
||||
update_post_meta( $id, 'sp_format', 'calendar' );
|
||||
}
|
||||
|
||||
$redirect_to = add_query_arg( 'sp_bulk_generated_calendars', count( $post_ids ), $redirect_to );
|
||||
return $redirect_to;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add option to the event bulk actions dropdown.
|
||||
*/
|
||||
public function event_actions( $bulk_actions ) {
|
||||
$bulk_actions['sp_postpone'] = __( 'Postpone events', 'sportspress' );
|
||||
$bulk_actions['sp_cancel'] = __( 'Cancel events', 'sportspress' );
|
||||
$bulk_actions['sp_ok'] = __( 'Set events as on time', 'sportspress' );
|
||||
return $bulk_actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle form submission for event bulk actions.
|
||||
*/
|
||||
public function event_actions_handler( $redirect_to, $doaction, $post_ids ) {
|
||||
if ( ! in_array( $doaction, array( 'sp_postpone', 'sp_cancel', 'sp_ok' ) ) ) {
|
||||
return $redirect_to;
|
||||
}
|
||||
|
||||
if ( 'sp_postpone' == $doaction ) {
|
||||
foreach ( $post_ids as $post_id ) {
|
||||
update_post_meta( $post_id, 'sp_status', 'postponed' );
|
||||
// Notices
|
||||
add_action( 'admin_notices', array( $this, 'admin_notices' ) );
|
||||
}
|
||||
$redirect_to = add_query_arg( 'sp_bulk_postponed_events', count( $post_ids ), $redirect_to );
|
||||
} elseif ( 'sp_cancel' == $doaction ) {
|
||||
foreach ( $post_ids as $post_id ) {
|
||||
update_post_meta( $post_id, 'sp_status', 'cancelled' );
|
||||
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( ! defined( 'SP_BULK_ACTIONS_VERSION' ) ) {
|
||||
define( 'SP_BULK_ACTIONS_VERSION', '2.7.6' );
|
||||
}
|
||||
|
||||
if ( ! defined( 'SP_BULK_ACTIONS_URL' ) ) {
|
||||
define( 'SP_BULK_ACTIONS_URL', plugin_dir_url( __FILE__ ) );
|
||||
}
|
||||
|
||||
if ( ! defined( 'SP_BULK_ACTIONS_DIR' ) ) {
|
||||
define( 'SP_BULK_ACTIONS_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
}
|
||||
$redirect_to = add_query_arg( 'sp_bulk_cancelled_events', count( $post_ids ), $redirect_to );
|
||||
} elseif ( 'sp_ok' == $doaction ) {
|
||||
foreach ( $post_ids as $post_id ) {
|
||||
update_post_meta( $post_id, 'sp_status', 'ok' );
|
||||
|
||||
/**
|
||||
* Add option to the team bulk actions dropdown.
|
||||
*/
|
||||
public function team_actions( $bulk_actions ) {
|
||||
$bulk_actions['sp_calendar'] = __( 'Generate Calendars', 'sportspress' );
|
||||
return $bulk_actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle form submission for team bulk actions.
|
||||
*/
|
||||
public function team_actions_handler( $redirect_to, $doaction, $post_ids ) {
|
||||
if ( $doaction !== 'sp_calendar' ) {
|
||||
return $redirect_to;
|
||||
}
|
||||
|
||||
foreach ( $post_ids as $post_id ) {
|
||||
$post = array();
|
||||
$post['post_title'] = get_the_title( $post_id ) . ' ' . __( 'Calendar', 'sportspress' );
|
||||
$post['post_type'] = 'sp_calendar';
|
||||
$post['post_status'] = 'publish';
|
||||
|
||||
// Insert post
|
||||
$id = wp_insert_post( $post );
|
||||
|
||||
// Flag as bulk
|
||||
update_post_meta( $id, '_sp_bulk', 1 );
|
||||
|
||||
// Update meta
|
||||
update_post_meta( $id, 'sp_team', $post_id );
|
||||
update_post_meta( $id, 'sp_format', 'calendar' );
|
||||
}
|
||||
|
||||
$redirect_to = add_query_arg( 'sp_bulk_generated_calendars', count( $post_ids ), $redirect_to );
|
||||
return $redirect_to;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add option to the event bulk actions dropdown.
|
||||
*/
|
||||
public function event_actions( $bulk_actions ) {
|
||||
$bulk_actions['sp_postpone'] = __( 'Postpone events', 'sportspress' );
|
||||
$bulk_actions['sp_cancel'] = __( 'Cancel events', 'sportspress' );
|
||||
$bulk_actions['sp_ok'] = __( 'Set events as on time', 'sportspress' );
|
||||
return $bulk_actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle form submission for event bulk actions.
|
||||
*/
|
||||
public function event_actions_handler( $redirect_to, $doaction, $post_ids ) {
|
||||
if ( ! in_array( $doaction, array( 'sp_postpone', 'sp_cancel', 'sp_ok' ) ) ) {
|
||||
return $redirect_to;
|
||||
}
|
||||
|
||||
if ( 'sp_postpone' == $doaction ) {
|
||||
foreach ( $post_ids as $post_id ) {
|
||||
update_post_meta( $post_id, 'sp_status', 'postponed' );
|
||||
}
|
||||
$redirect_to = add_query_arg( 'sp_bulk_postponed_events', count( $post_ids ), $redirect_to );
|
||||
} elseif ( 'sp_cancel' == $doaction ) {
|
||||
foreach ( $post_ids as $post_id ) {
|
||||
update_post_meta( $post_id, 'sp_status', 'cancelled' );
|
||||
}
|
||||
$redirect_to = add_query_arg( 'sp_bulk_cancelled_events', count( $post_ids ), $redirect_to );
|
||||
} elseif ( 'sp_ok' == $doaction ) {
|
||||
foreach ( $post_ids as $post_id ) {
|
||||
update_post_meta( $post_id, 'sp_status', 'ok' );
|
||||
}
|
||||
$redirect_to = add_query_arg( 'sp_bulk_ok_events', count( $post_ids ), $redirect_to );
|
||||
}
|
||||
|
||||
return $redirect_to;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display notices after form submission.
|
||||
*/
|
||||
public function admin_notices() {
|
||||
if ( ! empty( $_REQUEST['sp_bulk_generated_calendars'] ) ) {
|
||||
$count = intval( $_REQUEST['sp_bulk_generated_calendars'] );
|
||||
|
||||
printf(
|
||||
'<div id="message" class="updated notice notice-success is-dismissible"><p>' .
|
||||
_n(
|
||||
'Generated %s calendar.',
|
||||
'Generated %s calendars.',
|
||||
$count,
|
||||
'sportspress'
|
||||
) . ' <a href="' . admin_url( 'edit.php?post_type=sp_calendar' ) . '">' . __( 'View', 'sportspress' ) . '</a></p><button type="button" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></button></div>',
|
||||
$count
|
||||
);
|
||||
} elseif ( ! empty( $_REQUEST['sp_bulk_postponed_events'] ) ) {
|
||||
$count = intval( $_REQUEST['sp_bulk_postponed_events'] );
|
||||
|
||||
printf(
|
||||
'<div id="message" class="updated notice notice-success is-dismissible"><p>' .
|
||||
_n(
|
||||
'Postponed %s event.',
|
||||
'Postponed %s events.',
|
||||
$count,
|
||||
'sportspress'
|
||||
) . '</p><button type="button" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></button></div>',
|
||||
$count
|
||||
);
|
||||
} elseif ( ! empty( $_REQUEST['sp_bulk_cancelled_events'] ) ) {
|
||||
$count = intval( $_REQUEST['sp_bulk_cancelled_events'] );
|
||||
|
||||
printf(
|
||||
'<div id="message" class="updated notice notice-success is-dismissible"><p>' .
|
||||
_n(
|
||||
'Canceled %s event.',
|
||||
'Canceled %s events.',
|
||||
$count,
|
||||
'sportspress'
|
||||
) . '</p><button type="button" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></button></div>',
|
||||
$count
|
||||
);
|
||||
} elseif ( ! empty( $_REQUEST['sp_bulk_ok_events'] ) ) {
|
||||
$count = intval( $_REQUEST['sp_bulk_ok_events'] );
|
||||
|
||||
printf(
|
||||
'<div id="message" class="updated notice notice-success is-dismissible"><p>' .
|
||||
_n(
|
||||
'Set %s event as on time.',
|
||||
'Set %s event as on time.',
|
||||
$count,
|
||||
'sportspress'
|
||||
) . '</p><button type="button" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></button></div>',
|
||||
$count
|
||||
);
|
||||
}
|
||||
}
|
||||
$redirect_to = add_query_arg( 'sp_bulk_ok_events', count( $post_ids ), $redirect_to );
|
||||
}
|
||||
|
||||
return $redirect_to;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display notices after form submission.
|
||||
*/
|
||||
public function admin_notices() {
|
||||
if ( ! empty( $_REQUEST['sp_bulk_generated_calendars'] ) ) {
|
||||
$count = intval( $_REQUEST['sp_bulk_generated_calendars'] );
|
||||
|
||||
printf( '<div id="message" class="updated notice notice-success is-dismissible"><p>' .
|
||||
_n( 'Generated %s calendar.',
|
||||
'Generated %s calendars.',
|
||||
$count,
|
||||
'sportspress'
|
||||
) . ' <a href="' . admin_url('edit.php?post_type=sp_calendar') . '">' . __( 'View', 'sportspress' ) . '</a></p><button type="button" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></button></div>', $count );
|
||||
} elseif ( ! empty( $_REQUEST['sp_bulk_postponed_events'] ) ) {
|
||||
$count = intval( $_REQUEST['sp_bulk_postponed_events'] );
|
||||
|
||||
printf( '<div id="message" class="updated notice notice-success is-dismissible"><p>' .
|
||||
_n( 'Postponed %s event.',
|
||||
'Postponed %s events.',
|
||||
$count,
|
||||
'sportspress'
|
||||
) . '</p><button type="button" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></button></div>', $count );
|
||||
} elseif ( ! empty( $_REQUEST['sp_bulk_cancelled_events'] ) ) {
|
||||
$count = intval( $_REQUEST['sp_bulk_cancelled_events'] );
|
||||
|
||||
printf( '<div id="message" class="updated notice notice-success is-dismissible"><p>' .
|
||||
_n( 'Canceled %s event.',
|
||||
'Canceled %s events.',
|
||||
$count,
|
||||
'sportspress'
|
||||
) . '</p><button type="button" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></button></div>', $count );
|
||||
} elseif ( ! empty( $_REQUEST['sp_bulk_ok_events'] ) ) {
|
||||
$count = intval( $_REQUEST['sp_bulk_ok_events'] );
|
||||
|
||||
printf( '<div id="message" class="updated notice notice-success is-dismissible"><p>' .
|
||||
_n( 'Set %s event as on time.',
|
||||
'Set %s event as on time.',
|
||||
$count,
|
||||
'sportspress'
|
||||
) . '</p><button type="button" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></button></div>', $count );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
new SportsPress_Bulk_Actions();
|
||||
|
||||
@@ -9,466 +9,500 @@
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SportsPress_Calendars' ) ) :
|
||||
|
||||
/**
|
||||
* Main SportsPress Calendars Class
|
||||
*
|
||||
* @class SportsPress_Calendars
|
||||
* @version 2.6.15
|
||||
*/
|
||||
class SportsPress_Calendars {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Main SportsPress Calendars Class
|
||||
*
|
||||
* @class SportsPress_Calendars
|
||||
* @version 2.6.15
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
class SportsPress_Calendars {
|
||||
|
||||
// Actions
|
||||
add_action( 'init', array( $this, 'register_post_type' ) );
|
||||
add_action( 'add_meta_boxes', array( $this, 'remove_meta_boxes' ), 10 );
|
||||
add_action( 'sportspress_include_post_type_handlers', array( $this, 'include_post_type_handler' ) );
|
||||
add_action( 'sportspress_widgets', array( $this, 'include_widgets' ) );
|
||||
add_action( 'sportspress_create_rest_routes', array( $this, 'create_rest_routes' ) );
|
||||
add_action( 'sportspress_register_rest_fields', array( $this, 'register_rest_fields' ) );
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
// Filters
|
||||
add_filter( 'sportspress_meta_boxes', array( $this, 'add_meta_boxes' ) );
|
||||
add_filter( 'sportspress_shortcodes', array( $this, 'add_shortcodes' ) );
|
||||
add_filter( 'sportspress_event_settings', array( $this, 'add_event_settings' ) );
|
||||
add_filter( 'sportspress_team_options', array( $this, 'add_team_options' ) );
|
||||
add_filter( 'sportspress_after_team_template', array( $this, 'add_team_template' ), 40 );
|
||||
add_filter( 'sportspress_player_options', array( $this, 'add_player_options' ) );
|
||||
add_filter( 'sportspress_after_player_template', array( $this, 'add_player_template' ), 40 );
|
||||
}
|
||||
// Actions
|
||||
add_action( 'init', array( $this, 'register_post_type' ) );
|
||||
add_action( 'add_meta_boxes', array( $this, 'remove_meta_boxes' ), 10 );
|
||||
add_action( 'sportspress_include_post_type_handlers', array( $this, 'include_post_type_handler' ) );
|
||||
add_action( 'sportspress_widgets', array( $this, 'include_widgets' ) );
|
||||
add_action( 'sportspress_create_rest_routes', array( $this, 'create_rest_routes' ) );
|
||||
add_action( 'sportspress_register_rest_fields', array( $this, 'register_rest_fields' ) );
|
||||
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( !defined( 'SP_CALENDARS_VERSION' ) )
|
||||
define( 'SP_CALENDARS_VERSION', '2.6.15' );
|
||||
// Filters
|
||||
add_filter( 'sportspress_meta_boxes', array( $this, 'add_meta_boxes' ) );
|
||||
add_filter( 'sportspress_shortcodes', array( $this, 'add_shortcodes' ) );
|
||||
add_filter( 'sportspress_event_settings', array( $this, 'add_event_settings' ) );
|
||||
add_filter( 'sportspress_team_options', array( $this, 'add_team_options' ) );
|
||||
add_filter( 'sportspress_after_team_template', array( $this, 'add_team_template' ), 40 );
|
||||
add_filter( 'sportspress_player_options', array( $this, 'add_player_options' ) );
|
||||
add_filter( 'sportspress_after_player_template', array( $this, 'add_player_template' ), 40 );
|
||||
}
|
||||
|
||||
if ( !defined( 'SP_CALENDARS_URL' ) )
|
||||
define( 'SP_CALENDARS_URL', plugin_dir_url( __FILE__ ) );
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( ! defined( 'SP_CALENDARS_VERSION' ) ) {
|
||||
define( 'SP_CALENDARS_VERSION', '2.6.15' );
|
||||
}
|
||||
|
||||
if ( !defined( 'SP_CALENDARS_DIR' ) )
|
||||
define( 'SP_CALENDARS_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
if ( ! defined( 'SP_CALENDARS_URL' ) ) {
|
||||
define( 'SP_CALENDARS_URL', plugin_dir_url( __FILE__ ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register calendars post type
|
||||
*/
|
||||
public static function register_post_type() {
|
||||
register_post_type( 'sp_calendar',
|
||||
apply_filters( 'sportspress_register_post_type_calendar',
|
||||
array(
|
||||
'labels' => array(
|
||||
'name' => __( 'Calendars', 'sportspress' ),
|
||||
'singular_name' => __( 'Calendar', 'sportspress' ),
|
||||
'add_new_item' => __( 'Add New Calendar', 'sportspress' ),
|
||||
'edit_item' => __( 'Edit Calendar', 'sportspress' ),
|
||||
'new_item' => __( 'New', 'sportspress' ),
|
||||
'view_item' => __( 'View Calendar', 'sportspress' ),
|
||||
'search_items' => __( 'Search', 'sportspress' ),
|
||||
'not_found' => __( 'No results found.', 'sportspress' ),
|
||||
'not_found_in_trash' => __( 'No results found.', 'sportspress' ),
|
||||
),
|
||||
'public' => true,
|
||||
'show_ui' => true,
|
||||
'capability_type' => 'sp_calendar',
|
||||
'map_meta_cap' => true,
|
||||
'publicly_queryable' => true,
|
||||
'exclude_from_search' => false,
|
||||
'hierarchical' => false,
|
||||
'rewrite' => array( 'slug' => get_option( 'sportspress_calendar_slug', 'calendar' ) ),
|
||||
'supports' => array( 'title', 'editor', 'author', 'thumbnail' ),
|
||||
'has_archive' => false,
|
||||
'show_in_nav_menus' => true,
|
||||
'show_in_menu' => 'edit.php?post_type=sp_event',
|
||||
'show_in_admin_bar' => true,
|
||||
'show_in_rest' => true,
|
||||
'rest_controller_class' => 'SP_REST_Posts_Controller',
|
||||
'rest_base' => 'calendars',
|
||||
if ( ! defined( 'SP_CALENDARS_DIR' ) ) {
|
||||
define( 'SP_CALENDARS_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register calendars post type
|
||||
*/
|
||||
public static function register_post_type() {
|
||||
register_post_type(
|
||||
'sp_calendar',
|
||||
apply_filters(
|
||||
'sportspress_register_post_type_calendar',
|
||||
array(
|
||||
'labels' => array(
|
||||
'name' => __( 'Calendars', 'sportspress' ),
|
||||
'singular_name' => __( 'Calendar', 'sportspress' ),
|
||||
'add_new_item' => __( 'Add New Calendar', 'sportspress' ),
|
||||
'edit_item' => __( 'Edit Calendar', 'sportspress' ),
|
||||
'new_item' => __( 'New', 'sportspress' ),
|
||||
'view_item' => __( 'View Calendar', 'sportspress' ),
|
||||
'search_items' => __( 'Search', 'sportspress' ),
|
||||
'not_found' => __( 'No results found.', 'sportspress' ),
|
||||
'not_found_in_trash' => __( 'No results found.', 'sportspress' ),
|
||||
),
|
||||
'public' => true,
|
||||
'show_ui' => true,
|
||||
'capability_type' => 'sp_calendar',
|
||||
'map_meta_cap' => true,
|
||||
'publicly_queryable' => true,
|
||||
'exclude_from_search' => false,
|
||||
'hierarchical' => false,
|
||||
'rewrite' => array( 'slug' => get_option( 'sportspress_calendar_slug', 'calendar' ) ),
|
||||
'supports' => array( 'title', 'editor', 'author', 'thumbnail' ),
|
||||
'has_archive' => false,
|
||||
'show_in_nav_menus' => true,
|
||||
'show_in_menu' => 'edit.php?post_type=sp_event',
|
||||
'show_in_admin_bar' => true,
|
||||
'show_in_rest' => true,
|
||||
'rest_controller_class' => 'SP_REST_Posts_Controller',
|
||||
'rest_base' => 'calendars',
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove meta boxes.
|
||||
*/
|
||||
public function remove_meta_boxes() {
|
||||
remove_meta_box( 'sp_seasondiv', 'sp_calendar', 'side' );
|
||||
remove_meta_box( 'sp_leaguediv', 'sp_calendar', 'side' );
|
||||
remove_meta_box( 'sp_venuediv', 'sp_calendar', 'side' );
|
||||
}
|
||||
/**
|
||||
* Remove meta boxes.
|
||||
*/
|
||||
public function remove_meta_boxes() {
|
||||
remove_meta_box( 'sp_seasondiv', 'sp_calendar', 'side' );
|
||||
remove_meta_box( 'sp_leaguediv', 'sp_calendar', 'side' );
|
||||
remove_meta_box( 'sp_venuediv', 'sp_calendar', 'side' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Conditonally load the class and functions only needed when viewing this post type.
|
||||
*/
|
||||
public function include_post_type_handler() {
|
||||
include_once( SP()->plugin_path() . '/includes/admin/post-types/class-sp-admin-cpt-calendar.php' );
|
||||
}
|
||||
/**
|
||||
* Conditonally load the class and functions only needed when viewing this post type.
|
||||
*/
|
||||
public function include_post_type_handler() {
|
||||
include_once SP()->plugin_path() . '/includes/admin/post-types/class-sp-admin-cpt-calendar.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Add widgets.
|
||||
*/
|
||||
public function include_widgets() {
|
||||
include_once( SP()->plugin_path() . '/includes/widgets/class-sp-widget-event-calendar.php' );
|
||||
include_once( SP()->plugin_path() . '/includes/widgets/class-sp-widget-event-list.php' );
|
||||
include_once( SP()->plugin_path() . '/includes/widgets/class-sp-widget-event-blocks.php' );
|
||||
}
|
||||
/**
|
||||
* Add widgets.
|
||||
*/
|
||||
public function include_widgets() {
|
||||
include_once SP()->plugin_path() . '/includes/widgets/class-sp-widget-event-calendar.php';
|
||||
include_once SP()->plugin_path() . '/includes/widgets/class-sp-widget-event-list.php';
|
||||
include_once SP()->plugin_path() . '/includes/widgets/class-sp-widget-event-blocks.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Create REST API routes.
|
||||
*/
|
||||
public function create_rest_routes() {
|
||||
$controller = new SP_REST_Posts_Controller( 'sp_calendar' );
|
||||
$controller->register_routes();
|
||||
}
|
||||
/**
|
||||
* Create REST API routes.
|
||||
*/
|
||||
public function create_rest_routes() {
|
||||
$controller = new SP_REST_Posts_Controller( 'sp_calendar' );
|
||||
$controller->register_routes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register REST API fields.
|
||||
*/
|
||||
public function register_rest_fields() {
|
||||
register_rest_field( 'sp_calendar',
|
||||
'format',
|
||||
array(
|
||||
'get_callback' => 'SP_REST_API::get_post_meta',
|
||||
'update_callback' => 'SP_REST_API::update_post_meta',
|
||||
'schema' => array(
|
||||
'description' => __( 'Layout', 'sportspress' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
'sanitize_callback' => 'rest_sanitize_request_arg',
|
||||
/**
|
||||
* Register REST API fields.
|
||||
*/
|
||||
public function register_rest_fields() {
|
||||
register_rest_field(
|
||||
'sp_calendar',
|
||||
'format',
|
||||
array(
|
||||
'get_callback' => 'SP_REST_API::get_post_meta',
|
||||
'update_callback' => 'SP_REST_API::update_post_meta',
|
||||
'schema' => array(
|
||||
'description' => __( 'Layout', 'sportspress' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
'sanitize_callback' => 'rest_sanitize_request_arg',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
register_rest_field(
|
||||
'sp_calendar',
|
||||
'data',
|
||||
array(
|
||||
'get_callback' => 'SP_REST_API::get_post_data',
|
||||
'schema' => array(
|
||||
'description' => __( 'Events', 'sportspress' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view' ),
|
||||
'arg_options' => array(
|
||||
'sanitize_callback' => 'rest_sanitize_request_arg',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add meta boxes to calendars.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_meta_boxes( $meta_boxes ) {
|
||||
$meta_boxes['sp_calendar'] = array(
|
||||
'shortcode' => array(
|
||||
'title' => __( 'Shortcode', 'sportspress' ),
|
||||
'output' => 'SP_Meta_Box_Calendar_Shortcode::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'feeds' => array(
|
||||
'title' => __( 'Feeds', 'sportspress' ),
|
||||
'output' => 'SP_Meta_Box_Calendar_Feeds::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'format' => array(
|
||||
'title' => __( 'Layout', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Calendar_Format::save',
|
||||
'output' => 'SP_Meta_Box_Calendar_Format::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'columns' => array(
|
||||
'title' => __( 'Columns', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Calendar_Columns::save',
|
||||
'output' => 'SP_Meta_Box_Calendar_Columns::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'details' => array(
|
||||
'title' => __( 'Details', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Calendar_Details::save',
|
||||
'output' => 'SP_Meta_Box_Calendar_Details::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'data' => array(
|
||||
'title' => __( 'Events', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Calendar_Data::save',
|
||||
'output' => 'SP_Meta_Box_Calendar_Data::output',
|
||||
'context' => 'normal',
|
||||
'priority' => 'high',
|
||||
),
|
||||
);
|
||||
return $meta_boxes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add shortcodes.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_shortcodes( $shortcodes ) {
|
||||
$shortcodes['event'][] = 'calendar';
|
||||
$shortcodes['event'][] = 'list';
|
||||
$shortcodes['event'][] = 'blocks';
|
||||
return $shortcodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add event settings.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_event_settings( $settings ) {
|
||||
$settings = array_merge(
|
||||
$settings,
|
||||
array(
|
||||
array(
|
||||
'title' => __( 'Event List', 'sportspress' ),
|
||||
'type' => 'title',
|
||||
'id' => 'event_list_options',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
register_rest_field( 'sp_calendar',
|
||||
'data',
|
||||
array(
|
||||
'get_callback' => 'SP_REST_API::get_post_data',
|
||||
'schema' => array(
|
||||
'description' => __( 'Events', 'sportspress' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view' ),
|
||||
'arg_options' => array(
|
||||
'sanitize_callback' => 'rest_sanitize_request_arg',
|
||||
apply_filters(
|
||||
'sportspress_event_list_options',
|
||||
array(
|
||||
array(
|
||||
'title' => __( 'Title', 'sportspress' ),
|
||||
'desc' => __( 'Display calendar title', 'sportspress' ),
|
||||
'id' => 'sportspress_event_list_show_title',
|
||||
'default' => 'yes',
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Teams', 'sportspress' ),
|
||||
'desc' => __( 'Display logos', 'sportspress' ),
|
||||
'id' => 'sportspress_event_list_show_logos',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Title Format', 'sportspress' ),
|
||||
'id' => 'sportspress_event_list_title_format',
|
||||
'default' => 'title',
|
||||
'type' => 'select',
|
||||
'options' => array(
|
||||
'title' => __( 'Title', 'sportspress' ),
|
||||
'teams' => __( 'Teams', 'sportspress' ),
|
||||
'homeaway' => sprintf( '%s | %s', __( 'Home', 'sportspress' ), __( 'Away', 'sportspress' ) ),
|
||||
),
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Time/Results Format', 'sportspress' ),
|
||||
'id' => 'sportspress_event_list_time_format',
|
||||
'default' => 'combined',
|
||||
'type' => 'select',
|
||||
'options' => array(
|
||||
'combined' => __( 'Combined', 'sportspress' ),
|
||||
'separate' => __( 'Separate', 'sportspress' ),
|
||||
'time' => __( 'Time Only', 'sportspress' ),
|
||||
'results' => __( 'Results Only', 'sportspress' ),
|
||||
),
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Pagination', 'sportspress' ),
|
||||
'desc' => __( 'Paginate', 'sportspress' ),
|
||||
'id' => 'sportspress_event_list_paginated',
|
||||
'default' => 'yes',
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Limit', 'sportspress' ),
|
||||
'id' => 'sportspress_event_list_rows',
|
||||
'class' => 'small-text',
|
||||
'default' => '10',
|
||||
'desc' => __( 'events', 'sportspress' ),
|
||||
'type' => 'number',
|
||||
'custom_attributes' => array(
|
||||
'min' => 1,
|
||||
'step' => 1,
|
||||
),
|
||||
),
|
||||
)
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'type' => 'sectionend',
|
||||
'id' => 'event_list_options',
|
||||
),
|
||||
array(
|
||||
'title' => __( 'Event Blocks', 'sportspress' ),
|
||||
'type' => 'title',
|
||||
'id' => 'event_blocks_options',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
apply_filters(
|
||||
'sportspress_event_blocks_options',
|
||||
array(
|
||||
array(
|
||||
'title' => __( 'Title', 'sportspress' ),
|
||||
'desc' => __( 'Display calendar title', 'sportspress' ),
|
||||
'id' => 'sportspress_event_blocks_show_title',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
|
||||
/**
|
||||
* Add meta boxes to calendars.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_meta_boxes( $meta_boxes ) {
|
||||
$meta_boxes['sp_calendar'] = array(
|
||||
'shortcode' => array(
|
||||
'title' => __( 'Shortcode', 'sportspress' ),
|
||||
'output' => 'SP_Meta_Box_Calendar_Shortcode::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'feeds' => array(
|
||||
'title' => __( 'Feeds', 'sportspress' ),
|
||||
'output' => 'SP_Meta_Box_Calendar_Feeds::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'format' => array(
|
||||
'title' => __( 'Layout', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Calendar_Format::save',
|
||||
'output' => 'SP_Meta_Box_Calendar_Format::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'columns' => array(
|
||||
'title' => __( 'Columns', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Calendar_Columns::save',
|
||||
'output' => 'SP_Meta_Box_Calendar_Columns::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'details' => array(
|
||||
'title' => __( 'Details', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Calendar_Details::save',
|
||||
'output' => 'SP_Meta_Box_Calendar_Details::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'data' => array(
|
||||
'title' => __( 'Events', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Calendar_Data::save',
|
||||
'output' => 'SP_Meta_Box_Calendar_Data::output',
|
||||
'context' => 'normal',
|
||||
'priority' => 'high',
|
||||
),
|
||||
);
|
||||
return $meta_boxes;
|
||||
}
|
||||
array(
|
||||
'title' => __( 'Teams', 'sportspress' ),
|
||||
'desc' => __( 'Display logos', 'sportspress' ),
|
||||
'id' => 'sportspress_event_blocks_show_logos',
|
||||
'default' => 'yes',
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
|
||||
/**
|
||||
* Add shortcodes.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_shortcodes( $shortcodes ) {
|
||||
$shortcodes['event'][] = 'calendar';
|
||||
$shortcodes['event'][] = 'list';
|
||||
$shortcodes['event'][] = 'blocks';
|
||||
return $shortcodes;
|
||||
}
|
||||
array(
|
||||
'title' => __( 'Details', 'sportspress' ),
|
||||
'desc' => __( 'Display league', 'sportspress' ),
|
||||
'id' => 'sportspress_event_blocks_show_league',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'start',
|
||||
),
|
||||
|
||||
/**
|
||||
* Add event settings.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_event_settings( $settings ) {
|
||||
$settings = array_merge( $settings,
|
||||
array(
|
||||
array( 'title' => __( 'Event List', 'sportspress' ), 'type' => 'title', 'id' => 'event_list_options' ),
|
||||
),
|
||||
array(
|
||||
'desc' => __( 'Display season', 'sportspress' ),
|
||||
'id' => 'sportspress_event_blocks_show_season',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => '',
|
||||
),
|
||||
|
||||
apply_filters( 'sportspress_event_list_options', array(
|
||||
array(
|
||||
'title' => __( 'Title', 'sportspress' ),
|
||||
'desc' => __( 'Display calendar title', 'sportspress' ),
|
||||
'id' => 'sportspress_event_list_show_title',
|
||||
'default' => 'yes',
|
||||
'type' => 'checkbox',
|
||||
array(
|
||||
'desc' => __( 'Display matchday', 'sportspress' ),
|
||||
'id' => 'sportspress_event_blocks_show_matchday',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => '',
|
||||
),
|
||||
|
||||
array(
|
||||
'desc' => __( 'Display venue', 'sportspress' ),
|
||||
'id' => 'sportspress_event_blocks_show_venue',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'end',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Pagination', 'sportspress' ),
|
||||
'desc' => __( 'Paginate', 'sportspress' ),
|
||||
'id' => 'sportspress_event_blocks_paginated',
|
||||
'default' => 'yes',
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Limit', 'sportspress' ),
|
||||
'id' => 'sportspress_event_blocks_rows',
|
||||
'class' => 'small-text',
|
||||
'default' => '5',
|
||||
'desc' => __( 'events', 'sportspress' ),
|
||||
'type' => 'number',
|
||||
'custom_attributes' => array(
|
||||
'min' => 1,
|
||||
'step' => 1,
|
||||
),
|
||||
),
|
||||
)
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Teams', 'sportspress' ),
|
||||
'desc' => __( 'Display logos', 'sportspress' ),
|
||||
'id' => 'sportspress_event_list_show_logos',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Title Format', 'sportspress' ),
|
||||
'id' => 'sportspress_event_list_title_format',
|
||||
'default' => 'title',
|
||||
'type' => 'select',
|
||||
'options' => array(
|
||||
'title' => __( 'Title', 'sportspress' ),
|
||||
'teams' => __( 'Teams', 'sportspress' ),
|
||||
'homeaway' => sprintf( '%s | %s', __( 'Home', 'sportspress' ), __( 'Away', 'sportspress' ) ),
|
||||
array(
|
||||
'type' => 'sectionend',
|
||||
'id' => 'event_list_options',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
return $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add team options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_team_options( $options ) {
|
||||
return array_merge(
|
||||
$options,
|
||||
array(
|
||||
'title' => __( 'Time/Results Format', 'sportspress' ),
|
||||
'id' => 'sportspress_event_list_time_format',
|
||||
'default' => 'combined',
|
||||
'type' => 'select',
|
||||
'options' => array(
|
||||
'combined' => __( 'Combined', 'sportspress' ),
|
||||
'separate' => __( 'Separate', 'sportspress' ),
|
||||
'time' => __( 'Time Only', 'sportspress' ),
|
||||
'results' => __( 'Results Only', 'sportspress' ),
|
||||
array(
|
||||
'title' => __( 'Events', 'sportspress' ),
|
||||
'id' => 'sportspress_team_events_format',
|
||||
'default' => 'title',
|
||||
'type' => 'select',
|
||||
'options' => array(
|
||||
'blocks' => __( 'Blocks', 'sportspress' ),
|
||||
'calendar' => __( 'Calendar', 'sportspress' ),
|
||||
'list' => __( 'List', 'sportspress' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add player template.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_player_template( $templates ) {
|
||||
return array_merge(
|
||||
$templates,
|
||||
array(
|
||||
'title' => __( 'Pagination', 'sportspress' ),
|
||||
'desc' => __( 'Paginate', 'sportspress' ),
|
||||
'id' => 'sportspress_event_list_paginated',
|
||||
'default' => 'yes',
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Limit', 'sportspress' ),
|
||||
'id' => 'sportspress_event_list_rows',
|
||||
'class' => 'small-text',
|
||||
'default' => '10',
|
||||
'desc' => __( 'events', 'sportspress' ),
|
||||
'type' => 'number',
|
||||
'custom_attributes' => array(
|
||||
'min' => 1,
|
||||
'step' => 1
|
||||
'events' => array(
|
||||
'title' => __( 'Events', 'sportspress' ),
|
||||
'option' => 'sportspress_player_show_events',
|
||||
'action' => 'sportspress_output_player_events',
|
||||
'default' => 'no',
|
||||
),
|
||||
),
|
||||
)),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
array(
|
||||
array( 'type' => 'sectionend', 'id' => 'event_list_options' ),
|
||||
array( 'title' => __( 'Event Blocks', 'sportspress' ), 'type' => 'title', 'id' => 'event_blocks_options' ),
|
||||
),
|
||||
|
||||
apply_filters( 'sportspress_event_blocks_options', array(
|
||||
/**
|
||||
* Add player options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_player_options( $options ) {
|
||||
return array_merge(
|
||||
$options,
|
||||
array(
|
||||
'title' => __( 'Title', 'sportspress' ),
|
||||
'desc' => __( 'Display calendar title', 'sportspress' ),
|
||||
'id' => 'sportspress_event_blocks_show_title',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Teams', 'sportspress' ),
|
||||
'desc' => __( 'Display logos', 'sportspress' ),
|
||||
'id' => 'sportspress_event_blocks_show_logos',
|
||||
'default' => 'yes',
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Details', 'sportspress' ),
|
||||
'desc' => __( 'Display league', 'sportspress' ),
|
||||
'id' => 'sportspress_event_blocks_show_league',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'start',
|
||||
),
|
||||
|
||||
array(
|
||||
'desc' => __( 'Display season', 'sportspress' ),
|
||||
'id' => 'sportspress_event_blocks_show_season',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => '',
|
||||
),
|
||||
|
||||
array(
|
||||
'desc' => __( 'Display matchday', 'sportspress' ),
|
||||
'id' => 'sportspress_event_blocks_show_matchday',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => '',
|
||||
),
|
||||
|
||||
array(
|
||||
'desc' => __( 'Display venue', 'sportspress' ),
|
||||
'id' => 'sportspress_event_blocks_show_venue',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'end',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Pagination', 'sportspress' ),
|
||||
'desc' => __( 'Paginate', 'sportspress' ),
|
||||
'id' => 'sportspress_event_blocks_paginated',
|
||||
'default' => 'yes',
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Limit', 'sportspress' ),
|
||||
'id' => 'sportspress_event_blocks_rows',
|
||||
'class' => 'small-text',
|
||||
'default' => '5',
|
||||
'desc' => __( 'events', 'sportspress' ),
|
||||
'type' => 'number',
|
||||
'custom_attributes' => array(
|
||||
'min' => 1,
|
||||
'step' => 1
|
||||
array(
|
||||
'title' => __( 'Events', 'sportspress' ),
|
||||
'id' => 'sportspress_player_events_format',
|
||||
'default' => 'title',
|
||||
'type' => 'select',
|
||||
'options' => array(
|
||||
'blocks' => __( 'Blocks', 'sportspress' ),
|
||||
'calendar' => __( 'Calendar', 'sportspress' ),
|
||||
'list' => __( 'List', 'sportspress' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
)),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
array(
|
||||
array( 'type' => 'sectionend', 'id' => 'event_list_options' ),
|
||||
)
|
||||
);
|
||||
return $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add team options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_team_options( $options ) {
|
||||
return array_merge( $options,
|
||||
array(
|
||||
/**
|
||||
* Add team template.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_team_template( $templates ) {
|
||||
return array_merge(
|
||||
$templates,
|
||||
array(
|
||||
'title' => __( 'Events', 'sportspress' ),
|
||||
'id' => 'sportspress_team_events_format',
|
||||
'default' => 'title',
|
||||
'type' => 'select',
|
||||
'options' => array(
|
||||
'blocks' => __( 'Blocks', 'sportspress' ),
|
||||
'calendar' => __( 'Calendar', 'sportspress' ),
|
||||
'list' => __( 'List', 'sportspress' ),
|
||||
'events' => array(
|
||||
'title' => __( 'Events', 'sportspress' ),
|
||||
'option' => 'sportspress_team_show_events',
|
||||
'action' => 'sportspress_output_team_events',
|
||||
'default' => 'no',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add player template.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_player_template( $templates ) {
|
||||
return array_merge( $templates, array(
|
||||
'events' => array(
|
||||
'title' => __( 'Events', 'sportspress' ),
|
||||
'option' => 'sportspress_player_show_events',
|
||||
'action' => 'sportspress_output_player_events',
|
||||
'default' => 'no',
|
||||
),
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add player options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_player_options( $options ) {
|
||||
return array_merge( $options,
|
||||
array(
|
||||
array(
|
||||
'title' => __( 'Events', 'sportspress' ),
|
||||
'id' => 'sportspress_player_events_format',
|
||||
'default' => 'title',
|
||||
'type' => 'select',
|
||||
'options' => array(
|
||||
'blocks' => __( 'Blocks', 'sportspress' ),
|
||||
'calendar' => __( 'Calendar', 'sportspress' ),
|
||||
'list' => __( 'List', 'sportspress' ),
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add team template.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_team_template( $templates ) {
|
||||
return array_merge( $templates, array(
|
||||
'events' => array(
|
||||
'title' => __( 'Events', 'sportspress' ),
|
||||
'option' => 'sportspress_team_show_events',
|
||||
'action' => 'sportspress_output_team_events',
|
||||
'default' => 'no',
|
||||
),
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
if ( get_option( 'sportspress_load_calendars_module', 'yes' ) == 'yes' ) {
|
||||
|
||||
@@ -9,138 +9,143 @@
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SportsPress_Comments_Scheduled_Events' ) ) :
|
||||
/**
|
||||
* Main SportsPress Comments Scheduled Events Class
|
||||
*
|
||||
* @class SportsPress_Comments_Scheduled_Events
|
||||
* @version 2.6.8
|
||||
*/
|
||||
class SportsPress_Comments_Scheduled_Events {
|
||||
/**
|
||||
* Constructor
|
||||
* Main SportsPress Comments Scheduled Events Class
|
||||
*
|
||||
* @class SportsPress_Comments_Scheduled_Events
|
||||
* @version 2.6.8
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
// Actions
|
||||
add_action( 'comment_on_draft', array( $this, 'sp_publish_comment' ) );
|
||||
class SportsPress_Comments_Scheduled_Events {
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
// Actions
|
||||
add_action( 'comment_on_draft', array( $this, 'sp_publish_comment' ) );
|
||||
|
||||
}
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( !defined( 'SP_COMMENTS_SCHEDULED_EVENTS_VERSION' ) )
|
||||
define( 'SP_COMMENTS_SCHEDULED_EVENTS_VERSION', '2.6.8' );
|
||||
if ( !defined( 'SP_COMMENTS_SCHEDULED_EVENTS_URL' ) )
|
||||
define( 'SP_COMMENTS_SCHEDULED_EVENTS_URL', plugin_dir_url( __FILE__ ) );
|
||||
if ( !defined( 'SP_COMMENTS_SCHEDULED_EVENTS_DIR' ) )
|
||||
define( 'SP_COMMENTS_SCHEDULED_EVENTS_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Save Additional Statistics
|
||||
*/
|
||||
public function sp_publish_comment( $comment_post_ID ) {
|
||||
|
||||
do_action( 'pre_comment_on_post', $comment_post_ID );
|
||||
|
||||
$comment_author = ( isset( $_POST['author'] ) ) ? trim( strip_tags( $_POST['author'] ) ) : null;
|
||||
$comment_author_email = ( isset( $_POST['email'] ) ) ? sanitize_email ( trim( $_POST['email'] ) ) : null;
|
||||
$comment_author_url = ( isset($_POST['url'] ) ) ? esc_url( trim( $_POST['url'] ) ) : null;
|
||||
$comment_content = ( isset( $_POST['comment'] ) ) ? esc_textarea( trim( $_POST['comment'] ) ) : null;
|
||||
|
||||
// If the user is logged in
|
||||
$user = wp_get_current_user();
|
||||
if ( $user->exists() ) {
|
||||
if ( empty( $user->display_name ) ) {
|
||||
$user->display_name=$user->user_login;
|
||||
}
|
||||
$comment_author = $user->display_name;
|
||||
$comment_author_email = $user->user_email;
|
||||
$comment_author_url = $user->user_url;
|
||||
$user_ID = $user->ID;
|
||||
if ( current_user_can( 'unfiltered_html' ) ) {
|
||||
if ( ! isset( $comment_data['_wp_unfiltered_html_comment'] )
|
||||
|| ! wp_verify_nonce( $comment_data['_wp_unfiltered_html_comment'], 'unfiltered-html-comment_' . $comment_post_ID )
|
||||
) {
|
||||
kses_remove_filters(); // start with a clean slate
|
||||
kses_init_filters(); // set up the filters
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( ! defined( 'SP_COMMENTS_SCHEDULED_EVENTS_VERSION' ) ) {
|
||||
define( 'SP_COMMENTS_SCHEDULED_EVENTS_VERSION', '2.6.8' );
|
||||
}
|
||||
if ( ! defined( 'SP_COMMENTS_SCHEDULED_EVENTS_URL' ) ) {
|
||||
define( 'SP_COMMENTS_SCHEDULED_EVENTS_URL', plugin_dir_url( __FILE__ ) );
|
||||
}
|
||||
if ( ! defined( 'SP_COMMENTS_SCHEDULED_EVENTS_DIR' ) ) {
|
||||
define( 'SP_COMMENTS_SCHEDULED_EVENTS_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ( get_option( 'comment_registration' ) ) {
|
||||
return new WP_Error( 'not_logged_in', __( 'Sorry, you must be logged in to comment.' ), 403 );
|
||||
}
|
||||
}
|
||||
|
||||
$comment_type = '';
|
||||
|
||||
if ( get_option( 'require_name_email' ) && ! $user->exists() ) {
|
||||
if ( '' == $comment_author_email || '' == $comment_author ) {
|
||||
//return new WP_Error( 'require_name_email', __( '<strong>ERROR</strong>: please fill the required fields (name, email).' ), 200 );
|
||||
wp_die( __( '<strong>ERROR</strong>: please fill the required fields (name, email).' ), __( 'ERROR: please fill the required fields (name, email).' ), array ( 'back_link' => true ) );
|
||||
} elseif ( ! is_email( $comment_author_email ) ) {
|
||||
//return new WP_Error( 'require_valid_email', __( '<strong>ERROR</strong>: please enter a valid email address.' ), 200 );
|
||||
wp_die( __( '<strong>ERROR</strong>: please enter a valid email address.' ), __( 'ERROR: please enter a valid email address.' ), array ( 'back_link' => true ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( '' == $comment_content ) {
|
||||
//return new WP_Error( 'require_valid_comment', __( '<strong>ERROR</strong>: please type a comment.' ), 200 );
|
||||
wp_die( __( '<strong>ERROR</strong>: please type a comment.' ), __( 'ERROR: please type a comment.' ), array ( 'back_link' => true ) );
|
||||
}
|
||||
|
||||
$comment_parent = isset($_POST['comment_parent']) ? absint($_POST['comment_parent']) : 0;
|
||||
|
||||
$commentdata = compact(
|
||||
'comment_post_ID',
|
||||
'comment_author',
|
||||
'comment_author_email',
|
||||
'comment_author_url',
|
||||
'comment_content',
|
||||
'comment_type',
|
||||
'comment_parent',
|
||||
'user_ID'
|
||||
);
|
||||
|
||||
$check_max_lengths = wp_check_comment_data_max_lengths( $commentdata );
|
||||
if ( is_wp_error( $check_max_lengths ) ) {
|
||||
return $check_max_lengths;
|
||||
}
|
||||
|
||||
$comment_id = wp_new_comment( wp_slash( $commentdata ), true );
|
||||
if ( is_wp_error( $comment_id ) ) {
|
||||
return $comment_id;
|
||||
}
|
||||
|
||||
if ( ! $comment_id ) {
|
||||
//return new WP_Error( 'comment_save_error', __( '<strong>ERROR</strong>: The comment could not be saved. Please try again later.' ), 500 );
|
||||
wp_die( __( '<strong>ERROR</strong>: The comment could not be saved. Please try again later.' ), __( 'ERROR: The comment could not be saved. Please try again later.' ), array ( 'back_link' => true ) );
|
||||
}
|
||||
|
||||
$comment = get_comment( $comment_id );
|
||||
|
||||
do_action( 'set_comment_cookies', $comment, $user );
|
||||
|
||||
if ( $user->exists() ) {
|
||||
wp_set_comment_status( $comment_id, 'approve' );
|
||||
}
|
||||
|
||||
$location = empty($_POST['redirect_to']) ? get_comment_link($comment_id) : $_POST['redirect_to'] . '#comment-' . $comment_id;
|
||||
|
||||
$location = apply_filters( 'comment_post_redirect', $location, $comment );
|
||||
|
||||
wp_safe_redirect( $location );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save Additional Statistics
|
||||
*/
|
||||
public function sp_publish_comment( $comment_post_ID ) {
|
||||
|
||||
}
|
||||
do_action( 'pre_comment_on_post', $comment_post_ID );
|
||||
|
||||
$comment_author = ( isset( $_POST['author'] ) ) ? trim( strip_tags( $_POST['author'] ) ) : null;
|
||||
$comment_author_email = ( isset( $_POST['email'] ) ) ? sanitize_email( trim( $_POST['email'] ) ) : null;
|
||||
$comment_author_url = ( isset( $_POST['url'] ) ) ? esc_url( trim( $_POST['url'] ) ) : null;
|
||||
$comment_content = ( isset( $_POST['comment'] ) ) ? esc_textarea( trim( $_POST['comment'] ) ) : null;
|
||||
|
||||
// If the user is logged in
|
||||
$user = wp_get_current_user();
|
||||
if ( $user->exists() ) {
|
||||
if ( empty( $user->display_name ) ) {
|
||||
$user->display_name = $user->user_login;
|
||||
}
|
||||
$comment_author = $user->display_name;
|
||||
$comment_author_email = $user->user_email;
|
||||
$comment_author_url = $user->user_url;
|
||||
$user_ID = $user->ID;
|
||||
if ( current_user_can( 'unfiltered_html' ) ) {
|
||||
if ( ! isset( $comment_data['_wp_unfiltered_html_comment'] )
|
||||
|| ! wp_verify_nonce( $comment_data['_wp_unfiltered_html_comment'], 'unfiltered-html-comment_' . $comment_post_ID )
|
||||
) {
|
||||
kses_remove_filters(); // start with a clean slate
|
||||
kses_init_filters(); // set up the filters
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ( get_option( 'comment_registration' ) ) {
|
||||
return new WP_Error( 'not_logged_in', __( 'Sorry, you must be logged in to comment.' ), 403 );
|
||||
}
|
||||
}
|
||||
|
||||
$comment_type = '';
|
||||
|
||||
if ( get_option( 'require_name_email' ) && ! $user->exists() ) {
|
||||
if ( '' == $comment_author_email || '' == $comment_author ) {
|
||||
// return new WP_Error( 'require_name_email', __( '<strong>ERROR</strong>: please fill the required fields (name, email).' ), 200 );
|
||||
wp_die( __( '<strong>ERROR</strong>: please fill the required fields (name, email).' ), __( 'ERROR: please fill the required fields (name, email).' ), array( 'back_link' => true ) );
|
||||
} elseif ( ! is_email( $comment_author_email ) ) {
|
||||
// return new WP_Error( 'require_valid_email', __( '<strong>ERROR</strong>: please enter a valid email address.' ), 200 );
|
||||
wp_die( __( '<strong>ERROR</strong>: please enter a valid email address.' ), __( 'ERROR: please enter a valid email address.' ), array( 'back_link' => true ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( '' == $comment_content ) {
|
||||
// return new WP_Error( 'require_valid_comment', __( '<strong>ERROR</strong>: please type a comment.' ), 200 );
|
||||
wp_die( __( '<strong>ERROR</strong>: please type a comment.' ), __( 'ERROR: please type a comment.' ), array( 'back_link' => true ) );
|
||||
}
|
||||
|
||||
$comment_parent = isset( $_POST['comment_parent'] ) ? absint( $_POST['comment_parent'] ) : 0;
|
||||
|
||||
$commentdata = compact(
|
||||
'comment_post_ID',
|
||||
'comment_author',
|
||||
'comment_author_email',
|
||||
'comment_author_url',
|
||||
'comment_content',
|
||||
'comment_type',
|
||||
'comment_parent',
|
||||
'user_ID'
|
||||
);
|
||||
|
||||
$check_max_lengths = wp_check_comment_data_max_lengths( $commentdata );
|
||||
if ( is_wp_error( $check_max_lengths ) ) {
|
||||
return $check_max_lengths;
|
||||
}
|
||||
|
||||
$comment_id = wp_new_comment( wp_slash( $commentdata ), true );
|
||||
if ( is_wp_error( $comment_id ) ) {
|
||||
return $comment_id;
|
||||
}
|
||||
|
||||
if ( ! $comment_id ) {
|
||||
// return new WP_Error( 'comment_save_error', __( '<strong>ERROR</strong>: The comment could not be saved. Please try again later.' ), 500 );
|
||||
wp_die( __( '<strong>ERROR</strong>: The comment could not be saved. Please try again later.' ), __( 'ERROR: The comment could not be saved. Please try again later.' ), array( 'back_link' => true ) );
|
||||
}
|
||||
|
||||
$comment = get_comment( $comment_id );
|
||||
|
||||
do_action( 'set_comment_cookies', $comment, $user );
|
||||
|
||||
if ( $user->exists() ) {
|
||||
wp_set_comment_status( $comment_id, 'approve' );
|
||||
}
|
||||
|
||||
$location = empty( $_POST['redirect_to'] ) ? get_comment_link( $comment_id ) : $_POST['redirect_to'] . '#comment-' . $comment_id;
|
||||
|
||||
$location = apply_filters( 'comment_post_redirect', $location, $comment );
|
||||
|
||||
wp_safe_redirect( $location );
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
endif;
|
||||
|
||||
new SportsPress_Comments_Scheduled_Events();
|
||||
|
||||
@@ -9,136 +9,140 @@
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SportsPress_Conditional_Equations' ) ) :
|
||||
|
||||
/**
|
||||
* Main SportsPress Conditional Equations Class
|
||||
*
|
||||
* @class SportsPress_Conditional_Equations
|
||||
* @version 2.6
|
||||
*/
|
||||
|
||||
class SportsPress_Conditional_Equations {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
// Actions
|
||||
|
||||
// Filters
|
||||
add_filter( 'sportspress_equation_options', array( $this, 'add_options' ) );
|
||||
add_filter( 'sportspress_equation_alter', array( $this, 'alter_equation' ), 10, 2 );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( !defined( 'SP_CONDITIONAL_EQUATIONS_VERSION' ) )
|
||||
define( 'SP_CONDITIONAL_EQUATIONS_VERSION', '2.6' );
|
||||
|
||||
if ( !defined( 'SP_CONDITIONAL_EQUATIONS_URL' ) )
|
||||
define( 'SP_CONDITIONAL_EQUATIONS_URL', plugin_dir_url( __FILE__ ) );
|
||||
|
||||
if ( !defined( 'SP_CONDITIONAL_EQUATIONS_DIR' ) )
|
||||
define( 'SP_CONDITIONAL_EQUATIONS_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add additional options.
|
||||
* Main SportsPress Conditional Equations Class
|
||||
*
|
||||
* @return array
|
||||
* @class SportsPress_Conditional_Equations
|
||||
* @version 2.6
|
||||
*/
|
||||
public function add_options( $options ) {
|
||||
$options[ 'Operators' ]['>'] = '>';
|
||||
$options[ 'Operators' ]['<'] = '<';
|
||||
$options[ 'Operators' ]['=='] = '≡';
|
||||
$options[ 'Operators' ]['!='] = '≠';
|
||||
$options[ 'Operators' ]['>='] = '≥';
|
||||
$options[ 'Operators' ]['<='] = '≤';
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alter.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function alter_equation( $equation, $vars ) {
|
||||
|
||||
// Remove space between equation parts
|
||||
$equation = str_replace( ' ', '', $equation );
|
||||
|
||||
// Find all parentheses with conditional operators
|
||||
$re = '/([^[\(|\)]*[<=>][^[\(|\)]*)/';
|
||||
if ( preg_match_all( $re, $equation, $matches ) ) {
|
||||
|
||||
foreach ( $matches[1] as $match ) {
|
||||
|
||||
// Find which Conditional Operator is used
|
||||
preg_match ( '/[\!\>\=\<]+/' ,$match, $conop );
|
||||
$conop = $conop[0];
|
||||
|
||||
//preg_match ( '/.+?(?=[\>\=\<])/' ,$match, $leftvar );
|
||||
preg_match ( '/.+?(?='.$conop.')/' ,$match, $leftvar );
|
||||
|
||||
//preg_match ( '/(?<=[\>\=\<]).*/' ,$match, $rightvar );
|
||||
preg_match ( '/(?<='.$conop.').*/' ,$match, $rightvar );
|
||||
class SportsPress_Conditional_Equations {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
// Actions
|
||||
|
||||
// Filters
|
||||
add_filter( 'sportspress_equation_options', array( $this, 'add_options' ) );
|
||||
add_filter( 'sportspress_equation_alter', array( $this, 'alter_equation' ), 10, 2 );
|
||||
|
||||
// Check if it is a variable or a number
|
||||
if ( strpos ( $leftvar[0], '$' ) !== FALSE ) {
|
||||
$leftvar = str_replace ( '$', '', $leftvar[0] );
|
||||
$leftvar = $vars[$leftvar];
|
||||
} else {
|
||||
$leftvar = $leftvar[0];
|
||||
}
|
||||
|
||||
// Check if it is a variable or a number
|
||||
if ( strpos ( $rightvar[0], '$' ) !== FALSE ) {
|
||||
$rightvar = str_replace ( '$', '', $rightvar[0] );
|
||||
$rightvar = $vars[$rightvar];
|
||||
} else {
|
||||
$rightvar = $rightvar[0];
|
||||
}
|
||||
|
||||
// Select the correct conditional operator
|
||||
switch ( $conop ) {
|
||||
case '>':
|
||||
$solution = (int) ( $leftvar > $rightvar );
|
||||
break;
|
||||
case '<':
|
||||
$solution = (int) ( $leftvar < $rightvar );
|
||||
break;
|
||||
case '==':
|
||||
$solution = (int) ( $leftvar == $rightvar );
|
||||
break;
|
||||
case '!=':
|
||||
$solution = (int) ( $leftvar != $rightvar );
|
||||
break;
|
||||
case '>=':
|
||||
$solution = (int) ( $leftvar >= $rightvar );
|
||||
break;
|
||||
case '<=':
|
||||
$solution = (int) ( $leftvar <= $rightvar );
|
||||
break;
|
||||
}
|
||||
|
||||
// Replace the result of the conditional sub-equation to the equation
|
||||
$equation = str_replace ( $match, $solution, $equation );
|
||||
}
|
||||
|
||||
}
|
||||
return $equation;
|
||||
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( ! defined( 'SP_CONDITIONAL_EQUATIONS_VERSION' ) ) {
|
||||
define( 'SP_CONDITIONAL_EQUATIONS_VERSION', '2.6' );
|
||||
}
|
||||
|
||||
if ( ! defined( 'SP_CONDITIONAL_EQUATIONS_URL' ) ) {
|
||||
define( 'SP_CONDITIONAL_EQUATIONS_URL', plugin_dir_url( __FILE__ ) );
|
||||
}
|
||||
|
||||
if ( ! defined( 'SP_CONDITIONAL_EQUATIONS_DIR' ) ) {
|
||||
define( 'SP_CONDITIONAL_EQUATIONS_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add additional options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_options( $options ) {
|
||||
$options['Operators']['>'] = '>';
|
||||
$options['Operators']['<'] = '<';
|
||||
$options['Operators']['=='] = '≡';
|
||||
$options['Operators']['!='] = '≠';
|
||||
$options['Operators']['>='] = '≥';
|
||||
$options['Operators']['<='] = '≤';
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alter.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function alter_equation( $equation, $vars ) {
|
||||
|
||||
// Remove space between equation parts
|
||||
$equation = str_replace( ' ', '', $equation );
|
||||
|
||||
// Find all parentheses with conditional operators
|
||||
$re = '/([^[\(|\)]*[<=>][^[\(|\)]*)/';
|
||||
if ( preg_match_all( $re, $equation, $matches ) ) {
|
||||
|
||||
foreach ( $matches[1] as $match ) {
|
||||
|
||||
// Find which Conditional Operator is used
|
||||
preg_match( '/[\!\>\=\<]+/', $match, $conop );
|
||||
$conop = $conop[0];
|
||||
|
||||
// preg_match ( '/.+?(?=[\>\=\<])/' ,$match, $leftvar );
|
||||
preg_match( '/.+?(?=' . $conop . ')/', $match, $leftvar );
|
||||
|
||||
// preg_match ( '/(?<=[\>\=\<]).*/' ,$match, $rightvar );
|
||||
preg_match( '/(?<=' . $conop . ').*/', $match, $rightvar );
|
||||
|
||||
// Check if it is a variable or a number
|
||||
if ( strpos( $leftvar[0], '$' ) !== false ) {
|
||||
$leftvar = str_replace( '$', '', $leftvar[0] );
|
||||
$leftvar = $vars[ $leftvar ];
|
||||
} else {
|
||||
$leftvar = $leftvar[0];
|
||||
}
|
||||
|
||||
// Check if it is a variable or a number
|
||||
if ( strpos( $rightvar[0], '$' ) !== false ) {
|
||||
$rightvar = str_replace( '$', '', $rightvar[0] );
|
||||
$rightvar = $vars[ $rightvar ];
|
||||
} else {
|
||||
$rightvar = $rightvar[0];
|
||||
}
|
||||
|
||||
// Select the correct conditional operator
|
||||
switch ( $conop ) {
|
||||
case '>':
|
||||
$solution = (int) ( $leftvar > $rightvar );
|
||||
break;
|
||||
case '<':
|
||||
$solution = (int) ( $leftvar < $rightvar );
|
||||
break;
|
||||
case '==':
|
||||
$solution = (int) ( $leftvar == $rightvar );
|
||||
break;
|
||||
case '!=':
|
||||
$solution = (int) ( $leftvar != $rightvar );
|
||||
break;
|
||||
case '>=':
|
||||
$solution = (int) ( $leftvar >= $rightvar );
|
||||
break;
|
||||
case '<=':
|
||||
$solution = (int) ( $leftvar <= $rightvar );
|
||||
break;
|
||||
}
|
||||
|
||||
// Replace the result of the conditional sub-equation to the equation
|
||||
$equation = str_replace( $match, $solution, $equation );
|
||||
}
|
||||
}
|
||||
return $equation;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
@@ -9,115 +9,132 @@
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SportsPress_Countdowns' ) ) :
|
||||
|
||||
/**
|
||||
* Main SportsPress Countdowns Class
|
||||
*
|
||||
* @class SportsPress_Countdowns
|
||||
* @version 2.7
|
||||
*/
|
||||
class SportsPress_Countdowns {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
// Actions
|
||||
add_action( 'sportspress_widgets', array( $this, 'include_widgets' ) );
|
||||
|
||||
// Filters
|
||||
add_filter( 'sportspress_shortcodes', array( $this, 'add_shortcodes' ) );
|
||||
add_filter( 'sportspress_event_settings', array( $this, 'add_settings' ) );
|
||||
add_filter( 'sportspress_text', array( $this, 'add_text_options' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( !defined( 'SP_COUNTDOWNS_VERSION' ) )
|
||||
define( 'SP_COUNTDOWNS_VERSION', '2.7' );
|
||||
|
||||
if ( !defined( 'SP_COUNTDOWNS_URL' ) )
|
||||
define( 'SP_COUNTDOWNS_URL', plugin_dir_url( __FILE__ ) );
|
||||
|
||||
if ( !defined( 'SP_COUNTDOWNS_DIR' ) )
|
||||
define( 'SP_COUNTDOWNS_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add widgets.
|
||||
* Main SportsPress Countdowns Class
|
||||
*
|
||||
* @return array
|
||||
* @class SportsPress_Countdowns
|
||||
* @version 2.7
|
||||
*/
|
||||
public function include_widgets() {
|
||||
include_once( SP()->plugin_path() . '/includes/widgets/class-sp-widget-countdown.php' );
|
||||
}
|
||||
class SportsPress_Countdowns {
|
||||
|
||||
/**
|
||||
* Add shortcodes.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_shortcodes( $shortcodes ) {
|
||||
$shortcodes['event'][] = 'countdown';
|
||||
return $shortcodes;
|
||||
}
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
/**
|
||||
* Add settings.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_settings( $settings ) {
|
||||
$settings = array_merge( $settings,
|
||||
array(
|
||||
array( 'title' => __( 'Countdown', 'sportspress' ), 'type' => 'title', 'id' => 'countdown_options' ),
|
||||
),
|
||||
// Actions
|
||||
add_action( 'sportspress_widgets', array( $this, 'include_widgets' ) );
|
||||
|
||||
apply_filters( 'sportspress_countdown_options', array(
|
||||
// Filters
|
||||
add_filter( 'sportspress_shortcodes', array( $this, 'add_shortcodes' ) );
|
||||
add_filter( 'sportspress_event_settings', array( $this, 'add_settings' ) );
|
||||
add_filter( 'sportspress_text', array( $this, 'add_text_options' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( ! defined( 'SP_COUNTDOWNS_VERSION' ) ) {
|
||||
define( 'SP_COUNTDOWNS_VERSION', '2.7' );
|
||||
}
|
||||
|
||||
if ( ! defined( 'SP_COUNTDOWNS_URL' ) ) {
|
||||
define( 'SP_COUNTDOWNS_URL', plugin_dir_url( __FILE__ ) );
|
||||
}
|
||||
|
||||
if ( ! defined( 'SP_COUNTDOWNS_DIR' ) ) {
|
||||
define( 'SP_COUNTDOWNS_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add widgets.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function include_widgets() {
|
||||
include_once SP()->plugin_path() . '/includes/widgets/class-sp-widget-countdown.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Add shortcodes.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_shortcodes( $shortcodes ) {
|
||||
$shortcodes['event'][] = 'countdown';
|
||||
return $shortcodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add settings.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_settings( $settings ) {
|
||||
$settings = array_merge(
|
||||
$settings,
|
||||
array(
|
||||
'title' => __( 'Display', 'sportspress' ),
|
||||
'desc' => __( 'Logos', 'sportspress' ),
|
||||
'id' => 'sportspress_countdown_show_logos',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'start',
|
||||
array(
|
||||
'title' => __( 'Countdown', 'sportspress' ),
|
||||
'type' => 'title',
|
||||
'id' => 'countdown_options',
|
||||
),
|
||||
),
|
||||
apply_filters(
|
||||
'sportspress_countdown_options',
|
||||
array(
|
||||
array(
|
||||
'title' => __( 'Display', 'sportspress' ),
|
||||
'desc' => __( 'Logos', 'sportspress' ),
|
||||
'id' => 'sportspress_countdown_show_logos',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'start',
|
||||
),
|
||||
array(
|
||||
'desc' => __( 'Featured Image', 'sportspress' ),
|
||||
'id' => 'sportspress_countdown_show_thumbnail',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'end',
|
||||
),
|
||||
)
|
||||
),
|
||||
array(
|
||||
'desc' => __( 'Featured Image', 'sportspress' ),
|
||||
'id' => 'sportspress_countdown_show_thumbnail',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'end',
|
||||
),
|
||||
)),
|
||||
array(
|
||||
'type' => 'sectionend',
|
||||
'id' => 'countdown_options',
|
||||
),
|
||||
)
|
||||
);
|
||||
return $settings;
|
||||
}
|
||||
|
||||
array(
|
||||
array( 'type' => 'sectionend', 'id' => 'countdown_options' ),
|
||||
)
|
||||
);
|
||||
return $settings;
|
||||
/**
|
||||
* Add text options
|
||||
*/
|
||||
public function add_text_options( $options = array() ) {
|
||||
return array_merge(
|
||||
$options,
|
||||
array(
|
||||
__( 'days', 'sportspress' ),
|
||||
__( 'hrs', 'sportspress' ),
|
||||
__( 'mins', 'sportspress' ),
|
||||
__( 'secs', 'sportspress' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add text options
|
||||
*/
|
||||
public function add_text_options( $options = array() ) {
|
||||
return array_merge( $options, array(
|
||||
__( 'days', 'sportspress' ),
|
||||
__( 'hrs', 'sportspress' ),
|
||||
__( 'mins', 'sportspress' ),
|
||||
__( 'secs', 'sportspress' ),
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
@@ -9,61 +9,66 @@
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SportsPress_Default_Nationality' ) ) :
|
||||
|
||||
/**
|
||||
* Main SportsPress Default Nationality Class
|
||||
*
|
||||
* @class SportsPress_Default_Nationality
|
||||
* @version 2.6.18
|
||||
*/
|
||||
class SportsPress_Default_Nationality {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Main SportsPress Default Nationality Class
|
||||
*
|
||||
* @class SportsPress_Default_Nationality
|
||||
* @version 2.6.18
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
class SportsPress_Default_Nationality {
|
||||
|
||||
add_filter( 'sportspress_general_options', array( $this, 'add_general_options' ) );
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
add_filter( 'sportspress_general_options', array( $this, 'add_general_options' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( ! defined( 'SP_DEFAULT_NATIONALITY_VERSION' ) ) {
|
||||
define( 'SP_DEFAULT_NATIONALITY_VERSION', '2.6.18' );
|
||||
}
|
||||
|
||||
if ( ! defined( 'SP_DEFAULT_NATIONALITY_URL' ) ) {
|
||||
define( 'SP_DEFAULT_NATIONALITY_URL', plugin_dir_url( __FILE__ ) );
|
||||
}
|
||||
|
||||
if ( ! defined( 'SP_DEFAULT_NATIONALITY_DIR' ) ) {
|
||||
define( 'SP_DEFAULT_NATIONALITY_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add option to SportsPress General Settings.
|
||||
*/
|
||||
public function add_general_options( $settings ) {
|
||||
$countries[''] = __( '— None —', 'sportspress' );
|
||||
$sp_countries = new SP_Countries();
|
||||
$countries = array_merge( $countries, $sp_countries->countries );
|
||||
|
||||
$settings[] = array(
|
||||
'title' => __( 'Default Nationality', 'sportspress' ),
|
||||
'id' => 'sportspress_default_nationality',
|
||||
'default' => '',
|
||||
'type' => 'select',
|
||||
'options' => $countries,
|
||||
);
|
||||
return $settings;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( !defined( 'SP_DEFAULT_NATIONALITY_VERSION' ) )
|
||||
define( 'SP_DEFAULT_NATIONALITY_VERSION', '2.6.18' );
|
||||
|
||||
if ( !defined( 'SP_DEFAULT_NATIONALITY_URL' ) )
|
||||
define( 'SP_DEFAULT_NATIONALITY_URL', plugin_dir_url( __FILE__ ) );
|
||||
|
||||
if ( !defined( 'SP_DEFAULT_NATIONALITY_DIR' ) )
|
||||
define( 'SP_DEFAULT_NATIONALITY_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add option to SportsPress General Settings.
|
||||
*/
|
||||
public function add_general_options( $settings ) {
|
||||
$countries[''] = __( '— None —', 'sportspress' );
|
||||
$sp_countries = new SP_Countries();
|
||||
$countries = array_merge ( $countries, $sp_countries->countries );
|
||||
|
||||
$settings[]=array(
|
||||
'title' => __( 'Default Nationality', 'sportspress' ),
|
||||
'id' => 'sportspress_default_nationality',
|
||||
'default' => '',
|
||||
'type' => 'select',
|
||||
'options' => $countries,
|
||||
);
|
||||
return $settings;
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
new SportsPress_Default_Nationality();
|
||||
|
||||
@@ -9,138 +9,149 @@
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SportsPress_Event_Specs' ) ) :
|
||||
|
||||
/**
|
||||
* Main SportsPress Event Specs Class
|
||||
*
|
||||
* @class SportsPress_Event_Specs
|
||||
* @version 2.6.15
|
||||
*/
|
||||
class SportsPress_Event_Specs {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
// Actions
|
||||
add_action( 'init', array( $this, 'register_post_type' ) );
|
||||
add_action( 'sportspress_config_page', array( $this, 'sp_specs_config' ), 9 );
|
||||
add_action( 'sportspress_include_post_type_handlers', array( $this, 'include_post_type_handler' ) );
|
||||
add_action( 'sportspress_event_list_head_row', array( $this, 'event_list_head_row' ), 11 );
|
||||
add_action( 'sportspress_event_list_row', array( $this, 'event_list_row' ), 11, 2 );
|
||||
add_action( 'sportspress_event_blocks_after', array( $this, 'event_blocks_after' ), 11, 2 );
|
||||
|
||||
// Filters
|
||||
add_filter( 'sportspress_meta_boxes', array( $this, 'add_meta_boxes' ) );
|
||||
add_filter( 'sportspress_screen_ids', array( $this, 'screen_ids' ) );
|
||||
add_filter( 'sportspress_config_types', array( $this, 'add_post_type' ) );
|
||||
add_filter( 'sportspress_event_details', array( $this, 'event_details' ), 10, 2 );
|
||||
add_filter( 'sportspress_calendar_columns', array( $this, 'calendar_columns' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( !defined( 'SP_EVENT_SPECS_VERSION' ) )
|
||||
define( 'SP_EVENT_SPECS_VERSION', '2.6.15' );
|
||||
|
||||
if ( !defined( 'SP_EVENT_SPECS_URL' ) )
|
||||
define( 'SP_EVENT_SPECS_URL', plugin_dir_url( __FILE__ ) );
|
||||
|
||||
if ( !defined( 'SP_EVENT_SPECS_DIR' ) )
|
||||
define( 'SP_EVENT_SPECS_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register event specs post type
|
||||
*/
|
||||
public static function register_post_type() {
|
||||
register_post_type( 'sp_spec',
|
||||
apply_filters( 'sportspress_register_post_type_spec',
|
||||
array(
|
||||
'labels' => array(
|
||||
'name' => __( 'Event Specs', 'sportspress' ),
|
||||
'singular_name' => __( 'Event Spec', 'sportspress' ),
|
||||
'add_new_item' => __( 'Add New Event Spec', 'sportspress' ),
|
||||
'edit_item' => __( 'Edit Event Spec', 'sportspress' ),
|
||||
'new_item' => __( 'New', 'sportspress' ),
|
||||
'view_item' => __( 'View', 'sportspress' ),
|
||||
'search_items' => __( 'Search', 'sportspress' ),
|
||||
'not_found' => __( 'No results found.', 'sportspress' ),
|
||||
'not_found_in_trash' => __( 'No results found.', 'sportspress' ),
|
||||
),
|
||||
'public' => false,
|
||||
'show_ui' => true,
|
||||
'capability_type' => 'sp_config',
|
||||
'map_meta_cap' => true,
|
||||
'publicly_queryable' => false,
|
||||
'exclude_from_search' => true,
|
||||
'hierarchical' => false,
|
||||
'supports' => array( 'title', 'page-attributes', 'excerpt' ),
|
||||
'has_archive' => false,
|
||||
'show_in_nav_menus' => false,
|
||||
'can_export' => false,
|
||||
'show_in_menu' => false,
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add screen ids.
|
||||
* Main SportsPress Event Specs Class
|
||||
*
|
||||
* @return array
|
||||
* @class SportsPress_Event_Specs
|
||||
* @version 2.6.15
|
||||
*/
|
||||
public function screen_ids( $ids ) {
|
||||
return array_merge( $ids, array(
|
||||
'edit-sp_spec',
|
||||
'sp_spec',
|
||||
) );
|
||||
}
|
||||
|
||||
public static function add_post_type( $post_types = array() ) {
|
||||
$post_types[] = 'sp_spec';
|
||||
return $post_types;
|
||||
}
|
||||
class SportsPress_Event_Specs {
|
||||
|
||||
/**
|
||||
* Conditonally load the class and functions only needed when viewing this post type.
|
||||
*/
|
||||
public function include_post_type_handler() {
|
||||
include_once( SP()->plugin_path() . '/includes/admin/post-types/class-sp-admin-cpt-spec.php' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Display Event Specs Table at Config Page
|
||||
* @return null
|
||||
*/
|
||||
public function sp_specs_config() {
|
||||
?>
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
// Actions
|
||||
add_action( 'init', array( $this, 'register_post_type' ) );
|
||||
add_action( 'sportspress_config_page', array( $this, 'sp_specs_config' ), 9 );
|
||||
add_action( 'sportspress_include_post_type_handlers', array( $this, 'include_post_type_handler' ) );
|
||||
add_action( 'sportspress_event_list_head_row', array( $this, 'event_list_head_row' ), 11 );
|
||||
add_action( 'sportspress_event_list_row', array( $this, 'event_list_row' ), 11, 2 );
|
||||
add_action( 'sportspress_event_blocks_after', array( $this, 'event_blocks_after' ), 11, 2 );
|
||||
|
||||
// Filters
|
||||
add_filter( 'sportspress_meta_boxes', array( $this, 'add_meta_boxes' ) );
|
||||
add_filter( 'sportspress_screen_ids', array( $this, 'screen_ids' ) );
|
||||
add_filter( 'sportspress_config_types', array( $this, 'add_post_type' ) );
|
||||
add_filter( 'sportspress_event_details', array( $this, 'event_details' ), 10, 2 );
|
||||
add_filter( 'sportspress_calendar_columns', array( $this, 'calendar_columns' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( ! defined( 'SP_EVENT_SPECS_VERSION' ) ) {
|
||||
define( 'SP_EVENT_SPECS_VERSION', '2.6.15' );
|
||||
}
|
||||
|
||||
if ( ! defined( 'SP_EVENT_SPECS_URL' ) ) {
|
||||
define( 'SP_EVENT_SPECS_URL', plugin_dir_url( __FILE__ ) );
|
||||
}
|
||||
|
||||
if ( ! defined( 'SP_EVENT_SPECS_DIR' ) ) {
|
||||
define( 'SP_EVENT_SPECS_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register event specs post type
|
||||
*/
|
||||
public static function register_post_type() {
|
||||
register_post_type(
|
||||
'sp_spec',
|
||||
apply_filters(
|
||||
'sportspress_register_post_type_spec',
|
||||
array(
|
||||
'labels' => array(
|
||||
'name' => __( 'Event Specs', 'sportspress' ),
|
||||
'singular_name' => __( 'Event Spec', 'sportspress' ),
|
||||
'add_new_item' => __( 'Add New Event Spec', 'sportspress' ),
|
||||
'edit_item' => __( 'Edit Event Spec', 'sportspress' ),
|
||||
'new_item' => __( 'New', 'sportspress' ),
|
||||
'view_item' => __( 'View', 'sportspress' ),
|
||||
'search_items' => __( 'Search', 'sportspress' ),
|
||||
'not_found' => __( 'No results found.', 'sportspress' ),
|
||||
'not_found_in_trash' => __( 'No results found.', 'sportspress' ),
|
||||
),
|
||||
'public' => false,
|
||||
'show_ui' => true,
|
||||
'capability_type' => 'sp_config',
|
||||
'map_meta_cap' => true,
|
||||
'publicly_queryable' => false,
|
||||
'exclude_from_search' => true,
|
||||
'hierarchical' => false,
|
||||
'supports' => array( 'title', 'page-attributes', 'excerpt' ),
|
||||
'has_archive' => false,
|
||||
'show_in_nav_menus' => false,
|
||||
'can_export' => false,
|
||||
'show_in_menu' => false,
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add screen ids.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function screen_ids( $ids ) {
|
||||
return array_merge(
|
||||
$ids,
|
||||
array(
|
||||
'edit-sp_spec',
|
||||
'sp_spec',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static function add_post_type( $post_types = array() ) {
|
||||
$post_types[] = 'sp_spec';
|
||||
return $post_types;
|
||||
}
|
||||
|
||||
/**
|
||||
* Conditonally load the class and functions only needed when viewing this post type.
|
||||
*/
|
||||
public function include_post_type_handler() {
|
||||
include_once SP()->plugin_path() . '/includes/admin/post-types/class-sp-admin-cpt-spec.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Display Event Specs Table at Config Page
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function sp_specs_config() {
|
||||
?>
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<?php
|
||||
$args = array(
|
||||
'post_type' => 'sp_spec',
|
||||
'numberposts' => -1,
|
||||
'post_type' => 'sp_spec',
|
||||
'numberposts' => -1,
|
||||
'posts_per_page' => -1,
|
||||
'orderby' => 'menu_order',
|
||||
'order' => 'ASC'
|
||||
'orderby' => 'menu_order',
|
||||
'order' => 'ASC',
|
||||
);
|
||||
$data = get_posts( $args );
|
||||
?>
|
||||
<tr valign="top">
|
||||
<th scope="row" class="titledesc">
|
||||
<?php _e( 'Event Specs', 'sportspress' ) ?>
|
||||
<?php _e( 'Event Specs', 'sportspress' ); ?>
|
||||
<p class="description"><?php _e( 'Add more details to an event.', 'sportspress' ); ?></p>
|
||||
</th>
|
||||
<td class="forminp">
|
||||
<td class="forminp">
|
||||
<table class="widefat sp-admin-config-table">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -150,14 +161,25 @@ class SportsPress_Event_Specs {
|
||||
<th scope="col" class="edit"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<?php if ( $data ): $i = 0; foreach ( $data as $row ): ?>
|
||||
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
|
||||
<?php
|
||||
if ( $data ) :
|
||||
$i = 0; foreach ( $data as $row ) :
|
||||
?>
|
||||
<tr
|
||||
<?php
|
||||
if ( $i % 2 == 0 ) {
|
||||
echo ' class="alternate"';}
|
||||
?>
|
||||
>
|
||||
<td class="row-title"><?php echo $row->post_title; ?></td>
|
||||
<td><code><?php echo $row->post_name; ?></code></td>
|
||||
<td><p class="description"><?php echo $row->post_excerpt; ?></p></td>
|
||||
<td class="edit"><a class="button" href="<?php echo get_edit_post_link( $row->ID ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></s></td>
|
||||
</tr>
|
||||
<?php $i++; endforeach; else: ?>
|
||||
<?php
|
||||
$i++;
|
||||
endforeach; else :
|
||||
?>
|
||||
<tr class="alternate">
|
||||
<td colspan="4"><?php _e( 'No results found.', 'sportspress' ); ?></td>
|
||||
</tr>
|
||||
@@ -172,117 +194,121 @@ class SportsPress_Event_Specs {
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php
|
||||
}
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Add meta boxes.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_meta_boxes( $meta_boxes ) {
|
||||
$meta_boxes['sp_spec'] = array(
|
||||
/**
|
||||
* Add meta boxes.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_meta_boxes( $meta_boxes ) {
|
||||
$meta_boxes['sp_spec'] = array(
|
||||
'details' => array(
|
||||
'title' => __( 'Specs', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Spec_Details::save',
|
||||
'output' => 'SP_Meta_Box_Spec_Details::output',
|
||||
'context' => 'normal',
|
||||
'title' => __( 'Specs', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Spec_Details::save',
|
||||
'output' => 'SP_Meta_Box_Spec_Details::output',
|
||||
'context' => 'normal',
|
||||
'priority' => 'high',
|
||||
),
|
||||
);
|
||||
$meta_boxes['sp_event']['specs'] = array(
|
||||
'title' => __( 'Specs', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Event_Specs::save',
|
||||
'output' => 'SP_Meta_Box_Event_Specs::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
);
|
||||
return $meta_boxes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add event details.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function event_details ( $data, $id ) {
|
||||
|
||||
$event = new SP_Event( $id );
|
||||
$meta_boxes['sp_event']['specs'] = array(
|
||||
'title' => __( 'Specs', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Event_Specs::save',
|
||||
'output' => 'SP_Meta_Box_Event_Specs::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
);
|
||||
return $meta_boxes;
|
||||
}
|
||||
|
||||
$specs_before = $event->specs( true );
|
||||
$specs_after = $event->specs( false );
|
||||
|
||||
$data = array_merge( $specs_before, $data, $specs_after );
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add calendar columns.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function calendar_columns( $columns = array() ) {
|
||||
$columns['event_specs'] = __( 'Event Specs', 'sportspress' );
|
||||
return $columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Event list head row.
|
||||
*/
|
||||
public function event_list_head_row( $usecolumns = array() ) {
|
||||
if ( sp_column_active( $usecolumns, 'event_specs' ) ) {
|
||||
$spec_labels = (array)sp_get_var_labels( 'sp_spec', null, false );
|
||||
/**
|
||||
* Add event details.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function event_details( $data, $id ) {
|
||||
|
||||
if ( empty( $spec_labels ) ) return;
|
||||
$event = new SP_Event( $id );
|
||||
|
||||
foreach ( $spec_labels as $spec_label ) {
|
||||
?>
|
||||
$specs_before = $event->specs( true );
|
||||
$specs_after = $event->specs( false );
|
||||
|
||||
$data = array_merge( $specs_before, $data, $specs_after );
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add calendar columns.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function calendar_columns( $columns = array() ) {
|
||||
$columns['event_specs'] = __( 'Event Specs', 'sportspress' );
|
||||
return $columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Event list head row.
|
||||
*/
|
||||
public function event_list_head_row( $usecolumns = array() ) {
|
||||
if ( sp_column_active( $usecolumns, 'event_specs' ) ) {
|
||||
$spec_labels = (array) sp_get_var_labels( 'sp_spec', null, false );
|
||||
|
||||
if ( empty( $spec_labels ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ( $spec_labels as $spec_label ) {
|
||||
?>
|
||||
<th class="data-specs">
|
||||
<?php echo $spec_label; ?>
|
||||
</th>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event list row.
|
||||
*/
|
||||
public function event_list_row( $event, $usecolumns = array() ) {
|
||||
if ( sp_column_active( $usecolumns, 'event_specs' ) ) {
|
||||
$event = new SP_Event( $event );
|
||||
$specs = $event->specs( false );
|
||||
$spec_labels = (array)sp_get_var_labels( 'sp_spec', null, false );
|
||||
/**
|
||||
* Event list row.
|
||||
*/
|
||||
public function event_list_row( $event, $usecolumns = array() ) {
|
||||
if ( sp_column_active( $usecolumns, 'event_specs' ) ) {
|
||||
$event = new SP_Event( $event );
|
||||
$specs = $event->specs( false );
|
||||
$spec_labels = (array) sp_get_var_labels( 'sp_spec', null, false );
|
||||
|
||||
foreach ( $spec_labels as $spec_label ) {
|
||||
?>
|
||||
foreach ( $spec_labels as $spec_label ) {
|
||||
?>
|
||||
<td class="data-spec">
|
||||
<?php if ( isset( $specs[$spec_label] ) ) {
|
||||
echo $specs[$spec_label];
|
||||
}else{
|
||||
<?php
|
||||
if ( isset( $specs[ $spec_label ] ) ) {
|
||||
echo $specs[ $spec_label ];
|
||||
} else {
|
||||
echo '-';
|
||||
}?>
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Event Specs after default template of Event blocks is loaded.
|
||||
*/
|
||||
public function event_blocks_after( $event, $usecolumns = array() ) {
|
||||
if ( sp_column_active( $usecolumns, 'event_specs' ) ) {
|
||||
$event = new SP_Event( $event );
|
||||
$specs = $event->specs( false );
|
||||
$spec_labels = (array) sp_get_var_labels( 'sp_spec', null, false );
|
||||
foreach ( $specs as $spec_label => $spec_value ) {
|
||||
echo '<div class="sp_event_spec"><span class="sp_event_spec_label">' . $spec_label . ':</span><span class="sp_event_spec_value"> ' . $spec_value . '</span></div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Event Specs after default template of Event blocks is loaded.
|
||||
*/
|
||||
public function event_blocks_after( $event, $usecolumns = array() ) {
|
||||
if ( sp_column_active( $usecolumns, 'event_specs' ) ) {
|
||||
$event = new SP_Event( $event );
|
||||
$specs = $event->specs( false );
|
||||
$spec_labels = (array)sp_get_var_labels( 'sp_spec', null, false );
|
||||
foreach ( $specs as $spec_label => $spec_value ) {
|
||||
echo '<div class="sp_event_spec"><span class="sp_event_spec_label">'.$spec_label.':</span><span class="sp_event_spec_value"> '.$spec_value.'</span></div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
@@ -9,73 +9,85 @@
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SportsPress_Event_Status' ) ) :
|
||||
|
||||
/**
|
||||
* Main SportsPress Event Status Class
|
||||
*
|
||||
* @class SportsPress_Event_Status
|
||||
* @version 2.1
|
||||
*/
|
||||
class SportsPress_Event_Status {
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* Main SportsPress Event Status Class
|
||||
*
|
||||
* @class SportsPress_Event_Status
|
||||
* @version 2.1
|
||||
*/
|
||||
public $statuses = array();
|
||||
class SportsPress_Event_Status {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $statuses = array();
|
||||
|
||||
add_action( 'init', array( $this, 'get_statuses' ) );
|
||||
add_action( 'post_submitbox_misc_actions', array( $this, 'section' ) );
|
||||
add_action( 'sportspress_process_sp_event_meta', array( $this, 'save' ), 10, 1 );
|
||||
add_filter( 'sportspress_event_time', array( $this, 'filter' ), 10, 2 );
|
||||
add_filter( 'sportspress_event_time_admin', array( $this, 'filter' ), 10, 2 );
|
||||
add_filter( 'sportspress_main_results_or_time', array( $this, 'filter_array' ), 10, 2 );
|
||||
add_filter( 'sportspress_event_blocks_team_result_or_time', array( $this, 'filter_array' ), 10, 2 );
|
||||
}
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( !defined( 'SP_EVENT_STATUS_VERSION' ) )
|
||||
define( 'SP_EVENT_STATUS_VERSION', '2.1' );
|
||||
add_action( 'init', array( $this, 'get_statuses' ) );
|
||||
add_action( 'post_submitbox_misc_actions', array( $this, 'section' ) );
|
||||
add_action( 'sportspress_process_sp_event_meta', array( $this, 'save' ), 10, 1 );
|
||||
add_filter( 'sportspress_event_time', array( $this, 'filter' ), 10, 2 );
|
||||
add_filter( 'sportspress_event_time_admin', array( $this, 'filter' ), 10, 2 );
|
||||
add_filter( 'sportspress_main_results_or_time', array( $this, 'filter_array' ), 10, 2 );
|
||||
add_filter( 'sportspress_event_blocks_team_result_or_time', array( $this, 'filter_array' ), 10, 2 );
|
||||
}
|
||||
|
||||
if ( !defined( 'SP_EVENT_STATUS_URL' ) )
|
||||
define( 'SP_EVENT_STATUS_URL', plugin_dir_url( __FILE__ ) );
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( ! defined( 'SP_EVENT_STATUS_VERSION' ) ) {
|
||||
define( 'SP_EVENT_STATUS_VERSION', '2.1' );
|
||||
}
|
||||
|
||||
if ( !defined( 'SP_EVENT_STATUS_DIR' ) )
|
||||
define( 'SP_EVENT_STATUS_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
if ( ! defined( 'SP_EVENT_STATUS_URL' ) ) {
|
||||
define( 'SP_EVENT_STATUS_URL', plugin_dir_url( __FILE__ ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define statuses.
|
||||
*/
|
||||
public function get_statuses() {
|
||||
$this->statuses = apply_filters( 'sportspress_event_statuses', array(
|
||||
'ok' => __( 'On time', 'sportspress' ),
|
||||
'tbd' => __( 'TBD', 'sportspress' ),
|
||||
'postponed' => __( 'Postponed', 'sportspress' ),
|
||||
'cancelled' => __( 'Canceled', 'sportspress' ),
|
||||
) );
|
||||
}
|
||||
if ( ! defined( 'SP_EVENT_STATUS_DIR' ) ) {
|
||||
define( 'SP_EVENT_STATUS_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add status section to submit box.
|
||||
*/
|
||||
public function section() {
|
||||
if ( 'sp_event' !== get_post_type() ) return;
|
||||
$status = get_post_meta( get_the_ID(), 'sp_status', true );
|
||||
if ( ! $status ) $status = 'ok';
|
||||
?>
|
||||
/**
|
||||
* Define statuses.
|
||||
*/
|
||||
public function get_statuses() {
|
||||
$this->statuses = apply_filters(
|
||||
'sportspress_event_statuses',
|
||||
array(
|
||||
'ok' => __( 'On time', 'sportspress' ),
|
||||
'tbd' => __( 'TBD', 'sportspress' ),
|
||||
'postponed' => __( 'Postponed', 'sportspress' ),
|
||||
'cancelled' => __( 'Canceled', 'sportspress' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add status section to submit box.
|
||||
*/
|
||||
public function section() {
|
||||
if ( 'sp_event' !== get_post_type() ) {
|
||||
return;
|
||||
}
|
||||
$status = get_post_meta( get_the_ID(), 'sp_status', true );
|
||||
if ( ! $status ) {
|
||||
$status = 'ok';
|
||||
}
|
||||
?>
|
||||
<div class="misc-pub-section sp-pub-event-status">
|
||||
<span class="sp-event-status"><?php _e( 'Time:', 'sportspress' ); ?> <strong class="sp-event-status-display" data-sp-event-status="<?php echo $status; ?>"><?php echo $this->statuses[ $status ]; ?></strong></span>
|
||||
<a href="#" class="sp-edit-event-status hide-if-no-js"><span aria-hidden="true"><?php _e( 'Edit', 'sportspress' ); ?></span> <span class="screen-reader-text"><?php _e( 'Edit status' ); ?></span></a>
|
||||
@@ -89,36 +101,44 @@ class SportsPress_Event_Status {
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Save status option.
|
||||
*/
|
||||
public function save( $post_id ) {
|
||||
update_post_meta( $post_id, 'sp_status', sp_array_value( $_POST, 'sp_status', 'ok' ) );
|
||||
}
|
||||
/**
|
||||
* Save status option.
|
||||
*/
|
||||
public function save( $post_id ) {
|
||||
update_post_meta( $post_id, 'sp_status', sp_array_value( $_POST, 'sp_status', 'ok' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Event time filter.
|
||||
*/
|
||||
public function filter( $time, $post_id = 0 ) {
|
||||
if ( ! $post_id ) $post_id = get_the_ID();
|
||||
$status = get_post_meta( $post_id, 'sp_status', true );
|
||||
if ( ! $status || 'ok' === $status || ! array_key_exists( $status, $this->statuses ) ) return $time;
|
||||
return $this->statuses[ $status ];
|
||||
}
|
||||
/**
|
||||
* Event time filter.
|
||||
*/
|
||||
public function filter( $time, $post_id = 0 ) {
|
||||
if ( ! $post_id ) {
|
||||
$post_id = get_the_ID();
|
||||
}
|
||||
$status = get_post_meta( $post_id, 'sp_status', true );
|
||||
if ( ! $status || 'ok' === $status || ! array_key_exists( $status, $this->statuses ) ) {
|
||||
return $time;
|
||||
}
|
||||
return $this->statuses[ $status ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Event time array filter.
|
||||
*/
|
||||
public function filter_array( $array, $post_id = 0 ) {
|
||||
if ( ! $post_id ) $post_id = get_the_ID();
|
||||
$status = get_post_meta( $post_id, 'sp_status', true );
|
||||
if ( ! $status || 'ok' === $status || ! array_key_exists( $status, $this->statuses ) ) return $array;
|
||||
return array( $this->statuses[ $status ] );
|
||||
/**
|
||||
* Event time array filter.
|
||||
*/
|
||||
public function filter_array( $array, $post_id = 0 ) {
|
||||
if ( ! $post_id ) {
|
||||
$post_id = get_the_ID();
|
||||
}
|
||||
$status = get_post_meta( $post_id, 'sp_status', true );
|
||||
if ( ! $status || 'ok' === $status || ! array_key_exists( $status, $this->statuses ) ) {
|
||||
return $array;
|
||||
}
|
||||
return array( $this->statuses[ $status ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
@@ -9,59 +9,64 @@
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SportsPress_Event_Videos' ) ) :
|
||||
|
||||
/**
|
||||
* Main SportsPress Event Videos Class
|
||||
*
|
||||
* @class SportsPress_Event_Videos
|
||||
* @version 1.8.3
|
||||
*/
|
||||
class SportsPress_Event_Videos {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
// Filters
|
||||
add_filter( 'sportspress_meta_boxes', array( $this, 'add_meta_box' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( !defined( 'SP_EVENT_VIDEOS_VERSION' ) )
|
||||
define( 'SP_EVENT_VIDEOS_VERSION', '1.8.3' );
|
||||
|
||||
if ( !defined( 'SP_EVENT_VIDEOS_URL' ) )
|
||||
define( 'SP_EVENT_VIDEOS_URL', plugin_dir_url( __FILE__ ) );
|
||||
|
||||
if ( !defined( 'SP_EVENT_VIDEOS_DIR' ) )
|
||||
define( 'SP_EVENT_VIDEOS_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add meta box to events.
|
||||
* Main SportsPress Event Videos Class
|
||||
*
|
||||
* @return array
|
||||
* @class SportsPress_Event_Videos
|
||||
* @version 1.8.3
|
||||
*/
|
||||
public function add_meta_box( $meta_boxes ) {
|
||||
$meta_boxes['sp_event']['video'] = array(
|
||||
'title' => __( 'Video', 'sportspress' ),
|
||||
'output' => 'SP_Meta_Box_Event_Video::output',
|
||||
'save' => 'SP_Meta_Box_Event_Video::save',
|
||||
'context' => 'side',
|
||||
'priority' => 'low',
|
||||
);
|
||||
return $meta_boxes;
|
||||
class SportsPress_Event_Videos {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
// Filters
|
||||
add_filter( 'sportspress_meta_boxes', array( $this, 'add_meta_box' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( ! defined( 'SP_EVENT_VIDEOS_VERSION' ) ) {
|
||||
define( 'SP_EVENT_VIDEOS_VERSION', '1.8.3' );
|
||||
}
|
||||
|
||||
if ( ! defined( 'SP_EVENT_VIDEOS_URL' ) ) {
|
||||
define( 'SP_EVENT_VIDEOS_URL', plugin_dir_url( __FILE__ ) );
|
||||
}
|
||||
|
||||
if ( ! defined( 'SP_EVENT_VIDEOS_DIR' ) ) {
|
||||
define( 'SP_EVENT_VIDEOS_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add meta box to events.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_meta_box( $meta_boxes ) {
|
||||
$meta_boxes['sp_event']['video'] = array(
|
||||
'title' => __( 'Video', 'sportspress' ),
|
||||
'output' => 'SP_Meta_Box_Event_Video::output',
|
||||
'save' => 'SP_Meta_Box_Event_Video::save',
|
||||
'context' => 'side',
|
||||
'priority' => 'low',
|
||||
);
|
||||
return $meta_boxes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
@@ -9,94 +9,102 @@
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SportsPress_Gutenberg' ) ) :
|
||||
|
||||
/**
|
||||
* Main SportsPress Gutenberg Class
|
||||
*
|
||||
* @class SportsPress_Gutenberg
|
||||
* @version 2.6.13
|
||||
*/
|
||||
class SportsPress_Gutenberg {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Main SportsPress Gutenberg Class
|
||||
*
|
||||
* @class SportsPress_Gutenberg
|
||||
* @version 2.6.13
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
class SportsPress_Gutenberg {
|
||||
|
||||
add_filter( 'gutenberg_can_edit_post_type', array( $this, 'can_edit_post_type' ), 10, 2 );
|
||||
add_filter( 'use_block_editor_for_post_type', array( $this, 'can_edit_post_type' ), 10, 2 );
|
||||
//add_filter( 'block_categories', array( $this, 'add_category' ), 10, 2 );
|
||||
//add_action( 'enqueue_block_editor_assets', array( $this, 'load_blocks' ) );
|
||||
}
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( !defined( 'SP_GUTENBERG_VERSION' ) )
|
||||
define( 'SP_GUTENBERG_VERSION', '2.6.13' );
|
||||
add_filter( 'gutenberg_can_edit_post_type', array( $this, 'can_edit_post_type' ), 10, 2 );
|
||||
add_filter( 'use_block_editor_for_post_type', array( $this, 'can_edit_post_type' ), 10, 2 );
|
||||
// add_filter( 'block_categories', array( $this, 'add_category' ), 10, 2 );
|
||||
// add_action( 'enqueue_block_editor_assets', array( $this, 'load_blocks' ) );
|
||||
}
|
||||
|
||||
if ( !defined( 'SP_GUTENBERG_URL' ) )
|
||||
define( 'SP_GUTENBERG_URL', plugin_dir_url( __FILE__ ) );
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( ! defined( 'SP_GUTENBERG_VERSION' ) ) {
|
||||
define( 'SP_GUTENBERG_VERSION', '2.6.13' );
|
||||
}
|
||||
|
||||
if ( !defined( 'SP_GUTENBERG_DIR' ) )
|
||||
define( 'SP_GUTENBERG_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
if ( ! defined( 'SP_GUTENBERG_URL' ) ) {
|
||||
define( 'SP_GUTENBERG_URL', plugin_dir_url( __FILE__ ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify Gutenberg behavior for custom post types.
|
||||
*/
|
||||
function can_edit_post_type( $enabled, $post_type ) {
|
||||
return is_sp_post_type( $post_type ) ? false : $enabled;
|
||||
}
|
||||
if ( ! defined( 'SP_GUTENBERG_DIR' ) ) {
|
||||
define( 'SP_GUTENBERG_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add SportsPress category to Gutenberg.
|
||||
*/
|
||||
function add_category( $categories, $post ) {
|
||||
return array_merge(
|
||||
$categories,
|
||||
array(
|
||||
/**
|
||||
* Modify Gutenberg behavior for custom post types.
|
||||
*/
|
||||
function can_edit_post_type( $enabled, $post_type ) {
|
||||
return is_sp_post_type( $post_type ) ? false : $enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add SportsPress category to Gutenberg.
|
||||
*/
|
||||
function add_category( $categories, $post ) {
|
||||
return array_merge(
|
||||
$categories,
|
||||
array(
|
||||
'slug' => 'sportspress',
|
||||
'title' => __( 'SportsPress', 'sportspress' ),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load Gutenberg blocks.
|
||||
*/
|
||||
function load_blocks() {
|
||||
wp_enqueue_script( 'sp-block-event-calendar', plugin_dir_url( SP_PLUGIN_FILE ) . 'assets/js/blocks/event-calendar.js', array( 'wp-blocks', 'wp-editor' ), true );
|
||||
|
||||
$strings = apply_filters( 'sportspress_localized_strings', array(
|
||||
'event_calendar' => __( 'Event Calendar', 'sportspress' ),
|
||||
'properties' => __( 'Properties', 'sportspress' ),
|
||||
'title' => __( 'Title', 'sportspress' ),
|
||||
'select_calendar' => sprintf( __( 'Select %s:', 'sportspress' ), __( 'Calendar', 'sportspress' ) ),
|
||||
'all' => __( 'All', 'sportspress' ),
|
||||
) );
|
||||
|
||||
$posts = array(
|
||||
'events' => (array) get_posts(
|
||||
array(
|
||||
'post_type' => 'sp_event',
|
||||
'posts_per_page' => -1,
|
||||
array(
|
||||
'slug' => 'sportspress',
|
||||
'title' => __( 'SportsPress', 'sportspress' ),
|
||||
),
|
||||
)
|
||||
),
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
wp_localize_script( 'sp-block-event-calendar', 'strings', $strings );
|
||||
wp_localize_script( 'sp-block-event-calendar', 'posts', $posts );
|
||||
/**
|
||||
* Load Gutenberg blocks.
|
||||
*/
|
||||
function load_blocks() {
|
||||
wp_enqueue_script( 'sp-block-event-calendar', plugin_dir_url( SP_PLUGIN_FILE ) . 'assets/js/blocks/event-calendar.js', array( 'wp-blocks', 'wp-editor' ), true );
|
||||
|
||||
$strings = apply_filters(
|
||||
'sportspress_localized_strings',
|
||||
array(
|
||||
'event_calendar' => __( 'Event Calendar', 'sportspress' ),
|
||||
'properties' => __( 'Properties', 'sportspress' ),
|
||||
'title' => __( 'Title', 'sportspress' ),
|
||||
'select_calendar' => sprintf( __( 'Select %s:', 'sportspress' ), __( 'Calendar', 'sportspress' ) ),
|
||||
'all' => __( 'All', 'sportspress' ),
|
||||
)
|
||||
);
|
||||
|
||||
$posts = array(
|
||||
'events' => (array) get_posts(
|
||||
array(
|
||||
'post_type' => 'sp_event',
|
||||
'posts_per_page' => -1,
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
wp_localize_script( 'sp-block-event-calendar', 'strings', $strings );
|
||||
wp_localize_script( 'sp-block-event-calendar', 'posts', $posts );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
@@ -9,193 +9,214 @@
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SportsPress_Icons' ) ) :
|
||||
|
||||
/**
|
||||
* Main SportsPress Icons Class
|
||||
*
|
||||
* @class SportsPress_Icons
|
||||
* @version 2.7
|
||||
*/
|
||||
class SportsPress_Icons {
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* Main SportsPress Icons Class
|
||||
*
|
||||
* @class SportsPress_Icons
|
||||
* @version 2.7
|
||||
*/
|
||||
public $icons = array();
|
||||
class SportsPress_Icons {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $icons = array();
|
||||
|
||||
// Define icons
|
||||
$this->get_icons();
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
add_filter( 'sportspress_enqueue_styles', array( $this, 'add_styles' ) );
|
||||
add_filter( 'sportspress_performance_icon', array( $this, 'icon' ), 10, 2 );
|
||||
add_filter( 'sportspress_event_performance_icons', array( $this, 'replace_icons' ), 10, 3 );
|
||||
add_filter( 'admin_post_thumbnail_html', array( $this, 'sp_admin_post_thumbnail_html' ), 10, 2 );
|
||||
add_action( 'sportspress_process_sp_performance_meta', array( $this, 'save' ), 10, 2 );
|
||||
add_action( 'sportspress_process_sp_statistic_meta', array( $this, 'save' ), 10, 2 );
|
||||
}
|
||||
// Define icons
|
||||
$this->get_icons();
|
||||
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( !defined( 'SP_ICONS_VERSION' ) )
|
||||
define( 'SP_ICONS_VERSION', '2.7' );
|
||||
|
||||
if ( !defined( 'SP_ICONS_URL' ) )
|
||||
define( 'SP_ICONS_URL', plugin_dir_url( __FILE__ ) );
|
||||
|
||||
if ( !defined( 'SP_ICONS_DIR' ) )
|
||||
define( 'SP_ICONS_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add stylesheet.
|
||||
*/
|
||||
public static function add_styles( $styles = array() ) {
|
||||
$styles['sportspress-icons'] = array(
|
||||
'src' => str_replace( array( 'http:', 'https:' ), '', SP()->plugin_url() ) . '/assets/css/icons.css',
|
||||
'deps' => '',
|
||||
'version' => SP_ICONS_VERSION,
|
||||
'media' => 'all'
|
||||
);
|
||||
return $styles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define icons.
|
||||
*/
|
||||
private function get_icons() {
|
||||
$this->icons = apply_filters( 'sportspress_icons', array(
|
||||
'soccerball',
|
||||
'soccerball-alt',
|
||||
'baseball',
|
||||
'baseball-alt',
|
||||
'basketball',
|
||||
'golfball',
|
||||
'cricketball',
|
||||
'bowling',
|
||||
'ice-hockey',
|
||||
'football',
|
||||
'poolball',
|
||||
'table-tennis',
|
||||
'tennis',
|
||||
'racing-flag',
|
||||
'shoe',
|
||||
'card',
|
||||
'league',
|
||||
'shield',
|
||||
'tshirt',
|
||||
'whistle',
|
||||
'time',
|
||||
'friendly',
|
||||
'sub',
|
||||
'update',
|
||||
'undo',
|
||||
'redo',
|
||||
'marker',
|
||||
'no',
|
||||
'heart',
|
||||
'star-filled',
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Display vector icon.
|
||||
*/
|
||||
public function icon( $icon = '', $id = 0 ) {
|
||||
if ( ! $id ) return $icon;
|
||||
$meta = get_post_meta( $id, 'sp_icon', true );
|
||||
if ( null !== $meta && in_array( $meta, $this->icons ) ) {
|
||||
$color = get_post_meta( $id, 'sp_color', true );
|
||||
$icon = '<i class="sp-icon-' . $meta . '" style="color:' . $color . ' !important"></i>';
|
||||
add_filter( 'sportspress_enqueue_styles', array( $this, 'add_styles' ) );
|
||||
add_filter( 'sportspress_performance_icon', array( $this, 'icon' ), 10, 2 );
|
||||
add_filter( 'sportspress_event_performance_icons', array( $this, 'replace_icons' ), 10, 3 );
|
||||
add_filter( 'admin_post_thumbnail_html', array( $this, 'sp_admin_post_thumbnail_html' ), 10, 2 );
|
||||
add_action( 'sportspress_process_sp_performance_meta', array( $this, 'save' ), 10, 2 );
|
||||
add_action( 'sportspress_process_sp_statistic_meta', array( $this, 'save' ), 10, 2 );
|
||||
}
|
||||
return $icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace icons with vectors when available.
|
||||
*/
|
||||
public function replace_icons( $icons = '', $id = 0, $value = 0 ) {
|
||||
if ( ! $id || ! $value ) return $icons;
|
||||
$icon = get_post_meta( $id, 'sp_icon', true );
|
||||
if ( null !== $icon && in_array( $icon, $this->icons ) ) {
|
||||
$title = sp_get_singular_name( $id );
|
||||
$color = get_post_meta( $id, 'sp_color', true );
|
||||
preg_match( '#\((.*?)\)#', $value, $match );
|
||||
if ( ! empty( $match ) && isset( $match[1] ) ) {
|
||||
$icons = '<i class="sp-icon-' . $icon . '" title="' . $title . '" style="color:' . $color . ' !important"></i> ' . $match[1] . '<br>';
|
||||
} else {
|
||||
$icons = str_repeat( '<i class="sp-icon-' . $icon . '" title="' . $title . '" style="color:' . $color . ' !important"></i> ', intval( $value ) );
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( ! defined( 'SP_ICONS_VERSION' ) ) {
|
||||
define( 'SP_ICONS_VERSION', '2.7' );
|
||||
}
|
||||
|
||||
if ( ! defined( 'SP_ICONS_URL' ) ) {
|
||||
define( 'SP_ICONS_URL', plugin_dir_url( __FILE__ ) );
|
||||
}
|
||||
|
||||
if ( ! defined( 'SP_ICONS_DIR' ) ) {
|
||||
define( 'SP_ICONS_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
}
|
||||
return $icons;
|
||||
}
|
||||
|
||||
/**
|
||||
* Post thumbnail HTML.
|
||||
*/
|
||||
public function sp_admin_post_thumbnail_html( $content = '', $id = 0 ) {
|
||||
// Bypass if no ID
|
||||
if ( ! $id ) return $content;
|
||||
|
||||
// Bypass if not performance or statistic post type
|
||||
$post_type = get_post_type( $id );
|
||||
if ( 'sp_performance' !== $post_type && 'sp_statistic' !== $post_type ) return $content;
|
||||
|
||||
// Detect if image uploaded
|
||||
$is_uploaded = isset( $_POST['thumbnail_id'] );
|
||||
|
||||
// Enqueue scripts
|
||||
wp_enqueue_script( 'sp_iconpicker', SP()->plugin_url() . '/assets/js/admin/iconpicker.js', array( 'jquery', 'wp-color-picker', 'iris' ), SP_ICONS_VERSION, true );
|
||||
|
||||
// Get selected icon
|
||||
$has_icon = has_post_thumbnail( $id );
|
||||
if ( $has_icon ) $selected = null;
|
||||
else $selected = $is_uploaded ? null : get_post_meta( $id, 'sp_icon', true );
|
||||
|
||||
// Generate icon selector
|
||||
$icons = '';
|
||||
foreach ( $this->icons as $icon ) {
|
||||
$icons .= '<label class="button"><input name="sp_icon" type="radio" value="' . $icon . '" ' . checked( $selected, $icon, false ) . '></input><i class="sp-icon-' . $icon . '"></i></label>';
|
||||
/**
|
||||
* Add stylesheet.
|
||||
*/
|
||||
public static function add_styles( $styles = array() ) {
|
||||
$styles['sportspress-icons'] = array(
|
||||
'src' => str_replace( array( 'http:', 'https:' ), '', SP()->plugin_url() ) . '/assets/css/icons.css',
|
||||
'deps' => '',
|
||||
'version' => SP_ICONS_VERSION,
|
||||
'media' => 'all',
|
||||
);
|
||||
return $styles;
|
||||
}
|
||||
|
||||
$icons .= '<label class="button"><input name="sp_icon" type="radio" value="" ' . checked( $selected, null, false ) . '></input>' . __( 'Image', 'sportspress' ) . '</label>';
|
||||
/**
|
||||
* Define icons.
|
||||
*/
|
||||
private function get_icons() {
|
||||
$this->icons = apply_filters(
|
||||
'sportspress_icons',
|
||||
array(
|
||||
'soccerball',
|
||||
'soccerball-alt',
|
||||
'baseball',
|
||||
'baseball-alt',
|
||||
'basketball',
|
||||
'golfball',
|
||||
'cricketball',
|
||||
'bowling',
|
||||
'ice-hockey',
|
||||
'football',
|
||||
'poolball',
|
||||
'table-tennis',
|
||||
'tennis',
|
||||
'racing-flag',
|
||||
'shoe',
|
||||
'card',
|
||||
'league',
|
||||
'shield',
|
||||
'tshirt',
|
||||
'whistle',
|
||||
'time',
|
||||
'friendly',
|
||||
'sub',
|
||||
'update',
|
||||
'undo',
|
||||
'redo',
|
||||
'marker',
|
||||
'no',
|
||||
'heart',
|
||||
'star-filled',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Get color value
|
||||
$value = get_post_meta( $id, 'sp_color', true );
|
||||
if ( empty( $value ) ) $value = '111111';
|
||||
/**
|
||||
* Display vector icon.
|
||||
*/
|
||||
public function icon( $icon = '', $id = 0 ) {
|
||||
if ( ! $id ) {
|
||||
return $icon;
|
||||
}
|
||||
$meta = get_post_meta( $id, 'sp_icon', true );
|
||||
if ( null !== $meta && in_array( $meta, $this->icons ) ) {
|
||||
$color = get_post_meta( $id, 'sp_color', true );
|
||||
$icon = '<i class="sp-icon-' . $meta . '" style="color:' . $color . ' !important"></i>';
|
||||
}
|
||||
return $icon;
|
||||
}
|
||||
|
||||
$color = '<div class="sp-color-box-for-icon"><input name="sp_color" id="sp_color" type="text" value="' . esc_attr( $value ) . '" size="7" class="colorpick" /> <div id="colorPickerDiv" class="colorpickdiv"></div></div>';
|
||||
/**
|
||||
* Replace icons with vectors when available.
|
||||
*/
|
||||
public function replace_icons( $icons = '', $id = 0, $value = 0 ) {
|
||||
if ( ! $id || ! $value ) {
|
||||
return $icons;
|
||||
}
|
||||
$icon = get_post_meta( $id, 'sp_icon', true );
|
||||
if ( null !== $icon && in_array( $icon, $this->icons ) ) {
|
||||
$title = sp_get_singular_name( $id );
|
||||
$color = get_post_meta( $id, 'sp_color', true );
|
||||
preg_match( '#\((.*?)\)#', $value, $match );
|
||||
if ( ! empty( $match ) && isset( $match[1] ) ) {
|
||||
$icons = '<i class="sp-icon-' . $icon . '" title="' . $title . '" style="color:' . $color . ' !important"></i> ' . $match[1] . '<br>';
|
||||
} else {
|
||||
$icons = str_repeat( '<i class="sp-icon-' . $icon . '" title="' . $title . '" style="color:' . $color . ' !important"></i> ', intval( $value ) );
|
||||
}
|
||||
}
|
||||
return $icons;
|
||||
}
|
||||
|
||||
$content = '<p><strong>' . __( 'Select Icon', 'sportspress' ) . '</strong></p>
|
||||
/**
|
||||
* Post thumbnail HTML.
|
||||
*/
|
||||
public function sp_admin_post_thumbnail_html( $content = '', $id = 0 ) {
|
||||
// Bypass if no ID
|
||||
if ( ! $id ) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
// Bypass if not performance or statistic post type
|
||||
$post_type = get_post_type( $id );
|
||||
if ( 'sp_performance' !== $post_type && 'sp_statistic' !== $post_type ) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
// Detect if image uploaded
|
||||
$is_uploaded = isset( $_POST['thumbnail_id'] );
|
||||
|
||||
// Enqueue scripts
|
||||
wp_enqueue_script( 'sp_iconpicker', SP()->plugin_url() . '/assets/js/admin/iconpicker.js', array( 'jquery', 'wp-color-picker', 'iris' ), SP_ICONS_VERSION, true );
|
||||
|
||||
// Get selected icon
|
||||
$has_icon = has_post_thumbnail( $id );
|
||||
if ( $has_icon ) {
|
||||
$selected = null;
|
||||
} else {
|
||||
$selected = $is_uploaded ? null : get_post_meta( $id, 'sp_icon', true );
|
||||
}
|
||||
|
||||
// Generate icon selector
|
||||
$icons = '';
|
||||
foreach ( $this->icons as $icon ) {
|
||||
$icons .= '<label class="button"><input name="sp_icon" type="radio" value="' . $icon . '" ' . checked( $selected, $icon, false ) . '></input><i class="sp-icon-' . $icon . '"></i></label>';
|
||||
}
|
||||
|
||||
$icons .= '<label class="button"><input name="sp_icon" type="radio" value="" ' . checked( $selected, null, false ) . '></input>' . __( 'Image', 'sportspress' ) . '</label>';
|
||||
|
||||
// Get color value
|
||||
$value = get_post_meta( $id, 'sp_color', true );
|
||||
if ( empty( $value ) ) {
|
||||
$value = '111111';
|
||||
}
|
||||
|
||||
$color = '<div class="sp-color-box-for-icon"><input name="sp_color" id="sp_color" type="text" value="' . esc_attr( $value ) . '" size="7" class="colorpick" /> <div id="colorPickerDiv" class="colorpickdiv"></div></div>';
|
||||
|
||||
$content = '<p><strong>' . __( 'Select Icon', 'sportspress' ) . '</strong></p>
|
||||
<p class="sp-icons">' . $icons . '</p>
|
||||
<div class="sp-para sp-custom-colors' . ( null == $selected ? ' hidden' : '' ) . '"><label data-sp-colors="' . $value . '"><strong>' . __( 'Customize', 'sportspress' ) . '</strong><br></label>' . $color . '</div>
|
||||
<div class="sp-custom-thumbnail' . ( null == $selected ? '' : ' hidden' ) . '">' . $content . '</div>';
|
||||
return $content;
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save meta boxes data
|
||||
*/
|
||||
public static function save( $post_id, $post ) {
|
||||
update_post_meta( $post_id, 'sp_icon', sp_array_value( $_POST, 'sp_icon', null ) );
|
||||
update_post_meta( $post_id, 'sp_color', sp_array_value( $_POST, 'sp_color', null ) );
|
||||
if ( null != sp_array_value( $_POST, 'sp_icon', null ) ) {
|
||||
delete_post_thumbnail( $post );
|
||||
/**
|
||||
* Save meta boxes data
|
||||
*/
|
||||
public static function save( $post_id, $post ) {
|
||||
update_post_meta( $post_id, 'sp_icon', sp_array_value( $_POST, 'sp_icon', null ) );
|
||||
update_post_meta( $post_id, 'sp_color', sp_array_value( $_POST, 'sp_color', null ) );
|
||||
if ( null != sp_array_value( $_POST, 'sp_icon', null ) ) {
|
||||
delete_post_thumbnail( $post );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
new SportsPress_Icons();
|
||||
new SportsPress_Icons();
|
||||
|
||||
@@ -9,51 +9,56 @@
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SportsPress_Importers' ) ) :
|
||||
|
||||
/**
|
||||
* Main SportsPress Importers Class
|
||||
*
|
||||
* @class SportsPress_Importers
|
||||
* @version 1.8.3
|
||||
*/
|
||||
class SportsPress_Importers {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Main SportsPress Importers Class
|
||||
*
|
||||
* @class SportsPress_Importers
|
||||
* @version 1.8.3
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
class SportsPress_Importers {
|
||||
|
||||
add_action( 'init', array( $this, 'includes' ) );
|
||||
}
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( !defined( 'SP_IMPORTERS_VERSION' ) )
|
||||
define( 'SP_IMPORTERS_VERSION', '1.8.3' );
|
||||
add_action( 'init', array( $this, 'includes' ) );
|
||||
}
|
||||
|
||||
if ( !defined( 'SP_IMPORTERS_URL' ) )
|
||||
define( 'SP_IMPORTERS_URL', plugin_dir_url( __FILE__ ) );
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( ! defined( 'SP_IMPORTERS_VERSION' ) ) {
|
||||
define( 'SP_IMPORTERS_VERSION', '1.8.3' );
|
||||
}
|
||||
|
||||
if ( !defined( 'SP_IMPORTERS_DIR' ) )
|
||||
define( 'SP_IMPORTERS_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
if ( ! defined( 'SP_IMPORTERS_URL' ) ) {
|
||||
define( 'SP_IMPORTERS_URL', plugin_dir_url( __FILE__ ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Include importers.
|
||||
*/
|
||||
public function includes() {
|
||||
if ( is_admin() && defined( 'WP_LOAD_IMPORTERS' ) ) {
|
||||
include( SP()->plugin_path() . '/includes/admin/class-sp-admin-importers.php' );
|
||||
if ( ! defined( 'SP_IMPORTERS_DIR' ) ) {
|
||||
define( 'SP_IMPORTERS_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Include importers.
|
||||
*/
|
||||
public function includes() {
|
||||
if ( is_admin() && defined( 'WP_LOAD_IMPORTERS' ) ) {
|
||||
include SP()->plugin_path() . '/includes/admin/class-sp-admin-importers.php';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
@@ -9,215 +9,214 @@
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SportsPress_Lazy_Loading' ) ) :
|
||||
|
||||
/**
|
||||
* Main SportsPress Lazy Loading Class
|
||||
*
|
||||
* @class SportsPress_Lazy_Loading
|
||||
* @version 2.7.9
|
||||
*/
|
||||
class SportsPress_Lazy_Loading {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Main SportsPress Lazy Loading Class
|
||||
*
|
||||
* @class SportsPress_Lazy_Loading
|
||||
* @version 2.7.9
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'wp_ajax_sp-get-players', array( $this, 'get_players' ) );
|
||||
add_action( 'sportspress_event_teams_meta_box_checklist', array( $this, 'checklist' ), 10, 6 );
|
||||
add_filter( 'sportspress_localized_strings', array( $this, 'strings' ) );
|
||||
}
|
||||
class SportsPress_Lazy_Loading {
|
||||
|
||||
/**
|
||||
* Get players.
|
||||
*/
|
||||
public function get_players() {
|
||||
check_ajax_referer( 'sp-get-players', 'nonce' );
|
||||
|
||||
$team = sp_array_value( $_POST, 'team' );
|
||||
|
||||
if ( 'yes' == get_option( 'sportspress_event_filter_teams_by_league', 'no' ) ) {
|
||||
$league = sp_array_value( $_POST, 'league' );
|
||||
} else {
|
||||
$league = false;
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'wp_ajax_sp-get-players', array( $this, 'get_players' ) );
|
||||
add_action( 'sportspress_event_teams_meta_box_checklist', array( $this, 'checklist' ), 10, 6 );
|
||||
add_filter( 'sportspress_localized_strings', array( $this, 'strings' ) );
|
||||
}
|
||||
|
||||
if ( 'yes' == get_option( 'sportspress_event_filter_teams_by_season', 'no' ) ) {
|
||||
$season = sp_array_value( $_POST, 'season' );
|
||||
} else {
|
||||
$season = false;
|
||||
}
|
||||
|
||||
$index = sp_array_value( $_POST, 'index', 1 );
|
||||
$selected = sp_array_value( $_POST, 'selected', array() );
|
||||
|
||||
$args = array(
|
||||
'orderby' => 'menu_order',
|
||||
);
|
||||
/**
|
||||
* Get players.
|
||||
*/
|
||||
public function get_players() {
|
||||
check_ajax_referer( 'sp-get-players', 'nonce' );
|
||||
|
||||
if ( $team ) {
|
||||
$args['meta_query'] = array(
|
||||
array(
|
||||
'key' => 'sp_current_team',
|
||||
'value' => sp_array_value( $_POST, 'team' ),
|
||||
),
|
||||
$team = sp_array_value( $_POST, 'team' );
|
||||
|
||||
if ( 'yes' == get_option( 'sportspress_event_filter_teams_by_league', 'no' ) ) {
|
||||
$league = sp_array_value( $_POST, 'league' );
|
||||
} else {
|
||||
$league = false;
|
||||
}
|
||||
|
||||
if ( 'yes' == get_option( 'sportspress_event_filter_teams_by_season', 'no' ) ) {
|
||||
$season = sp_array_value( $_POST, 'season' );
|
||||
} else {
|
||||
$season = false;
|
||||
}
|
||||
|
||||
$index = sp_array_value( $_POST, 'index', 1 );
|
||||
$selected = sp_array_value( $_POST, 'selected', array() );
|
||||
|
||||
$args = array(
|
||||
'orderby' => 'menu_order',
|
||||
);
|
||||
}
|
||||
|
||||
if ( $league || $season ) {
|
||||
$args['tax_query'] = array( 'relation' => 'AND' );
|
||||
|
||||
if ( $league ) {
|
||||
$args['tax_query'][] = array(
|
||||
'taxonomy' => 'sp_league',
|
||||
'field' => 'term_id',
|
||||
'terms' => $league,
|
||||
if ( $team ) {
|
||||
$args['meta_query'] = array(
|
||||
array(
|
||||
'key' => 'sp_current_team',
|
||||
'value' => sp_array_value( $_POST, 'team' ),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if ( $season ) {
|
||||
$args['tax_query'][] = array(
|
||||
'taxonomy' => 'sp_season',
|
||||
'field' => 'term_id',
|
||||
'terms' => $season,
|
||||
);
|
||||
if ( $league || $season ) {
|
||||
$args['tax_query'] = array( 'relation' => 'AND' );
|
||||
|
||||
if ( $league ) {
|
||||
$args['tax_query'][] = array(
|
||||
'taxonomy' => 'sp_league',
|
||||
'field' => 'term_id',
|
||||
'terms' => $league,
|
||||
);
|
||||
}
|
||||
|
||||
if ( $season ) {
|
||||
$args['tax_query'][] = array(
|
||||
'taxonomy' => 'sp_season',
|
||||
'field' => 'term_id',
|
||||
'terms' => $season,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$player_sort = get_option( 'sportspress_event_player_sort', 'jersey' );
|
||||
|
||||
|
||||
$player_sort = get_option( 'sportspress_event_player_sort', 'jersey' );
|
||||
|
||||
if( $player_sort == 'name' )
|
||||
{
|
||||
$args['order'] = 'ASC';
|
||||
$args['orderby'] = 'title';
|
||||
}
|
||||
else // default 'jersey'
|
||||
{
|
||||
$args['meta_key'] = 'sp_number';
|
||||
$args['orderby'] = 'meta_value_num';
|
||||
$args['order'] = 'ASC';
|
||||
}
|
||||
|
||||
$player_args = $args;
|
||||
|
||||
$players = sp_get_posts( 'sp_player', $player_args );
|
||||
$staff = sp_get_posts( 'sp_staff', $args );
|
||||
$data = array( 'index' => $index );
|
||||
|
||||
foreach ( $players as $key => $value ) {
|
||||
switch( $player_sort )
|
||||
{
|
||||
case 'name':
|
||||
$players[ $key ]->post_title = sp_get_player_name_then_number( $value->ID );
|
||||
break;
|
||||
default: // 'jersey'
|
||||
$players[ $key ]->post_title = sp_get_player_name_with_number( $value->ID );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$data['players'] = $players;
|
||||
$data['staff'] = $staff;
|
||||
$data['sections'] = get_option( 'sportspress_event_performance_sections', -1 );
|
||||
|
||||
wp_send_json_success( $data );
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax checklist.
|
||||
*/
|
||||
public function checklist( $post_id = null, $post_type = 'post', $display = 'block', $team = null, $index = null, $slug = null ) {
|
||||
if ( ! isset( $slug ) ):
|
||||
$slug = $post_type;
|
||||
endif;
|
||||
|
||||
$selected = (array)get_post_meta( $post_id, $slug, false );
|
||||
if ( sizeof( $selected ) ) {
|
||||
$selected = sp_array_between( $selected, 0, $index );
|
||||
} else {
|
||||
$selected = sp_array_between( (array)get_post_meta( $post_id, $post_type, false ), 0, $index );
|
||||
}
|
||||
|
||||
if ( 'yes' == get_option( 'sportspress_event_filter_teams_by_league', 'no' ) ) {
|
||||
$leagues = get_the_terms( $post_id, 'sp_league' );
|
||||
} else {
|
||||
$leagues = false;
|
||||
}
|
||||
|
||||
if ( 'yes' == get_option( 'sportspress_event_filter_teams_by_season', 'no' ) ) {
|
||||
$seasons = get_the_terms( $post_id, 'sp_season' );
|
||||
} else {
|
||||
$seasons = false;
|
||||
}
|
||||
|
||||
$args = array(
|
||||
'orderby' => 'menu_order',
|
||||
);
|
||||
|
||||
$player_sort = get_option( 'sportspress_event_player_sort', 'jersey' );
|
||||
|
||||
if ( 'sp_player' == $post_type )
|
||||
{
|
||||
if( $player_sort == 'name' )
|
||||
{
|
||||
$args['order'] = 'ASC';
|
||||
if ( $player_sort == 'name' ) {
|
||||
$args['order'] = 'ASC';
|
||||
$args['orderby'] = 'title';
|
||||
}
|
||||
else // default 'jersey'
|
||||
} else // default 'jersey'
|
||||
{
|
||||
$args['meta_key'] = 'sp_number';
|
||||
$args['orderby'] = 'meta_value_num';
|
||||
$args['order'] = 'ASC';
|
||||
$args['orderby'] = 'meta_value_num';
|
||||
$args['order'] = 'ASC';
|
||||
}
|
||||
|
||||
$player_args = $args;
|
||||
|
||||
$players = sp_get_posts( 'sp_player', $player_args );
|
||||
$staff = sp_get_posts( 'sp_staff', $args );
|
||||
$data = array( 'index' => $index );
|
||||
|
||||
foreach ( $players as $key => $value ) {
|
||||
switch ( $player_sort ) {
|
||||
case 'name':
|
||||
$players[ $key ]->post_title = sp_get_player_name_then_number( $value->ID );
|
||||
break;
|
||||
default: // 'jersey'
|
||||
$players[ $key ]->post_title = sp_get_player_name_with_number( $value->ID );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$data['players'] = $players;
|
||||
$data['staff'] = $staff;
|
||||
$data['sections'] = get_option( 'sportspress_event_performance_sections', -1 );
|
||||
|
||||
wp_send_json_success( $data );
|
||||
}
|
||||
|
||||
$args['meta_query'] = array(
|
||||
array(
|
||||
'key' => 'sp_current_team',
|
||||
'value' => $team,
|
||||
),
|
||||
);
|
||||
/**
|
||||
* Ajax checklist.
|
||||
*/
|
||||
public function checklist( $post_id = null, $post_type = 'post', $display = 'block', $team = null, $index = null, $slug = null ) {
|
||||
if ( ! isset( $slug ) ) :
|
||||
$slug = $post_type;
|
||||
endif;
|
||||
|
||||
if ( $leagues || $seasons ) {
|
||||
$args['tax_query'] = array( 'relation' => 'AND' );
|
||||
|
||||
if ( $leagues ) {
|
||||
$args['tax_query'][] = array(
|
||||
'taxonomy' => 'sp_league',
|
||||
'field' => 'term_id',
|
||||
'terms' => wp_list_pluck( $leagues, 'term_id' ),
|
||||
);
|
||||
$selected = (array) get_post_meta( $post_id, $slug, false );
|
||||
if ( sizeof( $selected ) ) {
|
||||
$selected = sp_array_between( $selected, 0, $index );
|
||||
} else {
|
||||
$selected = sp_array_between( (array) get_post_meta( $post_id, $post_type, false ), 0, $index );
|
||||
}
|
||||
|
||||
if ( $seasons ) {
|
||||
$args['tax_query'][] = array(
|
||||
'taxonomy' => 'sp_season',
|
||||
'field' => 'term_id',
|
||||
'terms' => wp_list_pluck( $seasons, 'term_id' ),
|
||||
);
|
||||
if ( 'yes' == get_option( 'sportspress_event_filter_teams_by_league', 'no' ) ) {
|
||||
$leagues = get_the_terms( $post_id, 'sp_league' );
|
||||
} else {
|
||||
$leagues = false;
|
||||
}
|
||||
}
|
||||
|
||||
$posts = sp_get_posts( $post_type, $args );
|
||||
$post_ids = wp_list_pluck( $posts, 'ID' );
|
||||
$diff = array_diff( $post_ids, $selected );
|
||||
$borrowed = array_diff( $selected, $post_ids );
|
||||
$selected = array_flip( $selected );
|
||||
|
||||
if ( sizeof( $borrowed ) ) {
|
||||
$args = array( 'post__in' => $borrowed );
|
||||
$borrowed_posts = sp_get_posts( $post_type, $args );
|
||||
if ( is_array( $borrowed_posts ) ) {
|
||||
$posts += $borrowed_posts;
|
||||
if ( 'yes' == get_option( 'sportspress_event_filter_teams_by_season', 'no' ) ) {
|
||||
$seasons = get_the_terms( $post_id, 'sp_season' );
|
||||
} else {
|
||||
$seasons = false;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
$args = array(
|
||||
'orderby' => 'menu_order',
|
||||
);
|
||||
|
||||
$player_sort = get_option( 'sportspress_event_player_sort', 'jersey' );
|
||||
|
||||
if ( 'sp_player' == $post_type ) {
|
||||
if ( $player_sort == 'name' ) {
|
||||
$args['order'] = 'ASC';
|
||||
$args['orderby'] = 'title';
|
||||
} else // default 'jersey'
|
||||
{
|
||||
$args['meta_key'] = 'sp_number';
|
||||
$args['orderby'] = 'meta_value_num';
|
||||
$args['order'] = 'ASC';
|
||||
}
|
||||
}
|
||||
|
||||
$args['meta_query'] = array(
|
||||
array(
|
||||
'key' => 'sp_current_team',
|
||||
'value' => $team,
|
||||
),
|
||||
);
|
||||
|
||||
if ( $leagues || $seasons ) {
|
||||
$args['tax_query'] = array( 'relation' => 'AND' );
|
||||
|
||||
if ( $leagues ) {
|
||||
$args['tax_query'][] = array(
|
||||
'taxonomy' => 'sp_league',
|
||||
'field' => 'term_id',
|
||||
'terms' => wp_list_pluck( $leagues, 'term_id' ),
|
||||
);
|
||||
}
|
||||
|
||||
if ( $seasons ) {
|
||||
$args['tax_query'][] = array(
|
||||
'taxonomy' => 'sp_season',
|
||||
'field' => 'term_id',
|
||||
'terms' => wp_list_pluck( $seasons, 'term_id' ),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$posts = sp_get_posts( $post_type, $args );
|
||||
$post_ids = wp_list_pluck( $posts, 'ID' );
|
||||
$diff = array_diff( $post_ids, $selected );
|
||||
$borrowed = array_diff( $selected, $post_ids );
|
||||
$selected = array_flip( $selected );
|
||||
|
||||
if ( sizeof( $borrowed ) ) {
|
||||
$args = array( 'post__in' => $borrowed );
|
||||
$borrowed_posts = sp_get_posts( $post_type, $args );
|
||||
if ( is_array( $borrowed_posts ) ) {
|
||||
$posts += $borrowed_posts;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<div id="<?php echo $slug; ?>-all" class="posttypediv tabs-panel wp-tab-panel sp-tab-panel sp-ajax-checklist sp-select-all-range" style="display: <?php echo $display; ?>;">
|
||||
<input type="hidden" value="0" name="<?php echo $slug; ?><?php if ( isset( $index ) ) echo '[' . $index . ']'; ?>[]" />
|
||||
<input type="hidden" value="0" name="<?php echo $slug; ?>
|
||||
<?php
|
||||
if ( isset( $index ) ) {
|
||||
echo '[' . $index . ']';}
|
||||
?>
|
||||
[]" />
|
||||
<ul class="categorychecklist form-no-clear">
|
||||
<?php if ( is_array( $posts ) && sizeof( $posts ) ) { ?>
|
||||
<li class="sp-select-all-container">
|
||||
@@ -229,39 +228,56 @@ class SportsPress_Lazy_Loading {
|
||||
<?php foreach ( $posts as $post ) { ?>
|
||||
<li>
|
||||
<label class="selectit">
|
||||
<input type="checkbox" value="<?php echo $post->ID; ?>" name="<?php echo $slug; ?><?php if ( isset( $index ) ) echo '[' . $index . ']'; ?>[]" <?php checked( array_key_exists( $post->ID, $selected ) ); ?>>
|
||||
<input type="checkbox" value="<?php echo $post->ID; ?>" name="<?php echo $slug; ?>
|
||||
<?php
|
||||
if ( isset( $index ) ) {
|
||||
echo '[' . $index . ']';}
|
||||
?>
|
||||
[]" <?php checked( array_key_exists( $post->ID, $selected ) ); ?>>
|
||||
<?php
|
||||
switch( $player_sort )
|
||||
{
|
||||
switch ( $player_sort ) {
|
||||
case 'name':
|
||||
echo esc_html( sp_get_player_name_then_number( $post->ID ) );
|
||||
break;
|
||||
default: // 'jersey'
|
||||
echo esc_html( sp_get_player_name_with_number( $post->ID ) );
|
||||
}
|
||||
}
|
||||
?>
|
||||
</label>
|
||||
</li>
|
||||
<?php unset( $selected[ $post->ID ] ); ?>
|
||||
<?php } ?>
|
||||
<?php if ( is_array( $selected ) && sizeof( $selected ) ) { foreach ( $selected as $post_id => $post ) { ?>
|
||||
<?php if ( ! $post_id ) continue; ?>
|
||||
<?php
|
||||
if ( is_array( $selected ) && sizeof( $selected ) ) {
|
||||
foreach ( $selected as $post_id => $post ) {
|
||||
?>
|
||||
<?php
|
||||
if ( ! $post_id ) {
|
||||
continue;}
|
||||
?>
|
||||
<li>
|
||||
<label class="selectit">
|
||||
<input type="checkbox" value="<?php echo $post_id; ?>" name="<?php echo $slug; ?><?php if ( isset( $index ) ) echo '[' . $index . ']'; ?>[]" <?php checked( true ); ?>>
|
||||
<?php
|
||||
switch( $player_sort )
|
||||
{
|
||||
case 'name':
|
||||
echo esc_html( sp_get_player_name_then_number( $post_id ) );
|
||||
break;
|
||||
default: // 'jersey'
|
||||
echo esc_html( sp_get_player_name_with_number( $post_id ) );
|
||||
}
|
||||
?>
|
||||
<input type="checkbox" value="<?php echo $post_id; ?>" name="<?php echo $slug; ?>
|
||||
<?php
|
||||
if ( isset( $index ) ) {
|
||||
echo '[' . $index . ']';}
|
||||
?>
|
||||
[]" <?php checked( true ); ?>>
|
||||
<?php
|
||||
switch ( $player_sort ) {
|
||||
case 'name':
|
||||
echo esc_html( sp_get_player_name_then_number( $post_id ) );
|
||||
break;
|
||||
default: // 'jersey'
|
||||
echo esc_html( sp_get_player_name_with_number( $post_id ) );
|
||||
}
|
||||
?>
|
||||
</label>
|
||||
</li>
|
||||
<?php } } ?>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
<li class="sp-ajax-show-all-container"><a class="sp-ajax-show-all" href="#show-all-<?php echo $slug; ?>s"><?php _e( 'Show all', 'sportspress' ); ?></a></li>
|
||||
<?php } else { ?>
|
||||
<li class="sp-ajax-show-all-container"><?php _e( 'No results found.', 'sportspress' ); ?>
|
||||
@@ -269,25 +285,28 @@ class SportsPress_Lazy_Loading {
|
||||
<?php } ?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
<?php
|
||||
}
|
||||
|
||||
/*
|
||||
* Localized strings.
|
||||
*/
|
||||
public function strings( $strings ) {
|
||||
$strings = array_merge( $strings, array(
|
||||
'no_results_found' => __( 'No results found.', 'sportspress' ),
|
||||
'select_all' => __( 'Select All', 'sportspress' ),
|
||||
'show_all' => __( 'Show all', 'sportspress' ),
|
||||
'loading' => __( 'Loading…', 'sportspress' ),
|
||||
'option_filter_by_league' => get_option( 'sportspress_event_filter_teams_by_league', 'no' ),
|
||||
'option_filter_by_season' => get_option( 'sportspress_event_filter_teams_by_season', 'no' ),
|
||||
) ) ;
|
||||
return $strings;
|
||||
/*
|
||||
* Localized strings.
|
||||
*/
|
||||
public function strings( $strings ) {
|
||||
$strings = array_merge(
|
||||
$strings,
|
||||
array(
|
||||
'no_results_found' => __( 'No results found.', 'sportspress' ),
|
||||
'select_all' => __( 'Select All', 'sportspress' ),
|
||||
'show_all' => __( 'Show all', 'sportspress' ),
|
||||
'loading' => __( 'Loading…', 'sportspress' ),
|
||||
'option_filter_by_league' => get_option( 'sportspress_event_filter_teams_by_league', 'no' ),
|
||||
'option_filter_by_season' => get_option( 'sportspress_event_filter_teams_by_season', 'no' ),
|
||||
)
|
||||
);
|
||||
return $strings;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
new SportsPress_Lazy_Loading();
|
||||
new SportsPress_Lazy_Loading();
|
||||
|
||||
@@ -9,325 +9,345 @@
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SportsPress_League_Tables' ) ) :
|
||||
|
||||
/**
|
||||
* Main SportsPress League Tables Class
|
||||
*
|
||||
* @class SportsPress_League_Tables
|
||||
* @version 2.6.15
|
||||
*/
|
||||
class SportsPress_League_Tables {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Main SportsPress League Tables Class
|
||||
*
|
||||
* @class SportsPress_League_Tables
|
||||
* @version 2.6.15
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
class SportsPress_League_Tables {
|
||||
|
||||
// Actions
|
||||
add_action( 'init', array( $this, 'register_post_type' ) );
|
||||
add_action( 'add_meta_boxes', array( $this, 'remove_meta_boxes' ), 10 );
|
||||
add_action( 'sportspress_include_post_type_handlers', array( $this, 'include_post_type_handler' ) );
|
||||
add_action( 'sportspress_widgets', array( $this, 'include_widgets' ) );
|
||||
add_action( 'sportspress_create_rest_routes', array( $this, 'create_rest_routes' ) );
|
||||
add_action( 'sportspress_register_rest_fields', array( $this, 'register_rest_fields' ) );
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
// Filters
|
||||
add_filter( 'sportspress_meta_boxes', array( $this, 'add_meta_boxes' ) );
|
||||
add_filter( 'sportspress_shortcodes', array( $this, 'add_shortcodes' ) );
|
||||
add_filter( 'sportspress_team_settings', array( $this, 'add_settings' ) );
|
||||
add_filter( 'sportspress_after_team_template', array( $this, 'add_team_template' ), 30 );
|
||||
}
|
||||
// Actions
|
||||
add_action( 'init', array( $this, 'register_post_type' ) );
|
||||
add_action( 'add_meta_boxes', array( $this, 'remove_meta_boxes' ), 10 );
|
||||
add_action( 'sportspress_include_post_type_handlers', array( $this, 'include_post_type_handler' ) );
|
||||
add_action( 'sportspress_widgets', array( $this, 'include_widgets' ) );
|
||||
add_action( 'sportspress_create_rest_routes', array( $this, 'create_rest_routes' ) );
|
||||
add_action( 'sportspress_register_rest_fields', array( $this, 'register_rest_fields' ) );
|
||||
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( !defined( 'SP_LEAGUE_TABLES_VERSION' ) )
|
||||
define( 'SP_LEAGUE_TABLES_VERSION', '2.6.15' );
|
||||
// Filters
|
||||
add_filter( 'sportspress_meta_boxes', array( $this, 'add_meta_boxes' ) );
|
||||
add_filter( 'sportspress_shortcodes', array( $this, 'add_shortcodes' ) );
|
||||
add_filter( 'sportspress_team_settings', array( $this, 'add_settings' ) );
|
||||
add_filter( 'sportspress_after_team_template', array( $this, 'add_team_template' ), 30 );
|
||||
}
|
||||
|
||||
if ( !defined( 'SP_LEAGUE_TABLES_URL' ) )
|
||||
define( 'SP_LEAGUE_TABLES_URL', plugin_dir_url( __FILE__ ) );
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( ! defined( 'SP_LEAGUE_TABLES_VERSION' ) ) {
|
||||
define( 'SP_LEAGUE_TABLES_VERSION', '2.6.15' );
|
||||
}
|
||||
|
||||
if ( !defined( 'SP_LEAGUE_TABLES_DIR' ) )
|
||||
define( 'SP_LEAGUE_TABLES_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
if ( ! defined( 'SP_LEAGUE_TABLES_URL' ) ) {
|
||||
define( 'SP_LEAGUE_TABLES_URL', plugin_dir_url( __FILE__ ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register league tables post type
|
||||
*/
|
||||
public static function register_post_type() {
|
||||
register_post_type( 'sp_table',
|
||||
apply_filters( 'sportspress_register_post_type_table',
|
||||
array(
|
||||
'labels' => array(
|
||||
'name' => __( 'League Tables', 'sportspress' ),
|
||||
'singular_name' => __( 'League Table', 'sportspress' ),
|
||||
'add_new_item' => __( 'Add New League Table', 'sportspress' ),
|
||||
'edit_item' => __( 'Edit League Table', 'sportspress' ),
|
||||
'new_item' => __( 'New', 'sportspress' ),
|
||||
'view_item' => __( 'View League Table', 'sportspress' ),
|
||||
'search_items' => __( 'Search', 'sportspress' ),
|
||||
'not_found' => __( 'No results found.', 'sportspress' ),
|
||||
'not_found_in_trash' => __( 'No results found.', 'sportspress' ),
|
||||
),
|
||||
'public' => true,
|
||||
'show_ui' => true,
|
||||
'capability_type' => 'sp_table',
|
||||
'map_meta_cap' => true,
|
||||
'publicly_queryable' => true,
|
||||
'exclude_from_search' => false,
|
||||
'hierarchical' => false,
|
||||
'rewrite' => array( 'slug' => get_option( 'sportspress_table_slug', 'table' ) ),
|
||||
'supports' => array( 'title', 'editor', 'page-attributes', 'thumbnail' ),
|
||||
'has_archive' => false,
|
||||
'show_in_nav_menus' => true,
|
||||
'show_in_menu' => 'edit.php?post_type=sp_team',
|
||||
'show_in_admin_bar' => true,
|
||||
'show_in_rest' => true,
|
||||
'rest_controller_class' => 'SP_REST_Posts_Controller',
|
||||
'rest_base' => 'tables',
|
||||
if ( ! defined( 'SP_LEAGUE_TABLES_DIR' ) ) {
|
||||
define( 'SP_LEAGUE_TABLES_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register league tables post type
|
||||
*/
|
||||
public static function register_post_type() {
|
||||
register_post_type(
|
||||
'sp_table',
|
||||
apply_filters(
|
||||
'sportspress_register_post_type_table',
|
||||
array(
|
||||
'labels' => array(
|
||||
'name' => __( 'League Tables', 'sportspress' ),
|
||||
'singular_name' => __( 'League Table', 'sportspress' ),
|
||||
'add_new_item' => __( 'Add New League Table', 'sportspress' ),
|
||||
'edit_item' => __( 'Edit League Table', 'sportspress' ),
|
||||
'new_item' => __( 'New', 'sportspress' ),
|
||||
'view_item' => __( 'View League Table', 'sportspress' ),
|
||||
'search_items' => __( 'Search', 'sportspress' ),
|
||||
'not_found' => __( 'No results found.', 'sportspress' ),
|
||||
'not_found_in_trash' => __( 'No results found.', 'sportspress' ),
|
||||
),
|
||||
'public' => true,
|
||||
'show_ui' => true,
|
||||
'capability_type' => 'sp_table',
|
||||
'map_meta_cap' => true,
|
||||
'publicly_queryable' => true,
|
||||
'exclude_from_search' => false,
|
||||
'hierarchical' => false,
|
||||
'rewrite' => array( 'slug' => get_option( 'sportspress_table_slug', 'table' ) ),
|
||||
'supports' => array( 'title', 'editor', 'page-attributes', 'thumbnail' ),
|
||||
'has_archive' => false,
|
||||
'show_in_nav_menus' => true,
|
||||
'show_in_menu' => 'edit.php?post_type=sp_team',
|
||||
'show_in_admin_bar' => true,
|
||||
'show_in_rest' => true,
|
||||
'rest_controller_class' => 'SP_REST_Posts_Controller',
|
||||
'rest_base' => 'tables',
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove meta boxes.
|
||||
*/
|
||||
public function remove_meta_boxes() {
|
||||
remove_meta_box( 'sp_seasondiv', 'sp_table', 'side' );
|
||||
remove_meta_box( 'sp_leaguediv', 'sp_table', 'side' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Conditonally load the class and functions only needed when viewing this post type.
|
||||
*/
|
||||
public function include_post_type_handler() {
|
||||
include_once( SP()->plugin_path() . '/includes/admin/post-types/class-sp-admin-cpt-table.php' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add widgets.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function include_widgets() {
|
||||
include_once( SP()->plugin_path() . '/includes/widgets/class-sp-widget-league-table.php' );
|
||||
include_once( SP()->plugin_path() . '/includes/widgets/class-sp-widget-team-gallery.php' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Create REST API routes.
|
||||
*/
|
||||
public function create_rest_routes() {
|
||||
$controller = new SP_REST_Posts_Controller( 'sp_table' );
|
||||
$controller->register_routes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register REST API fields.
|
||||
*/
|
||||
public function register_rest_fields() {
|
||||
register_rest_field( 'sp_table',
|
||||
'data',
|
||||
array(
|
||||
'get_callback' => 'SP_REST_API::get_post_data',
|
||||
'update_callback' => 'SP_REST_API::update_post_meta_arrays',
|
||||
'schema' => array(
|
||||
'description' => __( 'League Table', 'sportspress' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
'sanitize_callback' => 'rest_sanitize_request_arg',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add meta boxes.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_meta_boxes( $meta_boxes ) {
|
||||
if ( 'yes' == get_option( 'sportspress_team_column_editing', 'no' ) ) {
|
||||
$meta_boxes['sp_team']['columns'] = array(
|
||||
'title' => __( 'Table Columns', 'sportspress' ),
|
||||
'output' => 'SP_Meta_Box_Team_Columns::output',
|
||||
'save' => 'SP_Meta_Box_Team_Columns::save',
|
||||
'context' => 'normal',
|
||||
'priority' => 'high',
|
||||
);
|
||||
}
|
||||
$meta_boxes['sp_team']['tables'] = array(
|
||||
'title' => __( 'League Tables', 'sportspress' ),
|
||||
'output' => 'SP_Meta_Box_Team_Tables::output',
|
||||
'save' => 'SP_Meta_Box_Team_Tables::save',
|
||||
'context' => 'normal',
|
||||
'priority' => 'high',
|
||||
);
|
||||
$meta_boxes['sp_table'] = array(
|
||||
'mode' => array(
|
||||
'title' => __( 'Mode', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Table_Mode::save',
|
||||
'output' => 'SP_Meta_Box_Table_Mode::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'shortcode' => array(
|
||||
'title' => __( 'Shortcode', 'sportspress' ),
|
||||
'output' => 'SP_Meta_Box_Table_Shortcode::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'format' => array(
|
||||
'title' => __( 'Layout', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Table_Format::save',
|
||||
'output' => 'SP_Meta_Box_Table_Format::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'details' => array(
|
||||
'title' => __( 'Details', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Table_Details::save',
|
||||
'output' => 'SP_Meta_Box_Table_Details::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'data' => array(
|
||||
'title' => __( 'League Table', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Table_Data::save',
|
||||
'output' => 'SP_Meta_Box_Table_Data::output',
|
||||
'context' => 'normal',
|
||||
|
||||
/**
|
||||
* Remove meta boxes.
|
||||
*/
|
||||
public function remove_meta_boxes() {
|
||||
remove_meta_box( 'sp_seasondiv', 'sp_table', 'side' );
|
||||
remove_meta_box( 'sp_leaguediv', 'sp_table', 'side' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Conditonally load the class and functions only needed when viewing this post type.
|
||||
*/
|
||||
public function include_post_type_handler() {
|
||||
include_once SP()->plugin_path() . '/includes/admin/post-types/class-sp-admin-cpt-table.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Add widgets.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function include_widgets() {
|
||||
include_once SP()->plugin_path() . '/includes/widgets/class-sp-widget-league-table.php';
|
||||
include_once SP()->plugin_path() . '/includes/widgets/class-sp-widget-team-gallery.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Create REST API routes.
|
||||
*/
|
||||
public function create_rest_routes() {
|
||||
$controller = new SP_REST_Posts_Controller( 'sp_table' );
|
||||
$controller->register_routes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register REST API fields.
|
||||
*/
|
||||
public function register_rest_fields() {
|
||||
register_rest_field(
|
||||
'sp_table',
|
||||
'data',
|
||||
array(
|
||||
'get_callback' => 'SP_REST_API::get_post_data',
|
||||
'update_callback' => 'SP_REST_API::update_post_meta_arrays',
|
||||
'schema' => array(
|
||||
'description' => __( 'League Table', 'sportspress' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
'sanitize_callback' => 'rest_sanitize_request_arg',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add meta boxes.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_meta_boxes( $meta_boxes ) {
|
||||
if ( 'yes' == get_option( 'sportspress_team_column_editing', 'no' ) ) {
|
||||
$meta_boxes['sp_team']['columns'] = array(
|
||||
'title' => __( 'Table Columns', 'sportspress' ),
|
||||
'output' => 'SP_Meta_Box_Team_Columns::output',
|
||||
'save' => 'SP_Meta_Box_Team_Columns::save',
|
||||
'context' => 'normal',
|
||||
'priority' => 'high',
|
||||
);
|
||||
}
|
||||
$meta_boxes['sp_team']['tables'] = array(
|
||||
'title' => __( 'League Tables', 'sportspress' ),
|
||||
'output' => 'SP_Meta_Box_Team_Tables::output',
|
||||
'save' => 'SP_Meta_Box_Team_Tables::save',
|
||||
'context' => 'normal',
|
||||
'priority' => 'high',
|
||||
),
|
||||
);
|
||||
return $meta_boxes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add shortcodes.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_shortcodes( $shortcodes ) {
|
||||
$shortcodes['team'][] = 'standings';
|
||||
$shortcodes['team'][] = 'gallery';
|
||||
return $shortcodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add settings.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_settings( $settings ) {
|
||||
return array_merge( $settings,
|
||||
array(
|
||||
array( 'title' => __( 'League Tables', 'sportspress' ), 'type' => 'title', 'id' => 'table_options' ),
|
||||
),
|
||||
|
||||
apply_filters( 'sportspress_table_options', array(
|
||||
array(
|
||||
'title' => __( 'Title', 'sportspress' ),
|
||||
'desc' => __( 'Display title', 'sportspress' ),
|
||||
'id' => 'sportspress_table_show_title',
|
||||
'default' => 'yes',
|
||||
'type' => 'checkbox',
|
||||
);
|
||||
$meta_boxes['sp_table'] = array(
|
||||
'mode' => array(
|
||||
'title' => __( 'Mode', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Table_Mode::save',
|
||||
'output' => 'SP_Meta_Box_Table_Mode::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Teams', 'sportspress' ),
|
||||
'desc' => __( 'Display logos', 'sportspress' ),
|
||||
'id' => 'sportspress_table_show_logos',
|
||||
'default' => 'yes',
|
||||
'type' => 'checkbox',
|
||||
'shortcode' => array(
|
||||
'title' => __( 'Shortcode', 'sportspress' ),
|
||||
'output' => 'SP_Meta_Box_Table_Shortcode::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Pagination', 'sportspress' ),
|
||||
'desc' => __( 'Paginate', 'sportspress' ),
|
||||
'id' => 'sportspress_table_paginated',
|
||||
'default' => 'yes',
|
||||
'type' => 'checkbox',
|
||||
'format' => array(
|
||||
'title' => __( 'Layout', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Table_Format::save',
|
||||
'output' => 'SP_Meta_Box_Table_Format::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
|
||||
'details' => array(
|
||||
'title' => __( 'Details', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Table_Details::save',
|
||||
'output' => 'SP_Meta_Box_Table_Details::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'data' => array(
|
||||
'title' => __( 'League Table', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Table_Data::save',
|
||||
'output' => 'SP_Meta_Box_Table_Data::output',
|
||||
'context' => 'normal',
|
||||
'priority' => 'high',
|
||||
),
|
||||
);
|
||||
return $meta_boxes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add shortcodes.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_shortcodes( $shortcodes ) {
|
||||
$shortcodes['team'][] = 'standings';
|
||||
$shortcodes['team'][] = 'gallery';
|
||||
return $shortcodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add settings.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_settings( $settings ) {
|
||||
return array_merge(
|
||||
$settings,
|
||||
array(
|
||||
'title' => __( 'Limit', 'sportspress' ),
|
||||
'id' => 'sportspress_table_rows',
|
||||
'class' => 'small-text',
|
||||
'default' => '10',
|
||||
'desc' => __( 'teams', 'sportspress' ),
|
||||
'type' => 'number',
|
||||
'custom_attributes' => array(
|
||||
'min' => 1,
|
||||
'step' => 1
|
||||
array(
|
||||
'title' => __( 'League Tables', 'sportspress' ),
|
||||
'type' => 'title',
|
||||
'id' => 'table_options',
|
||||
),
|
||||
),
|
||||
|
||||
apply_filters(
|
||||
'sportspress_table_options',
|
||||
array(
|
||||
array(
|
||||
'title' => __( 'Title', 'sportspress' ),
|
||||
'desc' => __( 'Display title', 'sportspress' ),
|
||||
'id' => 'sportspress_table_show_title',
|
||||
'default' => 'yes',
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Teams', 'sportspress' ),
|
||||
'desc' => __( 'Display logos', 'sportspress' ),
|
||||
'id' => 'sportspress_table_show_logos',
|
||||
'default' => 'yes',
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Pagination', 'sportspress' ),
|
||||
'desc' => __( 'Paginate', 'sportspress' ),
|
||||
'id' => 'sportspress_table_paginated',
|
||||
'default' => 'yes',
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Limit', 'sportspress' ),
|
||||
'id' => 'sportspress_table_rows',
|
||||
'class' => 'small-text',
|
||||
'default' => '10',
|
||||
'desc' => __( 'teams', 'sportspress' ),
|
||||
'type' => 'number',
|
||||
'custom_attributes' => array(
|
||||
'min' => 1,
|
||||
'step' => 1,
|
||||
),
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Form', 'sportspress' ),
|
||||
'id' => 'sportspress_form_limit',
|
||||
'class' => 'small-text',
|
||||
'default' => '5',
|
||||
'desc' => __( 'events', 'sportspress' ),
|
||||
'type' => 'number',
|
||||
'custom_attributes' => array(
|
||||
'min' => 1,
|
||||
'step' => 1,
|
||||
),
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Pos', 'sportspress' ),
|
||||
'desc' => __( 'Always increment', 'sportspress' ),
|
||||
'id' => 'sportspress_table_increment',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Tiebreaker', 'sportspress' ),
|
||||
'id' => 'sportspress_table_tiebreaker',
|
||||
'default' => 'none',
|
||||
'type' => 'select',
|
||||
'options' => array(
|
||||
'none' => __( 'None', 'sportspress' ),
|
||||
'h2h' => __( 'Head to head', 'sportspress' ),
|
||||
),
|
||||
),
|
||||
)
|
||||
),
|
||||
array(
|
||||
'title' => __( 'Form', 'sportspress' ),
|
||||
'id' => 'sportspress_form_limit',
|
||||
'class' => 'small-text',
|
||||
'default' => '5',
|
||||
'desc' => __( 'events', 'sportspress' ),
|
||||
'type' => 'number',
|
||||
'custom_attributes' => array(
|
||||
'min' => 1,
|
||||
'step' => 1
|
||||
array(
|
||||
'type' => 'sectionend',
|
||||
'id' => 'table_options',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add team template.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_team_template( $templates ) {
|
||||
return array_merge(
|
||||
$templates,
|
||||
array(
|
||||
'title' => __( 'Pos', 'sportspress' ),
|
||||
'desc' => __( 'Always increment', 'sportspress' ),
|
||||
'id' => 'sportspress_table_increment',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Tiebreaker', 'sportspress' ),
|
||||
'id' => 'sportspress_table_tiebreaker',
|
||||
'default' => 'none',
|
||||
'type' => 'select',
|
||||
'options' => array(
|
||||
'none' => __( 'None', 'sportspress' ),
|
||||
'h2h' => __( 'Head to head', 'sportspress' ),
|
||||
'tables' => array(
|
||||
'title' => __( 'League Tables', 'sportspress' ),
|
||||
'label' => __( 'League Table', 'sportspress' ),
|
||||
'option' => 'sportspress_team_show_tables',
|
||||
'action' => 'sportspress_output_team_tables',
|
||||
'default' => 'yes',
|
||||
),
|
||||
),
|
||||
) ),
|
||||
|
||||
array(
|
||||
array( 'type' => 'sectionend', 'id' => 'table_options' ),
|
||||
)
|
||||
);
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add team template.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_team_template( $templates ) {
|
||||
return array_merge( $templates, array(
|
||||
'tables' => array(
|
||||
'title' => __( 'League Tables', 'sportspress' ),
|
||||
'label' => __( 'League Table', 'sportspress' ),
|
||||
'option' => 'sportspress_team_show_tables',
|
||||
'action' => 'sportspress_output_team_tables',
|
||||
'default' => 'yes',
|
||||
),
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
if ( get_option( 'sportspress_load_league_tables_module', 'yes' ) == 'yes' ) {
|
||||
@@ -336,6 +356,6 @@ if ( get_option( 'sportspress_load_league_tables_module', 'yes' ) == 'yes' ) {
|
||||
/**
|
||||
* Create alias of SP_League_Table class for REST API.
|
||||
* Note: class_alias is not supported in PHP < 5.3 so extend the original class instead.
|
||||
*/
|
||||
*/
|
||||
class SP_Table extends SP_League_Table {}
|
||||
}
|
||||
|
||||
@@ -9,165 +9,174 @@
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SportsPress_Next_Team_Preset' ) ) :
|
||||
|
||||
/**
|
||||
* Main SportsPress Next Team Preset Class
|
||||
*
|
||||
* @class SportsPress_Next_Team_Preset
|
||||
* @version 2.6.3
|
||||
*/
|
||||
|
||||
class SportsPress_Next_Team_Preset {
|
||||
|
||||
/** @var bool The link events setting. */
|
||||
public $link_events = true;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
$this->link_events = get_option( 'sportspress_link_events', 'yes' ) === 'yes' ? true : false;
|
||||
|
||||
// Filters
|
||||
add_filter( 'sportspress_equation_options', array( $this, 'add_options' ) );
|
||||
add_filter( 'sportspress_equation_presets', array( $this, 'presets' ) );
|
||||
add_filter( 'sportspress_equation_solve_for_presets', array( $this, 'solve' ), 10, 3 );
|
||||
add_filter( 'sportspress_table_options', array( $this, 'add_settings' ) );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( !defined( 'SP_NEXT_TEAM_PRESET_VERSION' ) )
|
||||
define( 'SP_NEXT_TEAM_PRESET_VERSION', '2.6.3' );
|
||||
|
||||
if ( !defined( 'SP_NEXT_TEAM_PRESET_URL' ) )
|
||||
define( 'SP_NEXT_TEAM_PRESET_URL', plugin_dir_url( __FILE__ ) );
|
||||
|
||||
if ( !defined( 'SP_NEXT_TEAM_PRESET_DIR' ) )
|
||||
define( 'SP_NEXT_TEAM_PRESET_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add additional options.
|
||||
* Main SportsPress Next Team Preset Class
|
||||
*
|
||||
* @return array
|
||||
* @class SportsPress_Next_Team_Preset
|
||||
* @version 2.6.3
|
||||
*/
|
||||
public function add_options( $options ) {
|
||||
$options[ 'Presets' ]['$nextteam'] = __( 'Next Team', 'sportspress' );
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add preset
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function presets( $presets ) {
|
||||
$presets[] = '$nextteam';
|
||||
return $presets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Solve preset
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function solve( $input, $equation, $post_id ) {
|
||||
if ( strpos( $equation, '$nextteam' ) !== false ) {
|
||||
$args = array(
|
||||
'post_type' => 'sp_event',
|
||||
'numberposts' => 1,
|
||||
'posts_per_page' => 1,
|
||||
'post_status' => 'future',
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'key' => 'sp_team',
|
||||
'value' => $post_id,
|
||||
'compare' => 'IN',
|
||||
),
|
||||
),
|
||||
'order' => 'ASC',
|
||||
);
|
||||
|
||||
if ( get_option( 'sportspress_table_next_team_filter_league', 'no' ) === 'yes' ) {
|
||||
$leagues = get_the_terms( get_the_ID(), 'sp_league' );
|
||||
if ( ! isset( $league_ids ) ) $league_ids = array();
|
||||
if ( empty( $league_ids ) && $leagues ):
|
||||
foreach( $leagues as $league ):
|
||||
$league_ids[] = $league->term_id;
|
||||
endforeach;
|
||||
endif;
|
||||
$league_ids = sp_add_auto_term( $league_ids, get_the_ID(), 'sp_league' );
|
||||
|
||||
if ( isset( $league_ids ) ) {
|
||||
$args['tax_query'][] = array(
|
||||
'taxonomy' => 'sp_league',
|
||||
'field' => 'term_id',
|
||||
'terms' => $league_ids
|
||||
);
|
||||
}
|
||||
|
||||
class SportsPress_Next_Team_Preset {
|
||||
|
||||
/** @var bool The link events setting. */
|
||||
public $link_events = true;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
$this->link_events = get_option( 'sportspress_link_events', 'yes' ) === 'yes' ? true : false;
|
||||
|
||||
// Filters
|
||||
add_filter( 'sportspress_equation_options', array( $this, 'add_options' ) );
|
||||
add_filter( 'sportspress_equation_presets', array( $this, 'presets' ) );
|
||||
add_filter( 'sportspress_equation_solve_for_presets', array( $this, 'solve' ), 10, 3 );
|
||||
add_filter( 'sportspress_table_options', array( $this, 'add_settings' ) );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( ! defined( 'SP_NEXT_TEAM_PRESET_VERSION' ) ) {
|
||||
define( 'SP_NEXT_TEAM_PRESET_VERSION', '2.6.3' );
|
||||
}
|
||||
|
||||
$events = get_posts( $args );
|
||||
|
||||
if ( $events ) {
|
||||
$event = reset( $events );
|
||||
$teams = array_filter( (array) get_post_meta( $event->ID, 'sp_team', false ) );
|
||||
if ( ( $key = array_search( $post_id, $teams ) ) !== false ) {
|
||||
unset( $teams[ $key ] );
|
||||
if ( ! defined( 'SP_NEXT_TEAM_PRESET_URL' ) ) {
|
||||
define( 'SP_NEXT_TEAM_PRESET_URL', plugin_dir_url( __FILE__ ) );
|
||||
}
|
||||
|
||||
if ( ! defined( 'SP_NEXT_TEAM_PRESET_DIR' ) ) {
|
||||
define( 'SP_NEXT_TEAM_PRESET_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add additional options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_options( $options ) {
|
||||
$options['Presets']['$nextteam'] = __( 'Next Team', 'sportspress' );
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add preset
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function presets( $presets ) {
|
||||
$presets[] = '$nextteam';
|
||||
return $presets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Solve preset
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function solve( $input, $equation, $post_id ) {
|
||||
if ( strpos( $equation, '$nextteam' ) !== false ) {
|
||||
$args = array(
|
||||
'post_type' => 'sp_event',
|
||||
'numberposts' => 1,
|
||||
'posts_per_page' => 1,
|
||||
'post_status' => 'future',
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'key' => 'sp_team',
|
||||
'value' => $post_id,
|
||||
'compare' => 'IN',
|
||||
),
|
||||
),
|
||||
'order' => 'ASC',
|
||||
);
|
||||
|
||||
if ( get_option( 'sportspress_table_next_team_filter_league', 'no' ) === 'yes' ) {
|
||||
$leagues = get_the_terms( get_the_ID(), 'sp_league' );
|
||||
if ( ! isset( $league_ids ) ) {
|
||||
$league_ids = array();
|
||||
}
|
||||
if ( empty( $league_ids ) && $leagues ) :
|
||||
foreach ( $leagues as $league ) :
|
||||
$league_ids[] = $league->term_id;
|
||||
endforeach;
|
||||
endif;
|
||||
$league_ids = sp_add_auto_term( $league_ids, get_the_ID(), 'sp_league' );
|
||||
|
||||
if ( isset( $league_ids ) ) {
|
||||
$args['tax_query'][] = array(
|
||||
'taxonomy' => 'sp_league',
|
||||
'field' => 'term_id',
|
||||
'terms' => $league_ids,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$events = get_posts( $args );
|
||||
|
||||
if ( $events ) {
|
||||
$event = reset( $events );
|
||||
$teams = array_filter( (array) get_post_meta( $event->ID, 'sp_team', false ) );
|
||||
if ( ( $key = array_search( $post_id, $teams ) ) !== false ) {
|
||||
unset( $teams[ $key ] );
|
||||
} else {
|
||||
return '-';
|
||||
}
|
||||
|
||||
$team_id = reset( $teams );
|
||||
|
||||
if ( ! $team_id ) {
|
||||
return '-';
|
||||
}
|
||||
|
||||
if ( has_post_thumbnail( $team_id ) ) {
|
||||
$logo = get_the_post_thumbnail( $team_id, 'sportspress-fit-icon' );
|
||||
$icon = '<span class="team-logo">' . $logo . '</span>';
|
||||
} else {
|
||||
$icon = sp_team_abbreviation( $team_id, true );
|
||||
}
|
||||
|
||||
if ( $this->link_events ) {
|
||||
return '<a title="' . $event->post_title . '" href="' . get_post_permalink( $event->ID, false, true ) . '">' . $icon . '</a>';
|
||||
} else {
|
||||
return '<span title="' . $event->post_title . '">' . $icon . '</a>';
|
||||
}
|
||||
} else {
|
||||
return '-';
|
||||
}
|
||||
|
||||
$team_id = reset( $teams );
|
||||
|
||||
if ( ! $team_id ) return '-';
|
||||
|
||||
if ( has_post_thumbnail( $team_id ) ) {
|
||||
$logo = get_the_post_thumbnail( $team_id, 'sportspress-fit-icon' );
|
||||
$icon = '<span class="team-logo">' . $logo . '</span>';
|
||||
} else {
|
||||
$icon = sp_team_abbreviation( $team_id, true );
|
||||
}
|
||||
|
||||
if ( $this->link_events ) {
|
||||
return '<a title="' . $event->post_title . '" href="' . get_post_permalink( $event->ID, false, true ) . '">' . $icon . '</a>';
|
||||
} else {
|
||||
return '<span title="' . $event->post_title . '">' . $icon . '</a>';
|
||||
}
|
||||
} else {
|
||||
return '-';
|
||||
return $input;
|
||||
}
|
||||
} else {
|
||||
return $input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add settings.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_settings( $settings ) {
|
||||
$settings[] = array(
|
||||
'title' => __( 'Next Team', 'sportspress' ),
|
||||
'desc' => __( 'Filter by League', 'sportspress' ),
|
||||
'id' => 'sportspress_table_next_team_filter_league',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
);
|
||||
return $settings;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add settings.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_settings( $settings ) {
|
||||
$settings[] = array(
|
||||
'title' => __( 'Next Team', 'sportspress' ),
|
||||
'desc' => __( 'Filter by League', 'sportspress' ),
|
||||
'id' => 'sportspress_table_next_team_filter_league',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
);
|
||||
return $settings;
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -9,175 +9,180 @@
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SportsPress_OpenStreetMap' ) ):
|
||||
|
||||
/**
|
||||
* Main SportsPress OpenStreetMap Class
|
||||
*
|
||||
* @class SportsPress_OpenStreetMap
|
||||
* @version 2.7.5
|
||||
*/
|
||||
|
||||
class SportsPress_OpenStreetMap {
|
||||
if ( ! class_exists( 'SportsPress_OpenStreetMap' ) ) :
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
// Actions
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
|
||||
add_action( 'sp_admin_venue_scripts', array( $this, 'admin_venue_scripts' ) );
|
||||
add_action( 'sp_frontend_venue_scripts', array( $this, 'frontend_venue_scripts' ) );
|
||||
add_action( 'wp_enqueue_scripts', array( $this, 'frontend_scripts' ) );
|
||||
add_action( 'sp_venue_show_map', array( $this, 'show_venue_map' ), 10, 5 );
|
||||
add_action( 'sp_admin_geocoder_scripts', array( $this, 'admin_geocoder_scripts' ), 10 );
|
||||
add_action( 'sp_setup_geocoder_scripts', array( $this, 'setup_geocoder_scripts' ), 10 );
|
||||
add_action( 'sp_setup_venue_geocoder_scripts', array( $this, 'setup_venue_geocoder_scripts' ), 10 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( !defined( 'SP_OPENSTREETMAP_VERSION' ) )
|
||||
define( 'SP_OPENSTREETMAP_VERSION', '2.7.5' );
|
||||
|
||||
if ( !defined( 'SP_OPENSTREETMAP_URL' ) )
|
||||
define( 'SP_OPENSTREETMAP_URL', plugin_dir_url( __FILE__ ) );
|
||||
|
||||
if ( !defined( 'SP_OPENSTREETMAP_DIR' ) )
|
||||
define( 'SP_OPENSTREETMAP_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue admin scripts
|
||||
*/
|
||||
public function admin_scripts() {
|
||||
do_action( 'sp_admin_venue_scripts' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue admin venue scripts
|
||||
*/
|
||||
public function admin_venue_scripts() {
|
||||
$screen = get_current_screen();
|
||||
|
||||
if ( in_array( $screen->id, sp_get_screen_ids() ) ) {
|
||||
wp_enqueue_style( 'leaflet_stylesheet', SP()->plugin_url() . '/assets/css/leaflet.css', array(), '1.7.1' );
|
||||
wp_enqueue_style( 'control-geocoder', SP()->plugin_url() . '/assets/css/Control.Geocoder.css', array(), '1.13.0' );
|
||||
}
|
||||
|
||||
if ( in_array( $screen->id, sp_get_screen_ids() ) ) {
|
||||
wp_register_script( 'leaflet_js', SP()->plugin_url() . '/assets/js/leaflet.js', array(), '1.7.1' );
|
||||
wp_register_script( 'control-geocoder', SP()->plugin_url() . '/assets/js/Control.Geocoder.min.js', array( 'leaflet_js' ), '1.13.0' );
|
||||
wp_register_script( 'sportspress-admin-geocoder', SP()->plugin_url() . '/assets/js/admin/sp-geocoder.js', array( 'leaflet_js', 'control-geocoder' ), SP_VERSION, true );
|
||||
}
|
||||
|
||||
if ( in_array( $screen->id, array( 'edit-sp_venue' ) ) ) {
|
||||
wp_enqueue_script( 'leaflet_js' );
|
||||
wp_enqueue_script( 'control-geocoder' );
|
||||
wp_enqueue_script( 'sportspress-admin-geocoder' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue frontend scripts
|
||||
*/
|
||||
public function frontend_scripts() {
|
||||
do_action( 'sp_frontend_venue_scripts' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue frontend venue scripts
|
||||
*/
|
||||
public function frontend_venue_scripts() {
|
||||
global $post;
|
||||
if( is_tax('sp_venue') || is_singular('sp_event') || ( isset( $post->post_content ) && sp_has_shortcodes( $post->post_content, array('event_full', 'event_venue') ) ) ) {
|
||||
wp_enqueue_style( 'leaflet_stylesheet', SP()->plugin_url() . '/assets/css/leaflet.css', array(), '1.7.1' );
|
||||
wp_enqueue_script( 'leaflet_js', SP()->plugin_url() . '/assets/js/leaflet.js', array(), '1.7.1' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Integrate OpenStreetMap (Show Venue)
|
||||
* Main SportsPress OpenStreetMap Class
|
||||
*
|
||||
* @return mix
|
||||
* @class SportsPress_OpenStreetMap
|
||||
* @version 2.7.5
|
||||
*/
|
||||
public function show_venue_map( $latitude, $longitude, $address, $zoom, $maptype ) {
|
||||
$lat = abs($latitude);
|
||||
$lat_deg = floor($lat);
|
||||
$lat_sec = ($lat - $lat_deg) * 3600;
|
||||
$lat_min = floor($lat_sec / 60);
|
||||
$lat_sec = floor($lat_sec - ($lat_min * 60));
|
||||
$lat_dir = $latitude > 0 ? 'N' : 'S';
|
||||
|
||||
$lon = abs($longitude);
|
||||
$lon_deg = floor($lon);
|
||||
$lon_sec = ($lon - $lon_deg) * 3600;
|
||||
$lon_min = floor($lon_sec / 60);
|
||||
$lon_sec = floor($lon_sec - ($lon_min * 60));
|
||||
$lon_dir = $longitude > 0 ? 'E' : 'W';
|
||||
?>
|
||||
<a href="https://www.google.com/maps/place/<?php echo urlencode("{$lat_deg}°{$lat_min}'{$lat_sec}\"{$lat_dir}").'+'.urlencode("{$lon_deg}°{$lon_min}'{$lon_sec}\"{$lon_dir}"); ?>/@<?php echo $latitude; ?>,<?php echo $longitude; ?>,<?php echo $zoom; ?>z" target="_blank"><div id="sp_openstreetmaps_container" style="width: 100%; height: 320px"></div></a>
|
||||
class SportsPress_OpenStreetMap {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
// Actions
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
|
||||
add_action( 'sp_admin_venue_scripts', array( $this, 'admin_venue_scripts' ) );
|
||||
add_action( 'sp_frontend_venue_scripts', array( $this, 'frontend_venue_scripts' ) );
|
||||
add_action( 'wp_enqueue_scripts', array( $this, 'frontend_scripts' ) );
|
||||
add_action( 'sp_venue_show_map', array( $this, 'show_venue_map' ), 10, 5 );
|
||||
add_action( 'sp_admin_geocoder_scripts', array( $this, 'admin_geocoder_scripts' ), 10 );
|
||||
add_action( 'sp_setup_geocoder_scripts', array( $this, 'setup_geocoder_scripts' ), 10 );
|
||||
add_action( 'sp_setup_venue_geocoder_scripts', array( $this, 'setup_venue_geocoder_scripts' ), 10 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( ! defined( 'SP_OPENSTREETMAP_VERSION' ) ) {
|
||||
define( 'SP_OPENSTREETMAP_VERSION', '2.7.5' );
|
||||
}
|
||||
|
||||
if ( ! defined( 'SP_OPENSTREETMAP_URL' ) ) {
|
||||
define( 'SP_OPENSTREETMAP_URL', plugin_dir_url( __FILE__ ) );
|
||||
}
|
||||
|
||||
if ( ! defined( 'SP_OPENSTREETMAP_DIR' ) ) {
|
||||
define( 'SP_OPENSTREETMAP_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue admin scripts
|
||||
*/
|
||||
public function admin_scripts() {
|
||||
do_action( 'sp_admin_venue_scripts' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue admin venue scripts
|
||||
*/
|
||||
public function admin_venue_scripts() {
|
||||
$screen = get_current_screen();
|
||||
|
||||
if ( in_array( $screen->id, sp_get_screen_ids() ) ) {
|
||||
wp_enqueue_style( 'leaflet_stylesheet', SP()->plugin_url() . '/assets/css/leaflet.css', array(), '1.7.1' );
|
||||
wp_enqueue_style( 'control-geocoder', SP()->plugin_url() . '/assets/css/Control.Geocoder.css', array(), '1.13.0' );
|
||||
}
|
||||
|
||||
if ( in_array( $screen->id, sp_get_screen_ids() ) ) {
|
||||
wp_register_script( 'leaflet_js', SP()->plugin_url() . '/assets/js/leaflet.js', array(), '1.7.1' );
|
||||
wp_register_script( 'control-geocoder', SP()->plugin_url() . '/assets/js/Control.Geocoder.min.js', array( 'leaflet_js' ), '1.13.0' );
|
||||
wp_register_script( 'sportspress-admin-geocoder', SP()->plugin_url() . '/assets/js/admin/sp-geocoder.js', array( 'leaflet_js', 'control-geocoder' ), SP_VERSION, true );
|
||||
}
|
||||
|
||||
if ( in_array( $screen->id, array( 'edit-sp_venue' ) ) ) {
|
||||
wp_enqueue_script( 'leaflet_js' );
|
||||
wp_enqueue_script( 'control-geocoder' );
|
||||
wp_enqueue_script( 'sportspress-admin-geocoder' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue frontend scripts
|
||||
*/
|
||||
public function frontend_scripts() {
|
||||
do_action( 'sp_frontend_venue_scripts' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue frontend venue scripts
|
||||
*/
|
||||
public function frontend_venue_scripts() {
|
||||
global $post;
|
||||
if ( is_tax( 'sp_venue' ) || is_singular( 'sp_event' ) || ( isset( $post->post_content ) && sp_has_shortcodes( $post->post_content, array( 'event_full', 'event_venue' ) ) ) ) {
|
||||
wp_enqueue_style( 'leaflet_stylesheet', SP()->plugin_url() . '/assets/css/leaflet.css', array(), '1.7.1' );
|
||||
wp_enqueue_script( 'leaflet_js', SP()->plugin_url() . '/assets/js/leaflet.js', array(), '1.7.1' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Integrate OpenStreetMap (Show Venue)
|
||||
*
|
||||
* @return mix
|
||||
*/
|
||||
public function show_venue_map( $latitude, $longitude, $address, $zoom, $maptype ) {
|
||||
$lat = abs( $latitude );
|
||||
$lat_deg = floor( $lat );
|
||||
$lat_sec = ( $lat - $lat_deg ) * 3600;
|
||||
$lat_min = floor( $lat_sec / 60 );
|
||||
$lat_sec = floor( $lat_sec - ( $lat_min * 60 ) );
|
||||
$lat_dir = $latitude > 0 ? 'N' : 'S';
|
||||
|
||||
$lon = abs( $longitude );
|
||||
$lon_deg = floor( $lon );
|
||||
$lon_sec = ( $lon - $lon_deg ) * 3600;
|
||||
$lon_min = floor( $lon_sec / 60 );
|
||||
$lon_sec = floor( $lon_sec - ( $lon_min * 60 ) );
|
||||
$lon_dir = $longitude > 0 ? 'E' : 'W';
|
||||
?>
|
||||
<a href="https://www.google.com/maps/place/<?php echo urlencode( "{$lat_deg}°{$lat_min}'{$lat_sec}\"{$lat_dir}" ) . '+' . urlencode( "{$lon_deg}°{$lon_min}'{$lon_sec}\"{$lon_dir}" ); ?>/@<?php echo $latitude; ?>,<?php echo $longitude; ?>,<?php echo $zoom; ?>z" target="_blank"><div id="sp_openstreetmaps_container" style="width: 100%; height: 320px"></div></a>
|
||||
<script>
|
||||
// position we will use later
|
||||
var lat = <?php echo $latitude; ?>;
|
||||
var lon = <?php echo $longitude; ?>;
|
||||
// initialize map
|
||||
map = L.map('sp_openstreetmaps_container', { zoomControl:false }).setView([lat, lon], <?php echo $zoom; ?>);
|
||||
// set map tiles source
|
||||
<?php if ( 'satellite' === $maptype ) { ?>
|
||||
// position we will use later
|
||||
var lat = <?php echo $latitude; ?>;
|
||||
var lon = <?php echo $longitude; ?>;
|
||||
// initialize map
|
||||
map = L.map('sp_openstreetmaps_container', { zoomControl:false }).setView([lat, lon], <?php echo $zoom; ?>);
|
||||
// set map tiles source
|
||||
<?php if ( 'satellite' === $maptype ) { ?>
|
||||
L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
|
||||
attribution: 'Tiles © Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community',
|
||||
maxZoom: 18,
|
||||
}).addTo(map);
|
||||
<?php }else{ ?>
|
||||
<?php } else { ?>
|
||||
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors',
|
||||
maxZoom: 18,
|
||||
}).addTo(map);
|
||||
<?php } ?>
|
||||
// add marker to the map
|
||||
marker = L.marker([lat, lon]).addTo(map);
|
||||
// add marker to the map
|
||||
marker = L.marker([lat, lon]).addTo(map);
|
||||
map.dragging.disable();
|
||||
map.touchZoom.disable();
|
||||
map.doubleClickZoom.disable();
|
||||
map.scrollWheelZoom.disable();
|
||||
</script>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Print geocoder script in admin
|
||||
*/
|
||||
public function admin_geocoder_scripts() {
|
||||
wp_print_scripts( 'sportspress-admin-setup-geocoder' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Print geocoder script in setup
|
||||
*/
|
||||
public function setup_geocoder_scripts() {
|
||||
wp_register_script( 'leaflet_js', SP()->plugin_url() . '/assets/js/leaflet.js', array(), '1.7.1' );
|
||||
wp_register_script( 'control-geocoder', SP()->plugin_url() . '/assets/js/Control.Geocoder.min.js', array( 'leaflet_js' ), '1.13.0' );
|
||||
wp_register_script( 'sportspress-admin-setup-geocoder', SP()->plugin_url() . '/assets/js/admin/sp-setup-geocoder.js', array( 'leaflet_js', 'control-geocoder' ), SP_VERSION, true );
|
||||
wp_enqueue_style( 'control-geocoder', SP()->plugin_url() . '/assets/css/Control.Geocoder.css', array(), '1.13.0' );
|
||||
wp_enqueue_style( 'leaflet_stylesheet', SP()->plugin_url() . '/assets/css/leaflet.css', array(), '1.7.1' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Print geocoder script in setup venue step
|
||||
*/
|
||||
public function setup_venue_geocoder_scripts() {
|
||||
wp_print_scripts( 'leaflet_js' );
|
||||
wp_print_scripts( 'control-geocoder' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Print geocoder script in admin
|
||||
*/
|
||||
public function admin_geocoder_scripts() {
|
||||
wp_print_scripts( 'sportspress-admin-setup-geocoder' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Print geocoder script in setup
|
||||
*/
|
||||
public function setup_geocoder_scripts() {
|
||||
wp_register_script( 'leaflet_js', SP()->plugin_url() . '/assets/js/leaflet.js', array(), '1.7.1' );
|
||||
wp_register_script( 'control-geocoder', SP()->plugin_url() . '/assets/js/Control.Geocoder.min.js', array( 'leaflet_js' ), '1.13.0' );
|
||||
wp_register_script( 'sportspress-admin-setup-geocoder', SP()->plugin_url() . '/assets/js/admin/sp-setup-geocoder.js', array( 'leaflet_js', 'control-geocoder' ), SP_VERSION, true );
|
||||
wp_enqueue_style( 'control-geocoder', SP()->plugin_url() . '/assets/css/Control.Geocoder.css', array(), '1.13.0' );
|
||||
wp_enqueue_style( 'leaflet_stylesheet', SP()->plugin_url() . '/assets/css/leaflet.css', array(), '1.7.1' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Print geocoder script in setup venue step
|
||||
*/
|
||||
public function setup_venue_geocoder_scripts() {
|
||||
wp_print_scripts( 'leaflet_js' );
|
||||
wp_print_scripts( 'control-geocoder' );
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -9,200 +9,227 @@
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SportsPress_Player_Assignments' ) ) :
|
||||
/**
|
||||
* Main SportsPress Player Assignments Class
|
||||
*
|
||||
* @class SportsPress_Player_Assignments
|
||||
* @version 2.7.3
|
||||
*/
|
||||
class SportsPress_Player_Assignments {
|
||||
/**
|
||||
* Constructor
|
||||
* Main SportsPress Player Assignments Class
|
||||
*
|
||||
* @class SportsPress_Player_Assignments
|
||||
* @version 2.7.3
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
// Actions
|
||||
add_action( 'sportspress_process_sp_player_meta', array( $this, 'save' ) );
|
||||
class SportsPress_Player_Assignments {
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
// Filters
|
||||
add_filter( 'sportspress_player_list_args', array( $this, 'add_args' ), 10, 2 );
|
||||
add_filter( 'sportspress_player_list_players', array( $this, 'add_players' ), 10, 4 );
|
||||
}
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( !defined( 'SP_PLAYER_ASSIGNMENTS_VERSION' ) )
|
||||
define( 'SP_PLAYER_ASSIGNMENTS_VERSION', '2.7.3' );
|
||||
if ( !defined( 'SP_PLAYER_ASSIGNMENTS_URL' ) )
|
||||
define( 'SP_PLAYER_ASSIGNMENTS_URL', plugin_dir_url( __FILE__ ) );
|
||||
if ( !defined( 'SP_PLAYER_ASSIGNMENTS_DIR' ) )
|
||||
define( 'SP_PLAYER_ASSIGNMENTS_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Save Additional Statistics
|
||||
*/
|
||||
public function save( $post_id ) {
|
||||
delete_post_meta( $post_id, 'sp_assignments' );
|
||||
|
||||
$leagues = sp_array_value( $_POST, 'sp_leagues', array() );
|
||||
// Actions
|
||||
add_action( 'sportspress_process_sp_player_meta', array( $this, 'save' ) );
|
||||
|
||||
if ( ! is_array( $leagues ) ) return;
|
||||
|
||||
foreach ( $leagues as $l_id => $season ) {
|
||||
if ( 0 === $l_id ) continue;
|
||||
foreach ( $season as $s_id => $team_id ) {
|
||||
if ( 0 >= $team_id ) continue;
|
||||
$serialized = intval($l_id).'_'.intval($s_id).'_'.intval($team_id);
|
||||
add_post_meta( $post_id, 'sp_assignments', $serialized, false );
|
||||
// Filters
|
||||
add_filter( 'sportspress_player_list_args', array( $this, 'add_args' ), 10, 2 );
|
||||
add_filter( 'sportspress_player_list_players', array( $this, 'add_players' ), 10, 4 );
|
||||
}
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( ! defined( 'SP_PLAYER_ASSIGNMENTS_VERSION' ) ) {
|
||||
define( 'SP_PLAYER_ASSIGNMENTS_VERSION', '2.7.3' );
|
||||
}
|
||||
if ( ! defined( 'SP_PLAYER_ASSIGNMENTS_URL' ) ) {
|
||||
define( 'SP_PLAYER_ASSIGNMENTS_URL', plugin_dir_url( __FILE__ ) );
|
||||
}
|
||||
if ( ! defined( 'SP_PLAYER_ASSIGNMENTS_DIR' ) ) {
|
||||
define( 'SP_PLAYER_ASSIGNMENTS_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add args to filter out assigned players
|
||||
*/
|
||||
public function add_args( $args = array(), $team = false ) {
|
||||
if ( ! $team ) return $args;
|
||||
|
||||
$tax_query = (array) sp_array_value( $args, 'tax_query', array() );
|
||||
$league_ids = array();
|
||||
$season_ids = array();
|
||||
/**
|
||||
* Save Additional Statistics
|
||||
*/
|
||||
public function save( $post_id ) {
|
||||
delete_post_meta( $post_id, 'sp_assignments' );
|
||||
|
||||
foreach ( $tax_query as $param ) {
|
||||
if ( 'sp_league' === sp_array_value( $param, 'taxonomy' ) ) $league_ids = sp_array_value( $param, 'terms', array() );
|
||||
if ( 'sp_season' === sp_array_value( $param, 'taxonomy' ) ) $season_ids = sp_array_value( $param, 'terms', array() );
|
||||
$leagues = sp_array_value( $_POST, 'sp_leagues', array() );
|
||||
|
||||
if ( ! is_array( $leagues ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ( $leagues as $l_id => $season ) {
|
||||
if ( 0 === $l_id ) {
|
||||
continue;
|
||||
}
|
||||
foreach ( $season as $s_id => $team_id ) {
|
||||
if ( 0 >= $team_id ) {
|
||||
continue;
|
||||
}
|
||||
$serialized = intval( $l_id ) . '_' . intval( $s_id ) . '_' . intval( $team_id );
|
||||
add_post_meta( $post_id, 'sp_assignments', $serialized, false );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( empty( $league_ids ) && empty( $season_ids ) ) return $args;
|
||||
/**
|
||||
* Add args to filter out assigned players
|
||||
*/
|
||||
public function add_args( $args = array(), $team = false ) {
|
||||
if ( ! $team ) {
|
||||
return $args;
|
||||
}
|
||||
|
||||
$args['meta_query'][] = array(
|
||||
'key' => 'sp_assignments',
|
||||
'value' => '',
|
||||
'compare' => 'NOT EXISTS',
|
||||
);
|
||||
$tax_query = (array) sp_array_value( $args, 'tax_query', array() );
|
||||
$league_ids = array();
|
||||
$season_ids = array();
|
||||
|
||||
$args['meta_query']['relation'] = 'AND';
|
||||
foreach ( $tax_query as $param ) {
|
||||
if ( 'sp_league' === sp_array_value( $param, 'taxonomy' ) ) {
|
||||
$league_ids = sp_array_value( $param, 'terms', array() );
|
||||
}
|
||||
if ( 'sp_season' === sp_array_value( $param, 'taxonomy' ) ) {
|
||||
$season_ids = sp_array_value( $param, 'terms', array() );
|
||||
}
|
||||
}
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add assigned players to player list
|
||||
*/
|
||||
public function add_players( $players = array(), $args = array(), $team = false, $team_key = 'sp_team' ) {
|
||||
if ( ! $team ) return $players;
|
||||
if ( empty( $league_ids ) && empty( $season_ids ) ) {
|
||||
return $args;
|
||||
}
|
||||
|
||||
$tax_query = (array) sp_array_value( $args, 'tax_query', array() );
|
||||
$league_ids = array();
|
||||
$season_ids = array();
|
||||
$args['meta_query'][] = array(
|
||||
'key' => 'sp_assignments',
|
||||
'value' => '',
|
||||
'compare' => 'NOT EXISTS',
|
||||
);
|
||||
|
||||
foreach ( $tax_query as $param ) {
|
||||
if ( 'sp_league' === sp_array_value( $param, 'taxonomy' ) ) $league_ids = sp_array_value( $param, 'terms', array() );
|
||||
if ( 'sp_season' === sp_array_value( $param, 'taxonomy' ) ) $season_ids = sp_array_value( $param, 'terms', array() );
|
||||
$args['meta_query']['relation'] = 'AND';
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
if ( empty( $league_ids ) && empty( $season_ids ) ) return $players;
|
||||
/**
|
||||
* Add assigned players to player list
|
||||
*/
|
||||
public function add_players( $players = array(), $args = array(), $team = false, $team_key = 'sp_team' ) {
|
||||
if ( ! $team ) {
|
||||
return $players;
|
||||
}
|
||||
|
||||
$assignments = array();
|
||||
|
||||
if ( !empty( $league_ids ) && !empty( $season_ids ) ) {
|
||||
foreach ( $league_ids as $l_id ) {
|
||||
foreach ( $season_ids as $s_id ) {
|
||||
if ( $team && $team != '0' ) {
|
||||
$assignments[] = $l_id.'_'.$s_id.'_'.$team;
|
||||
$compare = 'IN';
|
||||
$tax_query = (array) sp_array_value( $args, 'tax_query', array() );
|
||||
$league_ids = array();
|
||||
$season_ids = array();
|
||||
|
||||
foreach ( $tax_query as $param ) {
|
||||
if ( 'sp_league' === sp_array_value( $param, 'taxonomy' ) ) {
|
||||
$league_ids = sp_array_value( $param, 'terms', array() );
|
||||
}
|
||||
if ( 'sp_season' === sp_array_value( $param, 'taxonomy' ) ) {
|
||||
$season_ids = sp_array_value( $param, 'terms', array() );
|
||||
}
|
||||
}
|
||||
|
||||
if ( empty( $league_ids ) && empty( $season_ids ) ) {
|
||||
return $players;
|
||||
}
|
||||
|
||||
$assignments = array();
|
||||
|
||||
if ( ! empty( $league_ids ) && ! empty( $season_ids ) ) {
|
||||
foreach ( $league_ids as $l_id ) {
|
||||
foreach ( $season_ids as $s_id ) {
|
||||
if ( $team && $team != '0' ) {
|
||||
$assignments[] = $l_id . '_' . $s_id . '_' . $team;
|
||||
$compare = 'IN';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( empty( $league_ids ) && !empty( $season_ids ) ) {
|
||||
foreach ( $season_ids as $s_id ) {
|
||||
if ( $team && $team != '0' ) {
|
||||
$assignments[] = '_'.$s_id.'_'.$team;
|
||||
$compare = 'LIKE';
|
||||
|
||||
if ( empty( $league_ids ) && ! empty( $season_ids ) ) {
|
||||
foreach ( $season_ids as $s_id ) {
|
||||
if ( $team && $team != '0' ) {
|
||||
$assignments[] = '_' . $s_id . '_' . $team;
|
||||
$compare = 'LIKE';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( !empty( $league_ids ) && empty( $season_ids ) ) {
|
||||
foreach ( $league_ids as $l_id ) {
|
||||
if ( $team && $team != '0' ) {
|
||||
$assignments[] = $l_id.'_%_'.$team;
|
||||
$compare = 'LIKE';
|
||||
|
||||
if ( ! empty( $league_ids ) && empty( $season_ids ) ) {
|
||||
foreach ( $league_ids as $l_id ) {
|
||||
if ( $team && $team != '0' ) {
|
||||
$assignments[] = $l_id . '_%_' . $team;
|
||||
$compare = 'LIKE';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( sizeof( $assignments ) ) {
|
||||
if ( 'IN' == $compare ) {
|
||||
$args['meta_query'] = array(
|
||||
'relation' => 'AND',
|
||||
if ( sizeof( $assignments ) ) {
|
||||
if ( 'IN' == $compare ) {
|
||||
$args['meta_query'] = array(
|
||||
'relation' => 'AND',
|
||||
|
||||
array(
|
||||
'key' => 'sp_assignments',
|
||||
'value' => $assignments,
|
||||
'compare' => $compare,
|
||||
),
|
||||
array(
|
||||
'key' => 'sp_assignments',
|
||||
'value' => $assignments,
|
||||
'compare' => $compare,
|
||||
),
|
||||
|
||||
array(
|
||||
'key' => $team_key,
|
||||
'value' => $team,
|
||||
),
|
||||
);
|
||||
}
|
||||
if ( 'LIKE' == $compare ) {
|
||||
$args['meta_query'] = array(
|
||||
'relation' => 'AND',
|
||||
array(
|
||||
'key' => $team_key,
|
||||
'value' => $team,
|
||||
),
|
||||
);
|
||||
}
|
||||
if ( 'LIKE' == $compare ) {
|
||||
$args['meta_query'] = array(
|
||||
'relation' => 'AND',
|
||||
|
||||
array(
|
||||
'key' => $team_key,
|
||||
'value' => $team,
|
||||
),
|
||||
|
||||
array(
|
||||
'relation' => 'OR',
|
||||
),
|
||||
);
|
||||
foreach( $assignments as $assignment ) {
|
||||
$args['meta_query'][1][] = array(
|
||||
array(
|
||||
'key' => $team_key,
|
||||
'value' => $team,
|
||||
),
|
||||
|
||||
array(
|
||||
'relation' => 'OR',
|
||||
),
|
||||
);
|
||||
foreach ( $assignments as $assignment ) {
|
||||
$args['meta_query'][1][] = array(
|
||||
'key' => 'sp_assignments',
|
||||
'value' => $assignment,
|
||||
'compare' => $compare,
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$assigned_players = (array) get_posts( $args );
|
||||
|
||||
$players = array_merge( $assigned_players, $players );
|
||||
|
||||
$players = array_map( 'unserialize', array_unique( array_map( 'serialize', $players ) ) );
|
||||
|
||||
foreach ( $players as $i => $player ) {
|
||||
$player->sp_number = get_post_meta( $player->ID, 'sp_number', true );
|
||||
}
|
||||
|
||||
uasort( $players, array( $this, 'sort' ) );
|
||||
|
||||
return $players;
|
||||
}
|
||||
|
||||
$assigned_players = (array) get_posts( $args );
|
||||
|
||||
$players = array_merge( $assigned_players, $players );
|
||||
|
||||
$players = array_map( 'unserialize', array_unique( array_map( 'serialize', $players ) ) );
|
||||
|
||||
foreach ( $players as $i => $player ) {
|
||||
$player->sp_number = get_post_meta( $player->ID, 'sp_number', true );
|
||||
public function sort( $a, $b ) {
|
||||
if ( $a->sp_number == $b->sp_number ) {
|
||||
return 0;
|
||||
}
|
||||
return ( $a->sp_number < $b->sp_number ) ? -1 : 1;
|
||||
}
|
||||
|
||||
uasort( $players, array( $this, 'sort' ) );
|
||||
|
||||
return $players;
|
||||
}
|
||||
|
||||
public function sort( $a, $b ) {
|
||||
if ($a->sp_number == $b->sp_number) {
|
||||
return 0;
|
||||
}
|
||||
return ($a->sp_number < $b->sp_number) ? -1 : 1;
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
new SportsPress_Player_Assignments();
|
||||
|
||||
@@ -9,329 +9,352 @@
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SportsPress_Player_Lists' ) ) :
|
||||
|
||||
/**
|
||||
* Main SportsPress Player Lists Class
|
||||
*
|
||||
* @class SportsPress_Player_Lists
|
||||
* @version 2.6.15
|
||||
*/
|
||||
class SportsPress_Player_Lists {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Main SportsPress Player Lists Class
|
||||
*
|
||||
* @class SportsPress_Player_Lists
|
||||
* @version 2.6.15
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
class SportsPress_Player_Lists {
|
||||
|
||||
// Actions
|
||||
add_action( 'init', array( $this, 'register_post_type' ) );
|
||||
add_action( 'add_meta_boxes', array( $this, 'remove_meta_boxes' ), 10 );
|
||||
add_action( 'sportspress_include_post_type_handlers', array( $this, 'include_post_type_handler' ) );
|
||||
add_action( 'sportspress_widgets', array( $this, 'include_widgets' ) );
|
||||
add_action( 'sportspress_create_rest_routes', array( $this, 'create_rest_routes' ) );
|
||||
add_action( 'sportspress_register_rest_fields', array( $this, 'register_rest_fields' ) );
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
// Filters
|
||||
add_filter( 'sportspress_meta_boxes', array( $this, 'add_meta_boxes' ) );
|
||||
add_filter( 'sportspress_shortcodes', array( $this, 'add_shortcodes' ) );
|
||||
add_filter( 'sportspress_player_settings', array( $this, 'add_settings' ) );
|
||||
add_filter( 'sportspress_after_team_template', array( $this, 'add_team_template' ), 20 );
|
||||
}
|
||||
// Actions
|
||||
add_action( 'init', array( $this, 'register_post_type' ) );
|
||||
add_action( 'add_meta_boxes', array( $this, 'remove_meta_boxes' ), 10 );
|
||||
add_action( 'sportspress_include_post_type_handlers', array( $this, 'include_post_type_handler' ) );
|
||||
add_action( 'sportspress_widgets', array( $this, 'include_widgets' ) );
|
||||
add_action( 'sportspress_create_rest_routes', array( $this, 'create_rest_routes' ) );
|
||||
add_action( 'sportspress_register_rest_fields', array( $this, 'register_rest_fields' ) );
|
||||
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( !defined( 'SP_PLAYER_LISTS_VERSION' ) )
|
||||
define( 'SP_PLAYER_LISTS_VERSION', '2.6.15' );
|
||||
// Filters
|
||||
add_filter( 'sportspress_meta_boxes', array( $this, 'add_meta_boxes' ) );
|
||||
add_filter( 'sportspress_shortcodes', array( $this, 'add_shortcodes' ) );
|
||||
add_filter( 'sportspress_player_settings', array( $this, 'add_settings' ) );
|
||||
add_filter( 'sportspress_after_team_template', array( $this, 'add_team_template' ), 20 );
|
||||
}
|
||||
|
||||
if ( !defined( 'SP_PLAYER_LISTS_URL' ) )
|
||||
define( 'SP_PLAYER_LISTS_URL', plugin_dir_url( __FILE__ ) );
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( ! defined( 'SP_PLAYER_LISTS_VERSION' ) ) {
|
||||
define( 'SP_PLAYER_LISTS_VERSION', '2.6.15' );
|
||||
}
|
||||
|
||||
if ( !defined( 'SP_PLAYER_LISTS_DIR' ) )
|
||||
define( 'SP_PLAYER_LISTS_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
if ( ! defined( 'SP_PLAYER_LISTS_URL' ) ) {
|
||||
define( 'SP_PLAYER_LISTS_URL', plugin_dir_url( __FILE__ ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register league tables post type
|
||||
*/
|
||||
public static function register_post_type() {
|
||||
register_post_type( 'sp_list',
|
||||
apply_filters( 'sportspress_register_post_type_list',
|
||||
array(
|
||||
'labels' => array(
|
||||
'name' => __( 'Player Lists', 'sportspress' ),
|
||||
'singular_name' => __( 'Player List', 'sportspress' ),
|
||||
'add_new_item' => __( 'Add New Player List', 'sportspress' ),
|
||||
'edit_item' => __( 'Edit Player List', 'sportspress' ),
|
||||
'new_item' => __( 'New', 'sportspress' ),
|
||||
'view_item' => __( 'View Player List', 'sportspress' ),
|
||||
'search_items' => __( 'Search', 'sportspress' ),
|
||||
'not_found' => __( 'No results found.', 'sportspress' ),
|
||||
'not_found_in_trash' => __( 'No results found.', 'sportspress' ),
|
||||
),
|
||||
'public' => true,
|
||||
'show_ui' => true,
|
||||
'capability_type' => 'sp_list',
|
||||
'map_meta_cap' => true,
|
||||
'publicly_queryable' => true,
|
||||
'exclude_from_search' => false,
|
||||
'hierarchical' => false,
|
||||
'rewrite' => array( 'slug' => get_option( 'sportspress_list_slug', 'list' ) ),
|
||||
'supports' => array( 'title', 'editor', 'page-attributes', 'author', 'thumbnail' ),
|
||||
'has_archive' => false,
|
||||
'show_in_nav_menus' => true,
|
||||
'show_in_menu' => 'edit.php?post_type=sp_player',
|
||||
'show_in_admin_bar' => true,
|
||||
'show_in_rest' => true,
|
||||
'rest_controller_class' => 'SP_REST_Posts_Controller',
|
||||
'rest_base' => 'lists',
|
||||
if ( ! defined( 'SP_PLAYER_LISTS_DIR' ) ) {
|
||||
define( 'SP_PLAYER_LISTS_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register league tables post type
|
||||
*/
|
||||
public static function register_post_type() {
|
||||
register_post_type(
|
||||
'sp_list',
|
||||
apply_filters(
|
||||
'sportspress_register_post_type_list',
|
||||
array(
|
||||
'labels' => array(
|
||||
'name' => __( 'Player Lists', 'sportspress' ),
|
||||
'singular_name' => __( 'Player List', 'sportspress' ),
|
||||
'add_new_item' => __( 'Add New Player List', 'sportspress' ),
|
||||
'edit_item' => __( 'Edit Player List', 'sportspress' ),
|
||||
'new_item' => __( 'New', 'sportspress' ),
|
||||
'view_item' => __( 'View Player List', 'sportspress' ),
|
||||
'search_items' => __( 'Search', 'sportspress' ),
|
||||
'not_found' => __( 'No results found.', 'sportspress' ),
|
||||
'not_found_in_trash' => __( 'No results found.', 'sportspress' ),
|
||||
),
|
||||
'public' => true,
|
||||
'show_ui' => true,
|
||||
'capability_type' => 'sp_list',
|
||||
'map_meta_cap' => true,
|
||||
'publicly_queryable' => true,
|
||||
'exclude_from_search' => false,
|
||||
'hierarchical' => false,
|
||||
'rewrite' => array( 'slug' => get_option( 'sportspress_list_slug', 'list' ) ),
|
||||
'supports' => array( 'title', 'editor', 'page-attributes', 'author', 'thumbnail' ),
|
||||
'has_archive' => false,
|
||||
'show_in_nav_menus' => true,
|
||||
'show_in_menu' => 'edit.php?post_type=sp_player',
|
||||
'show_in_admin_bar' => true,
|
||||
'show_in_rest' => true,
|
||||
'rest_controller_class' => 'SP_REST_Posts_Controller',
|
||||
'rest_base' => 'lists',
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove meta boxes.
|
||||
*/
|
||||
public function remove_meta_boxes() {
|
||||
remove_meta_box( 'sp_positiondiv', 'sp_list', 'side' );
|
||||
remove_meta_box( 'sp_seasondiv', 'sp_list', 'side' );
|
||||
remove_meta_box( 'sp_leaguediv', 'sp_list', 'side' );
|
||||
}
|
||||
/**
|
||||
* Remove meta boxes.
|
||||
*/
|
||||
public function remove_meta_boxes() {
|
||||
remove_meta_box( 'sp_positiondiv', 'sp_list', 'side' );
|
||||
remove_meta_box( 'sp_seasondiv', 'sp_list', 'side' );
|
||||
remove_meta_box( 'sp_leaguediv', 'sp_list', 'side' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Conditonally load the class and functions only needed when viewing this post type.
|
||||
*/
|
||||
public function include_post_type_handler() {
|
||||
include_once( SP()->plugin_path() . '/includes/admin/post-types/class-sp-admin-cpt-list.php' );
|
||||
}
|
||||
/**
|
||||
* Conditonally load the class and functions only needed when viewing this post type.
|
||||
*/
|
||||
public function include_post_type_handler() {
|
||||
include_once SP()->plugin_path() . '/includes/admin/post-types/class-sp-admin-cpt-list.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Add widgets.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function include_widgets() {
|
||||
include_once( SP()->plugin_path() . '/includes/widgets/class-sp-widget-player-list.php' );
|
||||
include_once( SP()->plugin_path() . '/includes/widgets/class-sp-widget-player-gallery.php' );
|
||||
}
|
||||
/**
|
||||
* Add widgets.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function include_widgets() {
|
||||
include_once SP()->plugin_path() . '/includes/widgets/class-sp-widget-player-list.php';
|
||||
include_once SP()->plugin_path() . '/includes/widgets/class-sp-widget-player-gallery.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Create REST API routes.
|
||||
*/
|
||||
public function create_rest_routes() {
|
||||
$controller = new SP_REST_Posts_Controller( 'sp_list' );
|
||||
$controller->register_routes();
|
||||
}
|
||||
/**
|
||||
* Create REST API routes.
|
||||
*/
|
||||
public function create_rest_routes() {
|
||||
$controller = new SP_REST_Posts_Controller( 'sp_list' );
|
||||
$controller->register_routes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register REST API fields.
|
||||
*/
|
||||
public function register_rest_fields() {
|
||||
register_rest_field( 'sp_list',
|
||||
'format',
|
||||
array(
|
||||
'get_callback' => 'SP_REST_API::get_post_meta',
|
||||
'update_callback' => 'SP_REST_API::update_post_meta',
|
||||
'schema' => array(
|
||||
'description' => __( 'Layout', 'sportspress' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
'sanitize_callback' => 'rest_sanitize_request_arg',
|
||||
/**
|
||||
* Register REST API fields.
|
||||
*/
|
||||
public function register_rest_fields() {
|
||||
register_rest_field(
|
||||
'sp_list',
|
||||
'format',
|
||||
array(
|
||||
'get_callback' => 'SP_REST_API::get_post_meta',
|
||||
'update_callback' => 'SP_REST_API::update_post_meta',
|
||||
'schema' => array(
|
||||
'description' => __( 'Layout', 'sportspress' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
'sanitize_callback' => 'rest_sanitize_request_arg',
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
register_rest_field( 'sp_list',
|
||||
'data',
|
||||
array(
|
||||
'get_callback' => 'SP_REST_API::get_post_data',
|
||||
'update_callback' => 'SP_REST_API::update_post_meta_arrays',
|
||||
'schema' => array(
|
||||
'description' => __( 'Player List', 'sportspress' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
'sanitize_callback' => 'rest_sanitize_request_arg',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* Add meta boxes.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_meta_boxes( $meta_boxes ) {
|
||||
$meta_boxes['sp_team']['lists'] = array(
|
||||
'title' => __( 'Player Lists', 'sportspress' ),
|
||||
'output' => 'SP_Meta_Box_Team_Lists::output',
|
||||
'save' => 'SP_Meta_Box_Team_Lists::save',
|
||||
'context' => 'normal',
|
||||
'priority' => 'high',
|
||||
);
|
||||
$meta_boxes['sp_list'] = array(
|
||||
'shortcode' => array(
|
||||
'title' => __( 'Shortcode', 'sportspress' ),
|
||||
'output' => 'SP_Meta_Box_List_Shortcode::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'format' => array(
|
||||
'title' => __( 'Layout', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_List_Format::save',
|
||||
'output' => 'SP_Meta_Box_List_Format::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'columns' => array(
|
||||
'title' => __( 'Columns', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_List_Columns::save',
|
||||
'output' => 'SP_Meta_Box_List_Columns::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'details' => array(
|
||||
'title' => __( 'Details', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_List_Details::save',
|
||||
'output' => 'SP_Meta_Box_List_Details::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'data' => array(
|
||||
'title' => __( 'Player List', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_List_Data::save',
|
||||
'output' => 'SP_Meta_Box_List_Data::output',
|
||||
'context' => 'normal',
|
||||
register_rest_field(
|
||||
'sp_list',
|
||||
'data',
|
||||
array(
|
||||
'get_callback' => 'SP_REST_API::get_post_data',
|
||||
'update_callback' => 'SP_REST_API::update_post_meta_arrays',
|
||||
'schema' => array(
|
||||
'description' => __( 'Player List', 'sportspress' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
'sanitize_callback' => 'rest_sanitize_request_arg',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add meta boxes.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_meta_boxes( $meta_boxes ) {
|
||||
$meta_boxes['sp_team']['lists'] = array(
|
||||
'title' => __( 'Player Lists', 'sportspress' ),
|
||||
'output' => 'SP_Meta_Box_Team_Lists::output',
|
||||
'save' => 'SP_Meta_Box_Team_Lists::save',
|
||||
'context' => 'normal',
|
||||
'priority' => 'high',
|
||||
),
|
||||
);
|
||||
return $meta_boxes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add shortcodes.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_shortcodes( $shortcodes ) {
|
||||
$shortcodes['player'][] = 'list';
|
||||
$shortcodes['player'][] = 'gallery';
|
||||
return $shortcodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add settings.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_settings( $settings ) {
|
||||
return array_merge( $settings, array_merge(
|
||||
array(
|
||||
array( 'title' => __( 'Player Lists', 'sportspress' ), 'type' => 'title', 'id' => 'list_options' ),
|
||||
),
|
||||
|
||||
apply_filters( 'sportspress_player_list_options', array(
|
||||
array(
|
||||
'title' => __( 'Title', 'sportspress' ),
|
||||
'desc' => __( 'Display title', 'sportspress' ),
|
||||
'id' => 'sportspress_list_show_title',
|
||||
'default' => 'yes',
|
||||
'type' => 'checkbox',
|
||||
);
|
||||
$meta_boxes['sp_list'] = array(
|
||||
'shortcode' => array(
|
||||
'title' => __( 'Shortcode', 'sportspress' ),
|
||||
'output' => 'SP_Meta_Box_List_Shortcode::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Players', 'sportspress' ),
|
||||
'desc' => __( 'Display photos', 'sportspress' ),
|
||||
'id' => 'sportspress_list_show_photos',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'start',
|
||||
'format' => array(
|
||||
'title' => __( 'Layout', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_List_Format::save',
|
||||
'output' => 'SP_Meta_Box_List_Format::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
|
||||
array(
|
||||
'desc' => __( 'Display national flags', 'sportspress' ),
|
||||
'id' => 'sportspress_list_show_flags',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'end',
|
||||
'columns' => array(
|
||||
'title' => __( 'Columns', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_List_Columns::save',
|
||||
'output' => 'SP_Meta_Box_List_Columns::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Teams', 'sportspress' ),
|
||||
'desc' => __( 'Display logos', 'sportspress' ),
|
||||
'id' => 'sportspress_list_show_logos',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'details' => array(
|
||||
'title' => __( 'Details', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_List_Details::save',
|
||||
'output' => 'SP_Meta_Box_List_Details::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'data' => array(
|
||||
'title' => __( 'Player List', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_List_Data::save',
|
||||
'output' => 'SP_Meta_Box_List_Data::output',
|
||||
'context' => 'normal',
|
||||
'priority' => 'high',
|
||||
),
|
||||
);
|
||||
return $meta_boxes;
|
||||
}
|
||||
|
||||
array(
|
||||
'title' => __( 'Teams', 'sportspress' ),
|
||||
'id' => 'sportspress_list_team_format',
|
||||
'default' => 'name',
|
||||
'type' => 'radio',
|
||||
'options' => array(
|
||||
'name' => __( 'Name', 'sportspress' ),
|
||||
'logo' => __( 'Logo', 'sportspress' ),
|
||||
/**
|
||||
* Add shortcodes.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_shortcodes( $shortcodes ) {
|
||||
$shortcodes['player'][] = 'list';
|
||||
$shortcodes['player'][] = 'gallery';
|
||||
return $shortcodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add settings.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_settings( $settings ) {
|
||||
return array_merge(
|
||||
$settings,
|
||||
array_merge(
|
||||
array(
|
||||
array(
|
||||
'title' => __( 'Player Lists', 'sportspress' ),
|
||||
'type' => 'title',
|
||||
'id' => 'list_options',
|
||||
),
|
||||
),
|
||||
),
|
||||
apply_filters(
|
||||
'sportspress_player_list_options',
|
||||
array(
|
||||
array(
|
||||
'title' => __( 'Title', 'sportspress' ),
|
||||
'desc' => __( 'Display title', 'sportspress' ),
|
||||
'id' => 'sportspress_list_show_title',
|
||||
'default' => 'yes',
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Pagination', 'sportspress' ),
|
||||
'desc' => __( 'Paginate', 'sportspress' ),
|
||||
'id' => 'sportspress_list_paginated',
|
||||
'default' => 'yes',
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Limit', 'sportspress' ),
|
||||
'id' => 'sportspress_list_rows',
|
||||
'class' => 'small-text',
|
||||
'default' => '10',
|
||||
'desc' => __( 'players', 'sportspress' ),
|
||||
'type' => 'number',
|
||||
'custom_attributes' => array(
|
||||
'min' => 1,
|
||||
'step' => 1
|
||||
array(
|
||||
'title' => __( 'Players', 'sportspress' ),
|
||||
'desc' => __( 'Display photos', 'sportspress' ),
|
||||
'id' => 'sportspress_list_show_photos',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'start',
|
||||
),
|
||||
|
||||
array(
|
||||
'desc' => __( 'Display national flags', 'sportspress' ),
|
||||
'id' => 'sportspress_list_show_flags',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'end',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Teams', 'sportspress' ),
|
||||
'desc' => __( 'Display logos', 'sportspress' ),
|
||||
'id' => 'sportspress_list_show_logos',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Teams', 'sportspress' ),
|
||||
'id' => 'sportspress_list_team_format',
|
||||
'default' => 'name',
|
||||
'type' => 'radio',
|
||||
'options' => array(
|
||||
'name' => __( 'Name', 'sportspress' ),
|
||||
'logo' => __( 'Logo', 'sportspress' ),
|
||||
),
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Pagination', 'sportspress' ),
|
||||
'desc' => __( 'Paginate', 'sportspress' ),
|
||||
'id' => 'sportspress_list_paginated',
|
||||
'default' => 'yes',
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Limit', 'sportspress' ),
|
||||
'id' => 'sportspress_list_rows',
|
||||
'class' => 'small-text',
|
||||
'default' => '10',
|
||||
'desc' => __( 'players', 'sportspress' ),
|
||||
'type' => 'number',
|
||||
'custom_attributes' => array(
|
||||
'min' => 1,
|
||||
'step' => 1,
|
||||
),
|
||||
),
|
||||
)
|
||||
),
|
||||
),
|
||||
) ),
|
||||
array(
|
||||
array(
|
||||
'type' => 'sectionend',
|
||||
'id' => 'list_options',
|
||||
),
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
array(
|
||||
array( 'type' => 'sectionend', 'id' => 'list_options' ),
|
||||
)
|
||||
) );
|
||||
/**
|
||||
* Add team template.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_team_template( $templates ) {
|
||||
return array_merge(
|
||||
$templates,
|
||||
array(
|
||||
'lists' => array(
|
||||
'title' => __( 'Player Lists', 'sportspress' ),
|
||||
'label' => __( 'Players', 'sportspress' ),
|
||||
'option' => 'sportspress_team_show_lists',
|
||||
'action' => 'sportspress_output_team_lists',
|
||||
'default' => 'yes',
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add team template.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_team_template( $templates ) {
|
||||
return array_merge( $templates, array(
|
||||
'lists' => array(
|
||||
'title' => __( 'Player Lists', 'sportspress' ),
|
||||
'label' => __( 'Players', 'sportspress' ),
|
||||
'option' => 'sportspress_team_show_lists',
|
||||
'action' => 'sportspress_output_team_lists',
|
||||
'default' => 'yes',
|
||||
),
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
if ( get_option( 'sportspress_load_player_lists_module', 'yes' ) == 'yes' ) {
|
||||
@@ -340,6 +363,6 @@ if ( get_option( 'sportspress_load_player_lists_module', 'yes' ) == 'yes' ) {
|
||||
/**
|
||||
* Create alias of SP_Player_List class for REST API.
|
||||
* Note: class_alias is not supported in PHP < 5.3 so extend the original class instead.
|
||||
*/
|
||||
*/
|
||||
class SP_List extends SP_Player_List {}
|
||||
}
|
||||
|
||||
@@ -9,161 +9,185 @@
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SportsPress_Styles' ) ) :
|
||||
|
||||
/**
|
||||
* Main SportsPress Styles Class
|
||||
*
|
||||
* @class SportsPress_Styles
|
||||
* @version 2.7
|
||||
*/
|
||||
class SportsPress_Styles {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Main SportsPress Styles Class
|
||||
*
|
||||
* @class SportsPress_Styles
|
||||
* @version 2.7
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
// Add option
|
||||
add_filter( 'sportspress_script_styling_options', array( $this, 'add_option' ) );
|
||||
class SportsPress_Styles {
|
||||
|
||||
// Add stylesheet
|
||||
add_filter( 'sportspress_enqueue_styles', array( $this, 'add_styles' ), 20 );
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
// Output custom CSS
|
||||
add_action( 'sportspress_frontend_css', array( $this, 'custom_css' ), 40 );
|
||||
}
|
||||
// Add option
|
||||
add_filter( 'sportspress_script_styling_options', array( $this, 'add_option' ) );
|
||||
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( !defined( 'SP_STYLES_VERSION' ) )
|
||||
define( 'SP_STYLES_VERSION', '2.7' );
|
||||
// Add stylesheet
|
||||
add_filter( 'sportspress_enqueue_styles', array( $this, 'add_styles' ), 20 );
|
||||
|
||||
if ( !defined( 'SP_STYLES_URL' ) )
|
||||
define( 'SP_STYLES_URL', plugin_dir_url( __FILE__ ) );
|
||||
// Output custom CSS
|
||||
add_action( 'sportspress_frontend_css', array( $this, 'custom_css' ), 40 );
|
||||
}
|
||||
|
||||
if ( !defined( 'SP_STYLES_DIR' ) )
|
||||
define( 'SP_STYLES_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( ! defined( 'SP_STYLES_VERSION' ) ) {
|
||||
define( 'SP_STYLES_VERSION', '2.7' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add option.
|
||||
*/
|
||||
public static function add_option( $options = array() ) {
|
||||
if ( current_theme_supports( 'sportspress' ) && ! current_theme_supports( 'sportspress-styles' ) ) return $options;
|
||||
if ( ! defined( 'SP_STYLES_URL' ) ) {
|
||||
define( 'SP_STYLES_URL', plugin_dir_url( __FILE__ ) );
|
||||
}
|
||||
|
||||
array_unshift( $options, array(
|
||||
'title' => __( 'Frontend Styles', 'sportspress' ),
|
||||
'desc' => __( 'Enable', 'sportspress' ),
|
||||
'id' => 'sportspress_styles',
|
||||
'default' => 'yes',
|
||||
'type' => 'checkbox',
|
||||
) );
|
||||
if ( ! defined( 'SP_STYLES_DIR' ) ) {
|
||||
define( 'SP_STYLES_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
/**
|
||||
* Add option.
|
||||
*/
|
||||
public static function add_option( $options = array() ) {
|
||||
if ( current_theme_supports( 'sportspress' ) && ! current_theme_supports( 'sportspress-styles' ) ) {
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add stylesheet.
|
||||
*/
|
||||
public static function add_styles( $styles = array() ) {
|
||||
if ( current_theme_supports( 'sportspress' ) && ! current_theme_supports( 'sportspress-styles' ) ) return $styles;
|
||||
if ( 'no' === get_option( 'sportspress_styles', 'yes' ) ) return $styles;
|
||||
|
||||
$styles['sportspress-roboto'] = array(
|
||||
'src' => '//fonts.googleapis.com/css?family=Roboto:400,500&subset=cyrillic,cyrillic-ext,greek,greek-ext,latin-ext,vietnamese',
|
||||
'deps' => '',
|
||||
'version' => SP_STYLES_VERSION,
|
||||
'media' => 'all'
|
||||
);
|
||||
|
||||
$styles['sportspress-style'] = array(
|
||||
'src' => str_replace( array( 'http:', 'https:' ), '', SP()->plugin_url() ) . '/assets/css/sportspress-style.css',
|
||||
'deps' => '',
|
||||
'version' => SP_STYLES_VERSION,
|
||||
'media' => 'all'
|
||||
);
|
||||
|
||||
if ( is_rtl() ) {
|
||||
$styles['sportspress-style-rtl'] = array(
|
||||
'src' => str_replace( array( 'http:', 'https:' ), '', SP()->plugin_url() ) . '/assets/css/sportspress-style-rtl.css',
|
||||
'deps' => 'sportspress-style',
|
||||
'version' => SP_STYLES_VERSION,
|
||||
'media' => 'all'
|
||||
array_unshift(
|
||||
$options,
|
||||
array(
|
||||
'title' => __( 'Frontend Styles', 'sportspress' ),
|
||||
'desc' => __( 'Enable', 'sportspress' ),
|
||||
'id' => 'sportspress_styles',
|
||||
'default' => 'yes',
|
||||
'type' => 'checkbox',
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$styles['sportspress-style-ltr'] = array(
|
||||
'src' => str_replace( array( 'http:', 'https:' ), '', SP()->plugin_url() ) . '/assets/css/sportspress-style-ltr.css',
|
||||
'deps' => 'sportspress-style',
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add stylesheet.
|
||||
*/
|
||||
public static function add_styles( $styles = array() ) {
|
||||
if ( current_theme_supports( 'sportspress' ) && ! current_theme_supports( 'sportspress-styles' ) ) {
|
||||
return $styles;
|
||||
}
|
||||
if ( 'no' === get_option( 'sportspress_styles', 'yes' ) ) {
|
||||
return $styles;
|
||||
}
|
||||
|
||||
$styles['sportspress-roboto'] = array(
|
||||
'src' => '//fonts.googleapis.com/css?family=Roboto:400,500&subset=cyrillic,cyrillic-ext,greek,greek-ext,latin-ext,vietnamese',
|
||||
'deps' => '',
|
||||
'version' => SP_STYLES_VERSION,
|
||||
'media' => 'all'
|
||||
'media' => 'all',
|
||||
);
|
||||
|
||||
$styles['sportspress-style'] = array(
|
||||
'src' => str_replace( array( 'http:', 'https:' ), '', SP()->plugin_url() ) . '/assets/css/sportspress-style.css',
|
||||
'deps' => '',
|
||||
'version' => SP_STYLES_VERSION,
|
||||
'media' => 'all',
|
||||
);
|
||||
|
||||
if ( is_rtl() ) {
|
||||
$styles['sportspress-style-rtl'] = array(
|
||||
'src' => str_replace( array( 'http:', 'https:' ), '', SP()->plugin_url() ) . '/assets/css/sportspress-style-rtl.css',
|
||||
'deps' => 'sportspress-style',
|
||||
'version' => SP_STYLES_VERSION,
|
||||
'media' => 'all',
|
||||
);
|
||||
} else {
|
||||
$styles['sportspress-style-ltr'] = array(
|
||||
'src' => str_replace( array( 'http:', 'https:' ), '', SP()->plugin_url() ) . '/assets/css/sportspress-style-ltr.css',
|
||||
'deps' => 'sportspress-style',
|
||||
'version' => SP_STYLES_VERSION,
|
||||
'media' => 'all',
|
||||
);
|
||||
}
|
||||
|
||||
return $styles;
|
||||
}
|
||||
|
||||
return $styles;
|
||||
/**
|
||||
* Output custom CSS.
|
||||
*/
|
||||
public function custom_css( $colors = array() ) {
|
||||
|
||||
if ( current_theme_supports( 'sportspress' ) && ! current_theme_supports( 'sportspress-styles' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( 'no' === get_option( 'sportspress_styles', 'yes' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Defaults
|
||||
if ( empty( $colors['primary'] ) ) {
|
||||
$colors['primary'] = '#2b353e';
|
||||
}
|
||||
if ( empty( $colors['background'] ) ) {
|
||||
$colors['background'] = '#f4f4f4';
|
||||
}
|
||||
if ( empty( $colors['text'] ) ) {
|
||||
$colors['text'] = '#222222';
|
||||
}
|
||||
if ( empty( $colors['heading'] ) ) {
|
||||
$colors['heading'] = '#ffffff';
|
||||
}
|
||||
if ( empty( $colors['link'] ) ) {
|
||||
$colors['link'] = '#00a69c';
|
||||
}
|
||||
|
||||
// Calculate primary variations
|
||||
$colors['primary_border'] = sp_hex_darker( $colors['primary'], 26, true );
|
||||
|
||||
// Calculate background variations
|
||||
$colors['background_highlight'] = sp_hex_darker( $colors['background'], 6, true );
|
||||
$colors['background_border'] = sp_hex_darker( $colors['background'], 26, true );
|
||||
|
||||
// Calculate text variations
|
||||
$rgb = sp_rgb_from_hex( $colors['text'] );
|
||||
$colors['text_muted'] = 'rgba(' . implode( ',', $rgb ) . ',0.5)';
|
||||
|
||||
// Primary
|
||||
echo '.sp-data-table th,.sp-template-countdown .sp-event-venue,.sp-template-countdown .sp-event-league,.sp-template-gallery .gallery-caption{background:' . $colors['primary'] . ' !important}';
|
||||
echo '.sp-data-table th,.sp-template-countdown .sp-event-venue,.sp-template-countdown .sp-event-league,.sp-template-gallery .gallery-caption{border-color:' . $colors['primary_border'] . ' !important}';
|
||||
|
||||
// Background
|
||||
echo '.sp-table-caption,.sp-data-table,.sp-data-table tfoot,.sp-template .sp-view-all-link,.sp-template-gallery .sp-gallery-group-name,.sp-template-gallery .sp-gallery-wrapper,.sp-template-countdown .sp-event-name,.sp-countdown time,.sp-template-details dl,.sp-event-statistics .sp-statistic-bar,.sp-tournament-bracket .sp-team-name,.sp-profile-selector{background:' . $colors['background'] . ' !important}';
|
||||
echo '.sp-table-caption,.sp-data-table,.sp-data-table td,.sp-template .sp-view-all-link,.sp-template-gallery .sp-gallery-group-name,.sp-template-gallery .sp-gallery-wrapper,.sp-template-countdown .sp-event-name,.sp-countdown time,.sp-countdown span,.sp-template-details dl,.sp-event-statistics .sp-statistic-bar,.sp-tournament-bracket thead th,.sp-tournament-bracket .sp-team-name,.sp-tournament-bracket .sp-event,.sp-profile-selector{border-color:' . $colors['background_border'] . ' !important}';
|
||||
echo '.sp-tournament-bracket .sp-team .sp-team-name:before{border-left-color:' . $colors['background_border'] . ' !important;border-right-color:' . $colors['background_border'] . ' !important}';
|
||||
echo '.sp-data-table .sp-highlight,.sp-data-table .highlighted td,.sp-template-scoreboard td:hover{background:' . $colors['background_highlight'] . ' !important}';
|
||||
|
||||
// Text
|
||||
echo '.sp-template *,.sp-data-table *,.sp-table-caption,.sp-data-table tfoot a:hover,.sp-template .sp-view-all-link a:hover,.sp-template-gallery .sp-gallery-group-name,.sp-template-details dd,.sp-template-event-logos .sp-team-result,.sp-template-event-blocks .sp-event-results,.sp-template-scoreboard a,.sp-template-scoreboard a:hover,.sp-tournament-bracket,.sp-tournament-bracket .sp-event .sp-event-title:hover,.sp-tournament-bracket .sp-event .sp-event-title:hover *{color:' . $colors['text'] . ' !important}';
|
||||
echo '.sp-template .sp-view-all-link a,.sp-countdown span small,.sp-template-event-calendar tfoot a,.sp-template-event-blocks .sp-event-date,.sp-template-details dt,.sp-template-scoreboard .sp-scoreboard-date,.sp-tournament-bracket th,.sp-tournament-bracket .sp-event .sp-event-title,.sp-template-scoreboard .sp-scoreboard-date,.sp-tournament-bracket .sp-event .sp-event-title *{color:' . $colors['text_muted'] . ' !important}';
|
||||
|
||||
// Heading
|
||||
echo '.sp-data-table th,.sp-template-countdown .sp-event-venue,.sp-template-countdown .sp-event-league,.sp-template-gallery .gallery-item a,.sp-template-gallery .gallery-caption,.sp-template-scoreboard .sp-scoreboard-nav,.sp-tournament-bracket .sp-team-name:hover,.sp-tournament-bracket thead th,.sp-tournament-bracket .sp-heading{color:' . $colors['heading'] . ' !important}';
|
||||
|
||||
// Link
|
||||
echo '.sp-template a,.sp-data-table a,.sp-tab-menu-item-active a, .sp-tab-menu-item-active a:hover,.sp-template .sp-message{color:' . $colors['link'] . ' !important}';
|
||||
echo '.sp-template-gallery .gallery-caption strong,.sp-tournament-bracket .sp-team-name:hover,.sp-template-scoreboard .sp-scoreboard-nav,.sp-tournament-bracket .sp-heading{background:' . $colors['link'] . ' !important}';
|
||||
echo '.sp-tournament-bracket .sp-team-name:hover,.sp-tournament-bracket .sp-heading,.sp-tab-menu-item-active a, .sp-tab-menu-item-active a:hover,.sp-template .sp-message{border-color:' . $colors['link'] . ' !important}';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Output custom CSS.
|
||||
*/
|
||||
public function custom_css( $colors = array() ) {
|
||||
|
||||
if ( current_theme_supports( 'sportspress' ) && ! current_theme_supports( 'sportspress-styles' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( 'no' === get_option( 'sportspress_styles', 'yes' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Defaults
|
||||
if ( empty( $colors['primary'] ) ) $colors['primary'] = '#2b353e';
|
||||
if ( empty( $colors['background'] ) ) $colors['background'] = '#f4f4f4';
|
||||
if ( empty( $colors['text'] ) ) $colors['text'] = '#222222';
|
||||
if ( empty( $colors['heading'] ) ) $colors['heading'] = '#ffffff';
|
||||
if ( empty( $colors['link'] ) ) $colors['link'] = '#00a69c';
|
||||
|
||||
// Calculate primary variations
|
||||
$colors['primary_border'] = sp_hex_darker( $colors['primary'], 26, true );
|
||||
|
||||
// Calculate background variations
|
||||
$colors['background_highlight'] = sp_hex_darker( $colors['background'], 6, true );
|
||||
$colors['background_border'] = sp_hex_darker( $colors['background'], 26, true );
|
||||
|
||||
// Calculate text variations
|
||||
$rgb = sp_rgb_from_hex( $colors['text'] );
|
||||
$colors['text_muted'] = 'rgba(' . implode( ',', $rgb ) . ',0.5)';
|
||||
|
||||
// Primary
|
||||
echo '.sp-data-table th,.sp-template-countdown .sp-event-venue,.sp-template-countdown .sp-event-league,.sp-template-gallery .gallery-caption{background:' . $colors['primary'] . ' !important}';
|
||||
echo '.sp-data-table th,.sp-template-countdown .sp-event-venue,.sp-template-countdown .sp-event-league,.sp-template-gallery .gallery-caption{border-color:' . $colors['primary_border'] . ' !important}';
|
||||
|
||||
// Background
|
||||
echo '.sp-table-caption,.sp-data-table,.sp-data-table tfoot,.sp-template .sp-view-all-link,.sp-template-gallery .sp-gallery-group-name,.sp-template-gallery .sp-gallery-wrapper,.sp-template-countdown .sp-event-name,.sp-countdown time,.sp-template-details dl,.sp-event-statistics .sp-statistic-bar,.sp-tournament-bracket .sp-team-name,.sp-profile-selector{background:' . $colors['background'] . ' !important}';
|
||||
echo '.sp-table-caption,.sp-data-table,.sp-data-table td,.sp-template .sp-view-all-link,.sp-template-gallery .sp-gallery-group-name,.sp-template-gallery .sp-gallery-wrapper,.sp-template-countdown .sp-event-name,.sp-countdown time,.sp-countdown span,.sp-template-details dl,.sp-event-statistics .sp-statistic-bar,.sp-tournament-bracket thead th,.sp-tournament-bracket .sp-team-name,.sp-tournament-bracket .sp-event,.sp-profile-selector{border-color:' . $colors['background_border'] . ' !important}';
|
||||
echo '.sp-tournament-bracket .sp-team .sp-team-name:before{border-left-color:' . $colors['background_border'] . ' !important;border-right-color:' . $colors['background_border'] . ' !important}';
|
||||
echo '.sp-data-table .sp-highlight,.sp-data-table .highlighted td,.sp-template-scoreboard td:hover{background:' . $colors['background_highlight'] . ' !important}';
|
||||
|
||||
// Text
|
||||
echo '.sp-template *,.sp-data-table *,.sp-table-caption,.sp-data-table tfoot a:hover,.sp-template .sp-view-all-link a:hover,.sp-template-gallery .sp-gallery-group-name,.sp-template-details dd,.sp-template-event-logos .sp-team-result,.sp-template-event-blocks .sp-event-results,.sp-template-scoreboard a,.sp-template-scoreboard a:hover,.sp-tournament-bracket,.sp-tournament-bracket .sp-event .sp-event-title:hover,.sp-tournament-bracket .sp-event .sp-event-title:hover *{color:' . $colors['text'] . ' !important}';
|
||||
echo '.sp-template .sp-view-all-link a,.sp-countdown span small,.sp-template-event-calendar tfoot a,.sp-template-event-blocks .sp-event-date,.sp-template-details dt,.sp-template-scoreboard .sp-scoreboard-date,.sp-tournament-bracket th,.sp-tournament-bracket .sp-event .sp-event-title,.sp-template-scoreboard .sp-scoreboard-date,.sp-tournament-bracket .sp-event .sp-event-title *{color:' . $colors['text_muted'] . ' !important}';
|
||||
|
||||
// Heading
|
||||
echo '.sp-data-table th,.sp-template-countdown .sp-event-venue,.sp-template-countdown .sp-event-league,.sp-template-gallery .gallery-item a,.sp-template-gallery .gallery-caption,.sp-template-scoreboard .sp-scoreboard-nav,.sp-tournament-bracket .sp-team-name:hover,.sp-tournament-bracket thead th,.sp-tournament-bracket .sp-heading{color:' . $colors['heading'] . ' !important}';
|
||||
|
||||
// Link
|
||||
echo '.sp-template a,.sp-data-table a,.sp-tab-menu-item-active a, .sp-tab-menu-item-active a:hover,.sp-template .sp-message{color:' . $colors['link'] . ' !important}';
|
||||
echo '.sp-template-gallery .gallery-caption strong,.sp-tournament-bracket .sp-team-name:hover,.sp-template-scoreboard .sp-scoreboard-nav,.sp-tournament-bracket .sp-heading{background:' . $colors['link'] . ' !important}';
|
||||
echo '.sp-tournament-bracket .sp-team-name:hover,.sp-tournament-bracket .sp-heading,.sp-tab-menu-item-active a, .sp-tab-menu-item-active a:hover,.sp-template .sp-message{border-color:' . $colors['link'] . ' !important}';
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
new SportsPress_Styles();
|
||||
|
||||
@@ -9,180 +9,194 @@
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SportsPress_Template_Selector' ) ) :
|
||||
|
||||
/**
|
||||
* Main SportsPress Template Selector Class
|
||||
*
|
||||
* @class SportsPress_Template_Selector
|
||||
* @version 2.3
|
||||
*/
|
||||
class SportsPress_Template_Selector {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Main SportsPress Template Selector Class
|
||||
*
|
||||
* @class SportsPress_Template_Selector
|
||||
* @version 2.3
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
class SportsPress_Template_Selector {
|
||||
|
||||
// Hooks
|
||||
add_filter( 'sportspress_event_options', array( $this, 'event_options' ) );
|
||||
add_filter( 'sportspress_calendar_options', array( $this, 'calendar_options' ) );
|
||||
add_filter( 'sportspress_team_options', array( $this, 'team_options' ) );
|
||||
add_filter( 'sportspress_table_options', array( $this, 'table_options' ) );
|
||||
add_filter( 'sportspress_player_options', array( $this, 'player_options' ) );
|
||||
add_filter( 'sportspress_player_list_options', array( $this, 'list_options' ) );
|
||||
add_filter( 'sportspress_staff_options', array( $this, 'staff_options' ) );
|
||||
add_filter( 'sportspress_post_type_options', array( $this, 'post_type_options' ), 10, 2 );
|
||||
add_filter( 'sportspress_event_settings', array( $this, 'add_event_settings' ), 9);
|
||||
add_filter( 'template_include', array( $this, 'template_loader' ), 99 );
|
||||
}
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( !defined( 'SP_TEMPLATE_SELECTOR_VERSION' ) )
|
||||
define( 'SP_TEMPLATE_SELECTOR_VERSION', '2.3' );
|
||||
|
||||
if ( !defined( 'SP_TEMPLATE_SELECTOR_URL' ) )
|
||||
define( 'SP_TEMPLATE_SELECTOR_URL', plugin_dir_url( __FILE__ ) );
|
||||
|
||||
if ( !defined( 'SP_TEMPLATE_SELECTOR_DIR' ) )
|
||||
define( 'SP_TEMPLATE_SELECTOR_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add option to event post type.
|
||||
*/
|
||||
public function event_options( $options ) {
|
||||
return $this->options( $options, 'event' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add option to calendar post type.
|
||||
*/
|
||||
public function calendar_options( $options ) {
|
||||
return $this->options( $options, 'calendar' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add option to team post type.
|
||||
*/
|
||||
public function team_options( $options ) {
|
||||
return $this->options( $options, 'team' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add option to league table post type.
|
||||
*/
|
||||
public function table_options( $options ) {
|
||||
return $this->options( $options, 'table' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add option to player post type.
|
||||
*/
|
||||
public function player_options( $options ) {
|
||||
return $this->options( $options, 'player' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add option to player list post type.
|
||||
*/
|
||||
public function list_options( $options ) {
|
||||
return $this->options( $options, 'list' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add option to staff post type.
|
||||
*/
|
||||
public function staff_options( $options ) {
|
||||
return $this->options( $options, 'staff' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter for other post types.
|
||||
*/
|
||||
public function post_type_options( $options = array(), $post_type = null ) {
|
||||
if ( null == $post_type ) {
|
||||
return $options;
|
||||
// Hooks
|
||||
add_filter( 'sportspress_event_options', array( $this, 'event_options' ) );
|
||||
add_filter( 'sportspress_calendar_options', array( $this, 'calendar_options' ) );
|
||||
add_filter( 'sportspress_team_options', array( $this, 'team_options' ) );
|
||||
add_filter( 'sportspress_table_options', array( $this, 'table_options' ) );
|
||||
add_filter( 'sportspress_player_options', array( $this, 'player_options' ) );
|
||||
add_filter( 'sportspress_player_list_options', array( $this, 'list_options' ) );
|
||||
add_filter( 'sportspress_staff_options', array( $this, 'staff_options' ) );
|
||||
add_filter( 'sportspress_post_type_options', array( $this, 'post_type_options' ), 10, 2 );
|
||||
add_filter( 'sportspress_event_settings', array( $this, 'add_event_settings' ), 9 );
|
||||
add_filter( 'template_include', array( $this, 'template_loader' ), 99 );
|
||||
}
|
||||
|
||||
return $this->options( $options, $post_type );
|
||||
}
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( ! defined( 'SP_TEMPLATE_SELECTOR_VERSION' ) ) {
|
||||
define( 'SP_TEMPLATE_SELECTOR_VERSION', '2.3' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add template option.
|
||||
*/
|
||||
public function options( $options, $post_type ) {
|
||||
// Get page templates from current theme
|
||||
$templates = wp_get_theme()->get_page_templates( get_post() );
|
||||
if ( ! defined( 'SP_TEMPLATE_SELECTOR_URL' ) ) {
|
||||
define( 'SP_TEMPLATE_SELECTOR_URL', plugin_dir_url( __FILE__ ) );
|
||||
}
|
||||
|
||||
// Sort options alphabetically
|
||||
asort( $templates );
|
||||
|
||||
// Add default option
|
||||
$templates = array_merge( array( 'default' => __( 'Default Template', 'sportspress' ) ), $templates );
|
||||
|
||||
$options = array_merge( array(
|
||||
array(
|
||||
'title' => __( 'Template', 'sportspress' ),
|
||||
'id' => 'sportspress_' . $post_type . '_page_template',
|
||||
'default' => 'default',
|
||||
'type' => 'select',
|
||||
'options' => $templates,
|
||||
),
|
||||
), $options );
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load page template.
|
||||
*/
|
||||
public function template_loader( $template ) {
|
||||
if ( is_single() ) {
|
||||
$post_type = get_post_type();
|
||||
|
||||
if ( is_sp_post_type( $post_type ) ) {
|
||||
$option = get_option( 'sportspress_' . str_replace( 'sp_', '', $post_type ) . '_page_template', 'default' );
|
||||
if ( 'default' !== $option ) {
|
||||
$new_template = locate_template( array( $option ) );
|
||||
if ( '' != $new_template ) {
|
||||
return $new_template ;
|
||||
}
|
||||
}
|
||||
if ( ! defined( 'SP_TEMPLATE_SELECTOR_DIR' ) ) {
|
||||
define( 'SP_TEMPLATE_SELECTOR_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
}
|
||||
|
||||
return $template;
|
||||
/**
|
||||
* Add option to event post type.
|
||||
*/
|
||||
public function event_options( $options ) {
|
||||
return $this->options( $options, 'event' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add option to calendar post type.
|
||||
*/
|
||||
public function calendar_options( $options ) {
|
||||
return $this->options( $options, 'calendar' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add option to team post type.
|
||||
*/
|
||||
public function team_options( $options ) {
|
||||
return $this->options( $options, 'team' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add option to league table post type.
|
||||
*/
|
||||
public function table_options( $options ) {
|
||||
return $this->options( $options, 'table' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add option to player post type.
|
||||
*/
|
||||
public function player_options( $options ) {
|
||||
return $this->options( $options, 'player' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add option to player list post type.
|
||||
*/
|
||||
public function list_options( $options ) {
|
||||
return $this->options( $options, 'list' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add option to staff post type.
|
||||
*/
|
||||
public function staff_options( $options ) {
|
||||
return $this->options( $options, 'staff' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter for other post types.
|
||||
*/
|
||||
public function post_type_options( $options = array(), $post_type = null ) {
|
||||
if ( null == $post_type ) {
|
||||
return $options;
|
||||
}
|
||||
|
||||
return $this->options( $options, $post_type );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add template option.
|
||||
*/
|
||||
public function options( $options, $post_type ) {
|
||||
// Get page templates from current theme
|
||||
$templates = wp_get_theme()->get_page_templates( get_post() );
|
||||
|
||||
// Sort options alphabetically
|
||||
asort( $templates );
|
||||
|
||||
// Add default option
|
||||
$templates = array_merge( array( 'default' => __( 'Default Template', 'sportspress' ) ), $templates );
|
||||
|
||||
$options = array_merge(
|
||||
array(
|
||||
array(
|
||||
'title' => __( 'Template', 'sportspress' ),
|
||||
'id' => 'sportspress_' . $post_type . '_page_template',
|
||||
'default' => 'default',
|
||||
'type' => 'select',
|
||||
'options' => $templates,
|
||||
),
|
||||
),
|
||||
$options
|
||||
);
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load page template.
|
||||
*/
|
||||
public function template_loader( $template ) {
|
||||
if ( is_single() ) {
|
||||
$post_type = get_post_type();
|
||||
|
||||
if ( is_sp_post_type( $post_type ) ) {
|
||||
$option = get_option( 'sportspress_' . str_replace( 'sp_', '', $post_type ) . '_page_template', 'default' );
|
||||
if ( 'default' !== $option ) {
|
||||
$new_template = locate_template( array( $option ) );
|
||||
if ( '' != $new_template ) {
|
||||
return $new_template;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $template;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add event settings.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_event_settings( $settings ) {
|
||||
$settings = array_merge(
|
||||
$settings,
|
||||
array(
|
||||
array(
|
||||
'title' => __( 'Calendars', 'sportspress' ),
|
||||
'type' => 'title',
|
||||
'id' => 'calendar_options',
|
||||
),
|
||||
),
|
||||
apply_filters( 'sportspress_calendar_options', array() ),
|
||||
array(
|
||||
array(
|
||||
'type' => 'sectionend',
|
||||
'id' => 'calendar_options',
|
||||
),
|
||||
)
|
||||
);
|
||||
return $settings;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add event settings.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_event_settings( $settings ) {
|
||||
$settings = array_merge( $settings,
|
||||
array(
|
||||
array( 'title' => __( 'Calendars', 'sportspress' ), 'type' => 'title', 'id' => 'calendar_options' ),
|
||||
),
|
||||
|
||||
apply_filters( 'sportspress_calendar_options', array() ),
|
||||
|
||||
array(
|
||||
array( 'type' => 'sectionend', 'id' => 'calendar_options' ),
|
||||
)
|
||||
);
|
||||
return $settings;
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
new SportsPress_Template_Selector();
|
||||
|
||||
@@ -9,157 +9,213 @@
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SportsPress_Tutorials' ) ) :
|
||||
|
||||
/**
|
||||
* Main SportsPress Tutorials Class
|
||||
*
|
||||
* @class SportsPress_Tutorials
|
||||
* @version 2.5
|
||||
*/
|
||||
class SportsPress_Tutorials {
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* Main SportsPress Tutorials Class
|
||||
*
|
||||
* @class SportsPress_Tutorials
|
||||
* @version 2.5
|
||||
*/
|
||||
public $ids = array();
|
||||
class SportsPress_Tutorials {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $ids = array();
|
||||
|
||||
add_action( 'init', array( $this, 'get_video_ids' ) );
|
||||
add_action( 'admin_menu', array( $this, 'admin_menu' ), 10 );
|
||||
add_action( 'sportspress_admin_css', array( $this, 'admin_styles' ) );
|
||||
add_action( 'sportspress_screen_ids', array( $this, 'screen_ids' ) );
|
||||
add_filter( 'sportspress_next_steps', array( $this, 'next_steps' ) );
|
||||
}
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
/**
|
||||
* Enqueue styles
|
||||
*/
|
||||
public function admin_styles( $screen ) {
|
||||
if ( strpos( $screen->id, 'sportspress-tutorials' ) !== false ) {
|
||||
wp_enqueue_style( 'sportspress-admin', SP()->plugin_url() . '/assets/css/admin.css', array(), SP_VERSION );
|
||||
add_action( 'init', array( $this, 'get_video_ids' ) );
|
||||
add_action( 'admin_menu', array( $this, 'admin_menu' ), 10 );
|
||||
add_action( 'sportspress_admin_css', array( $this, 'admin_styles' ) );
|
||||
add_action( 'sportspress_screen_ids', array( $this, 'screen_ids' ) );
|
||||
add_filter( 'sportspress_next_steps', array( $this, 'next_steps' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( !defined( 'SP_TUTORIALS_VERSION' ) )
|
||||
define( 'SP_TUTORIALS_VERSION', '2.5' );
|
||||
|
||||
if ( !defined( 'SP_TUTORIALS_URL' ) )
|
||||
define( 'SP_TUTORIALS_URL', plugin_dir_url( __FILE__ ) );
|
||||
|
||||
if ( !defined( 'SP_TUTORIALS_DIR' ) )
|
||||
define( 'SP_TUTORIALS_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get video IDs.
|
||||
*/
|
||||
public function get_video_ids() {
|
||||
$this->ids = apply_filters( 'sportspress_videos', array(
|
||||
'tutorials' => apply_filters( 'sportspress_tutorial_videos', array(
|
||||
__( 'Get Started', 'sportspress' ) => apply_filters( 'sportspress_get_started_tutorial_videos', array(
|
||||
__( 'Installation', 'sportspress' ) => '//www.youtube-nocookie.com/embed/nE8-RlbotmU?rel=0&showinfo=0',
|
||||
__( 'Leagues', 'sportspress' ) . ' & ' . __( 'Seasons', 'sportspress' ) => '//www.youtube-nocookie.com/embed/XAf2EsDrf8M?rel=0&showinfo=0',
|
||||
__( 'Venues', 'sportspress' ) => '//www.youtube-nocookie.com/embed/iTZnC_7VvYk?rel=0&showinfo=0',
|
||||
__( 'Positions', 'sportspress' ) . ' & ' . __( 'Jobs', 'sportspress' ) => '//www.youtube-nocookie.com/embed/g6QKbDH05n0?rel=0&showinfo=0',
|
||||
) ),
|
||||
__( 'Teams', 'sportspress' ) => apply_filters( 'sportspress_team_tutorial_videos', array(
|
||||
__( 'Add New Team', 'sportspress' ) => '//www.youtube-nocookie.com/embed/x8GoxaHwC9U?rel=0&showinfo=0',
|
||||
__( 'League Tables', 'sportspress' ) => '//www.youtube-nocookie.com/embed/8AXh399Vstc?rel=0&showinfo=0',
|
||||
) ),
|
||||
__( 'Players', 'sportspress' ) . ' & ' . __( 'Staff', 'sportspress' ) => array_merge(
|
||||
apply_filters( 'sportspress_player_tutorial_videos', array(
|
||||
__( 'Add New Player', 'sportspress' ) => '//www.youtube-nocookie.com/embed/wWYQNHITz-g?rel=0&showinfo=0',
|
||||
) ),
|
||||
apply_filters( 'sportspress_staff_tutorial_videos', array(
|
||||
__( 'Add New Staff', 'sportspress' ) => '//www.youtube-nocookie.com/embed/cxm2S7qYSL4?rel=0&showinfo=0',
|
||||
) )
|
||||
),
|
||||
__( 'Events', 'sportspress' ) => apply_filters( 'sportspress_event_tutorial_videos', array(
|
||||
__( 'Add New Event', 'sportspress' ) => '//www.youtube-nocookie.com/embed/UA25lgqgnSc?rel=0&showinfo=0',
|
||||
__( 'Edit Event', 'sportspress' ) => '//www.youtube-nocookie.com/embed/nL0ObdPMyBM?rel=0&showinfo=0',
|
||||
__( 'Calendars', 'sportspress' ) => '//www.youtube-nocookie.com/embed/NIHBKMMqN0s?rel=0&showinfo=0',
|
||||
) ),
|
||||
) ),
|
||||
'advanced' => apply_filters( 'sportspress_advanced_videos', array(
|
||||
__( 'Settings', 'sportspress' ) => apply_filters( 'sportspress_settings_advanced_videos', array(
|
||||
__( 'Text', 'sportspress' ) => '//www.youtube-nocookie.com/embed/qEucgVVsDcE?rel=0&showinfo=0',
|
||||
__( 'Permalinks', 'sportspress' ) => '//www.youtube-nocookie.com/embed/QuHmsdVyjU8?rel=0&showinfo=0',
|
||||
) ),
|
||||
__( 'Events', 'sportspress' ) => apply_filters( 'sportspress_event_advanced_videos', array(
|
||||
__( 'Event Outcomes', 'sportspress' ) . ' ' . __( '(Auto)', 'sportspress' ) => '//www.youtube-nocookie.com/embed/pCVfPv2O5yY?rel=0&showinfo=0',
|
||||
__( 'Box Score', 'sportspress' ) => '//www.youtube-nocookie.com/embed/rERU6X7vjTc?rel=0&showinfo=0',
|
||||
) ),
|
||||
__( 'Calendars', 'sportspress' ) => apply_filters( 'sportspress_calendar_advanced_videos', array(
|
||||
__( 'Layout', 'sportspress' ) => '//www.youtube-nocookie.com/embed/aLx_5D0Xgnc?rel=0&showinfo=0',
|
||||
) ),
|
||||
__( 'Teams', 'sportspress' ) => apply_filters( 'sportspress_team_advanced_videos', array(
|
||||
__( 'Logo', 'sportspress' ) => '//www.youtube-nocookie.com/embed/tLJZKB0fnXw?rel=0&showinfo=0',
|
||||
__( 'Adjustments', 'sportspress' ) => '//www.youtube-nocookie.com/embed/VJkhn9Or0jA?rel=0&showinfo=0',
|
||||
__( 'Highlight', 'sportspress' ) => '//www.youtube-nocookie.com/embed/1rKRmRzVWoU?rel=0&showinfo=0',
|
||||
) ),
|
||||
__( 'Players', 'sportspress' ) => apply_filters( 'sportspress_player_advanced_videos', array(
|
||||
__( 'Player Metrics', 'sportspress' ) => '//www.youtube-nocookie.com/embed/dGXYgi8esPc?rel=0&showinfo=0',
|
||||
__( 'Player Ranking', 'sportspress' ) => '//www.youtube-nocookie.com/embed/xAQRZf7VOTg?rel=0&showinfo=0',
|
||||
) ),
|
||||
__( 'Other', 'sportspress' ) => apply_filters( 'sportspress_other_advanced_videos', array(
|
||||
__( 'Demo Content', 'sportspress' ) => '//www.youtube-nocookie.com/embed/sARiHQJqSBw?rel=0&showinfo=0',
|
||||
__( 'Overview', 'sportspress' ) => '//www.youtube-nocookie.com/embed/osXGpBJDMpY?rel=0&showinfo=0',
|
||||
__( 'User Roles', 'sportspress' ) => '//www.youtube-nocookie.com/embed/UancX-33NE4?rel=0&showinfo=0',
|
||||
__( 'Shortcodes', 'sportspress' ) => '//www.youtube-nocookie.com/embed/czrhafIcLaM?rel=0&showinfo=0',
|
||||
__( 'Page not found', 'sportspress' ) => '//www.youtube-nocookie.com/embed/2rss9qfMubw?rel=0&showinfo=0',
|
||||
) ),
|
||||
) ),
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add menu item
|
||||
*/
|
||||
public function admin_menu() {
|
||||
if ( current_user_can( 'manage_sportspress' ) ) {
|
||||
add_submenu_page( 'sportspress', __( 'Tutorials', 'sportspress' ), __( 'Tutorials', 'sportspress' ), 'manage_sportspress', 'sportspress-tutorials', array( $this, 'tutorials_page' ) );
|
||||
} else {
|
||||
add_menu_page( __( 'Tutorials', 'sportspress' ), __( 'Tutorials', 'sportspress' ), 'edit_sp_players', 'sportspress-tutorials', array( $this, 'tutorials_page' ), 'dashicons-video-alt3' );
|
||||
/**
|
||||
* Enqueue styles
|
||||
*/
|
||||
public function admin_styles( $screen ) {
|
||||
if ( strpos( $screen->id, 'sportspress-tutorials' ) !== false ) {
|
||||
wp_enqueue_style( 'sportspress-admin', SP()->plugin_url() . '/assets/css/admin.css', array(), SP_VERSION );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Init the tutorials page
|
||||
*/
|
||||
public function tutorials_page() {
|
||||
$tabs = apply_filters( 'sportspress_tutorial_tabs', array(
|
||||
'tutorials' => __( 'Tutorials', 'sportspress' ),
|
||||
'advanced' => __( 'Advanced', 'sportspress' ),
|
||||
) );
|
||||
if ( isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $tabs ) ) {
|
||||
$current_tab = sanitize_key( $_GET['tab'] );
|
||||
} else {
|
||||
$current_tab = key( $tabs );
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( ! defined( 'SP_TUTORIALS_VERSION' ) ) {
|
||||
define( 'SP_TUTORIALS_VERSION', '2.5' );
|
||||
}
|
||||
|
||||
if ( ! defined( 'SP_TUTORIALS_URL' ) ) {
|
||||
define( 'SP_TUTORIALS_URL', plugin_dir_url( __FILE__ ) );
|
||||
}
|
||||
|
||||
if ( ! defined( 'SP_TUTORIALS_DIR' ) ) {
|
||||
define( 'SP_TUTORIALS_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
}
|
||||
$i = 0;
|
||||
?>
|
||||
|
||||
/**
|
||||
* Get video IDs.
|
||||
*/
|
||||
public function get_video_ids() {
|
||||
$this->ids = apply_filters(
|
||||
'sportspress_videos',
|
||||
array(
|
||||
'tutorials' => apply_filters(
|
||||
'sportspress_tutorial_videos',
|
||||
array(
|
||||
__( 'Get Started', 'sportspress' ) => apply_filters(
|
||||
'sportspress_get_started_tutorial_videos',
|
||||
array(
|
||||
__( 'Installation', 'sportspress' ) => '//www.youtube-nocookie.com/embed/nE8-RlbotmU?rel=0&showinfo=0',
|
||||
__( 'Leagues', 'sportspress' ) . ' & ' . __( 'Seasons', 'sportspress' ) => '//www.youtube-nocookie.com/embed/XAf2EsDrf8M?rel=0&showinfo=0',
|
||||
__( 'Venues', 'sportspress' ) => '//www.youtube-nocookie.com/embed/iTZnC_7VvYk?rel=0&showinfo=0',
|
||||
__( 'Positions', 'sportspress' ) . ' & ' . __( 'Jobs', 'sportspress' ) => '//www.youtube-nocookie.com/embed/g6QKbDH05n0?rel=0&showinfo=0',
|
||||
)
|
||||
),
|
||||
__( 'Teams', 'sportspress' ) => apply_filters(
|
||||
'sportspress_team_tutorial_videos',
|
||||
array(
|
||||
__( 'Add New Team', 'sportspress' ) => '//www.youtube-nocookie.com/embed/x8GoxaHwC9U?rel=0&showinfo=0',
|
||||
__( 'League Tables', 'sportspress' ) => '//www.youtube-nocookie.com/embed/8AXh399Vstc?rel=0&showinfo=0',
|
||||
)
|
||||
),
|
||||
__( 'Players', 'sportspress' ) . ' & ' . __( 'Staff', 'sportspress' ) => array_merge(
|
||||
apply_filters(
|
||||
'sportspress_player_tutorial_videos',
|
||||
array(
|
||||
__( 'Add New Player', 'sportspress' ) => '//www.youtube-nocookie.com/embed/wWYQNHITz-g?rel=0&showinfo=0',
|
||||
)
|
||||
),
|
||||
apply_filters(
|
||||
'sportspress_staff_tutorial_videos',
|
||||
array(
|
||||
__( 'Add New Staff', 'sportspress' ) => '//www.youtube-nocookie.com/embed/cxm2S7qYSL4?rel=0&showinfo=0',
|
||||
)
|
||||
)
|
||||
),
|
||||
__( 'Events', 'sportspress' ) => apply_filters(
|
||||
'sportspress_event_tutorial_videos',
|
||||
array(
|
||||
__( 'Add New Event', 'sportspress' ) => '//www.youtube-nocookie.com/embed/UA25lgqgnSc?rel=0&showinfo=0',
|
||||
__( 'Edit Event', 'sportspress' ) => '//www.youtube-nocookie.com/embed/nL0ObdPMyBM?rel=0&showinfo=0',
|
||||
__( 'Calendars', 'sportspress' ) => '//www.youtube-nocookie.com/embed/NIHBKMMqN0s?rel=0&showinfo=0',
|
||||
)
|
||||
),
|
||||
)
|
||||
),
|
||||
'advanced' => apply_filters(
|
||||
'sportspress_advanced_videos',
|
||||
array(
|
||||
__( 'Settings', 'sportspress' ) => apply_filters(
|
||||
'sportspress_settings_advanced_videos',
|
||||
array(
|
||||
__( 'Text', 'sportspress' ) => '//www.youtube-nocookie.com/embed/qEucgVVsDcE?rel=0&showinfo=0',
|
||||
__( 'Permalinks', 'sportspress' ) => '//www.youtube-nocookie.com/embed/QuHmsdVyjU8?rel=0&showinfo=0',
|
||||
)
|
||||
),
|
||||
__( 'Events', 'sportspress' ) => apply_filters(
|
||||
'sportspress_event_advanced_videos',
|
||||
array(
|
||||
__( 'Event Outcomes', 'sportspress' ) . ' ' . __( '(Auto)', 'sportspress' ) => '//www.youtube-nocookie.com/embed/pCVfPv2O5yY?rel=0&showinfo=0',
|
||||
__( 'Box Score', 'sportspress' ) => '//www.youtube-nocookie.com/embed/rERU6X7vjTc?rel=0&showinfo=0',
|
||||
)
|
||||
),
|
||||
__( 'Calendars', 'sportspress' ) => apply_filters(
|
||||
'sportspress_calendar_advanced_videos',
|
||||
array(
|
||||
__( 'Layout', 'sportspress' ) => '//www.youtube-nocookie.com/embed/aLx_5D0Xgnc?rel=0&showinfo=0',
|
||||
)
|
||||
),
|
||||
__( 'Teams', 'sportspress' ) => apply_filters(
|
||||
'sportspress_team_advanced_videos',
|
||||
array(
|
||||
__( 'Logo', 'sportspress' ) => '//www.youtube-nocookie.com/embed/tLJZKB0fnXw?rel=0&showinfo=0',
|
||||
__( 'Adjustments', 'sportspress' ) => '//www.youtube-nocookie.com/embed/VJkhn9Or0jA?rel=0&showinfo=0',
|
||||
__( 'Highlight', 'sportspress' ) => '//www.youtube-nocookie.com/embed/1rKRmRzVWoU?rel=0&showinfo=0',
|
||||
)
|
||||
),
|
||||
__( 'Players', 'sportspress' ) => apply_filters(
|
||||
'sportspress_player_advanced_videos',
|
||||
array(
|
||||
__( 'Player Metrics', 'sportspress' ) => '//www.youtube-nocookie.com/embed/dGXYgi8esPc?rel=0&showinfo=0',
|
||||
__( 'Player Ranking', 'sportspress' ) => '//www.youtube-nocookie.com/embed/xAQRZf7VOTg?rel=0&showinfo=0',
|
||||
)
|
||||
),
|
||||
__( 'Other', 'sportspress' ) => apply_filters(
|
||||
'sportspress_other_advanced_videos',
|
||||
array(
|
||||
__( 'Demo Content', 'sportspress' ) => '//www.youtube-nocookie.com/embed/sARiHQJqSBw?rel=0&showinfo=0',
|
||||
__( 'Overview', 'sportspress' ) => '//www.youtube-nocookie.com/embed/osXGpBJDMpY?rel=0&showinfo=0',
|
||||
__( 'User Roles', 'sportspress' ) => '//www.youtube-nocookie.com/embed/UancX-33NE4?rel=0&showinfo=0',
|
||||
__( 'Shortcodes', 'sportspress' ) => '//www.youtube-nocookie.com/embed/czrhafIcLaM?rel=0&showinfo=0',
|
||||
__( 'Page not found', 'sportspress' ) => '//www.youtube-nocookie.com/embed/2rss9qfMubw?rel=0&showinfo=0',
|
||||
)
|
||||
),
|
||||
)
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add menu item
|
||||
*/
|
||||
public function admin_menu() {
|
||||
if ( current_user_can( 'manage_sportspress' ) ) {
|
||||
add_submenu_page( 'sportspress', __( 'Tutorials', 'sportspress' ), __( 'Tutorials', 'sportspress' ), 'manage_sportspress', 'sportspress-tutorials', array( $this, 'tutorials_page' ) );
|
||||
} else {
|
||||
add_menu_page( __( 'Tutorials', 'sportspress' ), __( 'Tutorials', 'sportspress' ), 'edit_sp_players', 'sportspress-tutorials', array( $this, 'tutorials_page' ), 'dashicons-video-alt3' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Init the tutorials page
|
||||
*/
|
||||
public function tutorials_page() {
|
||||
$tabs = apply_filters(
|
||||
'sportspress_tutorial_tabs',
|
||||
array(
|
||||
'tutorials' => __( 'Tutorials', 'sportspress' ),
|
||||
'advanced' => __( 'Advanced', 'sportspress' ),
|
||||
)
|
||||
);
|
||||
if ( isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $tabs ) ) {
|
||||
$current_tab = sanitize_key( $_GET['tab'] );
|
||||
} else {
|
||||
$current_tab = key( $tabs );
|
||||
}
|
||||
$i = 0;
|
||||
?>
|
||||
<div class="wrap sportspress sportspress-tutorials-wrap">
|
||||
<h2 class="nav-tab-wrapper">
|
||||
<?php foreach ( $tabs as $name => $label ): ?><a href="<?php echo admin_url( 'admin.php?page=sportspress-tutorials&tab=' . $name ); ?>" class="nav-tab <?php echo ( $current_tab == $name ? 'nav-tab-active' : '' ); ?>"><?php echo $label; ?></a><?php endforeach; ?>
|
||||
<?php
|
||||
foreach ( $tabs as $name => $label ) :
|
||||
?>
|
||||
<a href="<?php echo admin_url( 'admin.php?page=sportspress-tutorials&tab=' . $name ); ?>" class="nav-tab <?php echo ( $current_tab == $name ? 'nav-tab-active' : '' ); ?>"><?php echo $label; ?></a><?php endforeach; ?>
|
||||
</h2>
|
||||
<div class="sp-tutorials-main">
|
||||
<?php foreach ( $this->ids[$current_tab] as $section => $urls ) { ?>
|
||||
<?php foreach ( $this->ids[ $current_tab ] as $section => $urls ) { ?>
|
||||
<h3><?php echo $section; ?></h3>
|
||||
<ul class="sp-tutorials-list">
|
||||
<?php foreach ( $urls as $label => $url ) { $i++; ?>
|
||||
<?php
|
||||
foreach ( $urls as $label => $url ) {
|
||||
$i++;
|
||||
?>
|
||||
<li>
|
||||
<table class="widefat" cellspacing="0">
|
||||
<thead>
|
||||
@@ -185,30 +241,31 @@ class SportsPress_Tutorials {
|
||||
<?php } ?>
|
||||
<?php do_action( 'sportspress_tutorials_page' ); ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Add screen ids
|
||||
*/
|
||||
public function screen_ids( $ids = array() ) {
|
||||
$ids[] = 'sportspress_page_sportspress-tutorials';
|
||||
return $ids;
|
||||
}
|
||||
/**
|
||||
* Add screen ids
|
||||
*/
|
||||
public function screen_ids( $ids = array() ) {
|
||||
$ids[] = 'sportspress_page_sportspress-tutorials';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add link to next steps
|
||||
*/
|
||||
public function next_steps( $steps = array() ) {
|
||||
$steps = array(
|
||||
'tutorials' => array(
|
||||
'link' => admin_url( add_query_arg( array( 'page' => 'sportspress-tutorials' ), 'admin.php' ) ),
|
||||
'icon' => 'dashicons dashicons-video-alt3',
|
||||
'label' => __( 'Watch Tutorials', 'sportspress' ),
|
||||
) ) + $steps;
|
||||
return $steps;
|
||||
/**
|
||||
* Add link to next steps
|
||||
*/
|
||||
public function next_steps( $steps = array() ) {
|
||||
$steps = array(
|
||||
'tutorials' => array(
|
||||
'link' => admin_url( add_query_arg( array( 'page' => 'sportspress-tutorials' ), 'admin.php' ) ),
|
||||
'icon' => 'dashicons dashicons-video-alt3',
|
||||
'label' => __( 'Watch Tutorials', 'sportspress' ),
|
||||
),
|
||||
) + $steps;
|
||||
return $steps;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
@@ -9,193 +9,203 @@
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SportsPress_User_Registration' ) ) :
|
||||
|
||||
/**
|
||||
* Main SportsPress User Registration Class
|
||||
*
|
||||
* @class SportsPress_User_Registration
|
||||
* @version 2.4
|
||||
*/
|
||||
class SportsPress_User_Registration {
|
||||
/**
|
||||
* Main SportsPress User Registration Class
|
||||
*
|
||||
* @class SportsPress_User_Registration
|
||||
* @version 2.4
|
||||
*/
|
||||
class SportsPress_User_Registration {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
// Hooks
|
||||
add_filter( 'sportspress_player_options', array( $this, 'add_player_options' ) );
|
||||
add_action( 'register_form', array( $this, 'register_form' ) );
|
||||
add_action( 'user_register', array( $this, 'user_register' ) );
|
||||
}
|
||||
// Hooks
|
||||
add_filter( 'sportspress_player_options', array( $this, 'add_player_options' ) );
|
||||
add_action( 'register_form', array( $this, 'register_form' ) );
|
||||
add_action( 'user_register', array( $this, 'user_register' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( !defined( 'SP_USER_REGISTRATION_VERSION' ) )
|
||||
define( 'SP_USER_REGISTRATION_VERSION', '2.4' );
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( ! defined( 'SP_USER_REGISTRATION_VERSION' ) ) {
|
||||
define( 'SP_USER_REGISTRATION_VERSION', '2.4' );
|
||||
}
|
||||
|
||||
if ( !defined( 'SP_USER_REGISTRATION_URL' ) )
|
||||
define( 'SP_USER_REGISTRATION_URL', plugin_dir_url( __FILE__ ) );
|
||||
if ( ! defined( 'SP_USER_REGISTRATION_URL' ) ) {
|
||||
define( 'SP_USER_REGISTRATION_URL', plugin_dir_url( __FILE__ ) );
|
||||
}
|
||||
|
||||
if ( !defined( 'SP_USER_REGISTRATION_DIR' ) )
|
||||
define( 'SP_USER_REGISTRATION_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
if ( ! defined( 'SP_USER_REGISTRATION_DIR' ) ) {
|
||||
define( 'SP_USER_REGISTRATION_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add options to player settings page.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_player_options( $options ) {
|
||||
$options = array_merge( $options, array(
|
||||
array(
|
||||
'title' => __( 'User Registration', 'sportspress' ),
|
||||
'desc' => __( 'Add name fields to signup form', 'sportspress' ),
|
||||
'id' => 'sportspress_registration_name_inputs',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'start',
|
||||
),
|
||||
/**
|
||||
* Add options to player settings page.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_player_options( $options ) {
|
||||
$options = array_merge(
|
||||
$options,
|
||||
array(
|
||||
array(
|
||||
'title' => __( 'User Registration', 'sportspress' ),
|
||||
'desc' => __( 'Add name fields to signup form', 'sportspress' ),
|
||||
'id' => 'sportspress_registration_name_inputs',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'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 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' => __( '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',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'end',
|
||||
),
|
||||
) );
|
||||
array(
|
||||
'desc' => __( 'Create player profiles for new users', 'sportspress' ),
|
||||
'id' => 'sportspress_registration_add_player',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'end',
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
return $options;
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add name fields to user registration form.
|
||||
*/
|
||||
public static function register_form() {
|
||||
if ( 'yes' === get_option( 'sportspress_registration_name_inputs', 'no' ) ) {
|
||||
$first_name = ( ! empty( $_POST['first_name'] ) ) ? trim( sanitize_text_field( $_POST['first_name'] ) ) : '';
|
||||
$last_name = ( ! empty( $_POST['last_name'] ) ) ? trim( sanitize_text_field( $_POST['last_name'] ) ) : '';
|
||||
?>
|
||||
<p>
|
||||
<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>
|
||||
/**
|
||||
* Add name fields to user registration form.
|
||||
*/
|
||||
public static function register_form() {
|
||||
if ( 'yes' === get_option( 'sportspress_registration_name_inputs', 'no' ) ) {
|
||||
$first_name = ( ! empty( $_POST['first_name'] ) ) ? trim( sanitize_text_field( $_POST['first_name'] ) ) : '';
|
||||
$last_name = ( ! empty( $_POST['last_name'] ) ) ? trim( sanitize_text_field( $_POST['last_name'] ) ) : '';
|
||||
?>
|
||||
<p>
|
||||
<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', '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
|
||||
}
|
||||
<p>
|
||||
<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' );
|
||||
}
|
||||
}
|
||||
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' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save fields and add player during user registration.
|
||||
*/
|
||||
public static function user_register( $user_id ) {
|
||||
$parts = array();
|
||||
/**
|
||||
* Save fields and add player during user registration.
|
||||
*/
|
||||
public static function user_register( $user_id ) {
|
||||
$parts = array();
|
||||
|
||||
// Save first and last name
|
||||
if ( 'yes' === get_option( 'sportspress_registration_name_inputs', 'no' ) ) {
|
||||
if ( ! empty( $_POST['first_name'] ) ) {
|
||||
$meta = trim( sanitize_text_field( $_POST['first_name'] ) );
|
||||
$parts[] = $meta;
|
||||
update_user_meta( $user_id, 'first_name', $meta );
|
||||
}
|
||||
// Save first and last name
|
||||
if ( 'yes' === get_option( 'sportspress_registration_name_inputs', 'no' ) ) {
|
||||
if ( ! empty( $_POST['first_name'] ) ) {
|
||||
$meta = trim( sanitize_text_field( $_POST['first_name'] ) );
|
||||
$parts[] = $meta;
|
||||
update_user_meta( $user_id, 'first_name', $meta );
|
||||
}
|
||||
|
||||
if ( ! empty( $_POST['last_name'] ) ) {
|
||||
$meta = trim( sanitize_text_field( $_POST['last_name'] ) );
|
||||
$parts[] = $meta;
|
||||
update_user_meta( $user_id, 'last_name', $meta );
|
||||
}
|
||||
}
|
||||
if ( ! empty( $_POST['last_name'] ) ) {
|
||||
$meta = trim( sanitize_text_field( $_POST['last_name'] ) );
|
||||
$parts[] = $meta;
|
||||
update_user_meta( $user_id, 'last_name', $meta );
|
||||
}
|
||||
}
|
||||
|
||||
// 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( sanitize_text_field( $_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 );
|
||||
}
|
||||
}
|
||||
// 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( sanitize_text_field( $_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( sanitize_text_field( $_POST['sp_team'] ) );
|
||||
if ( $team <= 0 ) $team = 0;
|
||||
update_user_meta( $user_id, 'sp_team', $team );
|
||||
}
|
||||
}
|
||||
// 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( sanitize_text_field( $_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'] ) ) {
|
||||
$parts[] = trim( sanitize_text_field( $_POST['user_login'] ) );
|
||||
}
|
||||
// Add player
|
||||
if ( 'yes' === get_option( 'sportspress_registration_add_player', 'no' ) ) {
|
||||
if ( ! sizeof( $parts ) && ! empty( $_POST['user_login'] ) ) {
|
||||
$parts[] = trim( sanitize_text_field( $_POST['user_login'] ) );
|
||||
}
|
||||
|
||||
if ( sizeof( $parts ) ) {
|
||||
$name = implode( ' ', $parts );
|
||||
$post['post_type'] = 'sp_player';
|
||||
$post['post_title'] = trim( $name );
|
||||
$post['post_author'] = $user_id;
|
||||
$post['post_status'] = 'draft';
|
||||
$id = wp_insert_post( $post );
|
||||
if ( sizeof( $parts ) ) {
|
||||
$name = implode( ' ', $parts );
|
||||
$post['post_type'] = 'sp_player';
|
||||
$post['post_title'] = trim( $name );
|
||||
$post['post_author'] = $user_id;
|
||||
$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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( isset( $team ) && $team ) {
|
||||
update_post_meta( $id, 'sp_team', $team );
|
||||
update_post_meta( $id, 'sp_current_team', $team );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
@@ -9,133 +9,138 @@
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SportsPress_Widget_Alignment' ) ) :
|
||||
|
||||
/**
|
||||
* Main SportsPress Widget Alignment Class
|
||||
*
|
||||
* @class SportsPress_Widget_Alignment
|
||||
* @version 1.8.3
|
||||
*/
|
||||
class SportsPress_Widget_Alignment {
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* Main SportsPress Widget Alignment Class
|
||||
*
|
||||
* @class SportsPress_Widget_Alignment
|
||||
* @version 1.8.3
|
||||
*/
|
||||
public $options = array();
|
||||
class SportsPress_Widget_Alignment {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $options = array();
|
||||
|
||||
// Initialize
|
||||
add_action( 'init', array( $this, 'init' ) );
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
// Widgets
|
||||
add_filter( 'sportspress_widget_update', array( $this, 'widget_update' ), 10, 2 );
|
||||
add_filter( 'sportspress_widget_defaults', array( $this, 'widget_defaults' ) );
|
||||
add_filter( 'sportspress_shortcode_wrapper', array( $this, 'shortcode_wrapper' ), 10, 3 );
|
||||
add_action( 'sportspress_before_widget_template_form', array( $this, 'before_widget_form' ), 10, 2 );
|
||||
add_action( 'sportspress_before_widget', array( $this, 'before_widget'), 10, 2 );
|
||||
add_action( 'sportspress_after_widget', array( $this, 'after_widget') );
|
||||
add_action( 'sportspress_ajax_shortcode_form', array( $this, 'ajax_shortcode_form' ) );
|
||||
add_action( 'sportspress_ajax_scripts_before_shortcode', array( $this, 'ajax_scripts' ) );
|
||||
}
|
||||
// Initialize
|
||||
add_action( 'init', array( $this, 'init' ) );
|
||||
|
||||
/**
|
||||
* Define constants
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( !defined( 'SP_WIDGET_ALIGNMENT_VERSION' ) )
|
||||
define( 'SP_WIDGET_ALIGNMENT_VERSION', '1.8.3' );
|
||||
|
||||
if ( !defined( 'SP_WIDGET_ALIGNMENT_URL' ) )
|
||||
define( 'SP_WIDGET_ALIGNMENT_URL', plugin_dir_url( __FILE__ ) );
|
||||
|
||||
if ( !defined( 'SP_WIDGET_ALIGNMENT_DIR' ) )
|
||||
define( 'SP_WIDGET_ALIGNMENT_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
public function init() {
|
||||
$this->options = array(
|
||||
'none' => __( 'None', 'sportspress' ),
|
||||
'left' => __( 'Left', 'sportspress' ),
|
||||
'right' => __( 'Right', 'sportspress' ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Widget update
|
||||
*/
|
||||
function widget_update( $instance, $new_instance ) {
|
||||
$instance['align'] = strip_tags( $new_instance['align'] );
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Widget defaults
|
||||
*/
|
||||
function widget_defaults( $defaults ) {
|
||||
$defaults['align'] = 'none';
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcode wrapper
|
||||
*/
|
||||
function shortcode_wrapper( $wrapper = array(), $function = null, $atts = array() ) {
|
||||
if ( isset( $atts['align'] ) ) {
|
||||
$wrapper['class'] = sp_array_value( $wrapper, 'class', '' ) . ' ' . 'sp-widget-align-' . $atts['align'];
|
||||
// Widgets
|
||||
add_filter( 'sportspress_widget_update', array( $this, 'widget_update' ), 10, 2 );
|
||||
add_filter( 'sportspress_widget_defaults', array( $this, 'widget_defaults' ) );
|
||||
add_filter( 'sportspress_shortcode_wrapper', array( $this, 'shortcode_wrapper' ), 10, 3 );
|
||||
add_action( 'sportspress_before_widget_template_form', array( $this, 'before_widget_form' ), 10, 2 );
|
||||
add_action( 'sportspress_before_widget', array( $this, 'before_widget' ), 10, 2 );
|
||||
add_action( 'sportspress_after_widget', array( $this, 'after_widget' ) );
|
||||
add_action( 'sportspress_ajax_shortcode_form', array( $this, 'ajax_shortcode_form' ) );
|
||||
add_action( 'sportspress_ajax_scripts_before_shortcode', array( $this, 'ajax_scripts' ) );
|
||||
}
|
||||
|
||||
return $wrapper;
|
||||
}
|
||||
/**
|
||||
* Define constants
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( ! defined( 'SP_WIDGET_ALIGNMENT_VERSION' ) ) {
|
||||
define( 'SP_WIDGET_ALIGNMENT_VERSION', '1.8.3' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Before widget forms
|
||||
*/
|
||||
function before_widget_form( $object, $instance ) {
|
||||
?>
|
||||
<p><label for="<?php echo $object->get_field_id('align'); ?>"><?php printf( __( 'Alignment: %s', 'sportspress' ), '' ); ?></label>
|
||||
<select name="<?php echo $object->get_field_name('align'); ?>" id="<?php echo $object->get_field_id('align'); ?>">
|
||||
if ( ! defined( 'SP_WIDGET_ALIGNMENT_URL' ) ) {
|
||||
define( 'SP_WIDGET_ALIGNMENT_URL', plugin_dir_url( __FILE__ ) );
|
||||
}
|
||||
|
||||
if ( ! defined( 'SP_WIDGET_ALIGNMENT_DIR' ) ) {
|
||||
define( 'SP_WIDGET_ALIGNMENT_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
public function init() {
|
||||
$this->options = array(
|
||||
'none' => __( 'None', 'sportspress' ),
|
||||
'left' => __( 'Left', 'sportspress' ),
|
||||
'right' => __( 'Right', 'sportspress' ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Widget update
|
||||
*/
|
||||
function widget_update( $instance, $new_instance ) {
|
||||
$instance['align'] = strip_tags( $new_instance['align'] );
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Widget defaults
|
||||
*/
|
||||
function widget_defaults( $defaults ) {
|
||||
$defaults['align'] = 'none';
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcode wrapper
|
||||
*/
|
||||
function shortcode_wrapper( $wrapper = array(), $function = null, $atts = array() ) {
|
||||
if ( isset( $atts['align'] ) ) {
|
||||
$wrapper['class'] = sp_array_value( $wrapper, 'class', '' ) . ' ' . 'sp-widget-align-' . $atts['align'];
|
||||
}
|
||||
|
||||
return $wrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Before widget forms
|
||||
*/
|
||||
function before_widget_form( $object, $instance ) {
|
||||
?>
|
||||
<p><label for="<?php echo $object->get_field_id( 'align' ); ?>"><?php printf( __( 'Alignment: %s', 'sportspress' ), '' ); ?></label>
|
||||
<select name="<?php echo $object->get_field_name( 'align' ); ?>" id="<?php echo $object->get_field_id( 'align' ); ?>">
|
||||
<?php
|
||||
$align = strip_tags( sp_array_value( $instance, 'align', 'none' ) );
|
||||
foreach ( $this->options as $value => $label ) {
|
||||
printf( '<option value="%s" %s>%s</option>', $value, ( $align == $value ? 'selected' : '' ), $label );
|
||||
}
|
||||
foreach ( $this->options as $value => $label ) {
|
||||
printf( '<option value="%s" %s>%s</option>', $value, ( $align == $value ? 'selected' : '' ), $label );
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Before widget
|
||||
*/
|
||||
function before_widget( $args, $instance ) {
|
||||
echo '<div class="sp-widget-align-' . sp_array_value( $instance, 'align', 'none' ) . '">';
|
||||
}
|
||||
/**
|
||||
* Before widget
|
||||
*/
|
||||
function before_widget( $args, $instance ) {
|
||||
echo '<div class="sp-widget-align-' . sp_array_value( $instance, 'align', 'none' ) . '">';
|
||||
}
|
||||
|
||||
/**
|
||||
* After widget
|
||||
*/
|
||||
function after_widget() {
|
||||
echo '</div>';
|
||||
}
|
||||
/**
|
||||
* After widget
|
||||
*/
|
||||
function after_widget() {
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax shortcode form
|
||||
*/
|
||||
function ajax_shortcode_form() {
|
||||
?>
|
||||
/**
|
||||
* Ajax shortcode form
|
||||
*/
|
||||
function ajax_shortcode_form() {
|
||||
?>
|
||||
<p>
|
||||
<label>
|
||||
<?php printf( __( 'Alignment: %s', 'sportspress' ), '' ); ?>
|
||||
@@ -148,18 +153,18 @@ class SportsPress_Widget_Alignment {
|
||||
</select>
|
||||
</label>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax scripts
|
||||
*/
|
||||
function ajax_scripts() {
|
||||
?>
|
||||
/**
|
||||
* Ajax scripts
|
||||
*/
|
||||
function ajax_scripts() {
|
||||
?>
|
||||
args.align = $div.find('[name=align]').val();
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
@@ -9,52 +9,57 @@
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SportsPress_Widgets' ) ) :
|
||||
|
||||
/**
|
||||
* Main SportsPress Widgets Class
|
||||
*
|
||||
* @class SportsPress_Widgets
|
||||
* @version 1.8.3
|
||||
*/
|
||||
class SportsPress_Widgets {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Main SportsPress Widgets Class
|
||||
*
|
||||
* @class SportsPress_Widgets
|
||||
* @version 1.8.3
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
class SportsPress_Widgets {
|
||||
|
||||
add_action( 'widgets_init', array( $this, 'includes' ) );
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
add_action( 'widgets_init', array( $this, 'includes' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( ! defined( 'SP_WIDGETS_VERSION' ) ) {
|
||||
define( 'SP_WIDGETS_VERSION', '1.8.3' );
|
||||
}
|
||||
|
||||
if ( ! defined( 'SP_WIDGETS_URL' ) ) {
|
||||
define( 'SP_WIDGETS_URL', plugin_dir_url( __FILE__ ) );
|
||||
}
|
||||
|
||||
if ( ! defined( 'SP_WIDGETS_DIR' ) ) {
|
||||
define( 'SP_WIDGETS_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Include widgets.
|
||||
*/
|
||||
public function includes() {
|
||||
include_once SP()->plugin_path() . '/includes/widgets/class-sp-widget-staff.php';
|
||||
|
||||
do_action( 'sportspress_widgets' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( !defined( 'SP_WIDGETS_VERSION' ) )
|
||||
define( 'SP_WIDGETS_VERSION', '1.8.3' );
|
||||
|
||||
if ( !defined( 'SP_WIDGETS_URL' ) )
|
||||
define( 'SP_WIDGETS_URL', plugin_dir_url( __FILE__ ) );
|
||||
|
||||
if ( !defined( 'SP_WIDGETS_DIR' ) )
|
||||
define( 'SP_WIDGETS_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Include widgets.
|
||||
*/
|
||||
public function includes() {
|
||||
include_once( SP()->plugin_path() . '/includes/widgets/class-sp-widget-staff.php' );
|
||||
|
||||
do_action( 'sportspress_widgets' );
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
new SportsPress_Widgets();
|
||||
|
||||
@@ -9,227 +9,235 @@
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SportsPress_WordPay' ) ) :
|
||||
|
||||
/**
|
||||
* Main SportsPress WordPay Class
|
||||
*
|
||||
* @class SportsPress_WordPay
|
||||
* @version 2.6
|
||||
*/
|
||||
class SportsPress_WordPay {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Main SportsPress WordPay Class
|
||||
*
|
||||
* @class SportsPress_WordPay
|
||||
* @version 2.6
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
class SportsPress_WordPay {
|
||||
|
||||
// Shortcode
|
||||
add_action( 'init', array( $this, 'add_shortcodes' ) );
|
||||
add_action( 'wpay_register_form_after_fields', array( $this, 'form_field' ) );
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
// Editor
|
||||
add_filter( 'wordpay_shortcodes', array( $this, 'editor_shortcodes' ) );
|
||||
add_filter( 'wordpay_tinymce_strings', array( $this, 'editor_strings' ) );
|
||||
// Shortcode
|
||||
add_action( 'init', array( $this, 'add_shortcodes' ) );
|
||||
add_action( 'wpay_register_form_after_fields', array( $this, 'form_field' ) );
|
||||
|
||||
// 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 );
|
||||
}
|
||||
// Editor
|
||||
add_filter( 'wordpay_shortcodes', array( $this, 'editor_shortcodes' ) );
|
||||
add_filter( 'wordpay_tinymce_strings', array( $this, 'editor_strings' ) );
|
||||
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( !defined( 'SP_WORDPAY_VERSION' ) )
|
||||
define( 'SP_WORDPAY_VERSION', '2.6' );
|
||||
// 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 );
|
||||
}
|
||||
|
||||
if ( !defined( 'SP_WORDPAY_URL' ) )
|
||||
define( 'SP_WORDPAY_URL', plugin_dir_url( __FILE__ ) );
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( ! defined( 'SP_WORDPAY_VERSION' ) ) {
|
||||
define( 'SP_WORDPAY_VERSION', '2.6' );
|
||||
}
|
||||
|
||||
if ( !defined( 'SP_WORDPAY_DIR' ) )
|
||||
define( 'SP_WORDPAY_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
/**
|
||||
* Add team and player registration shortcodes.
|
||||
*/
|
||||
public function add_shortcodes() {
|
||||
add_shortcode( 'wpay-register-team', array( $this, 'register_team' ) );
|
||||
add_shortcode( 'wpay-register-player', array( $this, 'register_player' ) );
|
||||
}
|
||||
if ( ! defined( 'SP_WORDPAY_URL' ) ) {
|
||||
define( 'SP_WORDPAY_URL', plugin_dir_url( __FILE__ ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* 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',
|
||||
);
|
||||
if ( ! defined( 'SP_WORDPAY_DIR' ) ) {
|
||||
define( 'SP_WORDPAY_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Add team and player registration shortcodes.
|
||||
*/
|
||||
public function add_shortcodes() {
|
||||
add_shortcode( 'wpay-register-team', array( $this, 'register_team' ) );
|
||||
add_shortcode( 'wpay-register-player', array( $this, 'register_player' ) );
|
||||
}
|
||||
|
||||
$plans = get_posts( $args );
|
||||
/**
|
||||
* 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',
|
||||
);
|
||||
|
||||
if ( empty( $plans ) ) {
|
||||
return '<p>' . __( 'There are no plans associated with the Team Manager role.', 'sportspress' ) . '<p>';
|
||||
}
|
||||
$plans = get_posts( $args );
|
||||
|
||||
return self::register_form( $atts, 'team', $plans );
|
||||
}
|
||||
if ( empty( $plans ) ) {
|
||||
return '<p>' . __( 'There are no plans associated with the Team Manager role.', 'sportspress' ) . '<p>';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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',
|
||||
);
|
||||
return self::register_form( $atts, 'team', $plans );
|
||||
}
|
||||
|
||||
$plans = get_posts( $args );
|
||||
/**
|
||||
* 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',
|
||||
);
|
||||
|
||||
if ( empty( $plans ) ) {
|
||||
return '<p>' . __( 'There are no plans associated with the Player role.', 'sportspress' ) . '<p>';
|
||||
}
|
||||
$plans = get_posts( $args );
|
||||
|
||||
return self::register_form( $atts, 'player', $plans );
|
||||
}
|
||||
if ( empty( $plans ) ) {
|
||||
return '<p>' . __( 'There are no plans associated with the Player role.', 'sportspress' ) . '<p>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Registration form template.
|
||||
*/
|
||||
public static function register_form( $atts = array(), $context = '', $plans = array() ) {
|
||||
return self::register_form( $atts, 'player', $plans );
|
||||
}
|
||||
|
||||
$atts = shortcode_atts( array(
|
||||
'plans_position' => 'bottom',
|
||||
'selected' => '',
|
||||
), $atts );
|
||||
/**
|
||||
* Registration form template.
|
||||
*/
|
||||
public static function register_form( $atts = array(), $context = '', $plans = array() ) {
|
||||
|
||||
$atts['subscription_plans'] = implode( ',', $plans );
|
||||
$atts = shortcode_atts(
|
||||
array(
|
||||
'plans_position' => 'bottom',
|
||||
'selected' => '',
|
||||
),
|
||||
$atts
|
||||
);
|
||||
|
||||
$atts['context'] = $context;
|
||||
$atts['subscription_plans'] = implode( ',', $plans );
|
||||
|
||||
$shortcode = '[wpay-register';
|
||||
$atts['context'] = $context;
|
||||
|
||||
foreach ( $atts as $key => $value ) {
|
||||
$shortcode .= ' ' . $key . '="' . esc_attr( $value ) . '"';
|
||||
}
|
||||
$shortcode = '[wpay-register';
|
||||
|
||||
$shortcode .= ']';
|
||||
foreach ( $atts as $key => $value ) {
|
||||
$shortcode .= ' ' . $key . '="' . esc_attr( $value ) . '"';
|
||||
}
|
||||
|
||||
return do_shortcode( $shortcode );
|
||||
}
|
||||
$shortcode .= ']';
|
||||
|
||||
/**
|
||||
* Add field to registration form.
|
||||
*/
|
||||
public static function form_field( $atts = array() ) {
|
||||
if ( 'team' == $atts['context'] ) {
|
||||
?>
|
||||
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'] ) {
|
||||
?>
|
||||
<?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',
|
||||
'post_type' => 'sp_team',
|
||||
'name' => 'sp_team',
|
||||
'values' => 'ID',
|
||||
'show_option_none' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Team', 'sportspress' ) ),
|
||||
'class' => 'widefat',
|
||||
'class' => 'widefat',
|
||||
);
|
||||
sp_dropdown_pages( $args );
|
||||
?>
|
||||
</li>
|
||||
<?php
|
||||
wp_nonce_field( 'submit_team', 'sp_register_form_player' );
|
||||
<?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 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 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' ),
|
||||
);
|
||||
?>
|
||||
/**
|
||||
* 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'); ?>">
|
||||
<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 );
|
||||
<?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;
|
||||
}
|
||||
return $shortcode;
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
new SportsPress_WordPay();
|
||||
new SportsPress_WordPay();
|
||||
|
||||
Reference in New Issue
Block a user