From 1aad90b7385341d39c57cf05c5f6d0e64388d6de Mon Sep 17 00:00:00 2001
From: Brian Miyaji
Date: Wed, 28 May 2014 11:37:19 +1000
Subject: [PATCH] Update equation builder
---
assets/css/equation.css | 75 +++++++++
assets/css/sportspress.css | 9 +-
assets/js/admin/equationbuilder.js | 37 +++++
assets/js/sportspress.js | 3 +
includes/admin/class-sp-admin-assets.php | 15 +-
includes/admin/class-sp-admin-welcome.php | 2 +-
.../post-types/class-sp-admin-meta-boxes.php | 12 +-
.../class-sp-meta-box-column-details.php | 11 +-
.../class-sp-meta-box-column-equation.php | 28 ++++
.../meta-boxes/class-sp-meta-box-config.php | 117 +-------------
.../meta-boxes/class-sp-meta-box-equation.php | 146 ++++++++++++++++++
.../class-sp-meta-box-metric-details.php | 3 +-
.../class-sp-meta-box-statistic-details.php | 12 +-
.../class-sp-meta-box-statistic-equation.php | 28 ++++
.../settings/class-sp-settings-general.php | 15 +-
includes/class-sp-frontend-scripts.php | 11 +-
sportspress.php | 2 +
17 files changed, 377 insertions(+), 149 deletions(-)
create mode 100644 assets/css/equation.css
create mode 100644 assets/js/admin/equationbuilder.js
create mode 100644 includes/admin/post-types/meta-boxes/class-sp-meta-box-column-equation.php
create mode 100644 includes/admin/post-types/meta-boxes/class-sp-meta-box-equation.php
create mode 100644 includes/admin/post-types/meta-boxes/class-sp-meta-box-statistic-equation.php
diff --git a/assets/css/equation.css b/assets/css/equation.css
new file mode 100644
index 00000000..75a0b9e9
--- /dev/null
+++ b/assets/css/equation.css
@@ -0,0 +1,75 @@
+.sp-equation-builder .button {
+ margin: 2px;
+ padding: 0 10px 1px;
+}
+
+.sp-equation {
+ background: #f9f9f9;
+ border: 1px solid #ddd;
+ -webkit-box-shadow: inset 0 1px 2px rgba(0,0,0,0.07);
+ box-shadow: inset 0 1px 2px rgba(0,0,0,0.07);
+ transition: .05s border-color ease-in-out;
+ margin-top: 6px;
+ padding: 23px;
+}
+
+.sp-equation:hover,
+.sp-equation.ui-state-active {
+ background: #fff;
+}
+
+.sp-equation.ui-state-hover {
+ border-color: #5b9dd9;
+ -webkit-box-shadow: 0 0 2px rgba(30,140,190,0.8);
+ box-shadow: 0 0 2px rgba(30,140,190,0.8);
+}
+
+.sp-equation-variable {
+ font-weight: bold;
+ font-size: 14px;
+ line-height: 32px;
+}
+
+.sp-equation-formula .ui-sortable-placeholder {
+ visibility: visible !important;
+ margin: 2px;
+ padding: 1 10px 1px;
+ border: 1px dashed #bbb;
+ background: transparent;
+ height: 28px;
+}
+
+.sp-equation-formula .button {
+ position: relative;
+ margin: 2px 4px;
+}
+
+.sp-equation-formula .button .remove {
+ font-weight: bold;
+ font-size: 14px;
+ position: absolute;
+ top: -10px;
+ left: -8px;
+ border: 1px solid #ccc;
+ background: #f7f7f7;
+ display: block;
+ width: 16px;
+ height: 16px;
+ line-height: 16px;
+ text-align: center;
+ border-radius: 50%;
+ display: none;
+}
+
+.sp-equation-formula .button:hover .remove {
+ display: block;
+}
+
+.sp-equation-formula .button.ui-sortable-helper .remove,
+.sp-equation-formula .button.ui-sortable-helper:hover .remove {
+ display: none;
+}
+
+.sp-equation-formula .button .remove:hover {
+ background: #e0e0e0;
+}
\ No newline at end of file
diff --git a/assets/css/sportspress.css b/assets/css/sportspress.css
index 4b814131..45a9efaf 100644
--- a/assets/css/sportspress.css
+++ b/assets/css/sportspress.css
@@ -1,10 +1,15 @@
/* SportsPress */
-.sp-scrollable-table-wrapper {
- overflow: auto;
+/* Header */
+.sp-header {
+ position: relative;
+ overflow: visible;
}
/* Data Tables */
+.sp-scrollable-table-wrapper {
+ overflow: auto;
+}
.sp-data-table {
width: 100%;
position: relative;
diff --git a/assets/js/admin/equationbuilder.js b/assets/js/admin/equationbuilder.js
new file mode 100644
index 00000000..be5e248c
--- /dev/null
+++ b/assets/js/admin/equationbuilder.js
@@ -0,0 +1,37 @@
+jQuery(document).ready(function($){
+ $("#title").keyup(function() {
+ val = $(this).val();
+ if ( val == '' ) val = 'f(x)';
+ $(".sp-equation-variable").text( val + ' =' );
+ });
+
+ $(".sp-equation-parts .button").draggable({
+ appendTo: "body",
+ helper: "clone",
+ cursor: "move",
+ distance: 10,
+ containment: "#sp_equationdiv",
+ }).click(function() {
+ $("").text( $(this).text() ).append("×").appendTo( $(".sp-equation-formula") );
+ });
+
+ $(".sp-equation").droppable({
+ activeClass: "ui-state-active",
+ hoverClass: "ui-state-hover",
+ accept: ".button:not(.ui-sortable-helper)",
+ drop: function( event, ui ) {
+ $("").text( ui.draggable.text() ).append("×").appendTo( $(".sp-equation-formula") );
+ }
+ }).sortable({
+ items: ".button",
+ tolerance: "pointer",
+ containment: "#sp_equationdiv",
+ sort: function() {
+ $( this ).removeClass( "ui-state-active" );
+ }
+ });
+
+ $(".sp-equation-formula").on("click", ".button .remove", function() {
+ $(this).closest(".button").remove();
+ });
+});
\ No newline at end of file
diff --git a/assets/js/sportspress.js b/assets/js/sportspress.js
index b8304ea8..07129a80 100644
--- a/assets/js/sportspress.js
+++ b/assets/js/sportspress.js
@@ -11,6 +11,9 @@ function viewport() {
var sp_responsive_activated = false;
+ /* Header */
+ $('body').prepend( '' );
+
/* Countdown */
$("[data-countdown]").each(function() {
var $this = $(this), finalDate = $(this).data('countdown');
diff --git a/includes/admin/class-sp-admin-assets.php b/includes/admin/class-sp-admin-assets.php
index 9fd2fbb4..1c809f4f 100644
--- a/includes/admin/class-sp-admin-assets.php
+++ b/includes/admin/class-sp-admin-assets.php
@@ -48,7 +48,6 @@ class SP_Admin_Assets {
wp_enqueue_style( 'sportspress-admin-dashboard-styles', SP()->plugin_url() . '/assets/css/dashboard.css', array(), SP_VERSION );
}
-
if ( in_array( $screen->id, array( 'widgets' ) ) ) {
wp_enqueue_style( 'sportspress-admin-widgets-styles', SP()->plugin_url() . '/assets/css/widgets.css', array(), SP_VERSION );
}
@@ -57,6 +56,10 @@ class SP_Admin_Assets {
wp_enqueue_style( 'sportspress-admin-customize-styles', SP()->plugin_url() . '/assets/css/customize.css', array(), SP_VERSION );
}
+ if ( in_array( $screen->id, array( 'sp_column', 'sp_statistic' ) ) ) {
+ wp_enqueue_style( 'sportspress-admin-equation-styles', SP()->plugin_url() . '/assets/css/equation.css', array(), SP_VERSION );
+ }
+
do_action( 'sportspress_admin_css' );
}
@@ -82,6 +85,8 @@ class SP_Admin_Assets {
wp_register_script( 'jquery-locationpicker', SP()->plugin_url() . '/assets/js/locationpicker.jquery.js', array( 'jquery', 'google-maps' ), '0.1.6', true );
wp_register_script( 'sportspress-admin-locationpicker', SP()->plugin_url() . '/assets/js/admin/locationpicker.js', array( 'jquery', 'google-maps', 'jquery-locationpicker' ), SP_VERSION, true );
+
+ wp_register_script( 'sportspress-admin-equationbuilder', SP()->plugin_url() . '/assets/js/admin/equationbuilder.js', array( 'jquery', 'jquery-ui-core', 'jquery-ui-draggable', 'jquery-ui-droppable' ), SP_VERSION, true );
wp_register_script( 'sportspress-admin', SP()->plugin_url() . '/assets/js/admin/sportspress-admin.js', array( 'jquery', 'chosen', 'jquery-tiptip', 'jquery-caret', 'jquery-countdown' ), SP_VERSION, true );
@@ -120,11 +125,17 @@ class SP_Admin_Assets {
// Edit venue pages
if ( in_array( $screen->id, array( 'edit-sp_venue' ) ) ) {
-
wp_enqueue_script( 'google-maps' );
wp_enqueue_script( 'jquery-locationpicker' );
wp_enqueue_script( 'sportspress-admin-locationpicker' );
+ }
+ // Edit equation
+ if ( in_array( $screen->id, array( 'sp_column', 'sp_statistic' ) ) ) {
+ wp_enqueue_script( 'jquery-ui-core' );
+ wp_enqueue_script( 'jquery-ui-draggable' );
+ wp_enqueue_script( 'jquery-ui-droppable' );
+ wp_enqueue_script( 'sportspress-admin-equationbuilder' );
}
}
}
diff --git a/includes/admin/class-sp-admin-welcome.php b/includes/admin/class-sp-admin-welcome.php
index aad54b84..560c5f6d 100644
--- a/includes/admin/class-sp-admin-welcome.php
+++ b/includes/admin/class-sp-admin-welcome.php
@@ -236,7 +236,7 @@ class SP_Admin_Welcome {
Translate SportsPress.', 'sportspress' ); ?>
' . $handle . '';
diff --git a/includes/admin/post-types/class-sp-admin-meta-boxes.php b/includes/admin/post-types/class-sp-admin-meta-boxes.php
index 8a1c0f12..458aa8d0 100644
--- a/includes/admin/post-types/class-sp-admin-meta-boxes.php
+++ b/includes/admin/post-types/class-sp-admin-meta-boxes.php
@@ -7,7 +7,7 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta Boxes
- * @version 0.8
+ * @version 1.0
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -40,9 +40,11 @@ class SP_Admin_Meta_Boxes {
// Save Statistic Meta Boxes
add_action( 'sportspress_process_sp_statistic_meta', 'SP_Meta_Box_Statistic_Details::save', 10, 2 );
+ add_action( 'sportspress_process_sp_statistic_meta', 'SP_Meta_Box_Statistic_Equation::save', 20, 2 );
// Save Column Meta Boxes
add_action( 'sportspress_process_sp_column_meta', 'SP_Meta_Box_Column_Details::save', 10, 2 );
+ add_action( 'sportspress_process_sp_column_meta', 'SP_Meta_Box_Column_Equation::save', 20, 2 );
// Save Event Meta Boxes
add_action( 'sportspress_process_sp_event_meta', 'SP_Meta_Box_Event_Format::save', 10, 2 );
@@ -92,7 +94,8 @@ class SP_Admin_Meta_Boxes {
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Outcome_Details::output', 'sp_outcome', 'normal', 'high' );
// Columns
- add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Column_Details::output', 'sp_column', 'normal', 'high' );
+ add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Column_Details::output', 'sp_column', 'side', 'default' );
+ add_meta_box( 'sp_equationdiv', __( 'Equation', 'sportspress' ), 'SP_Meta_Box_Column_Equation::output', 'sp_column', 'normal', 'high' );
// Metrics
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Metric_Details::output', 'sp_metric', 'normal', 'high' );
@@ -100,8 +103,9 @@ class SP_Admin_Meta_Boxes {
// Performance
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Performance_Details::output', 'sp_performance', 'normal', 'high' );
- // Metrics
- add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Statistic_Details::output', 'sp_statistic', 'normal', 'high' );
+ // Statistics
+ add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Statistic_Details::output', 'sp_statistic', 'side', 'default' );
+ add_meta_box( 'sp_equationdiv', __( 'Equation', 'sportspress' ), 'SP_Meta_Box_Statistic_Equation::output', 'sp_statistic', 'normal', 'high' );
// Events
add_meta_box( 'sp_shortcodediv', __( 'Shortcodes', 'sportspress' ), 'SP_Meta_Box_Event_Shortcode::output', 'sp_event', 'side', 'default' );
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-column-details.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-column-details.php
index ff286af3..07031d86 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-column-details.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-column-details.php
@@ -5,7 +5,7 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta Boxes
- * @version 0.8
+ * @version 1.0
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -36,14 +36,6 @@ class SP_Meta_Box_Column_Details extends SP_Meta_Box_Config {
-
-
- ID, $piece, array( 'team_event', 'outcome', 'result' ) );
- endforeach;
- ?>
-
@@ -79,7 +71,6 @@ class SP_Meta_Box_Column_Details extends SP_Meta_Box_Config {
*/
public static function save( $post_id, $post ) {
self::delete_duplicate( $_POST );
- update_post_meta( $post_id, 'sp_equation', implode( ' ', sp_array_value( $_POST, 'sp_equation', array() ) ) );
update_post_meta( $post_id, 'sp_precision', (int) sp_array_value( $_POST, 'sp_precision', 1 ) );
update_post_meta( $post_id, 'sp_priority', sp_array_value( $_POST, 'sp_priority', '0' ) );
update_post_meta( $post_id, 'sp_order', sp_array_value( $_POST, 'sp_order', 'DESC' ) );
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-column-equation.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-column-equation.php
new file mode 100644
index 00000000..c5624b1c
--- /dev/null
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-column-equation.php
@@ -0,0 +1,28 @@
+ID, 'sp_equation', true );
+ self::builder( $post->post_title, $equation, array( 'team_event', 'outcome', 'result' ) );
+ }
+}
\ No newline at end of file
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-config.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-config.php
index 603a22bc..88a21041 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-config.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-config.php
@@ -5,7 +5,7 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta Boxes
- * @version 0.8
+ * @version 1.0
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -22,118 +22,6 @@ class SP_Meta_Box_Config {
self::delete_duplicate( $_POST );
}
- public static function select( $postid, $selected = null, $groups = array() ) {
-
- if ( ! isset( $postid ) )
- return;
-
- // Initialize options array
- $options = array();
-
- // Add groups to options
- foreach ( $groups as $group ):
- switch ( $group ):
- case 'player_event':
- $options[ __( 'Events', 'sportspress' ) ] = array( '$eventsattended' => __( 'Attended', 'sportspress' ), '$eventsplayed' => __( 'Played', 'sportspress' ), '$eventsstarted' => __( 'Started', 'sportspress' ), '$eventssubbed' => __( 'Substituted', 'sportspress' ) );
- break;
- case 'team_event':
- $options[ __( 'Events', 'sportspress' ) ] = array( '$eventsplayed' => __( 'Played', 'sportspress' ) );
- break;
- case 'result':
- $options[ __( 'Results', 'sportspress' ) ] = self::optgroup( $postid, 'sp_result', array( 'for' => '→', 'against' => '←' ), null, false );
- break;
- case 'outcome':
- $options[ __( 'Outcomes', 'sportspress' ) ] = self::optgroup( $postid, 'sp_outcome', array() );
- $options[ __( 'Outcomes', 'sportspress' ) ]['$streak'] = __( 'Streak', 'sportspress' );
- $options[ __( 'Outcomes', 'sportspress' ) ]['$last5'] = __( 'Last 5', 'sportspress' );
- $options[ __( 'Outcomes', 'sportspress' ) ]['$last10'] = __( 'Last 10', 'sportspress' );
- break;
- case 'performance':
- $options[ __( 'Performance', 'sportspress' ) ] = self::optgroup( $postid, 'sp_performance' );
- break;
- case 'metric':
- $options[ __( 'Metric', 'sportspress' ) ] = self::optgroup( $postid, 'sp_metric' );
- break;
- endswitch;
- endforeach;
-
- // Create array of operators
- $operators = array( '+' => '+', '-' => '−', '*' => '×', '/' => '÷', '(' => '(', ')' => ')' );
-
- // Add operators to options
- $options[ __( 'Operators', 'sportspress' ) ] = $operators;
-
- // Create array of constants
- $max = 10;
- $constants = array();
- for ( $i = 1; $i <= $max; $i ++ ):
- $constants[$i] = $i;
- endfor;
-
- // Add 100 to constants
- $constants[100] = 100;
-
- // Add constants to options
- $options[ __( 'Constants', 'sportspress' ) ] = (array) $constants;
-
- ?>
-
- $type,
- 'numberposts' => -1,
- 'posts_per_page' => -1,
- 'orderby' => 'menu_order',
- 'order' => 'ASC',
- 'exclude' => $postid
- );
- $vars = get_posts( $args );
-
- // Add extra vars to the array
- if ( isset( $defaults ) && is_array( $defaults ) ):
- foreach ( $defaults as $key => $value ):
- $arr[ $key ] = $value;
- endforeach;
- endif;
-
- // Add vars to the array
- if ( isset( $variations ) && is_array( $variations ) ):
- foreach ( $vars as $var ):
- if ( $totals ) $arr[ '$' . $var->post_name ] = $var->post_title;
- foreach ( $variations as $key => $value ):
- $arr[ '$' . $var->post_name . $key ] = $var->post_title . ' ' . $value;
- endforeach;
- endforeach;
- else:
- foreach ( $vars as $var ):
- $arr[ '$' . $var->post_name ] = $var->post_title;
- endforeach;
- endif;
-
- return (array) $arr;
- }
-
public static function delete_duplicate( &$post ) {
global $wpdb;
@@ -152,5 +40,4 @@ class SP_Meta_Box_Config {
return $post_name_check;
}
-
-}
\ No newline at end of file
+}
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-equation.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-equation.php
new file mode 100644
index 00000000..601369e6
--- /dev/null
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-equation.php
@@ -0,0 +1,146 @@
+ __( 'Attended', 'sportspress' ), '$eventsplayed' => __( 'Played', 'sportspress' ), '$eventsstarted' => __( 'Started', 'sportspress' ), '$eventssubbed' => __( 'Substituted', 'sportspress' ) );
+ break;
+ case 'team_event':
+ $options['Events'] = array( '$eventsplayed' => __( 'Played', 'sportspress' ) );
+ break;
+ case 'result':
+ $options['Results'] = self::optgroup( 'sp_result', array( 'for' => '(' . __( 'for', 'sportspress' ) . ')', 'against' => '(' . __( 'against', 'sportspress' ) . ')' ), null, false );
+ break;
+ case 'outcome':
+ $options['Outcomes'] = self::optgroup( 'sp_outcome' );
+ $options['Outcomes']['$streak'] = __( 'Streak', 'sportspress' );
+ $options['Outcomes']['$last5'] = __( 'Last 5', 'sportspress' );
+ $options['Outcomes']['$last10'] = __( 'Last 10', 'sportspress' );
+ break;
+ case 'performance':
+ $options['Performance'] = self::optgroup( 'sp_performance' );
+ break;
+ case 'metric':
+ $options['Metric'] = self::optgroup( 'sp_metric' );
+ break;
+ endswitch;
+ endforeach;
+
+ // Create array of operators
+ $operators = array( '+' => '+', '-' => '−', '*' => '×', '/' => '÷', '(' => '(', ')' => ')' );
+
+ // Add operators to options
+ $options['Operators'] = $operators;
+
+ // Create array of constants
+ $max = 10;
+ $constants = array();
+ for ( $i = 0; $i <= $max; $i ++ ):
+ $constants[$i] = $i;
+ endfor;
+
+ // Add 100 to constants
+ $constants[100] = 100;
+
+ // Add constants to options
+ $options['Constants'] = (array) $constants;
+ ?>
+
+
+
+ $option ): ?>
+ class="alternate">
+ |
+
+ $value ): $parts[ $key ] = $value;
+ ?>
+ |
+
+
+
+
+
+ =
+ ×
+
+
+ $type,
+ 'numberposts' => -1,
+ 'posts_per_page' => -1,
+ 'orderby' => 'menu_order',
+ 'order' => 'ASC',
+ );
+ $vars = get_posts( $args );
+
+ // Add extra vars to the array
+ if ( isset( $defaults ) && is_array( $defaults ) ):
+ foreach ( $defaults as $key => $value ):
+ $arr[ $key ] = $value;
+ endforeach;
+ endif;
+
+ // Add vars to the array
+ if ( isset( $variations ) && is_array( $variations ) ):
+ foreach ( $vars as $var ):
+ if ( $totals ) $arr[ '$' . $var->post_name ] = $var->post_title;
+ foreach ( $variations as $key => $value ):
+ $arr[ '$' . $var->post_name . $key ] = $var->post_title . ' ' . $value;
+ endforeach;
+ endforeach;
+ else:
+ foreach ( $vars as $var ):
+ $arr[ '$' . $var->post_name ] = $var->post_title;
+ endforeach;
+ endif;
+
+ return (array) $arr;
+ }
+}
\ No newline at end of file
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-metric-details.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-metric-details.php
index c1bf4118..0e03cdcd 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-metric-details.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-metric-details.php
@@ -5,7 +5,7 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta Boxes
- * @version 0.8
+ * @version 1.0
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -23,7 +23,6 @@ class SP_Meta_Box_Metric_Details extends SP_Meta_Box_Config {
*/
public static function output( $post ) {
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
- $calculate = get_post_meta( $post->ID, 'sp_calculate', true );
?>
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-statistic-details.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-statistic-details.php
index b28e0dac..1104472a 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-statistic-details.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-statistic-details.php
@@ -5,7 +5,7 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta Boxes
- * @version 0.8
+ * @version 1.0
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -23,7 +23,6 @@ class SP_Meta_Box_Statistic_Details extends SP_Meta_Box_Config {
*/
public static function output( $post ) {
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
- $equation = explode( ' ', get_post_meta( $post->ID, 'sp_equation', true ) );
$precision = get_post_meta( $post->ID, 'sp_precision', true );
// Defaults
@@ -34,14 +33,6 @@ class SP_Meta_Box_Statistic_Details extends SP_Meta_Box_Config {
-
-
- ID, $piece, array( 'player_event', 'outcome', 'performance', 'metric' ) );
- endforeach;
- ?>
-
@@ -54,7 +45,6 @@ class SP_Meta_Box_Statistic_Details extends SP_Meta_Box_Config {
*/
public static function save( $post_id, $post ) {
self::delete_duplicate( $_POST );
- update_post_meta( $post_id, 'sp_equation', implode( ' ', sp_array_value( $_POST, 'sp_equation', array() ) ) );
update_post_meta( $post_id, 'sp_precision', (int) sp_array_value( $_POST, 'sp_precision', 1 ) );
}
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-statistic-equation.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-statistic-equation.php
new file mode 100644
index 00000000..1c81d88c
--- /dev/null
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-statistic-equation.php
@@ -0,0 +1,28 @@
+ID, 'sp_equation', true );
+ self::builder( $post->post_title, $equation, array( 'player_event', 'outcome', 'performance', 'metric' ) );
+ }
+}
diff --git a/includes/admin/settings/class-sp-settings-general.php b/includes/admin/settings/class-sp-settings-general.php
index 1d07eb3c..728329c9 100644
--- a/includes/admin/settings/class-sp-settings-general.php
+++ b/includes/admin/settings/class-sp-settings-general.php
@@ -107,6 +107,19 @@ class SP_Settings_General extends SP_Settings_Page {
'checkboxgroup' => 'end',
'desc_tip' => __( 'This will enable a script allowing the countdowns to be animated.', 'sportspress' ),
),
+
+ array(
+ 'title' => __( 'Header Offset', 'sportspress' ),
+ 'id' => 'sportspress_header_offset',
+ 'class' => 'small-text',
+ 'default' => null,
+ 'placeholder' => __( 'Auto', 'sportspress' ),
+ 'desc' => 'px',
+ 'type' => 'number',
+ 'custom_attributes' => array(
+ 'step' => 1
+ ),
+ ),
array( 'type' => 'sectionend', 'id' => 'script_styling_options' ),
@@ -167,7 +180,7 @@ class SP_Settings_General extends SP_Settings_Page {
-
+
diff --git a/includes/class-sp-frontend-scripts.php b/includes/class-sp-frontend-scripts.php
index c84c16cf..7195dc45 100644
--- a/includes/class-sp-frontend-scripts.php
+++ b/includes/class-sp-frontend-scripts.php
@@ -97,7 +97,13 @@ class SP_Frontend_Scripts {
$enabled = get_option( 'sportspress_enable_frontend_css', 'yes' );
$custom = get_option( 'sportspress_custom_css', null );
- if ( $enabled == 'yes' || ! empty( $custom ) ) {
+ $offset = get_option( 'sportspress_header_offset', '' );
+ if ( $offset === '' ) {
+ $template = get_option( 'template' );
+ $offset = ( 'twentyfourteen' == $template ? 48 : 0 );
+ }
+
+ if ( $enabled == 'yes' || ! empty( $custom ) || $offset != 0 ) {
$colors = get_option( 'sportspress_frontend_css_colors' );
@@ -122,6 +128,9 @@ class SP_Frontend_Scripts {
echo '.sp-data-table tbody a,.sp-data-table tbody a:hover,.sp-calendar tbody a:focus{color: ' . $colors['link'] . ' !important}';
}
+ if ( $offset != 0 )
+ echo ' @media only screen and (min-width: 40.063em) {.sp-header{top: ' . $offset . 'px}}';
+
if ( ! empty( $custom ) )
echo ' /* SportsPress Custom CSS */ ' . $custom;
diff --git a/sportspress.php b/sportspress.php
index 804ed1fb..24d7b0dc 100644
--- a/sportspress.php
+++ b/sportspress.php
@@ -242,6 +242,8 @@ final class SportsPress {
include_once( 'includes/widgets/class-sp-widget-league-table.php' );
include_once( 'includes/widgets/class-sp-widget-player-list.php' );
include_once( 'includes/widgets/class-sp-widget-player-gallery.php' );
+
+ do_action( 'sportspress_widgets' );
}
/**
|