Merge pull request #303 from ThemeBoy/feature-new-event-shortcodes
Feature new event shortcodes
This commit is contained in:
@@ -4,7 +4,7 @@ $shortcodes = '';
|
||||
|
||||
$options = array(
|
||||
'event' => array(
|
||||
'details', 'results', 'performance'
|
||||
'details', 'results', 'performance', 'venue', 'officials', 'teams', 'full',
|
||||
),
|
||||
'team' => array(),
|
||||
'player' => array(
|
||||
@@ -30,6 +30,10 @@ $raw = apply_filters( 'sportspress_tinymce_strings', array(
|
||||
'results' => __( 'Results', 'sportspress' ),
|
||||
'countdown' => __( 'Countdown', 'sportspress' ),
|
||||
'performance' => __( 'Box Score', 'sportspress' ),
|
||||
'venue' => __( 'Venue', 'sportspress' ),
|
||||
'officials' => __( 'Officials', 'sportspress' ),
|
||||
'teams' => __( 'Teams', 'sportspress' ),
|
||||
'full' => __( 'Full Info', 'sportspress' ),
|
||||
'calendar' => __( 'Calendar', 'sportspress' ),
|
||||
'statistics' => __( 'Statistics', 'sportspress' ),
|
||||
'team' => __( 'Team', 'sportspress' ),
|
||||
|
||||
@@ -23,6 +23,10 @@ class SP_Meta_Box_Event_Shortcode {
|
||||
'event_results' => __( 'Results', 'sportspress' ),
|
||||
'event_details' => __( 'Details', 'sportspress' ),
|
||||
'event_performance' => __( 'Box Score', 'sportspress' ),
|
||||
'event_venue' => __( 'Venue', 'sportspress' ),
|
||||
'event_officials' => __( 'Officials', 'sportspress' ),
|
||||
'event_teams' => __( 'Teams', 'sportspress' ),
|
||||
'event_full' => __( 'Full Info', 'sportspress' ),
|
||||
) );
|
||||
if ( $shortcodes ) {
|
||||
?>
|
||||
|
||||
@@ -27,6 +27,9 @@ class SP_AJAX {
|
||||
'event_details_shortcode' => false,
|
||||
'event_results_shortcode' => false,
|
||||
'event_performance_shortcode' => false,
|
||||
'event_venue_shortcode' => false,
|
||||
'event_officials_shortcode' => false,
|
||||
'event_teams_shortcode' => false,
|
||||
'event_calendar_shortcode' => false,
|
||||
'event_list_shortcode' => false,
|
||||
'event_blocks_shortcode' => false,
|
||||
@@ -181,6 +184,126 @@ class SP_AJAX {
|
||||
self::scripts();
|
||||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX event_venue shortcode
|
||||
*/
|
||||
public function event_venue_shortcode() {
|
||||
?>
|
||||
<div class="wrap sp-thickbox-content" id="sp-thickbox-event_venue">
|
||||
<p>
|
||||
<label>
|
||||
<?php printf( __( 'Select %s:', 'sportspress' ), __( 'Event', 'sportspress' ) ); ?>
|
||||
<?php
|
||||
$args = array(
|
||||
'post_type' => 'sp_event',
|
||||
'name' => 'id',
|
||||
'values' => 'ID',
|
||||
);
|
||||
sp_dropdown_pages( $args );
|
||||
?>
|
||||
</label>
|
||||
</p>
|
||||
<?php do_action( 'sportspress_ajax_shortcode_form', 'event-venue' ); ?>
|
||||
<p class="submit">
|
||||
<input type="button" class="button-primary" value="<?php _e( 'Insert Shortcode', 'sportspress' ); ?>" onclick="insertSportsPress('event_venue');" />
|
||||
<a class="button-secondary" onclick="tb_remove();" title="<?php _e( 'Cancel', 'sportspress' ); ?>"><?php _e( 'Cancel', 'sportspress' ); ?></a>
|
||||
</p>
|
||||
</div>
|
||||
<?php
|
||||
self::scripts();
|
||||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX event_officials shortcode
|
||||
*/
|
||||
public function event_officials_shortcode() {
|
||||
?>
|
||||
<div class="wrap sp-thickbox-content" id="sp-thickbox-event_officials">
|
||||
<p>
|
||||
<label>
|
||||
<?php printf( __( 'Select %s:', 'sportspress' ), __( 'Event', 'sportspress' ) ); ?>
|
||||
<?php
|
||||
$args = array(
|
||||
'post_type' => 'sp_event',
|
||||
'name' => 'id',
|
||||
'values' => 'ID',
|
||||
);
|
||||
sp_dropdown_pages( $args );
|
||||
?>
|
||||
</label>
|
||||
</p>
|
||||
<?php do_action( 'sportspress_ajax_shortcode_form', 'event-officials' ); ?>
|
||||
<p class="submit">
|
||||
<input type="button" class="button-primary" value="<?php _e( 'Insert Shortcode', 'sportspress' ); ?>" onclick="insertSportsPress('event_officials');" />
|
||||
<a class="button-secondary" onclick="tb_remove();" title="<?php _e( 'Cancel', 'sportspress' ); ?>"><?php _e( 'Cancel', 'sportspress' ); ?></a>
|
||||
</p>
|
||||
</div>
|
||||
<?php
|
||||
self::scripts();
|
||||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX event_officials shortcode
|
||||
*/
|
||||
public function event_teams_shortcode() {
|
||||
?>
|
||||
<div class="wrap sp-thickbox-content" id="sp-thickbox-event_teams">
|
||||
<p>
|
||||
<label>
|
||||
<?php printf( __( 'Select %s:', 'sportspress' ), __( 'Event', 'sportspress' ) ); ?>
|
||||
<?php
|
||||
$args = array(
|
||||
'post_type' => 'sp_event',
|
||||
'name' => 'id',
|
||||
'values' => 'ID',
|
||||
);
|
||||
sp_dropdown_pages( $args );
|
||||
?>
|
||||
</label>
|
||||
</p>
|
||||
<?php do_action( 'sportspress_ajax_shortcode_form', 'event-teams' ); ?>
|
||||
<p class="submit">
|
||||
<input type="button" class="button-primary" value="<?php _e( 'Insert Shortcode', 'sportspress' ); ?>" onclick="insertSportsPress('event_teams');" />
|
||||
<a class="button-secondary" onclick="tb_remove();" title="<?php _e( 'Cancel', 'sportspress' ); ?>"><?php _e( 'Cancel', 'sportspress' ); ?></a>
|
||||
</p>
|
||||
</div>
|
||||
<?php
|
||||
self::scripts();
|
||||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX event_full shortcode
|
||||
*/
|
||||
public function event_full_shortcode() {
|
||||
?>
|
||||
<div class="wrap sp-thickbox-content" id="sp-thickbox-event_full">
|
||||
<p>
|
||||
<label>
|
||||
<?php printf( __( 'Select %s:', 'sportspress' ), __( 'Event', 'sportspress' ) ); ?>
|
||||
<?php
|
||||
$args = array(
|
||||
'post_type' => 'sp_event',
|
||||
'name' => 'id',
|
||||
'values' => 'ID',
|
||||
);
|
||||
sp_dropdown_pages( $args );
|
||||
?>
|
||||
</label>
|
||||
</p>
|
||||
<?php do_action( 'sportspress_ajax_shortcode_form', 'event-full' ); ?>
|
||||
<p class="submit">
|
||||
<input type="button" class="button-primary" value="<?php _e( 'Insert Shortcode', 'sportspress' ); ?>" onclick="insertSportsPress('event_full');" />
|
||||
<a class="button-secondary" onclick="tb_remove();" title="<?php _e( 'Cancel', 'sportspress' ); ?>"><?php _e( 'Cancel', 'sportspress' ); ?></a>
|
||||
</p>
|
||||
</div>
|
||||
<?php
|
||||
self::scripts();
|
||||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX event_calendar shortcode
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* SP_Shortcodes class.
|
||||
*
|
||||
* @class SP_Shortcodes
|
||||
* @version 2.5.5
|
||||
* @version 2.6.9
|
||||
* @package SportsPress/Classes
|
||||
* @category Class
|
||||
* @author ThemeBoy
|
||||
@@ -19,6 +19,10 @@ class SP_Shortcodes {
|
||||
'event_results' => __CLASS__ . '::event_results',
|
||||
'event_details' => __CLASS__ . '::event_details',
|
||||
'event_performance' => __CLASS__ . '::event_performance',
|
||||
'event_venue' => __CLASS__ . '::event_venue',
|
||||
'event_officials' => __CLASS__ . '::event_officials',
|
||||
'event_teams' => __CLASS__ . '::event_teams',
|
||||
'event_full' => __CLASS__ . '::event_full',
|
||||
'countdown' => __CLASS__ . '::countdown',
|
||||
'player_details' => __CLASS__ . '::player_details',
|
||||
'player_statistics' => __CLASS__ . '::player_statistics',
|
||||
@@ -101,6 +105,50 @@ class SP_Shortcodes {
|
||||
public static function event_performance( $atts ) {
|
||||
return self::shortcode_wrapper( array( 'SP_Shortcode_Event_Performance', 'output' ), $atts );
|
||||
}
|
||||
|
||||
/**
|
||||
* Event venue shortcode.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $atts
|
||||
* @return string
|
||||
*/
|
||||
public static function event_venue( $atts ) {
|
||||
return self::shortcode_wrapper( array( 'SP_Shortcode_Event_Venue', 'output' ), $atts );
|
||||
}
|
||||
|
||||
/**
|
||||
* Event officials shortcode.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $atts
|
||||
* @return string
|
||||
*/
|
||||
public static function event_officials( $atts ) {
|
||||
return self::shortcode_wrapper( array( 'SP_Shortcode_Event_Officials', 'output' ), $atts );
|
||||
}
|
||||
|
||||
/**
|
||||
* Event teams shortcode.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $atts
|
||||
* @return string
|
||||
*/
|
||||
public static function event_teams( $atts ) {
|
||||
return self::shortcode_wrapper( array( 'SP_Shortcode_Event_Teams', 'output' ), $atts );
|
||||
}
|
||||
|
||||
/**
|
||||
* Event full info shortcode.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $atts
|
||||
* @return string
|
||||
*/
|
||||
public static function event_full( $atts ) {
|
||||
return self::shortcode_wrapper( array( 'SP_Shortcode_Event_Full', 'output' ), $atts );
|
||||
}
|
||||
|
||||
/**
|
||||
* Countdown shortcode.
|
||||
|
||||
139
includes/shortcodes/class-sp-shortcode-event-full.php
Normal file
139
includes/shortcodes/class-sp-shortcode-event-full.php
Normal file
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
/**
|
||||
* Event Full info Shortcode
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Shortcodes
|
||||
* @package SportsPress/Shortcodes/Event_Full
|
||||
* @version 2.6.9
|
||||
*/
|
||||
class SP_Shortcode_Event_Full {
|
||||
|
||||
/**
|
||||
* Output the event full shortcode.
|
||||
*
|
||||
* @param array $atts
|
||||
*/
|
||||
public static function output( $atts ) {
|
||||
|
||||
if ( ! isset( $atts['id'] ) && isset( $atts[0] ) && is_numeric( $atts[0] ) )
|
||||
$atts['id'] = $atts[0];
|
||||
|
||||
$type = 'event';
|
||||
|
||||
$content = apply_filters( 'the_content', get_post_field( 'post_content', $atts['id'] ) );
|
||||
|
||||
// Get layout setting
|
||||
$layout = (array) get_option( 'sportspress_' . $type . '_template_order', array() );
|
||||
|
||||
// Get templates
|
||||
$templates = SP()->templates->$type;
|
||||
|
||||
// Combine layout setting with available templates
|
||||
$templates = array_merge( array_flip( $layout ), $templates );
|
||||
|
||||
$templates = apply_filters( 'sportspress_' . $type . '_templates', $templates );
|
||||
|
||||
// Split templates into sections and tabs
|
||||
$slice = array_search( 'tabs', array_keys( $templates ) );
|
||||
if ( $slice ) {
|
||||
$section_templates = array_slice( $templates, 0, $slice );
|
||||
$tab_templates = array_slice( $templates, $slice );
|
||||
} else {
|
||||
$section_templates = $templates;
|
||||
$tab_templates = array();
|
||||
}
|
||||
|
||||
ob_start();
|
||||
|
||||
// Before template hook
|
||||
do_action( 'sportspress_before_single_' . $type );
|
||||
|
||||
// Loop through sections
|
||||
if ( ! empty( $section_templates ) ) {
|
||||
foreach ( $section_templates as $key => $template ) {
|
||||
// Ignore templates that are unavailable or that have been turned off
|
||||
if ( ! is_array( $template ) ) continue;
|
||||
if ( ! isset( $template['option'] ) ) continue;
|
||||
if ( 'yes' !== get_option( $template['option'], sp_array_value( $template, 'default', 'yes' ) ) ) continue;
|
||||
|
||||
// Render the template
|
||||
echo '<div class="sp-section-content sp-section-content-' . $key . '">';
|
||||
if ( 'content' === $key ) {
|
||||
echo $content;
|
||||
// Template content hook
|
||||
do_action( 'sportspress_single_' . $type . '_content' );
|
||||
} elseif ( 'excerpt' === $key ) {
|
||||
sp_get_template( 'post-excerpt.php', $atts );
|
||||
} else {
|
||||
//call_user_func( $template['action'] );
|
||||
sp_get_template( 'event-' . $key . '.php', $atts );
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
// After template hook
|
||||
do_action( 'sportspress_after_single_' . $type );
|
||||
|
||||
$ob = ob_get_clean();
|
||||
|
||||
$tabs = '';
|
||||
|
||||
if ( ! empty( $tab_templates ) ) {
|
||||
$i = 0;
|
||||
$tab_content = '';
|
||||
|
||||
foreach ( $tab_templates as $key => $template ) {
|
||||
// Ignore templates that are unavailable or that have been turned off
|
||||
if ( ! is_array( $template ) ) continue;
|
||||
if ( ! isset( $template['option'] ) ) continue;
|
||||
if ( 'yes' !== get_option( $template['option'], sp_array_value( $template, 'default', 'yes' ) ) ) continue;
|
||||
|
||||
// Put tab content into buffer
|
||||
ob_start();
|
||||
if ( 'content' === $key ) {
|
||||
echo $content;
|
||||
// Template content hook
|
||||
do_action( 'sportspress_single_' . $type . '_content' );
|
||||
} elseif ( 'excerpt' === $key ) {
|
||||
sp_get_template( 'post-excerpt.php', $atts );
|
||||
} else {
|
||||
//call_user_func( $template['action'] );
|
||||
sp_get_template( 'event-' . $key . '.php', $atts );
|
||||
}
|
||||
$buffer = ob_get_clean();
|
||||
|
||||
// Trim whitespace from buffer
|
||||
$buffer = trim( $buffer );
|
||||
|
||||
// Continue if tab content is empty
|
||||
if ( empty( $buffer ) ) continue;
|
||||
|
||||
// Get template label
|
||||
$label = sp_array_value( $template, 'label', $template['title'] );
|
||||
|
||||
// Add to tabs
|
||||
$tabs .= '<li class="sp-tab-menu-item' . ( 0 === $i ? ' sp-tab-menu-item-active' : '' ) . '"><a href="#sp-tab-content-' . $key . '" data-sp-tab="' . $key . '">' . apply_filters( 'gettext', $label, $label, 'sportspress' ) . '</a></li>';
|
||||
|
||||
// Render the template
|
||||
$tab_content .= '<div class="sp-tab-content sp-tab-content-' . $key . '" id="sp-tab-content-' . $key . '"' . ( 0 === $i ? ' style="display: block;"' : '' ) . '>' . $buffer . '</div>';
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
$ob .= '<div class="sp-tab-group">';
|
||||
|
||||
if ( ! empty( $tabs ) ) {
|
||||
$ob .= '<ul class="sp-tab-menu">' . $tabs . '</ul>';
|
||||
}
|
||||
|
||||
$ob .= $tab_content;
|
||||
|
||||
$ob .= '</div>';
|
||||
}
|
||||
|
||||
echo $ob;
|
||||
|
||||
}
|
||||
}
|
||||
24
includes/shortcodes/class-sp-shortcode-event-officials.php
Normal file
24
includes/shortcodes/class-sp-shortcode-event-officials.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* Event Officials Shortcode
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Shortcodes
|
||||
* @package SportsPress/Shortcodes/Event_Officials
|
||||
* @version 2.6.9
|
||||
*/
|
||||
class SP_Shortcode_Event_Officials {
|
||||
|
||||
/**
|
||||
* Output the event officials shortcode.
|
||||
*
|
||||
* @param array $atts
|
||||
*/
|
||||
public static function output( $atts ) {
|
||||
|
||||
if ( ! isset( $atts['id'] ) && isset( $atts[0] ) && is_numeric( $atts[0] ) )
|
||||
$atts['id'] = $atts[0];
|
||||
|
||||
sp_get_template( 'event-officials.php', $atts );
|
||||
}
|
||||
}
|
||||
24
includes/shortcodes/class-sp-shortcode-event-teams.php
Normal file
24
includes/shortcodes/class-sp-shortcode-event-teams.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* Event Teams Shortcode
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Shortcodes
|
||||
* @package SportsPress/Shortcodes/Event_Officials
|
||||
* @version 2.6.9
|
||||
*/
|
||||
class SP_Shortcode_Event_Teams {
|
||||
|
||||
/**
|
||||
* Output the event teams shortcode.
|
||||
*
|
||||
* @param array $atts
|
||||
*/
|
||||
public static function output( $atts ) {
|
||||
|
||||
if ( ! isset( $atts['id'] ) && isset( $atts[0] ) && is_numeric( $atts[0] ) )
|
||||
$atts['id'] = $atts[0];
|
||||
|
||||
sp_get_template( 'event-logos.php', $atts );
|
||||
}
|
||||
}
|
||||
24
includes/shortcodes/class-sp-shortcode-event-venue.php
Normal file
24
includes/shortcodes/class-sp-shortcode-event-venue.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* Event Venue Shortcode
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Shortcodes
|
||||
* @package SportsPress/Shortcodes/Event_Venue
|
||||
* @version 2.6.9
|
||||
*/
|
||||
class SP_Shortcode_Event_Venue {
|
||||
|
||||
/**
|
||||
* Output the event venue shortcode.
|
||||
*
|
||||
* @param array $atts
|
||||
*/
|
||||
public static function output( $atts ) {
|
||||
|
||||
if ( ! isset( $atts['id'] ) && isset( $atts[0] ) && is_numeric( $atts[0] ) )
|
||||
$atts['id'] = $atts[0];
|
||||
|
||||
sp_get_template( 'event-venue.php', $atts );
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,9 @@
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
$id = get_the_ID();
|
||||
if ( ! isset( $id ) )
|
||||
$id = get_the_ID();
|
||||
|
||||
$post = get_post( $id );
|
||||
$excerpt = $post->post_excerpt;
|
||||
if ( $excerpt ) {
|
||||
|
||||
Reference in New Issue
Block a user