Last active
March 3, 2016 05:38
-
-
Save bravokeyl/4b8697df4405bd460c37 to your computer and use it in GitHub Desktop.
Daydreams functions.php
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 | |
// Uncomment this to test your localization, make sure to enter the right language code. | |
// function test_localization( $locale ) { | |
// return "nl_NL"; | |
// } | |
// add_filter('locale','test_localization'); | |
load_theme_textdomain('studiopress', TEMPLATEPATH.'/languages/'); | |
add_filter('comments_template', 'legacy_comments'); | |
// for slug - Start | |
//====================================================================================== | |
function myvar_flush_rewrite() { | |
global $wp_rewrite; | |
$wp_rewrite->flush_rules(); | |
} | |
function myvar_vars($public_query_vars) { | |
$public_query_vars[] = 'content'; | |
return $public_query_vars; | |
} | |
function myvar_add_rewrite_rules($wp_rewrite) { | |
$new_rules = array('/the-mailbag/(.+)' => 'the-mailbag/&content=' . $wp_rewrite->preg_index(1)); | |
$wp_rewrite->rules = $new_rules + $wp_rewrite->rules; | |
} | |
add_action('init', 'myvar_flush_rewrite'); | |
add_filter('query_vars', 'myvar_vars'); | |
add_action('generate_rewrite_rules', 'myvar_add_rewrite_rules'); | |
//====================================================================================== | |
// for slug - End | |
function legacy_comments($file) { | |
if(!function_exists('wp_list_comments')) : // WP 2.7-only check | |
$file = TEMPLATEPATH . '/legacy.comments.php'; | |
endif; | |
return $file; | |
} | |
// Turn a category ID to a Name | |
function cat_id_to_name($id) { | |
foreach((array)(get_categories()) as $category) { | |
if ($id == $category->cat_ID) { return $category->cat_name; break; } | |
} | |
} | |
// include the breadcrumb nav tool | |
include(TEMPLATEPATH."/tools/breadcrumbs.php"); | |
// include the theme options | |
include(TEMPLATEPATH."/tools/theme-options.php"); | |
// include the dashboard widget | |
include(TEMPLATEPATH."/tools/sp_dashboard_widget.php"); | |
if ( function_exists('register_sidebars') ) | |
register_sidebar(array('name'=>'Sidebar Top','before_title'=>'<h4>','after_title'=>'</h4>')); | |
register_sidebar(array('name'=>'Sidebar Bottom Left','before_title'=>'<h4>','after_title'=>'</h4>')); | |
register_sidebar(array('name'=>'Sidebar Bottom Right','before_title'=>'<h4>','after_title'=>'</h4>')); | |
register_sidebar(array('name'=>'468x60 Header Banner','before_title'=>'<h4>','after_title'=>'</h4>')); | |
register_sidebar(array('name'=>'Sidebar Middle','before_title'=>'<h4>','after_title'=>'</h4>')); | |
function the_content_limit($max_char, $more_link_text = '(more...)', $stripteaser = 0, $more_file = '') { | |
$content = get_the_content($more_link_text, $stripteaser, $more_file); | |
$content = apply_filters('the_content', $content); | |
$content = str_replace(']]>', ']]>', $content); | |
$content = strip_tags($content); | |
if (strlen($_GET['p']) > 0) { | |
/* | |
echo "<p>"; | |
echo $content; | |
echo " <a href='"; | |
//the_permalink(); | |
echo '?cat=24'; | |
echo "'>".__("<a href='?cat=24'>Read More</a>", 'studiopress')." →</a>"; | |
echo "</p>"; | |
*/ | |
echo "<p>"; | |
echo $content; | |
echo " <a href='"; | |
the_permalink(); | |
echo "'>".__("Read More", 'studiopress')." →</a>"; | |
echo "</p>"; | |
} | |
else if ((strlen($content)>$max_char) && ($espacio = strpos($content, " ", $max_char ))) { | |
$content = substr($content, 0, $espacio); | |
$content = $content; | |
echo "<p>"; | |
echo $content; | |
echo "..."; | |
echo " <a href='"; | |
the_permalink(); | |
echo "'>".$more_link_text."</a>"; | |
echo "</p>"; | |
} | |
else { | |
/* | |
echo "<p>"; | |
echo $content; | |
echo " <a href='"; | |
the_permalink(); | |
echo "'>".__("Read More", 'studiopress')." →</a>"; | |
echo "</p>"; | |
*/ | |
/*--Brainofast Changes - Start---*/ | |
echo "<p>"; | |
echo $content; | |
echo "..."; | |
echo "</p>"; | |
/*--Brainofast Changes - End---*/ | |
} | |
} | |
function clean_youtube ($content) { | |
$content = preg_replace ('/classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"/', '', $content); | |
return $content; | |
}; | |
add_filter('the_content', 'clean_youtube'); | |
add_filter('the_content_rss', 'clean_youtube'); | |
add_filter('the_excerpt', 'clean_youtube'); | |
add_filter('the_excerpt_rss', 'clean_youtube'); | |
add_filter('get_the_excerpt', 'clean_youtube'); | |
add_filter('content_edit_pre', 'clean_youtube'); | |
add_filter('content_save_pre', 'clean_youtube'); | |
add_filter('content_filtered_save_pre', 'clean_youtube'); | |
add_action('publish_post', 'clean_youtube'); | |
add_action('save_post', 'clean_youtube'); | |
add_action('edit_post', 'clean_youtube'); | |
function sbj_category_pages( $query ) { | |
if ( ! is_admin() && $query->is_category(array('blowjob-tips', 'steak-recipes', 'valentines-day-tips')) | |
&& $query->is_main_query() ) { | |
$query->set( 'posts_per_page', '-1' ); | |
} | |
} | |
add_action( 'pre_get_posts', 'sbj_category_pages' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment