From 8a9e211f5b1b52c016670ab305837cfce5dbca04 Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Sat, 29 Mar 2014 03:56:47 +1100 Subject: [PATCH] Add image sizes in main class --- includes/class-sp-install.php | 4 +-- includes/sp-template-hooks.php | 33 ------------------- sportspress.php | 58 ++++++++++++++++++++-------------- 3 files changed, 36 insertions(+), 59 deletions(-) diff --git a/includes/class-sp-install.php b/includes/class-sp-install.php index cb661076..0ffeacb2 100644 --- a/includes/class-sp-install.php +++ b/includes/class-sp-install.php @@ -47,7 +47,7 @@ class SP_Install { */ public function install_actions() { // Install - Add pages button - if ( ! empty( $_GET['install_sportspress_pages'] ) ) { + if ( ! empty( $_GET['install_sportspress'] ) ) { // We no longer need to install pages delete_option( '_sp_needs_pages' ); @@ -58,7 +58,7 @@ class SP_Install { exit; // Skip button - } elseif ( ! empty( $_GET['skip_install_sportspress_pages'] ) ) { + } elseif ( ! empty( $_GET['skip_install_sportspress'] ) ) { // We no longer need to install pages delete_option( '_sp_needs_pages' ); diff --git a/includes/sp-template-hooks.php b/includes/sp-template-hooks.php index 160bd778..9235b2d9 100644 --- a/includes/sp-template-hooks.php +++ b/includes/sp-template-hooks.php @@ -12,39 +12,6 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly -function sportspress_plugins_loaded() { - - // Load plugin textdomain - if ( function_exists( 'load_plugin_textdomain' ) ) { - load_plugin_textdomain ( 'sportspress', false, dirname( plugin_basename( SP_PLUGIN_FILE ) ) . '/languages/' ); - } - - // Add image sizes - if ( function_exists( 'add_image_size' ) ) { - - // Standard (3:2) - add_image_size( 'sportspress-standard', 637, 425, true ); - add_image_size( 'sportspress-standard-thumbnail', 303, 202, true ); - - // Wide (16:9) - add_image_size( 'sportspress-wide-header', 1600, 900, true ); - add_image_size( 'sportspress-wide', 637, 358, true ); - add_image_size( 'sportspress-wide-thumbnail', 303, 170, true ); - - // Square (1:1) - add_image_size( 'sportspress-square', 637, 637, true ); - add_image_size( 'sportspress-square-thumbnail', 303, 303, true ); - - // Fit (Proportional) - add_image_size( 'sportspress-fit', 637, 637, false ); - add_image_size( 'sportspress-fit-thumbnail', 303, 303, false ); - add_image_size( 'sportspress-fit-icon', 32, 32, false ); - - } - -} -add_action( 'plugins_loaded', 'sportspress_plugins_loaded' ); - function sportspress_default_venue_content( $query ) { if ( ! is_tax( 'sp_venue' ) ) return; diff --git a/sportspress.php b/sportspress.php index 2cf6a878..7d6a1a50 100644 --- a/sportspress.php +++ b/sportspress.php @@ -145,39 +145,31 @@ final class SportsPress { * @return void */ public function autoload( $class ) { - + $path = null; $class = strtolower( $class ); + $file = 'class-' . str_replace( '_', '-', $class ) . '.php'; if ( strpos( $class, 'sp_shortcode_' ) === 0 ) { - $path = $this->plugin_path() . '/includes/shortcodes/'; - $file = 'class-' . str_replace( '_', '-', $class ) . '.php'; - - if ( is_readable( $path . $file ) ) { - include_once( $path . $file ); - return; - } - - } elseif ( strpos( $class, 'sp_meta_box_' ) === 0 ) { - + } elseif ( strpos( $class, 'sp_meta_box' ) === 0 ) { $path = $this->plugin_path() . '/includes/admin/post-types/meta-boxes/'; - $file = 'class-' . str_replace( '_', '-', $class ) . '.php'; - - if ( is_readable( $path . $file ) ) { - include_once( $path . $file ); - return; - } + } elseif ( strpos( $class, 'sp_admin' ) === 0 ) { + $path = $this->plugin_path() . '/includes/admin/'; } + if ( $path && is_readable( $path . $file ) ) { + include_once( $path . $file ); + return; + } + + // Fallback if ( strpos( $class, 'sp_' ) === 0 ) { - $path = $this->plugin_path() . '/includes/'; - $file = 'class-' . str_replace( '_', '-', $class ) . '.php'; + } - if ( is_readable( $path . $file ) ) { - include_once( $path . $file ); - return; - } + if ( $path && is_readable( $path . $file ) ) { + include_once( $path . $file ); + return; } } @@ -208,7 +200,7 @@ final class SportsPress { include_once( 'includes/admin/class-sp-admin.php' ); } - if ( ! is_admin() ) { + if ( ! is_admin() || defined( 'DOING_AJAX' ) ) { $this->frontend_includes(); } @@ -289,6 +281,24 @@ final class SportsPress { */ public function setup_environment() { add_theme_support( 'post-thumbnails' ); + + // Standard (3:2) + add_image_size( 'sportspress-standard', 637, 425, true ); + add_image_size( 'sportspress-standard-thumbnail', 303, 202, true ); + + // Wide (16:9) + add_image_size( 'sportspress-wide-header', 1600, 900, true ); + add_image_size( 'sportspress-wide', 637, 358, true ); + add_image_size( 'sportspress-wide-thumbnail', 303, 170, true ); + + // Square (1:1) + add_image_size( 'sportspress-square', 637, 637, true ); + add_image_size( 'sportspress-square-thumbnail', 303, 303, true ); + + // Fit (Proportional) + add_image_size( 'sportspress-fit', 637, 637, false ); + add_image_size( 'sportspress-fit-thumbnail', 303, 303, false ); + add_image_size( 'sportspress-fit-icon', 32, 32, false ); } /** Helper functions ******************************************************/