Advertisement
JeffreySummers

shgww

Feb 8th, 2013
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. <?php
  2. /**
  3. * Roots functions
  4. */
  5.  
  6. if (!defined('__DIR__')) { define('__DIR__', dirname(__FILE__)); }
  7.  
  8. require_once locate_template('/inc/includes.php');
  9.  
  10. function roots_setup() {
  11.  
  12. // Make theme available for translation
  13. load_theme_textdomain('roots', get_template_directory() . '/lang');
  14.  
  15. // Register wp_nav_menu() menus (http://codex.wordpress.org/Function_Reference/register_nav_menus)
  16. register_nav_menus(array(
  17. 'primary_navigation' => __('Primary Navigation', 'roots'),
  18. ));
  19.  
  20. // Add post thumbnails (http://codex.wordpress.org/Post_Thumbnails)
  21. add_theme_support('post-thumbnails');
  22.  
  23.  
  24. // Add post formats (http://codex.wordpress.org/Post_Formats)
  25. add_theme_support('post-formats', array('gallery', 'link', 'image', 'quote', 'video', 'audio'));
  26.  
  27. // Tell the TinyMCE editor to use a custom stylesheet
  28. add_editor_style('assets/css/editor-style.css');
  29.  
  30. }
  31.  
  32. add_action('after_setup_theme', 'roots_setup');
  33.  
  34.  
  35. add_action( 'admin_notices', 'is_options_css_writable' );
  36. function is_options_css_writable(){
  37. if( !is_writable( locate_template('/css/options.css') ) )
  38. echo '<div class="updated"><p>css/options.css rights is not enough</p></div>';
  39. }
  40.  
  41.  
  42. add_filter( 'the_category', 'add_nofollow_cat' );
  43. function add_nofollow_cat( $text ) {
  44. $text = str_replace('rel="category tag"', "", $text); return $text;
  45. }
  46.  
  47. add_filter('widget_text', 'do_shortcode');
  48.  
  49. function limit_words($string, $word_limit) {
  50.  
  51. // creates an array of words from $string (this will be our excerpt)
  52. // explode divides the excerpt up by using a space character
  53.  
  54. $words = explode(' ', $string);
  55.  
  56. // this next bit chops the $words array and sticks it back together
  57. // starting at the first word '0' and ending at the $word_limit
  58. // the $word_limit which is passed in the function will be the number
  59. // of words we want to use
  60. // implode glues the chopped up array back together using a space character
  61.  
  62. return implode(' ', array_slice($words, 0, $word_limit));
  63.  
  64. }
  65.  
  66.  
  67. add_filter( 'wp_get_attachment_image', 'remove_thumbnail_dimensions', 10 );
  68. add_filter( 'image_send_to_editor', 'remove_thumbnail_dimensions', 10 );
  69.  
  70. function remove_thumbnail_dimensions( $html ) {
  71. $html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html );
  72. return $html;
  73. }
  74.  
  75. // show admin bar only for admins
  76. if (!current_user_can('manage_options')) {
  77. add_filter('show_admin_bar', '__return_false');
  78. }
  79. // show admin bar only for admins and editors
  80. if (!current_user_can('edit_posts')) {
  81. add_filter('show_admin_bar', '__return_false');
  82. }
  83.  
  84. function template_admin_head(){
  85. echo '<script>template_uri = "'.get_template_directory_uri().'";</script>';
  86. echo '<script>base_url = "'.home_url().'";</script>';
  87. }
  88. add_action('admin_head', 'template_admin_head');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement