1. <?php
  2. /**
  3.  * Custom Theme Functions
  4.  * @package WordPress
  5.  * @subpackage Hester Browne
  6.  * @author By Association Only | http://byassociationonly.com
  7.  * @copyright 2012-2013
  8.  **/
  9. ?>
  10. <?php
  11. /**
  12.  * @desc Add featured image support
  13.  **/
  14.  
  15. add_theme_support( 'post-thumbnails' );
  16. set_post_thumbnail_size( 540, 9999 ); // set width and height
  17.  
  18. /**
  19.  * @desc Add widget support
  20.  **/
  21.  
  22. if ( function_exists('register_sidebar') )
  23.     register_sidebar();
  24.  
  25. function quickchic_widgets_init() {
  26. register_sidebar(array(
  27. 'name' => __( 'Sidebar 1', 'quickchic' ),
  28. 'id' => 'sidebar-1',
  29. 'before_widget' => '',
  30. 'after_widget' => '',
  31. 'before_title' => '<h4>',
  32. 'after_title' => '</h4>',
  33. ));
  34. }
  35. add_action( 'init', 'quickchic_widgets_init' );
  36.  
  37. /**
  38.  * @desc Strip width and height dimensions from all featured images (post_thumbnails)
  39.  **/
  40.  
  41. add_filter( 'post_thumbnail_html', 'remove_thumbnail_dimensions', 10 );
  42. add_filter( 'image_send_to_editor', 'remove_thumbnail_dimensions', 10 );
  43.  
  44. function remove_thumbnail_dimensions( $html ) {
  45.     $html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html );
  46.     return $html;
  47. }
  48.  
  49. /**
  50.  * @desc Add/Remove links from page head
  51.  **/
  52.  
  53. add_theme_support( 'automatic-feed-links' );
  54. remove_action( 'wp_head', 'wlwmanifest_link');
  55.  
  56. /**
  57.  * @desc Configure Contact Form 7
  58.  **/
  59.  
  60. // Remove stylesheet
  61. add_action('wp_enqueue_scripts', 'my_scripts_method', 11);
  62.  
  63. add_action('wp_print_styles','remove_styles',100);
  64.  
  65. function remove_styles() {
  66.     // add handles for styles you wish to remove
  67.     wp_deregister_style('contact-form-7');
  68. }
  69.  
  70. /**
  71.  * @desc Use Google's hosted jQuery file
  72.  **/
  73.  
  74. if (!is_admin()) add_action("wp_enqueue_scripts", "my_jquery_enqueue", 10);
  75. function my_jquery_enqueue() {
  76.    wp_deregister_script('jquery');
  77.    wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js", false, null, true);
  78.    wp_enqueue_script('jquery');
  79. }
  80.  
  81. /**
  82.  * @desc Only load in these files when necessary
  83.  **/
  84.  
  85. function my_scripts_method() {
  86.            
  87.     if ( is_front_page() ) {   
  88.         wp_register_script('lettering', get_template_directory_uri() . '/js/jquery.lettering.js', false, null, true);  
  89.         wp_register_script('fittext', get_template_directory_uri() . '/js/jquery.fittext.js', false, null, true);
  90.         wp_register_script('plugins', get_template_directory_uri() . '/js/plugins.js', false, null, true); 
  91.         wp_register_script('script', get_template_directory_uri() . '/js/script.js', false, null, true);
  92.         wp_register_script('anything', get_template_directory_uri() . '/js/jquery.anythingslider.min.js', false, null, true);
  93.    
  94.         // enqueue the script
  95.         wp_enqueue_script('lettering');
  96.         wp_enqueue_script('fittext');
  97.         wp_enqueue_script('plugins');
  98.         wp_enqueue_script('script');
  99.         wp_enqueue_script('anything');
  100.     }        
  101.    
  102.     wp_register_script('tweets', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://twitterjs.googlecode.com/svn/trunk/src/twitter.min.js", false, null, true);
  103.    
  104.     wp_enqueue_script('tweets');
  105. }
  106.  
  107. add_action('wp_enqueue_scripts', 'my_scripts_method', 11);
  108.  
  109.  
  110. /**
  111.  * @desc Disable links on all post images
  112.  **/
  113.  
  114. add_filter( 'the_content', 'attachment_image_link_remove_filter' );
  115.  
  116. function attachment_image_link_remove_filter( $content ) {
  117.     $content =
  118.         preg_replace(
  119.             array('{<a(.*?)(wp-att|wp-content\/uploads)[^>]*><img}',
  120.                 '{ wp-image-[0-9]*" /></a>}'),
  121.             array('<img','" />'),
  122.             $content
  123.         );
  124.     return $content;
  125. }
  126.  
  127. /**
  128.  * @desc Disable more tag jump on continue reading links
  129.  **/
  130.  
  131. function remove_more_jump_link($link) {
  132. $offset = strpos($link, '#more-');
  133. if ($offset) {
  134. $end = strpos($link, '"',$offset);
  135. }
  136. if ($end) {
  137. $link = substr_replace($link, '', $offset, $end-$offset);
  138. }
  139. return $link;
  140. }
  141. add_filter('the_content_more_link', 'remove_more_jump_link');
  142.  
  143. /**
  144.  * @desc Customise footer message in admin panel
  145.  **/
  146.  
  147. function modify_footer_admin () {
  148.   echo '{ <a href="http://byassociationonly.com">By Association Only</a> } ';
  149.   echo 'Powered by <a href="http://WordPress.org">WordPress</a>.';
  150. }
  151.  
  152. add_filter('admin_footer_text', 'modify_footer_admin');
  153.  
  154. /**
  155.  * @desc Remove menu items from admin area that are not needed by the client
  156.  **/
  157.  
  158. function remove_menus () {
  159. global $menu;
  160.     $restricted = array(__('Links'), __('Tools'));
  161.     end ($menu);
  162.     while (prev($menu)){
  163.         $value = explode(' ',$menu[key($menu)][0]);
  164.         if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);}
  165.     }
  166. }
  167. add_action('admin_menu', 'remove_menus');
  168.  
  169. /**
  170.  * @desc Hide ACF menu item from all user types excluding admin
  171.  */
  172.  
  173. function hide_admin_menu()
  174. {
  175.     global $current_user;
  176.     get_currentuserinfo();
  177.  
  178.     if($current_user->user_login != 'admin')
  179.     {
  180.         echo '<style type="text/css">#toplevel_page_edit-post_type-acf{display:none;}</style>';
  181.     }
  182. }
  183.  
  184. add_action('admin_head', 'hide_admin_menu');
  185.  
  186. ?>