Define main SportsPress class

This commit is contained in:
Brian Miyaji
2014-03-25 00:19:34 +11:00
parent 6e778ad40c
commit 6db3e82d66
16 changed files with 357 additions and 168 deletions

View File

@@ -1,26 +1,26 @@
<?php
function sportspress_admin_enqueue_scripts( $hook ) {
wp_enqueue_style( 'jquery-chosen', SPORTSPRESS_PLUGIN_URL . 'assets/css/chosen.css', array(), null );
wp_enqueue_style( 'jquery-chosen', plugin_dir_url( SP_PLUGIN_FILE ) . 'assets/css/chosen.css', array(), null );
// Add ThemeBoy icon font, used in the admin stylesheet.
wp_enqueue_style( 'themeboy', SPORTSPRESS_PLUGIN_URL . 'assets/css/themeboy.css', array(), null );
wp_enqueue_style( 'themeboy', plugin_dir_url( SP_PLUGIN_FILE ) . 'assets/css/themeboy.css', array(), null );
// Load our admin stylesheet.
wp_enqueue_style( 'sportspress-admin', SPORTSPRESS_PLUGIN_URL . 'assets/css/admin.css', array(), time() );
wp_enqueue_style( 'sportspress-admin', plugin_dir_url( SP_PLUGIN_FILE ) . 'assets/css/admin.css', array(), time() );
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'jquery-chosen', SPORTSPRESS_PLUGIN_URL .'assets/js/chosen.jquery.min.js', array( 'jquery' ), '1.1.0', true );
wp_enqueue_script( 'jquery-tiptip', SPORTSPRESS_PLUGIN_URL .'assets/js/jquery.tipTip.min.js', array( 'jquery' ), '1.3', 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 );
wp_enqueue_script( 'jquery-chosen', plugin_dir_url( SP_PLUGIN_FILE ) .'assets/js/chosen.jquery.min.js', array( 'jquery' ), '1.1.0', true );
wp_enqueue_script( 'jquery-tiptip', plugin_dir_url( SP_PLUGIN_FILE ) .'assets/js/jquery.tipTip.min.js', array( 'jquery' ), '1.3', true );
wp_enqueue_script( 'jquery-caret', plugin_dir_url( SP_PLUGIN_FILE ) .'assets/js/jquery.caret.min.js', array( 'jquery' ), '1.02', true );
wp_enqueue_script( 'jquery-countdown', plugin_dir_url( SP_PLUGIN_FILE ) .'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' );
wp_enqueue_script( 'jquery-locationpicker', SPORTSPRESS_PLUGIN_URL .'assets/js/locationpicker.jquery.js', array( 'jquery' ), '0.1.6', true );
wp_enqueue_script( 'sportspress-admin-locationpicker', SPORTSPRESS_PLUGIN_URL .'assets/js/admin-locationpicker.js', array( 'jquery', 'google-maps', 'jquery-locationpicker' ), time(), true );
wp_enqueue_script( 'jquery-locationpicker', plugin_dir_url( SP_PLUGIN_FILE ) .'assets/js/locationpicker.jquery.js', array( 'jquery' ), '0.1.6', true );
wp_enqueue_script( 'sportspress-admin-locationpicker', plugin_dir_url( SP_PLUGIN_FILE ) .'assets/js/admin-locationpicker.js', array( 'jquery', 'google-maps', 'jquery-locationpicker' ), time(), true );
endif;
wp_enqueue_script( 'sportspress-admin', SPORTSPRESS_PLUGIN_URL .'assets/js/admin.js', array( 'jquery' ), time(), true );
wp_enqueue_script( 'sportspress-admin', plugin_dir_url( SP_PLUGIN_FILE ) .'assets/js/admin.js', array( 'jquery' ), time(), true );
// Localize scripts.
wp_localize_script( 'sportspress-admin', 'localized_strings', array( 'none' => __( 'None', 'sportspress' ), 'remove_text' => __( '&mdash; Remove &mdash;', 'sportspress' ), 'days' => __( 'days', 'sportspress' ), 'hrs' => __( 'hrs', 'sportspress' ), 'mins' => __( 'mins', 'sportspress' ), 'secs' => __( 'secs', 'sportspress' ) ) );

View File

@@ -34,7 +34,7 @@ add_action( 'admin_print_styles', 'sportspress_admin_notices_styles' );
* @return void
*/
function sportspress_admin_install_notices() {
// include( dirname( SPORTSPRESS_PLUGIN_FILE ) . '/admin/includes/notice-install.php' );
// include( dirname( SP_PLUGIN_FILE ) . '/admin/includes/notice-install.php' );
}
/**
@@ -44,5 +44,5 @@ function sportspress_admin_install_notices() {
* @return void
*/
function sportspress_theme_check_notice() {
// include( dirname( SPORTSPRESS_PLUGIN_FILE ) . '/admin/includes/notice-theme-support.php' );
// include( dirname( SP_PLUGIN_FILE ) . '/admin/includes/notice-theme-support.php' );
}

View File

@@ -2,6 +2,6 @@
function sportspress_current_screen() {
$screen = get_current_screen();
if ( $screen->id == 'dashboard' )
include_once( dirname( SPORTSPRESS_PLUGIN_FILE ) . '/admin/tools/dashboard.php' );
include_once( dirname( SP_PLUGIN_FILE ) . '/admin/tools/dashboard.php' );
}
add_action( 'current_screen', 'sportspress_current_screen' );

View File

@@ -9,5 +9,5 @@ function sportspress_plugin_action_links( $links ) {
return $links;
}
$plugin = SPORTSPRESS_PLUGIN_BASENAME;
$plugin = plugin_basename( SP_PLUGIN_FILE );
add_filter( "plugin_action_links_$plugin", 'sportspress_plugin_action_links' );

View File

@@ -3,7 +3,7 @@ function sportspress_plugins_loaded() {
// Load plugin textdomain
if ( function_exists( 'load_plugin_textdomain' ) ) {
load_plugin_textdomain ( 'sportspress', false, dirname( SPORTSPRESS_PLUGIN_BASENAME ) . '/languages/' );
load_plugin_textdomain ( 'sportspress', false, dirname( plugin_basename( SP_PLUGIN_FILE ) ) . '/languages/' );
}
// Add image sizes

View File

@@ -162,4 +162,4 @@ function sportspress_activation_hook() {
sportspress_flush_rewrite_rules();
}
register_activation_hook( SPORTSPRESS_PLUGIN_FILE, 'sportspress_activation_hook' );
register_activation_hook( SP_PLUGIN_FILE, 'sportspress_activation_hook' );

View File

@@ -3,7 +3,7 @@ function sportspress_save_post( $post_id ) {
global $post, $typenow;
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return $post_id;
if ( !current_user_can( 'edit_post', $post_id ) ) return $post_id;
if ( !isset( $_POST['sportspress_nonce'] ) || ! wp_verify_nonce( $_POST['sportspress_nonce'], SPORTSPRESS_PLUGIN_BASENAME ) ) return $post_id;
if ( !isset( $_POST['sportspress_nonce'] ) || ! wp_verify_nonce( $_POST['sportspress_nonce'], plugin_basename( SP_PLUGIN_FILE ) ) ) return $post_id;
switch ( $_POST['post_type'] ):
case ( 'sp_team' ):

View File

@@ -1,14 +1,14 @@
<?php
function sportspress_enqueue_scripts() {
// Styles
wp_enqueue_style( 'sportspress', SPORTSPRESS_PLUGIN_URL . 'assets/css/sportspress.css', array( 'dashicons' ), time() );
wp_enqueue_style( 'sportspress', plugin_dir_url( SP_PLUGIN_FILE ) . 'assets/css/sportspress.css', array( 'dashicons' ), time() );
// Scripts
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'google-maps', 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false', array(), '3.exp', true );
wp_enqueue_script( 'jquery-datatables', SPORTSPRESS_PLUGIN_URL .'assets/js/jquery.dataTables.min.js', array( 'jquery' ), '1.9.4', true );
wp_enqueue_script( 'jquery-countdown', SPORTSPRESS_PLUGIN_URL .'assets/js/jquery.countdown.min.js', array( 'jquery' ), '2.0.2', true );
wp_enqueue_script( 'sportspress', SPORTSPRESS_PLUGIN_URL .'assets/js/sportspress.js', array( 'jquery' ), time(), true );
wp_enqueue_script( 'jquery-datatables', plugin_dir_url( SP_PLUGIN_FILE ) .'assets/js/jquery.dataTables.min.js', array( 'jquery' ), '1.9.4', true );
wp_enqueue_script( 'jquery-countdown', plugin_dir_url( SP_PLUGIN_FILE ) .'assets/js/jquery.countdown.min.js', array( 'jquery' ), '2.0.2', true );
wp_enqueue_script( 'sportspress', plugin_dir_url( SP_PLUGIN_FILE ) .'assets/js/sportspress.js', array( 'jquery' ), time(), true );
// Localize scripts.
wp_localize_script( 'sportspress', 'localized_strings', array( 'days' => __( 'days', 'sportspress' ), 'hrs' => __( 'hrs', 'sportspress' ), 'mins' => __( 'mins', 'sportspress' ), 'secs' => __( 'secs', 'sportspress' ) ) );