Created
February 18, 2013 17:33
-
-
Save admataz/4979071 to your computer and use it in GitHub Desktop.
Base Starter for a WordPress Theme functions.php file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
new ThemeName(); | |
class ThemeName { | |
/** | |
* Starting off… | |
*/ | |
function __construct() { | |
//add_editor_style(); | |
$this->add_sidebars(); | |
$this->add_image_sizes(); | |
$this->actions_and_filters(); | |
} | |
function actions_and_filters() | |
{ | |
add_action( 'init', array( &$this, 'page_excerpts_init' ) ); | |
/** | |
* Automatically move JavaScript code to page footer, speeding up page loading time. | |
*/ | |
remove_action('wp_head', 'wp_print_scripts'); | |
remove_action('wp_head', 'wp_print_head_scripts', 9); | |
remove_action('wp_head', 'wp_enqueue_scripts', 1); | |
add_action('wp_footer', 'wp_print_scripts', 5); | |
add_action('wp_footer', 'wp_enqueue_scripts', 5); | |
add_action('wp_footer', 'wp_print_head_scripts', 5); | |
add_action( 'init', array( &$this, 'enqueue_scripts' ), 1 ); | |
add_filter('excerpt_more', array( &$this, 'new_excerpt_more')); | |
} | |
function new_excerpt_more($more) { | |
global $post; | |
// return ' <a href="'. get_permalink($post->ID) . '">more...</a>'; | |
return '…'; | |
} | |
/** | |
* [enqueue_scripts description] | |
* @return [type] [description] | |
*/ | |
function enqueue_scripts() { | |
if ( !is_admin() ) { | |
wp_dequeue_script( 'jquery' ); | |
wp_deregister_script( 'jquery' ); | |
wp_enqueue_style( 'foundation', get_bloginfo( 'template_url' ).'/foundation.min.css', array(), '1.0', $media = 'all' ) | |
wp_enqueue_script('jquery', get_bloginfo( 'template_url' ).'/javascripts/jquery.js', array(), '1.9.0', TRUE); | |
wp_enqueue_script('foundation', get_bloginfo( 'template_url' ).'/javascripts/foundation.min.js', array('jquery'), '1.0', TRUE); | |
wp_enqueue_script('app', get_bloginfo( 'template_url' ).'/javascripts/app.js', array('jquery'), '1.0', TRUE); | |
} | |
} | |
/** | |
* Custom image sizes used in this theme | |
*/ | |
function add_image_sizes() { | |
add_theme_support( 'post-thumbnails' ); | |
add_image_size( 'articlePreview', 144, 97, true ); // 4 thumb sub-nav | |
add_image_size( 'articleInline', 304, 209, false ); // blog thumbnail | |
add_image_size( 'homeFeatured', 304, 145, true ); // blog thumbnail | |
add_image_size( 'articleMain', 624, 352, false ); // blog splash | |
} | |
/** | |
* Sidebars used in this theme | |
*/ | |
function add_sidebars() { | |
if ( function_exists( 'register_sidebar' ) ) { | |
register_sidebar( | |
array( 'name' => __( 'Right Hand Sidebar' ), | |
'id' => 'right-sidebar', | |
'description' => __( 'Widgets in this area will be shown on the right-hand side.' ), | |
'before_title' => '<h1>', | |
'after_title' => '</h1>' | |
) | |
); | |
} | |
add_theme_support( 'post-thumbnails' ); | |
} | |
/** | |
* Add support for page excerpts | |
* @return [type] [description] | |
*/ | |
function page_excerpts_init() { | |
add_post_type_support( 'page', 'excerpt' ); | |
add_post_type_support( 'post', 'excerpt' ); | |
// register_nav_menu( 'main-menu', __( 'Main Menu' ) ); | |
} | |
/** | |
* Get the parent id of the current page | |
* @return [type] [description] | |
*/ | |
function get_parent_id() { | |
global $post; | |
if ( !$post ) { | |
return 0; | |
} | |
$p = $post; | |
$topparentpageid = $p->ID; | |
$post_parent_id = $p->post_parent; | |
while ( $post_parent_id ) { | |
$p = &get_post( $post_parent_id ); | |
$topparentpageid = $p->ID; | |
$post_parent_id = $p->post_parent; | |
} | |
return $topparentpageid; | |
} | |
/** | |
* [get_page_title description] | |
* @param [type] $post_id [description] | |
* @return [type] [description] | |
*/ | |
function get_page_title( $post_id=NULL ) { | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment