Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature event ticketshop #433

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions includes/admin/post-types/class-sp-admin-meta-boxes.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ public function __construct() {
'context' => 'side',
'priority' => 'default',
),
'ticketshop' => array(
'title' => esc_attr__( 'Ticketshop', 'sportspress' ),
'save' => 'SP_Meta_Box_Event_Ticketshop::save',
'output' => 'SP_Meta_Box_Event_Ticketshop::output',
'context' => 'side',
'priority' => 'default',
),
'team' => array(
'title' => esc_attr__( 'Teams', 'sportspress' ),
'save' => 'SP_Meta_Box_Event_Teams::save',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
/**
* Event Ticketshop
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta_Boxes
* @version 2.7.9
*/

if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}

/**
* SP_Meta_Box_Event_Ticketshop
*/
class SP_Meta_Box_Event_Ticketshop {

/**
* Output the metabox
*/
public static function output( $post ) {
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
$ticketshop_link = get_post_meta( $post->ID, 'sp_ticketshop_link', true );

?>
<div class="sp-event-ticketshop">
<p><strong><?php esc_attr_e( 'Ticketshop link', 'sportspress' ); ?></strong> <span class="dashicons dashicons-editor-help sp-desc-tip" title="<?php esc_attr_e( 'A link to an external ticket shop.', 'sportspress' ); ?>"></span></p>
<p>
<input name="sp_ticketshop_link" type="text" value="<?php echo esc_attr( $ticketshop_link ); ?>">
</p>
</div>
<?php
}

/**
* Save meta box data
*/
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_ticketshop_link', sp_array_value( $_POST, 'sp_ticketshop_link', '', 'text' ) );
}
}
35 changes: 35 additions & 0 deletions includes/admin/settings/class-sp-settings-events.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,41 @@ public function get_settings() {
'id' => 'event_options',
),
),
array(
array(
'title' => esc_attr__( 'Ticketshop', 'sportspress' ),
'type' => 'title',
'desc' => '',
'id' => 'ticketshop_options',
),
),
apply_filters(
'sportspress_ticketshop_options',
array(
array(
'title' => esc_attr__( 'Ticketshop label', 'sportspress' ),
'id' => 'sportspress_ticketshop_label',
'default' => 'Get your ticket',
'type' => 'text',
),

array(
'title' => esc_attr__( 'Past events', 'sportspress' ),
'desc' => esc_attr__( 'Hide ticketshop for past events', 'sportspress' ),
'id' => 'sportspress_ticketshop_hide_past_events',
'default' => 'yes',
'type' => 'checkbox',
),


)
),
array(
array(
'type' => 'sectionend',
'id' => 'event_options',
),
),
array(
array(
'title' => esc_attr__( 'Venues', 'sportspress' ),
Expand Down
1 change: 1 addition & 0 deletions includes/class-sp-ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@ public function event_list_shortcode() {
'league' => esc_attr__( 'League', 'sportspress' ),
'season' => esc_attr__( 'Season', 'sportspress' ),
'venue' => esc_attr__( 'Venue', 'sportspress' ),
'ticketshop' => esc_attr__( 'Ticketshop Link', 'sportspress' ),
'article' => esc_attr__( 'Article', 'sportspress' ),
'event_specs' => esc_attr__( 'Specs', 'sportspress' ),
);
Expand Down
5 changes: 5 additions & 0 deletions includes/class-sp-event.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ public function mode() {
return $mode;
}

public function ticketshop_link() {
$ticketshop_link = get_post_meta( $this->ID, 'sp_ticketshop_link', true );
return $ticketshop_link;
}

public function minutes() {
$minutes = get_post_meta( $this->ID, 'sp_minutes', true );
if ( '' === $minutes ) {
Expand Down
6 changes: 6 additions & 0 deletions includes/class-sp-templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ public function __construct() {
'action' => 'sportspress_output_event_performance',
'default' => 'yes',
),
'ticketshop_link' => array(
'title' => esc_attr__( 'Ticketshop link', 'sportspress' ),
'option' => 'sportspress_event_show_ticketshop_link',
'action' => 'sportspress_output_event_show_ticketshop_link',
'default' => 'no',
),
)
)
),
Expand Down
17 changes: 17 additions & 0 deletions includes/sp-template-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ function sp_body_class( $classes ) {
$classes[] = 'sp-has-results';
}
}
$show_ticketshop_link = get_option( 'sportspress_event_show_ticketshop_link', 'yes' ) == 'yes' ? true : false;
if ( $show_ticketshop_link && get_post_meta( $id, 'ticketshop_link', true ) ) {
$classes[] = 'sp-has-ticketshop-link';
}
$classes[] = 'sp-performance-sections-' . get_option( 'sportspress_event_performance_sections', -1 );
} elseif ( 'sp_team' == $post_type && 'yes' == get_option( 'sportspress_team_show_logo', 'yes' ) ) {
$classes[] = 'sp-show-image';
Expand Down Expand Up @@ -204,6 +208,19 @@ function sportspress_output_event_performance() {
sp_get_template( 'event-performance.php' );
}
}
if ( ! function_exists( 'sportspress_output_event_show_ticketshop_link' ) ) {

/**
* Output the event Ticketshop link.
*
* @access public
* @subpackage Event/Ticketshop
* @return void
*/
function sportspress_output_event_show_ticketshop_link() {
sp_get_template( 'event-ticketshop-link.php' );
}
}
if ( ! function_exists( 'sportspress_output_event_officials' ) ) {

/**
Expand Down
22 changes: 22 additions & 0 deletions templates/event-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
'scrollable' => get_option( 'sportspress_enable_scrollable_tables', 'yes' ) == 'yes' ? true : false,
'paginated' => get_option( 'sportspress_event_list_paginated', 'yes' ) == 'yes' ? true : false,
'rows' => get_option( 'sportspress_event_list_rows', 10 ),
'ticketshop_link' => null,
'ticketshop_label' => get_option( 'sportspress_ticketshop_label'),
'ticketshop_hide_past' => get_option( 'sportspress_ticketshop_hide_past_events', 'yes' ) == 'yes' ? true : false,
'order' => 'default',
'columns' => null,
'show_all_events_link' => false,
Expand Down Expand Up @@ -223,6 +226,10 @@
echo '<th class="data-article">' . esc_attr__( 'Article', 'sportspress' ) . '</th>';
}

if ( sp_column_active( $usecolumns, 'ticketshop' ) ) {
echo '<th class="data-ticketshop">' . esc_attr__( 'Ticketshop', 'sportspress' ) . '</th>';
}

if ( sp_column_active( $usecolumns, 'day' ) ) {
echo '<th class="data-day">' . esc_attr__( 'Match Day', 'sportspress' ) . '</th>';
}
Expand Down Expand Up @@ -528,6 +535,21 @@
echo '</td>';
endif;

if ( sp_column_active( $usecolumns, 'ticketshop' ) ) :
echo '<td class="data-ticketshop" data-label="' . esc_attr__( 'Ticketshop', 'sportspress' ) . '">';

if ($ticketshop_hide_past && $event->post_status != 'future' ) {
echo '';
} else {
$ticketshop_link = get_post_meta( $event->ID, 'sp_ticketshop_link', true );
if(isset($ticketshop_link) && $ticketshop_link != '') {
echo '<a class="sp-ticketshop-link" target="_blank" href="'.$ticketshop_link.'" itemprop="url">'.$ticketshop_label.'</a>';
}
}

echo '</td>';
endif;

if ( sp_column_active( $usecolumns, 'day' ) ) :
echo '<td class="data-day" data-label="' . esc_attr__( 'Match Day', 'sportspress' ) . '">';
$day = get_post_meta( $event->ID, 'sp_day', true );
Expand Down
52 changes: 52 additions & 0 deletions templates/event-ticketshop-link.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
/**
* Event Video
*
* @author ThemeBoy
* @package SportsPress/Templates
* @version 1.4
*/

if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}

if ( ! isset( $id ) ) {
$id = get_the_ID();
}
$event = new SP_Event( $id );
$post = get_post($id);
$ticketshop_link = $event->ticketshop_link();
$hide_past_events = get_option( 'sportspress_ticketshop_hide_past_events', 'yes' ) == 'yes' ? true : false;

if ($hide_past_events && $post->post_status != 'future' ) {
return;
}

if(isset($ticketshop_link) && $ticketshop_link != '') {
$ticketshop_label = get_option( 'sportspress_ticketshop_label');

?>
<h3 class="gdlr-core-sp-title-box">Ticketshop</h3>
<div class="sp-template sp-template-event-ticketshop sp-template-event-blocks sp-template-event-ticketshop-block">
<div class="sp-table-wrapper">
<table class="sp-event-blocks sp-data-table" data-sp-rows="1">
<thead><tr><th></th></tr></thead> <?php // Required for DataTables ?>
<tbody>
<tr class="sp-row sp-post alternate">
<td>
<a href="<?php echo $ticketshop_link; ?>" target="_blank" class="sp-event-ticketshop-link"><?php echo $ticketshop_label; ?></a>
</td>
</tr>
</tbody>
</table>
</div>
</div>

<?php
}



?>