From 9f46acc6b5309de3cfb010ea6ebc799790cf55cd Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Sat, 22 Feb 2014 12:25:27 +1100 Subject: [PATCH] Admin dashboard widget, namespace EOS, remove unused widgets --- admin/hooks/admin-enqueue-scripts.php | 7 +- admin/hooks/admin-init.php | 2 + admin/hooks/current-screen.php | 7 ++ admin/hooks/register-activation-hook.php | 2 + admin/tools/dashboard.php | 115 ++++++++++++++++++++ admin/widgets/future-events.php | 128 ----------------------- admin/widgets/recent-events.php | 128 ----------------------- assets/css/admin.css | 108 ++++++++++++++++++- assets/fonts/sportspress.eot | Bin 2084 -> 2240 bytes assets/fonts/sportspress.svg | 1 + assets/fonts/sportspress.ttf | Bin 1904 -> 2060 bytes assets/fonts/sportspress.woff | Bin 1676 -> 1780 bytes assets/js/admin.js | 14 ++- functions.php | 67 ++++-------- lib/eos/eos.class.php | 2 +- sportspress.php | 6 +- 16 files changed, 271 insertions(+), 316 deletions(-) create mode 100644 admin/hooks/current-screen.php create mode 100644 admin/tools/dashboard.php delete mode 100644 admin/widgets/future-events.php delete mode 100644 admin/widgets/recent-events.php diff --git a/admin/hooks/admin-enqueue-scripts.php b/admin/hooks/admin-enqueue-scripts.php index d838d953..6926dbe3 100644 --- a/admin/hooks/admin-enqueue-scripts.php +++ b/admin/hooks/admin-enqueue-scripts.php @@ -9,8 +9,9 @@ function sportspress_admin_enqueue_scripts( $hook ) { wp_enqueue_style( 'sportspress-admin', SPORTSPRESS_PLUGIN_URL . 'assets/css/admin.css', array(), time() ); wp_enqueue_script( 'jquery' ); - wp_enqueue_script( 'chosen', SPORTSPRESS_PLUGIN_URL .'assets/js/chosen.jquery.min.js', array( 'jquery' ), '1.1.0', true ); - wp_enqueue_script( 'caret', SPORTSPRESS_PLUGIN_URL .'assets/js/jquery.caret.min.js', array( 'jquery' ), '1.02', true ); + wp_enqueue_script( 'jquery-chosen', SPORTSPRESS_PLUGIN_URL .'assets/js/chosen.jquery.min.js', array( 'jquery' ), '1.1.0', true ); + wp_enqueue_script( 'jquery-caret', SPORTSPRESS_PLUGIN_URL .'assets/js/jquery.caret.min.js', array( 'jquery' ), '1.02', true ); + wp_enqueue_script( 'jquery-countdown', SPORTSPRESS_PLUGIN_URL .'assets/js/jquery.countdown.min.js', array( 'jquery' ), '2.0.2', true ); if ( $hook == 'edit-tags.php' && isset( $_GET['taxonomy'] ) && $_GET['taxonomy'] == 'sp_venue' ): wp_enqueue_script( 'google-maps', 'http://maps.googleapis.com/maps/api/js?sensor=false&libraries=places' ); @@ -21,6 +22,6 @@ function sportspress_admin_enqueue_scripts( $hook ) { wp_enqueue_script( 'sportspress-admin', SPORTSPRESS_PLUGIN_URL .'assets/js/admin.js', array( 'jquery' ), time(), true ); // Localize scripts. - wp_localize_script( 'sportspress-admin', 'localized_strings', array( 'remove_text' => __( '— Remove —', 'sportspress' ) ) ); + wp_localize_script( 'sportspress-admin', 'localized_strings', array( 'remove_text' => __( '— Remove —', 'sportspress' ), 'days' => __( 'days', 'sportspress' ), 'hrs' => __( 'hrs', 'sportspress' ), 'mins' => __( 'mins', 'sportspress' ), 'secs' => __( 'secs', 'sportspress' ) ) ); } add_action( 'admin_enqueue_scripts', 'sportspress_admin_enqueue_scripts' ); diff --git a/admin/hooks/admin-init.php b/admin/hooks/admin-init.php index 5f39597e..1b0b3ec6 100644 --- a/admin/hooks/admin-init.php +++ b/admin/hooks/admin-init.php @@ -35,5 +35,7 @@ function sportspress_admin_init() { $administrator->add_cap( $cap . '_' . $post_type . 's' ); endforeach; endforeach; + + $administrator->add_cap( 'view_sportspress_reports' ); } add_action( 'admin_init', 'sportspress_admin_init' ); diff --git a/admin/hooks/current-screen.php b/admin/hooks/current-screen.php new file mode 100644 index 00000000..a703d512 --- /dev/null +++ b/admin/hooks/current-screen.php @@ -0,0 +1,7 @@ +id == 'dashboard' ) + include_once( dirname( SPORTSPRESS_PLUGIN_FILE ) . '/admin/tools/dashboard.php' ); +} +add_action( 'current_screen', 'sportspress_current_screen' ); diff --git a/admin/hooks/register-activation-hook.php b/admin/hooks/register-activation-hook.php index de57cb63..e6089ae0 100644 --- a/admin/hooks/register-activation-hook.php +++ b/admin/hooks/register-activation-hook.php @@ -74,6 +74,8 @@ function sportspress_activation_hook() { 'delete_sp_tables' => true, 'delete_private_sp_tables' => true, 'delete_published_sp_tables' => true, + + 'view_sportspress_reports' => true, ) ); diff --git a/admin/tools/dashboard.php b/admin/tools/dashboard.php new file mode 100644 index 00000000..8287b6f5 --- /dev/null +++ b/admin/tools/dashboard.php @@ -0,0 +1,115 @@ +post_date ); + $interval = date_diff( $now, $date ); + + $count = wp_count_posts( 'sp_event' ); + $scheduled_count = $count->future; + $published_count = $count->publish; + ?> + + get_results( "SELECT *, SUBSTRING(comment_content,1,100) AS comment_excerpt + FROM $wpdb->comments + LEFT JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) + WHERE comment_approved = '1' + AND comment_type = '' + AND post_password = '' + AND post_type = 'product' + ORDER BY comment_date_gmt DESC + LIMIT 8" ); + + if ( $comments ) { + echo ''; + } else { + echo '

' . __( 'There are no product reviews yet.', 'sportspress' ) . '

'; + } + } + +} + +endif; + +return new SP_Admin_Dashboard(); diff --git a/admin/widgets/future-events.php b/admin/widgets/future-events.php deleted file mode 100644 index fa98f095..00000000 --- a/admin/widgets/future-events.php +++ /dev/null @@ -1,128 +0,0 @@ - 'widget_recent_entries widget_sp_future_events', 'description' => __( 'A list of upcoming events.', 'sportspress' ) ); - parent::__construct('sp_future_events', __( 'SportsPress Future Events', 'sportspress' ), $widget_ops); - } - - function widget( $args, $instance ) { - extract($args); - $title = apply_filters('widget_title', empty($instance['title']) ? __( 'Future Events' ) : $instance['title'], $instance, $this->id_base); - $league = empty($instance['league']) ? null : $instance['league']; - $season = empty($instance['season']) ? null : $instance['season']; - $venue = empty($instance['venue']) ? null : $instance['venue']; - $team = empty($instance['team']) ? null : $instance['team']; - $number = empty($instance['number']) ? get_option( 'posts_per_page' ) : $instance['number']; - $args = array( - 'status' => 'future', - 'league' => $league, - 'season' => $season, - 'venue' => $venue, - 'team' => $team, - 'number' => $number, - ); - echo $before_widget; - if ( $title ) - echo $before_title . $title . $after_title; - echo '
'; - echo sportspress_events( $args ); - echo '
'; - echo $after_widget; - } - - function update( $new_instance, $old_instance ) { - $instance = $old_instance; - $instance['title'] = strip_tags($new_instance['title']); - $instance['league'] = intval($new_instance['league']); - $instance['season'] = intval($new_instance['season']); - $instance['venue'] = intval($new_instance['venue']); - $instance['team'] = intval($new_instance['team']); - $instance['number'] = intval($new_instance['number']); - - return $instance; - } - - function form( $instance ) { - $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'league' => '', 'season' => '', 'venue' => '', 'team' => '', 'number' => 3 ) ); - $title = strip_tags($instance['title']); - $league = intval($instance['league']); - $season = intval($instance['season']); - $venue = intval($instance['venue']); - $team = intval($instance['team']); - $number = intval($instance['number']); -?> -

-

- -

- 'sp_league', - 'name' => $this->get_field_name('league'), - 'id' => $this->get_field_id('league'), - 'selected' => $league, - 'show_option_all' => __( 'All Leagues', 'sportspress' ), - 'hide_empty' => 0, - 'values' => 'term_id', - 'class' => 'widefat', - ); - wp_dropdown_categories( $args ); - ?> -

- -

- 'sp_season', - 'name' => $this->get_field_name('season'), - 'id' => $this->get_field_id('season'), - 'selected' => $season, - 'show_option_all' => __( 'All Seasons', 'sportspress' ), - 'hide_empty' => 0, - 'values' => 'term_id', - 'class' => 'widefat', - ); - wp_dropdown_categories( $args ); - ?> -

- -

- 'sp_venue', - 'name' => $this->get_field_name('venue'), - 'id' => $this->get_field_id('venue'), - 'selected' => $venue, - 'show_option_all' => __( 'All Venues', 'sportspress' ), - 'hide_empty' => 0, - 'values' => 'term_id', - 'class' => 'widefat', - ); - wp_dropdown_categories( $args ); - ?> -

- -

- 'sp_team', - 'name' => $this->get_field_name('team'), - 'id' => $this->get_field_id('team'), - 'selected' => $team, - 'show_option_all' => __( 'All Teams', 'sportspress' ), - 'values' => 'ID', - 'class' => 'widefat', - ); - if ( ! sportspress_dropdown_pages( $args ) ): - sportspress_post_adder( 'sp_table', __( 'Add New League Table', 'sportspress' ) ); - endif; - ?> -

- -

-

- 'widget_recent_entries widget_sp_recent_events', 'description' => __( 'A list of recent events.', 'sportspress' ) ); - parent::__construct('sp_recent_events', __( 'SportsPress Recent Events', 'sportspress' ), $widget_ops); - } - - function widget( $args, $instance ) { - extract($args); - $title = apply_filters('widget_title', empty($instance['title']) ? __( 'Recent Events' ) : $instance['title'], $instance, $this->id_base); - $league = empty($instance['league']) ? null : $instance['league']; - $season = empty($instance['season']) ? null : $instance['season']; - $venue = empty($instance['venue']) ? null : $instance['venue']; - $team = empty($instance['team']) ? null : $instance['team']; - $number = empty($instance['number']) ? get_option( 'posts_per_page' ) : $instance['number']; - $args = array( - 'status' => 'publish', - 'league' => $league, - 'season' => $season, - 'venue' => $venue, - 'team' => $team, - 'number' => $number, - ); - echo $before_widget; - if ( $title ) - echo $before_title . $title . $after_title; - echo '
'; - echo sportspress_events( $args ); - echo '
'; - echo $after_widget; - } - - function update( $new_instance, $old_instance ) { - $instance = $old_instance; - $instance['title'] = strip_tags($new_instance['title']); - $instance['league'] = intval($new_instance['league']); - $instance['season'] = intval($new_instance['season']); - $instance['venue'] = intval($new_instance['venue']); - $instance['team'] = intval($new_instance['team']); - $instance['number'] = intval($new_instance['number']); - - return $instance; - } - - function form( $instance ) { - $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'league' => '', 'season' => '', 'venue' => '', 'team' => '', 'number' => 3 ) ); - $title = strip_tags($instance['title']); - $league = intval($instance['league']); - $season = intval($instance['season']); - $venue = intval($instance['venue']); - $team = intval($instance['team']); - $number = intval($instance['number']); -?> -

-

- -

- 'sp_league', - 'name' => $this->get_field_name('league'), - 'id' => $this->get_field_id('league'), - 'selected' => $league, - 'show_option_all' => __( 'All Leagues', 'sportspress' ), - 'hide_empty' => 0, - 'values' => 'term_id', - 'class' => 'widefat', - ); - wp_dropdown_categories( $args ); - ?> -

