Advertisement
Guest User

funsctions.php

a guest
Oct 8th, 2011
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.38 KB | None | 0 0
  1. <?php
  2. $theme_name = "broadcast";
  3. global $theme_name;
  4.  
  5. /*** Make sure to change the theme name to the current theme for all functions etc.. ***/
  6.  
  7. include_once('scripts/admin/options.php');
  8. /* skyali admin functions and definitions */
  9.  
  10. /* extra functions */
  11. include_once('scripts/functions/extra_functions.php');
  12.  
  13. add_action( 'after_setup_theme', 'skyali_setup' );
  14.  
  15. if ( ! function_exists( 'skyali_setup' ) ):
  16. /* Sets up theme defaults and registers support for various WordPress features.*/
  17. function skyali_setup() {
  18.  
  19. // This theme styles the visual editor with editor-style.css to match the theme style.
  20. add_editor_style();
  21.  
  22. // This theme uses post thumbnails
  23. add_theme_support( 'post-thumbnails' );
  24.  
  25. // Add default posts and comments RSS feed links to head
  26. add_theme_support( 'automatic-feed-links' );
  27.  
  28. // Make theme available for translation
  29. // Translations can be filed in the /languages/ directory
  30. load_theme_textdomain( 'skyali', TEMPLATEPATH . '/languages' );
  31.  
  32. $locale = get_locale();
  33. $locale_file = TEMPLATEPATH . "/languages/$locale.php";
  34. if ( is_readable( $locale_file ) )
  35. require_once( $locale_file );
  36.  
  37. // Register the wp 3.0 Menus
  38. add_action( 'init', 'register_my_menus' );
  39.  
  40. // This theme uses wp_nav_menu() in one location.
  41. function register_my_menus() {
  42. register_nav_menus(
  43. array(
  44. 'top-menu' => __( 'Top Menu' ),
  45. 'second-menu' => __( 'Second Menu' )
  46. )
  47. );
  48. }
  49.  
  50. // This theme allows users to set a custom background
  51. add_custom_background();
  52.  
  53. // Your changeable header business starts here
  54. define( 'HEADER_TEXTCOLOR', '' );
  55. // No CSS, just IMG call. The %s is a placeholder for the theme template directory URI.
  56. define( 'HEADER_IMAGE', '%s/images/headers/path.jpg' );
  57.  
  58. // The height and width of your custom header. You can hook into the theme's own filters to change these values.
  59. // Add a filter to skyali_header_image_width and skyali_header_image_height to change these values.
  60. define( 'HEADER_IMAGE_WIDTH', apply_filters( 'skyali_header_image_width', 940 ) );
  61. define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'skyali_header_image_height', 198 ) );
  62.  
  63. // We'll be using post thumbnails for custom header images on posts and pages.
  64. // We want them to be 940 pixels wide by 198 pixels tall.
  65. // Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
  66. set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );
  67.  
  68. // Don't support text inside the header image.
  69. define( 'NO_HEADER_TEXT', true );
  70.  
  71. // Add a way for the custom header to be styled in the admin panel that controls
  72. // custom headers. See skyali_admin_header_style(), below.
  73. add_custom_image_header( '', 'skyali_admin_header_style' );
  74.  
  75. // ... and thus ends the changeable header business.
  76.  
  77. // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
  78. register_default_headers( array(
  79. 'berries' => array(
  80. 'url' => '%s/images/headers/berries.jpg',
  81. 'thumbnail_url' => '%s/images/headers/berries-thumbnail.jpg',
  82. /* translators: header image description */
  83. 'description' => __( 'Berries', 'skyali' )
  84. ),
  85. 'cherryblossom' => array(
  86. 'url' => '%s/images/headers/cherryblossoms.jpg',
  87. 'thumbnail_url' => '%s/images/headers/cherryblossoms-thumbnail.jpg',
  88. /* translators: header image description */
  89. 'description' => __( 'Cherry Blossoms', 'skyali' )
  90. ),
  91. 'concave' => array(
  92. 'url' => '%s/images/headers/concave.jpg',
  93. 'thumbnail_url' => '%s/images/headers/concave-thumbnail.jpg',
  94. /* translators: header image description */
  95. 'description' => __( 'Concave', 'skyali' )
  96. ),
  97. 'fern' => array(
  98. 'url' => '%s/images/headers/fern.jpg',
  99. 'thumbnail_url' => '%s/images/headers/fern-thumbnail.jpg',
  100. /* translators: header image description */
  101. 'description' => __( 'Fern', 'skyali' )
  102. ),
  103. 'forestfloor' => array(
  104. 'url' => '%s/images/headers/forestfloor.jpg',
  105. 'thumbnail_url' => '%s/images/headers/forestfloor-thumbnail.jpg',
  106. /* translators: header image description */
  107. 'description' => __( 'Forest Floor', 'skyali' )
  108. ),
  109. 'inkwell' => array(
  110. 'url' => '%s/images/headers/inkwell.jpg',
  111. 'thumbnail_url' => '%s/images/headers/inkwell-thumbnail.jpg',
  112. /* translators: header image description */
  113. 'description' => __( 'Inkwell', 'skyali' )
  114. ),
  115. 'path' => array(
  116. 'url' => '%s/images/headers/path.jpg',
  117. 'thumbnail_url' => '%s/images/headers/path-thumbnail.jpg',
  118. /* translators: header image description */
  119. 'description' => __( 'Path', 'skyali' )
  120. ),
  121. 'sunset' => array(
  122. 'url' => '%s/images/headers/sunset.jpg',
  123. 'thumbnail_url' => '%s/images/headers/sunset-thumbnail.jpg',
  124. /* translators: header image description */
  125. 'description' => __( 'Sunset', 'skyali' )
  126. )
  127. ) );
  128. }
  129. endif;
  130.  
  131. if ( ! function_exists( 'skyali_admin_header_style' ) ) :
  132. /**
  133. * Styles the header image displayed on the Appearance > Header admin panel.
  134. *
  135. * Referenced via add_custom_image_header() in skyali_setup().
  136. *
  137. *
  138. */
  139. function skyali_admin_header_style() {
  140. ?>
  141. <?php
  142. }
  143. endif;
  144.  
  145. /**
  146. * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
  147. *
  148. * To override this in a child theme, remove the filter and optionally add
  149. * your own function tied to the wp_page_menu_args filter hook.
  150. *
  151. *
  152. */
  153. function skyali_page_menu_args( $args ) {
  154. $args['show_home'] = true;
  155. return $args;
  156. }
  157. add_filter( 'wp_page_menu_args', 'skyali_page_menu_args' );
  158.  
  159. /**
  160. * Sets the post excerpt length to 40 characters.
  161. *
  162. * To override this length in a child theme, remove the filter and add your own
  163. * function tied to the excerpt_length filter hook.
  164. *
  165. *
  166. * @return int
  167. */
  168. function skyali_excerpt_length($length) {
  169. return 40;
  170. }
  171. add_filter( 'excerpt_length', 'skyali_excerpt_length' );
  172.  
  173. /**
  174. * Returns a "Continue Reading" link for excerpts
  175. *
  176. *
  177. * @return string "Continue Reading" link
  178. */
  179. function skyali_continue_reading_link() {
  180. //return ' <a href="'. get_permalink() . '">' . __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'skyali' ) . '</a>';
  181. }
  182.  
  183. /**
  184. * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and skyali_continue_reading_link().
  185. *
  186. * To override this in a child theme, remove the filter and add your own
  187. * function tied to the excerpt_more filter hook.
  188. *
  189. *
  190. * @return string An ellipsis
  191. */
  192. function skyali_auto_excerpt_more( $more ) {
  193. return ' [&hellip;]' . skyali_continue_reading_link();
  194. }
  195. add_filter( 'excerpt_more', 'skyali_auto_excerpt_more' );
  196.  
  197. /**
  198. * Adds a pretty "Continue Reading" link to custom post excerpts.
  199. *
  200. * To override this link in a child theme, remove the filter and add your own
  201. * function tied to the get_the_excerpt filter hook.
  202. *
  203. *
  204. * @return string Excerpt with a pretty "Continue Reading" link
  205. */
  206. function skyali_custom_excerpt_more( $output ) {
  207. if ( has_excerpt() && ! is_attachment() ) {
  208. $output .= skyali_continue_reading_link();
  209. }
  210. return $output;
  211. }
  212. add_filter( 'get_the_excerpt', 'skyali_custom_excerpt_more' );
  213.  
  214. /**
  215. * Remove inline styles printed when the gallery shortcode is used.
  216. * @return string The gallery style filter, with the styles themselves removed.
  217. */
  218. function skyali_remove_gallery_css( $css ) {
  219. return preg_replace( "#<style type='text/css'>(.*?)</style>#s", '', $css );
  220. }
  221. add_filter( 'gallery_style', 'skyali_remove_gallery_css' );
  222.  
  223. if ( ! function_exists( 'skyali_comment' ) ) :
  224. /* Template for comments and pingbacks. */
  225. function skyali_comment( $comment, $args, $depth ) {
  226.  
  227. $GLOBALS['comment'] = $comment;
  228. switch ( $comment->comment_type ) :
  229. case '' :
  230. ?>
  231. <li>
  232.  
  233. <div class="comment"><!-- start of new comment goes inside the li -->
  234.  
  235. <div class="avatar">
  236.  
  237. <?php echo get_avatar( $comment, 75 ); ?>
  238.  
  239. </div><!-- #avatar -->
  240.  
  241. <?php if ( $comment->comment_approved == '0' ) : ?>
  242.  
  243. <div id="comment-pending"><?php _e( 'Your comment is awaiting moderation.', 'skyali' ); ?></div>
  244.  
  245. <?php endif; ?>
  246.  
  247. <div class="comment_holder">
  248. <?php _e('', 'skyali'); printf( __( '%s', 'skyali' ), sprintf( '<h5>%s</h5><!-- Comment Maker Name -->', get_comment_author_link() ) ); _e('', 'skyali'); ?>
  249.  
  250. <?php _e('<span class="date">'); printf( __( '%1$s at %2$s', 'skyali' ), get_comment_date(), get_comment_time() ); ?><?php edit_comment_link( __( ' - (Edit)', 'skyali' ), '' ); _e('</span><!-- #comment date -->', 'skyali');
  251.  
  252. ?>
  253.  
  254. <div class="comment_box"><p class="no_margin_bottom"><?php echo $comment->comment_content; ?></p></div><!-- #comment box -->
  255.  
  256. <div class="button"><?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?></div><!-- #button -->
  257.  
  258. </div><!-- #comment_holder -->
  259.  
  260. </div><!-- #comment -->
  261.  
  262.  
  263. <?php
  264. break;
  265. case 'pingback' :
  266. case 'trackback' :
  267. ?>
  268. <li class="post pingback">
  269. <p><?php _e( 'Pingback:', 'skyali' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __('(Edit)', 'skyali'), ' ' ); ?></p>
  270. <?php
  271. break;
  272. endswitch;
  273. }
  274. endif;
  275.  
  276. /**
  277. * Register widgetized areas, including two sidebars and four widget-ready columns in the footer.
  278. *
  279. * To override skyali_widgets_init() in a child theme, remove the action hook and add your own
  280. * function tied to the init hook.
  281. *
  282. *
  283. * @uses register_sidebar
  284. */
  285. function skyali_widgets_init() {
  286. // Area 1, located at the top of the sidebar.
  287. register_sidebar( array(
  288. 'name' => __( 'Sidebar 1', 'skyali' ),
  289. 'id' => 'primary-widget-area',
  290. 'description' => __( 'The first sidebar widget area', 'skyali' ),
  291. 'before_widget' => '<div id="%1$s" class="widget-container %2$s rightwidget">',
  292. 'after_widget' => '</div><!-- #right_widget -->',
  293. 'before_title' => '<div class="heading"><div class="heading_bg"><h2>',
  294. 'after_title' => '</h2></div></div><!-- #heading -->',
  295. ) );
  296.  
  297. // Area 2, located below the tabs. Empty by default.
  298. register_sidebar( array(
  299. 'name' => __( 'Sidebar 2', 'skyali' ),
  300. 'id' => 'secondary-widget-area',
  301. 'description' => __( 'The second sidebar widget area', 'skyali' ),
  302. 'before_widget' => '<div id="%1$s" class="widget-container %2$s rightwidget">',
  303. 'after_widget' => '</div><!-- #right_widget -->',
  304. 'before_title' => '<div class="heading"><div class="heading_bg"><h2>',
  305. 'after_title' => '</h2></div></div><!-- #heading -->',
  306. ) );
  307.  
  308. // Area 3, located in the sidebar. Empty by default.
  309. register_sidebar( array(
  310. 'name' => __( 'Sidebar Column Left', 'skyali' ),
  311. 'id' => 'sidebar-column-left',
  312. 'description' => __( 'Left Sidebar Column', 'skyali' ),
  313. 'before_widget' => '<div id="%1$s" class="widget-container %2$s rightwidget column-left">',
  314. 'after_widget' => '</div>',
  315. 'before_title' => '<div class="heading"><div class="heading_bg"><h2>',
  316. 'after_title' => '</h2></div></div><!-- #heading -->',
  317. ) );
  318.  
  319. // Area 4, located in the footer. Empty by default.
  320. register_sidebar( array(
  321. 'name' => __( 'Sidebar Column Right', 'skyali' ),
  322. 'id' => 'sidebar-column-right',
  323. 'description' => __( 'Right Sidebar Column', 'skyali' ),
  324. 'before_widget' => '<div id="%1$s" class="widget-container %2$s rightwidget column-right">',
  325. 'after_widget' => '</div>',
  326. 'before_title' => '<div class="heading"><div class="heading_bg"><h2>',
  327. 'after_title' => '</h2></div></div><!-- #heading -->',
  328. ) );
  329.  
  330.  
  331. // Area 5, located in the sidebar. Empty by default.
  332. register_sidebar( array(
  333. 'name' => __( 'First Footer Widget Area', 'skyali' ),
  334. 'id' => 'first-footer-widget-area',
  335. 'description' => __( 'The first footer widget area', 'skyali' ),
  336. 'before_widget' => '<div id="%1$s" class="widget">',
  337. 'after_widget' => '</div><!-- #widget -->',
  338. 'before_title' => '<div class="heading"><h5>',
  339. 'after_title' => '</h5></div>',
  340. ) );
  341.  
  342. // Area 6, located in the footer. Empty by default.
  343. register_sidebar( array(
  344. 'name' => __( 'Second Footer Widget Area', 'skyali' ),
  345. 'id' => 'second-footer-widget-area',
  346. 'description' => __( 'The second footer widget area', 'skyali' ),
  347. 'before_widget' => '<div id="%1$s" class="widget">',
  348. 'after_widget' => '</div><!-- #widget -->',
  349. 'before_title' => '<div class="heading"><h5>',
  350. 'after_title' => '</h5></div>',
  351. ) );
  352.  
  353. // Area 7, located in the footer. Empty by default.
  354. register_sidebar( array(
  355. 'name' => __( 'Third Footer Widget Area', 'skyali' ),
  356. 'id' => 'third-footer-widget-area',
  357. 'description' => __( 'The third footer widget area', 'skyali' ),
  358. 'before_widget' => '<div id="%1$s" class="widget">',
  359. 'after_widget' => '</div><!-- #widget -->',
  360. 'before_title' => '<div class="heading"><h5>',
  361. 'after_title' => '</h5></div>',
  362. ) );
  363.  
  364. // Area 8, located in the footer. Empty by default.
  365. register_sidebar( array(
  366. 'name' => __( 'Fourth Footer Widget Area', 'skyali' ),
  367. 'id' => 'fourth-footer-widget-area',
  368. 'description' => __( 'The fourth footer widget area', 'skyali' ),
  369. 'before_widget' => '<div id="%1$s" class="widget">',
  370. 'after_widget' => '</div><!-- #widget -->',
  371. 'before_title' => '<div class="heading"><h5>',
  372. 'after_title' => '</h5></div>',
  373. ) );
  374.  
  375.  
  376. }
  377. /** Register sidebars by running skyali_widgets_init() on the widgets_init hook. */
  378. add_action( 'widgets_init', 'skyali_widgets_init' );
  379.  
  380.  
  381. /**
  382. * Removes the default styles that are packaged with the Recent Comments widget.
  383. *
  384. * To override this in a child theme, remove the filter and optionally add your own
  385. * function tied to the widgets_init action hook.
  386. *
  387. *
  388. */
  389. function skyali_remove_recent_comments_style() {
  390. global $wp_widget_factory;
  391. remove_action( 'wp_head', array( $wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style' ) );
  392. }
  393. add_action( 'widgets_init', 'skyali_remove_recent_comments_style' );
  394.  
  395. if ( ! function_exists( 'skyali_posted_on' ) ) :
  396. /**
  397. * Prints HTML with meta information for the current post—date/time and author.
  398. *
  399. *
  400. */
  401. function skyali_posted_on() {
  402. printf( __( '<span class="%1$s">Posted on</span> %2$s <span class="meta-sep">by</span> %3$s', 'skyali' ),
  403. 'meta-prep meta-prep-author',
  404. sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a>',
  405. get_permalink(),
  406. esc_attr( get_the_time() ),
  407. get_the_date()
  408. ),
  409. sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',
  410. get_author_posts_url( get_the_author_meta( 'ID' ) ),
  411. sprintf( esc_attr__( 'View all posts by %s', 'skyali' ), get_the_author() ),
  412. get_the_author()
  413. )
  414. );
  415. }
  416. endif;
  417.  
  418. if ( ! function_exists( 'skyali_posted_in' ) ) :
  419. /**
  420. * Prints HTML with meta information for the current post (category, tags and permalink).
  421. *
  422. *
  423. */
  424. function skyali_posted_in() {
  425. // Retrieves tag list of current post, separated by commas.
  426. $tag_list = get_the_tag_list( '', ', ' );
  427. if ( $tag_list ) {
  428. $posted_in = __( 'in %1$s', 'skyali' ); //__( 'in %1$s <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'skyali' );
  429. } elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) {
  430. $posted_in = __( 'in %1$s', 'skyali' ); //Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>
  431. } else {
  432. //$posted_in = __( 'in %1$s', 'skyali' ); //
  433. }
  434. // Prints the string, replacing the placeholders.
  435. printf(
  436. $posted_in,
  437. get_the_category_list( ', ' ),
  438. $tag_list,
  439. get_permalink(),
  440. the_title_attribute( 'echo=0' )
  441. );
  442. }
  443. endif;
  444.  
  445. if (function_exists('add_theme_support')) {
  446. add_theme_support('menus');
  447. }
  448.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement