Advertisement
cgsmith1

KGOC Functions File

Aug 3rd, 2015
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.72 KB | None | 0 0
  1. <?php
  2. ob_start();
  3.  
  4. // Load the extra layout and styles from their own file
  5. require_once(STYLESHEETPATH . '/includes/theme-options.php');
  6.  
  7. // Redirect to Theme FAQ on Activation - I know this is annoying, but I want people to read it.
  8. if ( is_admin() && isset($_GET['activated'] ) && $pagenow =="themes.php" )
  9. wp_redirect( 'themes.php?page=nomnom-theme-options' );
  10.  
  11. // Include the custom widgets
  12. include('includes/helper.php');
  13. include('includes/widget-func.php');
  14. include('includes/twitter.php');
  15. include('includes/blog-author.php');
  16. include('includes/flickr.php');
  17. include('includes/nomnom-slider/slider.php');
  18.  
  19.  
  20. // Call the various .js files and shortcode css
  21. function add_nomnom_scripts(){
  22. wp_register_script('jquery', 'http://code.jquery.com/jquery-1.5.2.min.js');
  23. wp_register_script('superfish', get_stylesheet_directory_uri() .'/includes/js/superfish.js');
  24. wp_register_style('color_options.css', get_stylesheet_directory_uri().'/includes/color_options_css.php');
  25.  
  26. wp_enqueue_script('jquery');
  27. wp_enqueue_script('superfish');
  28. }
  29.  
  30. function color_options_script ()
  31. {
  32.  
  33. wp_register_style('nomnom.css', get_stylesheet_directory_uri().'/includes/css/nomnom.css');
  34. wp_register_style('colorpicker.css', get_stylesheet_directory_uri().'/colorpicker/css/colorpicker.css');
  35. wp_register_style('layout.css', get_stylesheet_directory_uri().'/colorpicker/css/layout.css');
  36.  
  37. wp_register_script('noconflict.js', get_stylesheet_directory_uri().'/includes/js/noconflict.js', array('jquery'));
  38. wp_register_script('colorpicker.js', get_stylesheet_directory_uri().'/colorpicker/js/colorpicker.js', array('jquery'));
  39. wp_register_script('eye.js', get_stylesheet_directory_uri().'/colorpicker/js/eye.js', array('jquery'));
  40. wp_register_script('utils.js', get_stylesheet_directory_uri().'/colorpicker/js/utils.js', array('jquery'));
  41. wp_register_script('color_options.js', get_stylesheet_directory_uri().'/includes/js/color_options.js', array('jquery'));
  42.  
  43.  
  44. wp_enqueue_style('nomnom.css');
  45. wp_enqueue_style('colorpicker.css');
  46. wp_enqueue_style('layout.css');
  47.  
  48. wp_enqueue_script('noconflict.js');
  49. wp_enqueue_script('colorpicker.js');
  50. wp_enqueue_script('eye.js');
  51. wp_enqueue_script('utils.js');
  52. wp_enqueue_script('color_options.js');
  53. }
  54.  
  55. if (is_admin())
  56. add_action('init','color_options_script');
  57.  
  58. add_action('init','add_nomnom_scripts');
  59.  
  60. // Add a second menu
  61. register_nav_menus( array(
  62. 'secondary' => __( 'Top Menu (Above the Header)', 'NomNom'),
  63. 'primary' => __( 'Primary Menu', 'NomNom' ),
  64. ) );
  65.  
  66. // Add a sidebar to single posts view - http://transformationpowertools.com
  67. add_filter('body_class', 'blacklist_body_class', 20, 2);
  68. function blacklist_body_class($wp_classes, $extra_classes) {
  69. if( is_single() ) :
  70. // List of the classes to remove from the WP generated classes
  71. $blacklist = array('singular');
  72. // Filter the body classes
  73. foreach( $blacklist as $val ) {
  74. if (!in_array($val, $wp_classes)) : continue;
  75. else:
  76. foreach($wp_classes as $key => $value) {
  77. if ($value == $val) unset($wp_classes[$key]);
  78. }
  79. endif;
  80. }
  81. endif; // Add the extra classes back untouched
  82. return array_merge($wp_classes, (array) $extra_classes);
  83. }
  84.  
  85. // Excerpt Length - Adding this because of the different layouts, change 40 to what you like
  86. function change_excerpt_length()
  87. {
  88. function new_excerpt_length($length){return 40;}
  89. add_filter('excerpt_length', 'new_excerpt_length');
  90. }
  91. add_action('after_setup_theme', 'change_excerpt_length');
  92.  
  93. // Set the dimensions for the thumbnails displayed on the homepage
  94. add_theme_support( 'post-thumbnails' );
  95. add_image_size('excerpt-thumbnail', 120, 120, true);
  96.  
  97. // Show Wp-PageNavi when it's active - changed twentyeleven_content_nav in index.php to twentyeleven_child_content_nav
  98. function twentyeleven_child_content_nav( $nav_id ) {
  99. global $wp_query;
  100. if ( $wp_query->max_num_pages > 1 ) : ?>
  101. <?php /* add wp-pagenavi support for posts */ ?>
  102. <?php if(function_exists('wp_pagenavi') ) : ?>
  103. <?php wp_pagenavi(); ?>
  104. <br />
  105. <?php else: ?>
  106. <nav id="<?php echo $nav_id; ?>">
  107. <h3 class="assistive-text"><?php _e( 'Post navigation', 'twentyeleven' ); ?></h3>
  108. <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyeleven' ) ); ?></div>
  109. <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyeleven' ) ); ?></div>
  110. </nav><!-- #nav-above -->
  111. <?php endif; ?>
  112. <?php endif;
  113. }
  114.  
  115. // Make plain text links clickable - uncomment to use, conflicts with some plugins
  116. /*
  117. add_filter('the_content', 'make_clickable');
  118. add_filter('the_excerpt', 'make_clickable');
  119. */
  120.  
  121. // Add a Theme Options link to Admin Bar
  122. function theme_options_link()
  123. {
  124. global $wp_admin_bar, $wpdb;
  125. if (!is_super_admin() || !is_admin_bar_showing())
  126. return;
  127. $wp_admin_bar->add_menu(array('parent' => 'appearance', 'title' => __('Theme Options', 'Theme Options'), 'href' => home_url() . '/wp-admin/themes.php?page=theme_options'));
  128. $wp_admin_bar->add_menu(array('parent' => 'appearance', 'title' => __('NomNom Options', 'NomNom Options'), 'href' => home_url() . '/wp-admin/themes.php?page=nomnom-theme-options'));
  129. }
  130. add_action('admin_bar_menu', 'theme_options_link', 1000);
  131.  
  132. // Register our extra sidebar for the three column layouts
  133. register_sidebar( array(
  134. 'name' => __( 'Extra Sidebar', 'twentyeleven' ),
  135. 'id' => 'extra-sidebar',
  136. 'description' => __( 'The sidebar for three column layouts only', 'twentyeleven' ),
  137. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  138. 'after_widget' => "</aside>",
  139. 'before_title' => '<h3 class="widget-title">',
  140. 'after_title' => '</h3>',
  141. ) );
  142.  
  143. register_sidebar( array(
  144. 'name' => __( 'Multile Forums Display', 'twentyeleven' ),
  145. 'id' => 'extra-sidebar1',
  146. 'description' => __( 'The sidebar for three column layouts only', 'twentyeleven' ),
  147. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  148. 'after_widget' => "</aside>",
  149. 'before_title' => '<h3 class="widget-title">',
  150. 'after_title' => '</h3>',
  151. ) );
  152.  
  153.  
  154. //------
  155. function test_modify_user_table( $column ) {
  156. $column['url'] = 'User Id';
  157.  
  158. return $column;
  159. }
  160.  
  161. add_filter( 'manage_users_columns', 'test_modify_user_table' );
  162.  
  163. function test_modify_user_table_row( $val, $column_name, $user_id ) {
  164. $user = get_userdata( $user_id );
  165. return $user_id;
  166. }
  167.  
  168. add_filter( 'manage_users_custom_column', 'test_modify_user_table_row', 10, 3 );
  169. if ( current_user_can('subscriber') && !current_user_can('upload_files') )
  170. add_action('admin_init', 'allow_contributor_uploads');
  171.  
  172. function allow_contributor_uploads() {
  173. $subscriber = get_role('subscriber');
  174. $subscriber->add_cap('upload_files');
  175. }
  176. add_theme_support( 'bbPress' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement