Add heading option to calendars, league tables, and player lists
This commit is contained in:
@@ -20,6 +20,7 @@ class SP_Meta_Box_Calendar_Details {
|
|||||||
*/
|
*/
|
||||||
public static function output( $post ) {
|
public static function output( $post ) {
|
||||||
$taxonomies = get_object_taxonomies( 'sp_calendar' );
|
$taxonomies = get_object_taxonomies( 'sp_calendar' );
|
||||||
|
$caption = get_post_meta( $post->ID, 'sp_caption', true );
|
||||||
$status = get_post_meta( $post->ID, 'sp_status', true );
|
$status = get_post_meta( $post->ID, 'sp_status', true );
|
||||||
$date = get_post_meta( $post->ID, 'sp_date', true );
|
$date = get_post_meta( $post->ID, 'sp_date', true );
|
||||||
$date_from = get_post_meta( $post->ID, 'sp_date_from', true );
|
$date_from = get_post_meta( $post->ID, 'sp_date_from', true );
|
||||||
@@ -29,6 +30,9 @@ class SP_Meta_Box_Calendar_Details {
|
|||||||
$order = get_post_meta( $post->ID, 'sp_order', true );
|
$order = get_post_meta( $post->ID, 'sp_order', true );
|
||||||
?>
|
?>
|
||||||
<div>
|
<div>
|
||||||
|
<p><strong><?php _e( 'Heading', 'sportspress' ); ?></strong></p>
|
||||||
|
<p><input type="text" id="sp_caption" name="sp_caption" value="<?php echo esc_attr( $caption ); ?>" placeholder="<?php echo esc_attr( get_the_title() ); ?>"></p>
|
||||||
|
|
||||||
<p><strong><?php _e( 'Status', 'sportspress' ); ?></strong></p>
|
<p><strong><?php _e( 'Status', 'sportspress' ); ?></strong></p>
|
||||||
<p>
|
<p>
|
||||||
<?php
|
<?php
|
||||||
@@ -96,6 +100,7 @@ class SP_Meta_Box_Calendar_Details {
|
|||||||
* Save meta box data
|
* Save meta box data
|
||||||
*/
|
*/
|
||||||
public static function save( $post_id, $post ) {
|
public static function save( $post_id, $post ) {
|
||||||
|
update_post_meta( $post_id, 'sp_caption', esc_attr( sp_array_value( $_POST, 'sp_caption', 0 ) ) );
|
||||||
update_post_meta( $post_id, 'sp_status', sp_array_value( $_POST, 'sp_status', 0 ) );
|
update_post_meta( $post_id, 'sp_status', sp_array_value( $_POST, 'sp_status', 0 ) );
|
||||||
update_post_meta( $post_id, 'sp_date', sp_array_value( $_POST, 'sp_date', 0 ) );
|
update_post_meta( $post_id, 'sp_date', sp_array_value( $_POST, 'sp_date', 0 ) );
|
||||||
update_post_meta( $post_id, 'sp_date_from', sp_array_value( $_POST, 'sp_date_from', null ) );
|
update_post_meta( $post_id, 'sp_date_from', sp_array_value( $_POST, 'sp_date_from', null ) );
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ class SP_Meta_Box_List_Details {
|
|||||||
*/
|
*/
|
||||||
public static function output( $post ) {
|
public static function output( $post ) {
|
||||||
$taxonomies = get_object_taxonomies( 'sp_list' );
|
$taxonomies = get_object_taxonomies( 'sp_list' );
|
||||||
|
$caption = get_post_meta( $post->ID, 'sp_caption', true );
|
||||||
$team_id = get_post_meta( $post->ID, 'sp_team', true );
|
$team_id = get_post_meta( $post->ID, 'sp_team', true );
|
||||||
$grouping = get_post_meta( $post->ID, 'sp_grouping', true );
|
$grouping = get_post_meta( $post->ID, 'sp_grouping', true );
|
||||||
$orderby = get_post_meta( $post->ID, 'sp_orderby', true );
|
$orderby = get_post_meta( $post->ID, 'sp_orderby', true );
|
||||||
@@ -31,6 +32,9 @@ class SP_Meta_Box_List_Details {
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<div>
|
<div>
|
||||||
|
<p><strong><?php _e( 'Heading', 'sportspress' ); ?></strong></p>
|
||||||
|
<p><input type="text" id="sp_caption" name="sp_caption" value="<?php echo esc_attr( $caption ); ?>" placeholder="<?php echo esc_attr( get_the_title() ); ?>"></p>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
foreach ( $taxonomies as $taxonomy ) {
|
foreach ( $taxonomies as $taxonomy ) {
|
||||||
sp_taxonomy_field( $taxonomy, $post, true );
|
sp_taxonomy_field( $taxonomy, $post, true );
|
||||||
@@ -104,6 +108,7 @@ class SP_Meta_Box_List_Details {
|
|||||||
* Save meta box data
|
* Save meta box data
|
||||||
*/
|
*/
|
||||||
public static function save( $post_id, $post ) {
|
public static function save( $post_id, $post ) {
|
||||||
|
update_post_meta( $post_id, 'sp_caption', esc_attr( sp_array_value( $_POST, 'sp_caption', 0 ) ) );
|
||||||
update_post_meta( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) );
|
update_post_meta( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) );
|
||||||
update_post_meta( $post_id, 'sp_grouping', sp_array_value( $_POST, 'sp_grouping', array() ) );
|
update_post_meta( $post_id, 'sp_grouping', sp_array_value( $_POST, 'sp_grouping', array() ) );
|
||||||
update_post_meta( $post_id, 'sp_orderby', sp_array_value( $_POST, 'sp_orderby', array() ) );
|
update_post_meta( $post_id, 'sp_orderby', sp_array_value( $_POST, 'sp_orderby', array() ) );
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ class SP_Meta_Box_Table_Details {
|
|||||||
public static function output( $post ) {
|
public static function output( $post ) {
|
||||||
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
|
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
|
||||||
$taxonomies = get_object_taxonomies( 'sp_table' );
|
$taxonomies = get_object_taxonomies( 'sp_table' );
|
||||||
|
$caption = get_post_meta( $post->ID, 'sp_caption', true );
|
||||||
$select = get_post_meta( $post->ID, 'sp_select', true );
|
$select = get_post_meta( $post->ID, 'sp_select', true );
|
||||||
if ( ! $select ) {
|
if ( ! $select ) {
|
||||||
global $pagenow;
|
global $pagenow;
|
||||||
@@ -28,6 +29,9 @@ class SP_Meta_Box_Table_Details {
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<div>
|
<div>
|
||||||
|
<p><strong><?php _e( 'Heading', 'sportspress' ); ?></strong></p>
|
||||||
|
<p><input type="text" id="sp_caption" name="sp_caption" value="<?php echo esc_attr( $caption ); ?>" placeholder="<?php echo esc_attr( get_the_title() ); ?>"></p>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
foreach ( $taxonomies as $taxonomy ) {
|
foreach ( $taxonomies as $taxonomy ) {
|
||||||
sp_taxonomy_field( $taxonomy, $post, true );
|
sp_taxonomy_field( $taxonomy, $post, true );
|
||||||
@@ -56,6 +60,7 @@ class SP_Meta_Box_Table_Details {
|
|||||||
* Save meta box data
|
* Save meta box data
|
||||||
*/
|
*/
|
||||||
public static function save( $post_id, $post ) {
|
public static function save( $post_id, $post ) {
|
||||||
|
update_post_meta( $post_id, 'sp_caption', esc_attr( sp_array_value( $_POST, 'sp_caption', 0 ) ) );
|
||||||
update_post_meta( $post_id, 'sp_select', sp_array_value( $_POST, 'sp_select', array() ) );
|
update_post_meta( $post_id, 'sp_select', sp_array_value( $_POST, 'sp_select', array() ) );
|
||||||
sp_update_post_meta_recursive( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) );
|
sp_update_post_meta_recursive( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -298,7 +298,7 @@ if ( ! function_exists( 'sportspress_output_league_table' ) ) {
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function sportspress_output_league_table() {
|
function sportspress_output_league_table() {
|
||||||
sp_get_template( 'league-table.php', array( 'title' => __( 'League Table', 'sportspress' ) ) );
|
sp_get_template( 'league-table.php' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,8 +53,13 @@ if ( $order != 'default' )
|
|||||||
$data = $calendar->data();
|
$data = $calendar->data();
|
||||||
$usecolumns = $calendar->columns;
|
$usecolumns = $calendar->columns;
|
||||||
|
|
||||||
if ( $show_title && false === $title && $id )
|
if ( $show_title && false === $title && $id ):
|
||||||
$title = get_the_title( $id );
|
$caption = $calendar->caption;
|
||||||
|
if ( $caption )
|
||||||
|
$title = $caption;
|
||||||
|
else
|
||||||
|
$title = get_the_title( $id );
|
||||||
|
endif;
|
||||||
|
|
||||||
if ( isset( $columns ) ) {
|
if ( isset( $columns ) ) {
|
||||||
$usecolumns = $columns;
|
$usecolumns = $columns;
|
||||||
|
|||||||
@@ -62,8 +62,13 @@ if ( isset( $columns ) ):
|
|||||||
$usecolumns = explode( ',', $columns );
|
$usecolumns = explode( ',', $columns );
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
if ( $show_title && false === $title && $id )
|
if ( $show_title && false === $title && $id ):
|
||||||
$title = get_the_title( $id );
|
$caption = $calendar->caption;
|
||||||
|
if ( $caption )
|
||||||
|
$title = $caption;
|
||||||
|
else
|
||||||
|
$title = get_the_title( $id );
|
||||||
|
endif;
|
||||||
?>
|
?>
|
||||||
<div class="sp-template sp-template-event-list">
|
<div class="sp-template sp-template-event-list">
|
||||||
<?php if ( $title ) { ?>
|
<?php if ( $title ) { ?>
|
||||||
|
|||||||
@@ -31,8 +31,13 @@ if ( ! isset( $highlight ) ) $highlight = get_post_meta( $id, 'sp_highlight', tr
|
|||||||
|
|
||||||
$table = new SP_League_Table( $id );
|
$table = new SP_League_Table( $id );
|
||||||
|
|
||||||
if ( $show_title && false === $title && $id )
|
if ( $show_title && false === $title && $id ):
|
||||||
$title = get_the_title( $id );
|
$caption = $table->caption;
|
||||||
|
if ( $caption )
|
||||||
|
$title = $caption;
|
||||||
|
else
|
||||||
|
$title = get_the_title( $id );
|
||||||
|
endif;
|
||||||
|
|
||||||
$output = '';
|
$output = '';
|
||||||
|
|
||||||
|
|||||||
@@ -74,8 +74,13 @@ $output = '';
|
|||||||
if ( $grouping === 'position' ):
|
if ( $grouping === 'position' ):
|
||||||
$groups = get_terms( 'sp_position', array( 'orderby' => 'slug' ) );
|
$groups = get_terms( 'sp_position', array( 'orderby' => 'slug' ) );
|
||||||
else:
|
else:
|
||||||
if ( $show_title && false === $title && $id )
|
if ( $show_title && false === $title && $id ):
|
||||||
get_the_title( $id );
|
$caption = $list->caption;
|
||||||
|
if ( $caption )
|
||||||
|
$title = $caption;
|
||||||
|
else
|
||||||
|
$title = get_the_title( $id );
|
||||||
|
endif;
|
||||||
if ( $title )
|
if ( $title )
|
||||||
$output .= '<' . $grouptag . ' class="sp-table-caption">' . $title . '</' . $grouptag . '>';
|
$output .= '<' . $grouptag . ' class="sp-table-caption">' . $title . '</' . $grouptag . '>';
|
||||||
$group = new stdClass();
|
$group = new stdClass();
|
||||||
|
|||||||
Reference in New Issue
Block a user