Skip to content

Instantly share code, notes, and snippets.

@jasondavis
Created November 19, 2012 04:00
Show Gist options
  • Select an option

  • Save jasondavis/4108872 to your computer and use it in GitHub Desktop.

Select an option

Save jasondavis/4108872 to your computer and use it in GitHub Desktop.
testing
<?php
//define('WP_DEBUG', true);
include( TEMPLATEPATH . DIRECTORY_SEPARATOR . 'functions' . DIRECTORY_SEPARATOR . 'jdcoreclass.php');
include( TEMPLATEPATH . DIRECTORY_SEPARATOR . 'functions' . DIRECTORY_SEPARATOR . 'comments.php' );
include( TEMPLATEPATH . DIRECTORY_SEPARATOR . 'functions' . DIRECTORY_SEPARATOR . 'shortcodes.php' );
include( TEMPLATEPATH . DIRECTORY_SEPARATOR . 'functions' . DIRECTORY_SEPARATOR . 'tag-list-widget.php' );
include( TEMPLATEPATH . DIRECTORY_SEPARATOR . 'functions' . DIRECTORY_SEPARATOR . 'admin.php' );
//if ( is_admin() ) include( TEMPLATEPATH . DIRECTORY_SEPARATOR . 'functions' . DIRECTORY_SEPARATOR . 'settings.php' );
//if ( is_admin() )include( TEMPLATEPATH . DIRECTORY_SEPARATOR . 'functions' . DIRECTORY_SEPARATOR . 'debug.php' );
// Custom "Read More link" for excerpts and
//set word-count for excerpts when custom excerpt is left blank
function new_excerpt_more($more) {
global $post;
return $output . '<a href="'. get_permalink($post->ID) . '" class="read-more"> Read More...</a>';
}
add_filter('excerpt_more', 'new_excerpt_more');
function new_excerpt_length($length) {
return 70;
}
add_filter('excerpt_length', 'new_excerpt_length');
add_filter( 'post_thumbnail_html', 'my_post_image_html', 10, 3 );
function my_post_image_html( $html, $post_id, $post_image_id ) {
if ( is_home() ) {
$html = '<a href="' . get_permalink( $post_id ) . '">' . $html . '</a>';
}
elseif ( is_single() ) {
$html = $html;
}
return $html;
}
add_theme_support( 'post-thumbnails' );
add_image_size( 'featured', '735', '155', true);
if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 150, 150 ); // default Post Thumbnail dimensions
}
if ( function_exists( 'add_image_size' ) ) {
add_image_size( 'category-thumb', 300, 9999 ); //300 pixels wide (and unlimited height)
add_image_size( 'homepage-thumb', 220, 180, true ); //(cropped)
}
// pagination is called directly from theme files that use it!!!!!
/**
* A pagination function
* @param integer $range: The range of the slider, works best with even numbers
* Used WP functions:
* get_pagenum_link($i) - creates the link, e.g. http://site.com/page/4
* previous_posts_link(' « '); - returns the Previous page link
* next_posts_link(' » '); - returns the Next page link
*/
function get_pagination($range = 4){
// get total number of pages
global $wp_query;
$total = $wp_query->max_num_pages;
// only bother with the rest if we have more than 1 page!
if ( $total > 1 ) {
// get the current page
if ( !$current_page = get_query_var('paged') )
$current_page = 1;
// structure of “format” depends on whether we’re using pretty permalinks
$format = 'page/%#%/';
echo paginate_links(array(
'base' => get_pagenum_link(1) . '%_%',
'format' => $format,
'current' => $current_page,
'total' => $total,
'mid_size' => 4,
'type' => 'list'
));
}
}
//comment links
function delete_comment_link($id) {
if (current_user_can('edit_post')) {
// echo '| <a href="'.admin_url("comment.php?action=cdc&c=$id").'">del/a> ';
echo '| <a href="'.admin_url("comment.php?action=cdc&c=$id").'">delete</a> ';
echo '| <a href="'.admin_url("comment.php?action=cdc&dt=spam&c=$id").'">spam</a>';
}
}
// Set Posts per page to show on different pages
add_action( 'pre_get_posts', 'set_posts_per_page' );
function set_posts_per_page( $query ) {
if ( is_search() ) {
$query->set( 'posts_per_page', 5 );
}
elseif ( is_archive() ) {
$query->set( 'posts_per_page', 7 );
}
// Etc..
return $query;
}
//Display DB queries, time spent and memory consumption
function performance( $visible = false ) {
$stat = sprintf( '%d queries in %.3f seconds, using %.2fMB memory',
get_num_queries(),
timer_stop( 0, 3 ),
memory_get_peak_usage() / 1024 / 1024
);
echo $visible ? $stat : "<!-- {$stat} -->" ;
}
add_action( 'wp_footer', 'performance', 20 );
//Create custom admin panel with add_menu_page
add_action('admin_menu', 'create_custom_panel');
function create_custom_panel() {
add_menu_page('Custom panel', 'Custom panel', 'manage_options', 'custom-panel', 'custom_panel');
}
function custom_panel(){
echo '<div class="wrap"><div id="icon-options-general" class="icon32">
<br>
</div>
<h2>Custom panel</h2></div>';
}
//Remove WordPress version from RSS feed
function remove_feed_generator() {
return '';
}
add_filter('the_generator', 'remove_feed_generator');
// disable post revisions
define('WP_POST_REVISIONS', false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment