Clean up spaces, tabs, indentation, and bracket formatting
This commit is contained in:
@@ -6,11 +6,11 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
/**
|
||||
* Handles taxonomies in admin
|
||||
*
|
||||
* @class SP_Admin_Taxonomies
|
||||
* @version 2.7.9
|
||||
* @package SportsPress/Admin
|
||||
* @category Class
|
||||
* @author ThemeBoy
|
||||
* @class SP_Admin_Taxonomies
|
||||
* @version 2.7.9
|
||||
* @package SportsPress/Admin
|
||||
* @category Class
|
||||
* @author ThemeBoy
|
||||
*/
|
||||
class SP_Admin_Taxonomies {
|
||||
|
||||
@@ -71,7 +71,7 @@ class SP_Admin_Taxonomies {
|
||||
* @param mixed $term Term (category) being edited
|
||||
*/
|
||||
public function edit_taxonomy_fields( $term ) {
|
||||
$t_id = $term->term_id;
|
||||
$t_id = $term->term_id;
|
||||
?>
|
||||
<?php if ( function_exists( 'get_term_meta' ) ) { ?>
|
||||
<?php $order = get_term_meta( $t_id, 'sp_order', true ); ?>
|
||||
@@ -80,7 +80,7 @@ class SP_Admin_Taxonomies {
|
||||
<td><input name="sp_order" class="sp-number-input" type="text" step="1" size="4" id="sp_order" value="<?php echo (int) $order; ?>"></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,25 +91,25 @@ class SP_Admin_Taxonomies {
|
||||
*/
|
||||
public function add_venue_fields() {
|
||||
$args = array(
|
||||
'orderby' => 'id',
|
||||
'order' => 'DESC',
|
||||
'orderby' => 'id',
|
||||
'order' => 'DESC',
|
||||
'hide_empty' => false,
|
||||
'number' => 1,
|
||||
'number' => 1,
|
||||
);
|
||||
|
||||
// Get latitude and longitude from the last added venue
|
||||
$terms = get_terms( 'sp_venue', $args );
|
||||
if ( $terms && array_key_exists( 0, $terms) && is_object( reset( $terms ) ) ):
|
||||
$term = reset( $terms );
|
||||
$t_id = $term->term_id;
|
||||
if ( $terms && array_key_exists( 0, $terms ) && is_object( reset( $terms ) ) ) :
|
||||
$term = reset( $terms );
|
||||
$t_id = $term->term_id;
|
||||
$term_meta = get_option( "taxonomy_$t_id" );
|
||||
$latitude = sp_array_value( $term_meta, 'sp_latitude', '-37.8165647' );
|
||||
$latitude = sp_array_value( $term_meta, 'sp_latitude', '-37.8165647' );
|
||||
$longitude = sp_array_value( $term_meta, 'sp_longitude', '144.9475055' );
|
||||
$address = sp_array_value( $term_meta, 'sp_address', '' );
|
||||
$address = sp_array_value( $term_meta, 'sp_address', '' );
|
||||
endif;
|
||||
// Sanitize latitude and longitude, fallback to default.
|
||||
if( ! is_numeric( $latitude) || ! is_numeric( $longitude) ):
|
||||
$latitude = '-37.8165647';
|
||||
if ( ! is_numeric( $latitude ) || ! is_numeric( $longitude ) ) :
|
||||
$latitude = '-37.8165647';
|
||||
$longitude = '144.9475055';
|
||||
endif;
|
||||
?>
|
||||
@@ -129,7 +129,7 @@ class SP_Admin_Taxonomies {
|
||||
<label for="term_meta[sp_longitude]"><?php _e( 'Longitude', 'sportspress' ); ?></label>
|
||||
<input type="text" class="sp-longitude" name="term_meta[sp_longitude]" id="term_meta[sp_longitude]" value="<?php echo esc_attr( $longitude ); ?>">
|
||||
</div>
|
||||
<?php
|
||||
<?php
|
||||
do_action( 'sp_admin_geocoder_scripts' );
|
||||
}
|
||||
|
||||
@@ -140,11 +140,11 @@ class SP_Admin_Taxonomies {
|
||||
* @param mixed $term Term (category) being edited
|
||||
*/
|
||||
public function edit_venue_fields( $term ) {
|
||||
$t_id = $term->term_id;
|
||||
$term_meta = get_option( "taxonomy_$t_id" );
|
||||
$latitude = is_numeric( $term_meta['sp_latitude'] ) ? $term_meta['sp_latitude'] : '';
|
||||
$t_id = $term->term_id;
|
||||
$term_meta = get_option( "taxonomy_$t_id" );
|
||||
$latitude = is_numeric( $term_meta['sp_latitude'] ) ? $term_meta['sp_latitude'] : '';
|
||||
$longitude = is_numeric( $term_meta['sp_longitude'] ) ? $term_meta['sp_longitude'] : '';
|
||||
$address = $term_meta['sp_address'] ? $term_meta['sp_address'] : '';
|
||||
$address = $term_meta['sp_address'] ? $term_meta['sp_address'] : '';
|
||||
?>
|
||||
<tr class="form-field">
|
||||
<td colspan="2">
|
||||
@@ -170,7 +170,7 @@ class SP_Admin_Taxonomies {
|
||||
<input type="text" class="sp-longitude" name="term_meta[sp_longitude]" id="term_meta[sp_longitude]" value="<?php echo esc_attr( $longitude ); ?>">
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
<?php
|
||||
do_action( 'sp_admin_geocoder_scripts' );
|
||||
}
|
||||
|
||||
@@ -184,16 +184,29 @@ class SP_Admin_Taxonomies {
|
||||
?>
|
||||
<div class="form-field">
|
||||
<label><?php _e( 'Statistics', 'sportspress' ); ?></label>
|
||||
<select name="term_meta[sp_sections][]" id="term_meta[sp_sections][]" class="widefat chosen-select<?php if ( is_rtl() ): ?> chosen-rtl<?php endif; ?>" multiple="multiple">
|
||||
<select name="term_meta[sp_sections][]" id="term_meta[sp_sections][]" class="widefat chosen-select
|
||||
<?php
|
||||
if ( is_rtl() ) :
|
||||
?>
|
||||
chosen-rtl<?php endif; ?>" multiple="multiple">
|
||||
<?php
|
||||
$options = apply_filters( 'sportspress_performance_sections', array( 0 => __( 'Offense', 'sportspress' ), 1 => __( 'Defense', 'sportspress' ) ) );
|
||||
foreach ( $options as $key => $value ):
|
||||
$options = apply_filters(
|
||||
'sportspress_performance_sections',
|
||||
array(
|
||||
0 => __( 'Offense', 'sportspress' ),
|
||||
1 => __(
|
||||
'Defense',
|
||||
'sportspress'
|
||||
),
|
||||
)
|
||||
);
|
||||
foreach ( $options as $key => $value ) :
|
||||
printf( '<option value="%s" %s>%s</option>', $key, selected( true ), $value );
|
||||
endforeach;
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -203,17 +216,30 @@ class SP_Admin_Taxonomies {
|
||||
* @param mixed $term Term (category) being edited
|
||||
*/
|
||||
public function edit_position_fields( $term ) {
|
||||
$t_id = $term->term_id;
|
||||
$t_id = $term->term_id;
|
||||
$sections = sp_get_term_sections( $t_id );
|
||||
?>
|
||||
<tr class="form-field">
|
||||
<th scope="row" valign="top"><label for="term_meta[sp_sections]"><?php _e( 'Statistics', 'sportspress' ); ?></label></th>
|
||||
<input type="hidden" name="term_meta[sp_sections]" value="">
|
||||
<td>
|
||||
<select name="term_meta[sp_sections][]" id="term_meta[sp_sections][]" class="widefat chosen-select<?php if ( is_rtl() ): ?> chosen-rtl<?php endif; ?>" multiple="multiple">
|
||||
<select name="term_meta[sp_sections][]" id="term_meta[sp_sections][]" class="widefat chosen-select
|
||||
<?php
|
||||
if ( is_rtl() ) :
|
||||
?>
|
||||
chosen-rtl<?php endif; ?>" multiple="multiple">
|
||||
<?php
|
||||
$options = apply_filters( 'sportspress_performance_sections', array( 0 => __( 'Offense', 'sportspress' ), 1 => __( 'Defense', 'sportspress' ) ) );
|
||||
foreach ( $options as $key => $value ):
|
||||
$options = apply_filters(
|
||||
'sportspress_performance_sections',
|
||||
array(
|
||||
0 => __( 'Offense', 'sportspress' ),
|
||||
1 => __(
|
||||
'Defense',
|
||||
'sportspress'
|
||||
),
|
||||
)
|
||||
);
|
||||
foreach ( $options as $key => $value ) :
|
||||
printf( '<option value="%s" %s>%s</option>', $key, selected( in_array( $key, $sections ), true, false ), $value );
|
||||
endforeach;
|
||||
?>
|
||||
@@ -227,7 +253,7 @@ class SP_Admin_Taxonomies {
|
||||
<td><input name="sp_order" class="sp-number-input" type="text" step="1" size="4" id="sp_order" value="<?php echo (int) $order; ?>"></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -239,12 +265,12 @@ class SP_Admin_Taxonomies {
|
||||
*/
|
||||
public function save_fields( $term_id ) {
|
||||
if ( isset( $_POST['term_meta'] ) ) {
|
||||
$t_id = $term_id;
|
||||
$t_id = $term_id;
|
||||
$term_meta = get_option( "taxonomy_$t_id" );
|
||||
$cat_keys = array_keys( $_POST['term_meta'] );
|
||||
$cat_keys = array_keys( $_POST['term_meta'] );
|
||||
foreach ( $cat_keys as $key ) {
|
||||
if ( isset ( $_POST['term_meta'][ $key ] ) ) {
|
||||
$term_meta[$key] = sanitize_text_field( $_POST['term_meta'][ $key ] );
|
||||
if ( isset( $_POST['term_meta'][ $key ] ) ) {
|
||||
$term_meta[ $key ] = sanitize_text_field( $_POST['term_meta'][ $key ] );
|
||||
}
|
||||
}
|
||||
update_option( "taxonomy_$t_id", $term_meta );
|
||||
@@ -263,13 +289,15 @@ class SP_Admin_Taxonomies {
|
||||
*/
|
||||
public function taxonomy_columns( $columns ) {
|
||||
$new_columns = array();
|
||||
|
||||
if ( function_exists( 'get_term_meta' ) ) $new_columns['sp_order'] = __( 'Order', 'sportspress' );
|
||||
|
||||
if ( array_key_exists('posts', $columns) ) {
|
||||
$new_columns['posts'] = $columns['posts'];
|
||||
if ( function_exists( 'get_term_meta' ) ) {
|
||||
$new_columns['sp_order'] = __( 'Order', 'sportspress' );
|
||||
}
|
||||
|
||||
unset( $columns['posts'] );
|
||||
if ( array_key_exists( 'posts', $columns ) ) {
|
||||
$new_columns['posts'] = $columns['posts'];
|
||||
|
||||
unset( $columns['posts'] );
|
||||
}
|
||||
|
||||
return array_merge( $columns, $new_columns );
|
||||
@@ -283,12 +311,12 @@ class SP_Admin_Taxonomies {
|
||||
* @return array
|
||||
*/
|
||||
public function venue_columns( $columns ) {
|
||||
$new_columns = array();
|
||||
$new_columns = array();
|
||||
$new_columns['sp_address'] = __( 'Address', 'sportspress' );
|
||||
|
||||
if ( array_key_exists('posts', $columns) ) {
|
||||
$new_columns['posts'] = $columns['posts'];
|
||||
unset( $columns['posts'] );
|
||||
|
||||
if ( array_key_exists( 'posts', $columns ) ) {
|
||||
$new_columns['posts'] = $columns['posts'];
|
||||
unset( $columns['posts'] );
|
||||
}
|
||||
|
||||
unset( $columns['description'] );
|
||||
@@ -305,14 +333,16 @@ class SP_Admin_Taxonomies {
|
||||
* @return array
|
||||
*/
|
||||
public function position_columns( $columns ) {
|
||||
$new_columns = array();
|
||||
$new_columns = array();
|
||||
$new_columns['sp_sections'] = __( 'Statistics', 'sportspress' );
|
||||
|
||||
if ( function_exists( 'get_term_meta' ) ) $new_columns['sp_order'] = __( 'Order', 'sportspress' );
|
||||
|
||||
if ( array_key_exists('posts', $columns) ) {
|
||||
$new_columns['posts'] = $columns['posts'];
|
||||
unset( $columns['posts'] );
|
||||
if ( function_exists( 'get_term_meta' ) ) {
|
||||
$new_columns['sp_order'] = __( 'Order', 'sportspress' );
|
||||
}
|
||||
|
||||
if ( array_key_exists( 'posts', $columns ) ) {
|
||||
$new_columns['posts'] = $columns['posts'];
|
||||
unset( $columns['posts'] );
|
||||
}
|
||||
|
||||
unset( $columns['description'] );
|
||||
@@ -341,13 +371,22 @@ class SP_Admin_Taxonomies {
|
||||
$columns .= $address;
|
||||
|
||||
} elseif ( $column == 'sp_sections' ) {
|
||||
|
||||
$options = apply_filters( 'sportspress_performance_sections', array( 0 => __( 'Offense', 'sportspress' ), 1 => __( 'Defense', 'sportspress' ) ) );
|
||||
|
||||
$options = apply_filters(
|
||||
'sportspress_performance_sections',
|
||||
array(
|
||||
0 => __( 'Offense', 'sportspress' ),
|
||||
1 => __(
|
||||
'Defense',
|
||||
'sportspress'
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
$sections = sp_get_term_sections( $id );
|
||||
|
||||
|
||||
$section_names = array();
|
||||
|
||||
|
||||
if ( is_array( $sections ) ) {
|
||||
foreach ( $sections as $section ) {
|
||||
if ( array_key_exists( $section, $options ) ) {
|
||||
@@ -355,7 +394,7 @@ class SP_Admin_Taxonomies {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$columns .= implode( ', ', $section_names );
|
||||
|
||||
} elseif ( $column == 'sp_order' ) {
|
||||
|
||||
Reference in New Issue
Block a user