Guest User

myPHP2

a guest
Apr 15th, 2014
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.29 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * Custom amendments for the theme.
  5. *
  6. * @category Innovative
  7. * @subpackage Genesis
  8. * @copyright Copyright (c) 2013, Jessica Barnard
  9. * @license GPL-2.0+
  10. * @link http://thepixelista.com/themes/innovative/
  11. * @since 2.0.0
  12. *
  13. */
  14.  
  15. add_action( 'genesis_setup', 'innovative_theme_setup', 15 );
  16. /**
  17. * Theme Setup
  18. *
  19. * This setup function attaches all of the site-wide functions
  20. * to the correct hooks and filters. All the functions themselves
  21. * are defined below this setup function.
  22. *
  23. * @since 2.0.0
  24. */
  25. function innovative_theme_setup() {
  26.  
  27. //* Child theme (do not remove)
  28. define( 'CHILD_THEME_NAME', __( 'Innovative', 'innovative' ) );
  29. define( 'CHILD_THEME_VERSION', '2.0.0' );
  30. define( 'CHILD_THEME_URL', 'http://thepixelista.com/themes/innovative' );
  31. define( 'CHILD_THEME_DEVELOPER', __( 'The Pixelista', 'innovative' ) );
  32.  
  33. //* Set content width for embeds.
  34. $content_width = apply_filters( 'content_width', 470, 400, 910 );
  35.  
  36. //* Add viewport meta tag for mobile browsers.
  37. add_theme_support( 'genesis-responsive-viewport' );
  38.  
  39. //* Add HTML5 markup structure.
  40. add_theme_support( 'html5' );
  41.  
  42. //* Add new image sizes.
  43. add_image_size( 'home-bottom', 163, 245, true );
  44. add_image_size( 'home-middle', 265, 150, true );
  45. add_image_size( 'home-mini', 80, 80, true );
  46. add_image_size( 'home-supermini', 70, 48, true );
  47. add_image_size( 'primary-sidebar', 290, 150, true );
  48.  
  49. //* Create additional color style options.
  50. add_theme_support( 'genesis-style-selector',
  51. array(
  52. 'innovative-yellow' => 'Yellow & Orange',
  53. 'innovative-turquoise' => 'Turquoise & Red',
  54. )
  55. );
  56.  
  57. //* Add support for structural wraps.
  58. add_theme_support( 'genesis-structural-wraps',
  59. array(
  60. 'header',
  61. 'nav',
  62. 'subnav',
  63. 'inner',
  64. 'footer-widgets',
  65. 'footer'
  66. )
  67. );
  68.  
  69. //* Add support for custom background.
  70. add_theme_support( 'custom-background' );
  71.  
  72. //* Reposition the primary navigation.
  73. remove_action( 'genesis_after_header', 'genesis_do_nav' );
  74. add_action( 'genesis_before_header', 'genesis_do_nav' );
  75.  
  76. //* Customize the post info function.
  77. add_filter( 'genesis_post_info', 'innovative_post_info_filter' );
  78.  
  79. //* Customize the post meta function.
  80. add_filter( 'genesis_post_meta', 'innovative_post_meta_filter' );
  81.  
  82. //* Customize search button text.
  83. add_filter( 'genesis_search_button_text', 'innovative_search_button_text' );
  84.  
  85. //* Change the comment form arguments.
  86. add_filter( 'comment_form_defaults', 'innovative_comment_text' );
  87.  
  88. //* Remove the archive thumbnail from the blog page.
  89. add_action( 'genesis_before_content', 'innovative_conditional_actions' );
  90.  
  91. //* Load Google fonts.
  92. add_action( 'wp_enqueue_scripts', 'innovative_load_google_fonts' );
  93.  
  94. //* Load Theme Scripts.
  95. add_action( 'wp_enqueue_scripts', 'innovative_load_javascript' );
  96.  
  97. //* Load Theme Sidebars.
  98. innovative_sidebars();
  99.  
  100. //* Add support for 4-column footer widgets.
  101. add_theme_support( 'genesis-footer-widgets', 4 );
  102.  
  103. //* Modify the footer output.
  104. add_filter( 'genesis_footer_creds_text', 'innovative_footer_creds_text', 12 );
  105.  
  106. }
  107.  
  108. /**
  109. * Load Genesis
  110. *
  111. * This is technically not needed.
  112. * However, to make functions.php snippets useful, it is necessary.
  113. */
  114. require_once( get_template_directory() . '/lib/init.php' );
  115.  
  116. /**
  117. * Register a custom callback to style the custom header.
  118. *
  119. * @since 2.0.0
  120. */
  121. function innovative_admin_style() {
  122. $headimg = sprintf( '.site-header { background: url(%s) no-repeat center; min-height: %spx; }', get_header_image(), HEADER_IMAGE_HEIGHT );
  123. printf( '<style type="text/css">%1$s</style>', $headimg );
  124. }
  125.  
  126. /**
  127. * Modify the post info output.
  128. *
  129. * @since 2.0.0
  130. */
  131. function innovative_post_info_filter( $post_info ) {
  132. return '[post_date] &middot; by [post_author_posts_link] &middot; [post_comments] [post_edit]';
  133. }
  134.  
  135. /**
  136. * Modify the post meta output.
  137. *
  138. * @since 2.0.0
  139. */
  140. function innovative_post_meta_filter( $post_meta ) {
  141. return '[post_categories before="Filed Under: "] &#x00b7; [post_tags before="Tagged: "]';
  142. }
  143.  
  144. /**
  145. * Modify the search button text.
  146. *
  147. * @since 2.0.0
  148. */
  149. function innovative_search_button_text( $text ) {
  150. return esc_attr( 'Search' );
  151. }
  152.  
  153. /**
  154. * Change the comment form arguments.
  155. *
  156. * @since 2.0.0
  157. */
  158. function innovative_comment_text( $args ) {
  159. $args['title_reply'] = __( 'Speak Your Mind', 'innovative' );
  160. $args['comment_notes_before'] = '';
  161. $args['comment_notes_after'] = '';
  162. return $args;
  163. }
  164.  
  165. /**
  166. * Disable post image on archives.
  167. *
  168. * @since 2.0.0
  169. */
  170. function innovative_conditional_actions() {
  171. if( is_page_template( 'page_blog.php' ) && 'full' == genesis_get_option( 'content_archive' ) )
  172. remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 );
  173. }
  174.  
  175. /**
  176. * Register and enqueue Google Fonts.
  177. *
  178. * @since 2.0.0
  179. */
  180. function innovative_load_google_fonts() {
  181. wp_enqueue_style( 'innovative-google-fonts', 'http://fonts.googleapis.com/css?family=Rochester', array(), CHILD_THEME_VERSION );
  182. }
  183.  
  184. /**
  185. * Register and enqueue JavaScript Files.
  186. *
  187. * @since 2.0.0
  188. */
  189. function innovative_load_javascript() {
  190. wp_enqueue_script( 'innovative-mobile-menu', get_stylesheet_directory_uri() . '/js/mobile-menu.js', array('jquery'), CHILD_THEME_VERSION, true );
  191. }
  192.  
  193. /**
  194. * Registers sidebars for Innovative theme.
  195. *
  196. * @since 2.0.0
  197. */
  198. function innovative_sidebars() {
  199. genesis_register_sidebar( array(
  200. 'id' => 'home-top',
  201. 'name' => __( 'Home Top', 'innovative' ),
  202. 'description' => __( 'This is the home top section.', 'innovative' ),
  203. ) );
  204. genesis_register_sidebar( array(
  205. 'id' => 'home-left',
  206. 'name' => __( 'Home Left', 'innovative' ),
  207. 'description' => __( 'This is the home left section.', 'innovative' ),
  208. ) );
  209. genesis_register_sidebar( array(
  210. 'id' => 'home-right',
  211. 'name' => __( 'Home Right', 'innovative' ),
  212. 'description' => __( 'This is the home right section.', 'innovative' ),
  213. ) );
  214. genesis_register_sidebar( array(
  215. 'id' => 'home-bottom',
  216. 'name' => __( 'Home Bottom', 'innovative' ),
  217. 'description' => __( 'This is the home bottom section.', 'innovative' ),
  218. ) );
  219. }
  220.  
  221. /**
  222. * Customize the Credits Text
  223. *
  224. * @param string $creds_text Default Credits.
  225. * @return string Modified Pixelista Credits.
  226. *
  227. * @since 2.0.0
  228. */
  229. function innovative_footer_creds_text( $creds ) {
  230.  
  231. return sprintf(
  232. '[footer_copyright before="%s "] &#124; [footer_childtheme_link before=""] %s <a href="http://thepixelista.com">%s</a> &#124; %s [footer_genesis_link url="http://www.studiopress.com/" before=""]',
  233. __( 'Copyright', 'innovative' ),
  234. __( 'by', 'innovative' ),
  235. CHILD_THEME_DEVELOPER,
  236. __( 'Built on the ', 'innovative' )
  237. );
  238. return $output;
  239. }
  240. add_filter( 'the_content', 'add_related_posts_after_post_content' );
  241. function add_related_posts_after_post_content( $content ) {
  242.  
  243. //check if it's a single post page.
  244. if ( is_single() ) {
  245.  
  246. // check if we're inside the main loop
  247. if ( in_the_loop() && is_main_query() ) {
  248.  
  249. // use your own shortcode attributes here
  250. $shortcode = '[related_posts_by_tax posts_per_page="6" format="thumbnails" image_size="medium" columns="2"]';
  251.  
  252. // add the shortcode to the content
  253. $content .= do_shortcode( $shortcode );
  254. }
  255. }
  256.  
  257. return $content;
  258. }
Advertisement
Add Comment
Please, Sign In to add comment