- -

- 'sp_season', - 'name' => $this->get_field_name('season'), - 'id' => $this->get_field_id('season'), - 'selected' => $season, - 'show_option_all' => __( 'All Seasons', 'sportspress' ), - 'hide_empty' => 0, - 'values' => 'term_id', - 'class' => 'widefat', - ); - wp_dropdown_categories( $args ); - ?> -

- -

- 'sp_venue', - 'name' => $this->get_field_name('venue'), - 'id' => $this->get_field_id('venue'), - 'selected' => $venue, - 'show_option_all' => __( 'All Venues', 'sportspress' ), - 'hide_empty' => 0, - 'values' => 'term_id', - 'class' => 'widefat', - ); - wp_dropdown_categories( $args ); - ?> -

- -

- 'sp_team', - 'name' => $this->get_field_name('team'), - 'id' => $this->get_field_id('team'), - 'selected' => $team, - 'show_option_all' => __( 'All Teams', 'sportspress' ), - 'values' => 'ID', - 'class' => 'widefat', - ); - if ( ! sportspress_dropdown_pages( $args ) ): - sportspress_post_adder( 'sp_table', __( 'Add New League Table', 'sportspress' ) ); - endif; - ?> -

- -

-

-IuaJ|UoXDKQ)Bu!^0P=-$6DtZB)P)(Q0R?hE3i1+jQ+p>WMFaUg zKucl^@{3Ctn1M13>~ALLFuE~)$(+1}(bzr!C?WuaASp%$g^#WuLqD5*$^8HK|9_BT zG!e%CkNNiVZQ!}YJrAgZk%3{e9MgT~dS(WZ|GydEFkWI1VbEmI2b!eB$0RBu$7F0| z$7E`v$D}N%qz7c!0R`lM5`0X`!pfrJ=IV?LhG7n>st#d>Fj~#oNLJR!Sq(-Dsf0`U zGF}2HF@PvF04eXCj=ePOFz|92apVyhV8pMFm z5a&+TV3QSo1JeOk1|m2nN3hAr0kwgGo`Hc2NXs#FFbXj~VbTKfK^Aaq?qZw82ml5A Bbw2gxI}uLdwAFLIVqjp{1H=i*xrqh;Cf(p=U|^I1@?+8y ziwl6X0FYk+q&d=aD${zZX8r>58yFavPh_Mfru?^`uED^->H(BD%K!>6uV;J#j5BNAUCn1fI(e|VH!~20#HC9FEKZ@ccM}> zkpBT_No+xWaR~!6P=o+2F|aW(GAMj>{TTY$BJ_^X=!`z;g*`4C7`sru)p=j9^6!&&>Pg#Pi#HW#DE43!K-|HU=>u^#8w% tXBkgS-oqvMgV1@T2}x7 diff --git a/assets/fonts/sportspress.svg b/assets/fonts/sportspress.svg index ad98c684..a1ffe39b 100755 --- a/assets/fonts/sportspress.svg +++ b/assets/fonts/sportspress.svg @@ -10,4 +10,5 @@ + \ No newline at end of file diff --git a/assets/fonts/sportspress.ttf b/assets/fonts/sportspress.ttf index 83d49b7b64192dfc6362b17299c760e2307e8e6e..50a5bcc28b85090a00eb7aa35935d04540d637ba 100755 GIT binary patch delta 565 zcmeys*CSBRz{tSBz|GLWz|3IaAFOZ0q0B806xjpB3CX#M150V! zKw1FEZvfI9={c2Y9N7nWf&2~z29}VF)Wnqk$tem946Jv6@@5%80p@dzFBurvM1Xvi zjNFn6PO#Z*7C^p2PJXgwB6A8;15iN(P(Ua*v7&%Mm|+@_p94~mmzbN{J5ebb$nODK z5?hd8Tmp0`5U{_QxWkRkZ z^X=!`z;lUv9#99+_nWgA?=#mkGl=~E&G?4#5`zeXCWAiEBqcs3Q4u*NVAx6|B6W!3dUcR$M!Vi{NnemJz(8zrJ5M~n%~u9)CNTfJ&cxLq284z>7Z?u= z5NWVJ#s~i&FhB(u-@r@)YX=b=a2AjOvIeNt7>JcMfP^m)gCdH7feT2>F?28rF+O3^ P0`fsBIW}Kooy7I!OOtFC`p{FfgCUNKH)nZ$Djwfq~TnC~uYl6kuM@_yWiW$}^~B zh_FUm-6sH??=7QZ$hN z0cc5VL4I)w(4j!U9x!o-8`Ec#NsPwkAiMY&I2f21*nqxK_~`mE^s~wTzyJS(6r%7M z|3Bv2&$of+63`IF%|(p&nYBUQ2ZCqjeRJaZZN4&aGlBW%wX}^v3<&-IFXLIp6O%dE yWQETHtw06rlP%a}6u@F!3?dA23>}O@j8DMI*cqlUaDio*CVylX-rUbt%Lo91FIUb0 diff --git a/assets/fonts/sportspress.woff b/assets/fonts/sportspress.woff index 1ac066e30aea5112eafbd08ee1e3a78b47d9e05a..5e11a068bdfe338a167037da4a398a356dcbb745 100755 GIT binary patch delta 535 zcmeC-{lY6!?(gR29}?ovz`*u}fr|kM*w#!gWRsYv!&T30z`($4u<+VKDgR)7BL)T* z6`*ti2y-ZN%O~e1768Rsfcz8?e#ZJ#JUy`(B=!Qx=YV2?jMPM+Jj(|l-wcHRC#NW6 z00kKsST%rrkeMpX=NMmRL`}FnV4BJFfcK80uAP1Vqj!oVPFRa058K~MmHukrmD@e7*&~qzfbv*Ci+{fTT!ta zNd6Z4s`Oo~8;HJs0g>Ou6u$z6IlBK?h^ls5-s}F*{qgR-kKG@;?^<-LcB@%hsCIMA z{eDR_y}SFj;vwPOWgB-Iv5!kCYQ0usc7FT@r&oT`O3h}1lDt2XX0uQ1494* n&G?4#(&Qa1vchjbT2KJTlt5U?MS)kI%f*_I;NHCoiV&Gt8||hNU}s`rWME-n2YR2E;V`2cliKD*jH*nNrCGe0KATL=U@ -
+
    +
  • $meta, 'number' => 0 ) ); @@ -680,49 +681,6 @@ if ( !function_exists( 'sportspress_get_var_calculates' ) ) { } } -if ( !function_exists( 'sportspress_edit_calendar_table' ) ) { - function sportspress_edit_calendar_table( $data = array() ) { - if ( empty( $data ) ): - _e( 'No Events found.', 'sportspress' ); - return false; - endif; - ?> -
    - - - - - - - - - - - - - - - - - -
    - post_title, null, null, $event->ID ); ?> - - ID ); ?> - - ID ); ?> -
    -
    - @@ -827,7 +785,7 @@ if ( !function_exists( 'sportspress_edit_team_columns_table' ) ) { function sportspress_edit_team_columns_table( $league_id, $columns = array(), $data = array(), $placeholders = array(), $merged = array(), $seasons = array(), $readonly = true ) { ?>
    - +
    @@ -928,7 +886,7 @@ if ( !function_exists( 'sportspress_edit_player_statistics_table' ) ) { ), ); if ( ! sportspress_dropdown_pages( $args ) ): - _e( 'No teams found.', 'sportspress' ); + _e( 'No results found.', 'sportspress' ); endif; ?> @@ -1289,7 +1247,7 @@ if ( !function_exists( 'sportspress_solve' ) ) { if ( $clearance ): // Equation Operating System - $eos = new eqEOS(); + $eos = new SP_eqEOS(); // Solve using EOS return round( $eos->solveIF( str_replace( ' ', '', $equation ), $vars ), $precision ); @@ -2381,6 +2339,21 @@ if ( !function_exists( 'sportspress_get_player_statistics_data' ) ) { } } +if ( !function_exists( 'sportspress_get_next_event' ) ) { + function sportspress_get_next_event( $args = array() ) { + $options = array( + 'post_type' => 'sp_event', + 'posts_per_page' => 1, + 'order' => 'ASC', + 'post_status' => 'future', + 'meta_query' => $args, + ); + $posts = get_posts( $options ); + $post = array_pop( $posts ); + return $post; + } +} + if ( !function_exists( 'sportspress_delete_duplicate_post' ) ) { function sportspress_delete_duplicate_post( &$post ) { global $wpdb; diff --git a/lib/eos/eos.class.php b/lib/eos/eos.class.php index 0f11aa75..41986e44 100644 --- a/lib/eos/eos.class.php +++ b/lib/eos/eos.class.php @@ -73,7 +73,7 @@ require_once "stack.class.php"; * @subpackage EOS * @version 2.0 */ -class eqEOS { +class SP_eqEOS { /**#@+ *Private variables */ diff --git a/sportspress.php b/sportspress.php index 4e3d9eed..e345f83e 100644 --- a/sportspress.php +++ b/sportspress.php @@ -24,8 +24,7 @@ define( 'SPORTSPRESS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); define( 'SPORTSPRESS_PLUGIN_FILE', __FILE__ ); // Libraries -if ( ! class_exists( 'eqEOS' ) ) - require_once dirname( __FILE__ ) . '/lib/eos/eos.class.php' ; +require_once dirname( __FILE__ ) . '/lib/eos/eos.class.php' ; // Globals require_once dirname( __FILE__ ) . '/admin/globals/continents.php'; @@ -75,8 +74,6 @@ require_once dirname( __FILE__ ) . '/admin/terms/venue.php'; require_once dirname( __FILE__ ) . '/admin/terms/position.php'; // Widgets -require_once dirname( __FILE__ ) . '/admin/widgets/recent-events.php'; -require_once dirname( __FILE__ ) . '/admin/widgets/future-events.php'; require_once dirname( __FILE__ ) . '/admin/widgets/countdown.php'; require_once dirname( __FILE__ ) . '/admin/widgets/events-calendar.php'; require_once dirname( __FILE__ ) . '/admin/widgets/player-list.php'; @@ -97,6 +94,7 @@ require_once dirname( __FILE__ ) . '/admin/hooks/admin-menu.php'; require_once dirname( __FILE__ ) . '/admin/hooks/admin-enqueue-scripts.php'; require_once dirname( __FILE__ ) . '/admin/hooks/admin-print-styles.php'; require_once dirname( __FILE__ ) . '/admin/hooks/admin-head.php'; +require_once dirname( __FILE__ ) . '/admin/hooks/current-screen.php'; // Administrative actions require_once dirname( __FILE__ ) . '/admin/hooks/manage-posts-columns.php';