Advertisement
Guest User

Untitled

a guest
May 19th, 2015
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.13 KB | None | 0 0
  1. <?php
  2. //* Start the engine
  3. include_once( get_template_directory() . '/lib/init.php' );
  4.  
  5. //* Setup Theme
  6. include_once( get_stylesheet_directory() . '/lib/theme-defaults.php' );
  7.  
  8. //* Set Localization (do not remove)
  9. load_child_theme_textdomain( 'parallax', apply_filters( 'child_theme_textdomain', get_stylesheet_directory() . '/languages', 'parallax' ) );
  10.  
  11. //* Add Image upload to WordPress Theme Customizer
  12. add_action( 'customize_register', 'parallax_customizer' );
  13. function parallax_customizer(){
  14.  
  15. require_once( get_stylesheet_directory() . '/lib/customize.php' );
  16.  
  17. }
  18.  
  19. //* Include Google Fonts
  20. add_action( 'wp_enqueue_scripts', 'add_google_fonts' );
  21.  
  22. function add_google_fonts() {
  23. wp_enqueue_style( 'minimum-google-fonts', '//fonts.googleapis.com/css?family=Roboto|Open+Sans|Lato|Oswald', array() );
  24. }
  25.  
  26. //* Display a custom favicon
  27. add_filter( 'genesis_pre_load_favicon', 'sp_favicon_filter' );
  28. function sp_favicon_filter( $favicon_url ) {
  29. return '/wp-content/themes/genesis/images/favicon.ico';
  30. }
  31.  
  32. //* Include Section Image CSS
  33. include_once( get_stylesheet_directory() . '/lib/output.php' );
  34.  
  35. //* Child theme (do not remove)
  36. define( 'CHILD_THEME_NAME', 'Parallax Pro Theme' );
  37. define( 'CHILD_THEME_URL', 'http://my.studiopress.com/themes/parallax/' );
  38. define( 'CHILD_THEME_VERSION', '1.1' );
  39.  
  40. //* Enqueue scripts and styles
  41. add_action( 'wp_enqueue_scripts', 'parallax_enqueue_scripts_styles' );
  42. function parallax_enqueue_scripts_styles() {
  43.  
  44. wp_enqueue_script( 'parallax-responsive-menu', get_bloginfo( 'stylesheet_directory' ) . '/js/responsive-menu.js', array( 'jquery' ), '1.0.0' );
  45. wp_enqueue_style( 'dashicons' );
  46. wp_enqueue_style( 'parallax-google-fonts', '//fonts.googleapis.com/css?family=Montserrat|Sorts+Mill+Goudy', array(), CHILD_THEME_VERSION );
  47.  
  48. }
  49.  
  50. //* Add featured image into the feed
  51. add_filter( 'the_content', 'featured_image_in_feed' );
  52. function featured_image_in_feed( $content ) {
  53. global $post;
  54. if( is_feed() ) {
  55. if ( has_post_thumbnail( $post->ID ) ){
  56. $output = get_the_post_thumbnail( $post->ID, 'large', array( 'style' => 'float:right; margin:0 0 10px 10px;' ) );
  57. $content = $output . $content;
  58. }
  59. }
  60. return $content;
  61. }
  62.  
  63. //* Add HTML5 markup structure
  64. add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list' ) );
  65.  
  66. //* Add viewport meta tag for mobile browsers
  67. add_theme_support( 'genesis-responsive-viewport' );
  68.  
  69. //* Add support for 3-column footer widgets
  70. add_theme_support( 'genesis-footer-widgets', 1 );
  71.  
  72. //* Reposition the primary navigation menu
  73. remove_action( 'genesis_after_header', 'genesis_do_nav' );
  74. add_action( 'genesis_before_content_sidebar_wrap', 'genesis_do_nav' );
  75.  
  76. //* Reposition the secondary navigation menu
  77. remove_action( 'genesis_after_header', 'genesis_do_subnav' );
  78. add_action( 'genesis_footer', 'genesis_do_subnav', 7 );
  79.  
  80. //* Reduce the secondary navigation menu to one level depth
  81. add_filter( 'wp_nav_menu_args', 'parallax_secondary_menu_args' );
  82. function parallax_secondary_menu_args( $args ){
  83.  
  84. if( 'secondary' != $args['theme_location'] )
  85. return $args;
  86.  
  87. $args['depth'] = 1;
  88. return $args;
  89.  
  90. }
  91.  
  92. //* Unregister layout settings
  93. genesis_unregister_layout( 'content-sidebar-sidebar' );
  94. genesis_unregister_layout( 'sidebar-content-sidebar' );
  95. genesis_unregister_layout( 'sidebar-sidebar-content' );
  96.  
  97. //* Add support for additional color styles
  98. add_theme_support( 'genesis-style-selector', array(
  99. 'parallax-pro-blue' => __( 'Parallax Pro Blue', 'parallax' ),
  100. 'parallax-pro-green' => __( 'Parallax Pro Green', 'parallax' ),
  101. 'parallax-pro-orange' => __( 'Parallax Pro Orange', 'parallax' ),
  102. 'parallax-pro-pink' => __( 'Parallax Pro Pink', 'parallax' ),
  103. ) );
  104.  
  105. //* Unregister secondary sidebar
  106. unregister_sidebar( 'sidebar-alt' );
  107.  
  108. //* Add support for custom header
  109. add_theme_support( 'custom-header', array(
  110. 'width' => 360,
  111. 'height' => 70,
  112. 'header-selector' => '.site-title a',
  113. 'header-text' => false,
  114. ) );
  115.  
  116. //* Add support for structural wraps
  117. add_theme_support( 'genesis-structural-wraps', array(
  118. 'header',
  119. 'nav',
  120. 'subnav',
  121. 'footer-widgets',
  122. 'footer',
  123. ) );
  124.  
  125. //* Hook after post widget after the entry content
  126. add_action( 'genesis_after_entry', 'parallax_after_entry', 5 );
  127. function parallax_after_entry() {
  128.  
  129. if ( is_singular( 'post' ) )
  130. genesis_widget_area( 'after-entry', array(
  131. 'before' => '<div class="after-entry widget-area">',
  132. 'after' => '</div>',
  133. ) );
  134.  
  135. }
  136.  
  137. //* Register widget areas
  138. genesis_register_sidebar( array(
  139. 'id' => 'home-section-1',
  140. 'name' => __( 'Home Section 1', 'parallax' ),
  141. 'description' => __( 'This is the home section 1 section.', 'parallax' ),
  142. ) );
  143. genesis_register_sidebar( array(
  144. 'id' => 'home-section-2',
  145. 'name' => __( 'Home Section 2', 'parallax' ),
  146. 'description' => __( 'This is the home section 2 section.', 'parallax' ),
  147. ) );
  148. genesis_register_sidebar( array(
  149. 'id' => 'home-section-3',
  150. 'name' => __( 'Home Section 3', 'parallax' ),
  151. 'description' => __( 'This is the home section 3 section.', 'parallax' ),
  152. ) );
  153. genesis_register_sidebar( array(
  154. 'id' => 'home-section-4',
  155. 'name' => __( 'Home Section 4', 'parallax' ),
  156. 'description' => __( 'This is the home section 4 section.', 'parallax' ),
  157. ) );
  158. genesis_register_sidebar( array(
  159. 'id' => 'home-section-5',
  160. 'name' => __( 'Home Section 5', 'parallax' ),
  161. 'description' => __( 'This is the home section 5 section.', 'parallax' ),
  162. ) );
  163. genesis_register_sidebar( array(
  164. 'id' => 'after-entry',
  165. 'name' => __( 'After Entry', 'parallax' ),
  166. 'description' => __( 'This is the after entry widget area.', 'parallax' ),
  167. ) );
  168.  
  169. //* Customize the post info function
  170. add_filter( 'genesis_post_info', 'sp_post_info_filter' );
  171. function sp_post_info_filter($post_info) {
  172. if ( !is_page() ) {
  173. $post_info = 'Posted on [post_date] by [post_author_posts_link] [post_comments] [post_edit]';
  174. return $post_info;
  175. }}
  176.  
  177. //* Relocate Post Title and Post Info
  178. add_action( 'genesis_after_header', 'sk_relocate_post_title_info');
  179. function sk_relocate_post_title_info() {
  180.  
  181. if ( is_singular('post' ) ) {
  182.  
  183. remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 );
  184. remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 );
  185. remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
  186. remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
  187.  
  188.  
  189. echo '<div class="featured-single"><div class="wrap">';
  190. genesis_entry_header_markup_open();
  191. genesis_do_post_title();
  192. genesis_post_info();
  193. genesis_entry_header_markup_close();
  194. echo '</div></div>';
  195.  
  196. }
  197.  
  198. }
  199.  
  200. //* Enqueue site-wide scripts
  201. add_action( 'wp_enqueue_scripts', 'custom_load_scripts' );
  202. function custom_load_scripts() {
  203.  
  204. wp_enqueue_style( 'dashicons' );
  205.  
  206. wp_enqueue_script( 'header-fade', get_bloginfo( 'stylesheet_directory' ) . '/js/header-fade.js', array( 'jquery' ), '1.0.0', true );
  207.  
  208. }
  209.  
  210. //* Enqueue scripts on single Post pages
  211. add_action( 'wp_enqueue_scripts', 'enqueue_singular' );
  212. function enqueue_singular() {
  213.  
  214. if ( is_singular('post' ) ) {
  215.  
  216. // to add a dynamically-resized background image to .featured-single
  217. wp_enqueue_script( 'backstretch', get_stylesheet_directory_uri() . '/js/jquery.backstretch.min.js', array( 'jquery' ), '', true );
  218. wp_enqueue_script( 'backstretch-init', get_stylesheet_directory_uri() . '/js/backstretch-init.js', array( 'backstretch' ), '1.0.0', true );
  219.  
  220. // if the post has a featured image, send it to Backstretch else use a default one
  221. if ( has_post_thumbnail() ) {
  222. wp_localize_script( 'backstretch-init', 'BackStretchImg', array( 'src' => wp_get_attachment_url( get_post_thumbnail_id() ) ) );
  223. }
  224. else {
  225. wp_localize_script( 'backstretch-init', 'BackStretchImg', array( 'src' => '/wp-content/themes/parallax-pro/images/bg-1.jpg' ) );
  226. }
  227.  
  228. // for smooth scrolling when the down arrow is clicked
  229. wp_enqueue_script( 'scrollTo', get_stylesheet_directory_uri() . '/js/jquery.scrollTo.min.js', array( 'jquery' ), '', true );
  230. wp_enqueue_script( 'localScroll', get_stylesheet_directory_uri() . '/js/jquery.localScroll.min.js', array( 'scrollTo' ), '', true );
  231.  
  232. // for setting the height of 'Featured Single' section so its background fills the viewport, adding the down arrow, and setting smooth scrolling speed
  233. wp_enqueue_script( 'singular', get_bloginfo( 'stylesheet_directory' ) . '/js/singular-scripts.js', array( 'jquery' ), '1.0.0', true );
  234.  
  235. // for fading away Post title and info when scrolling down and fading in when scrolling up
  236. wp_enqueue_script( 'fade-on-scroll', get_stylesheet_directory_uri() . '/js/fade-on-scroll.js', array( 'scrollTo' ), '1.0.0', true );
  237.  
  238. }
  239.  
  240. }
  241.  
  242. //* Add a ID to .site-inner
  243. add_filter( 'genesis_attr_site-inner', 'custom_attributes_content' );
  244. function custom_attributes_content( $attributes ) {
  245.  
  246. if ( is_singular('post' ) ) {
  247. $attributes['id'] = 'site-inner';
  248. }
  249. return $attributes;
  250.  
  251. }
  252.  
  253. add_image_size( 'homepage-image', 1140, 450, TRUE );
  254.  
  255. add_image_size( 'custom-square-thumbnail', 800, 450, TRUE );
  256.  
  257. /**
  258. * Template Redirect
  259. * Use custom-archive.php for specified archives.
  260. * Props: Bill Erickson
  261. */
  262. add_filter( 'template_include', 'sk_template_redirect' );
  263. function sk_template_redirect( $template ) {
  264.  
  265. if ( is_category() || is_tag() )
  266. $template = get_query_template( 'custom-archive' );
  267. return $template;
  268.  
  269. }
  270.  
  271. // Enable Agency Like Featured Posts after Post
  272. add_image_size( 'agency-after-entry', 187, 130, TRUE );
  273.  
  274. genesis_register_sidebar( array(
  275. 'id' => 'agency-after-entry',
  276. 'name' => __( 'Agency-like Featured After Entry', 'theme-name' ),
  277. 'description' => __( 'This is the agency like featured posts section.', 'theme-name' ),
  278. ) );
  279.  
  280. add_action( 'genesis_after_entry', 'ms_featured_posts' );
  281. function ms_featured_posts() {
  282.  
  283. if ( is_singular('post' ) ) {
  284.  
  285. genesis_widget_area( 'agency-after-entry', array(
  286. 'before' => '<div class="agency-like-featured-posts-entry widget-area"><div class="wrap">',
  287. 'after' => '</div></div>',
  288. ) );
  289.  
  290. }
  291.  
  292. }
  293.  
  294. //* Customize the post meta function
  295. add_filter( 'genesis_post_meta', 'sp_post_meta_filter' );
  296. function sp_post_meta_filter($post_meta) {
  297. if ( !is_page() ) {
  298. $post_meta = '[post_categories before="Filed Under: "] [post_tags before="Tagged: "]';
  299. return $post_meta;
  300. }}
  301.  
  302. //* Customize the credits
  303. add_filter( 'genesis_footer_creds_text', 'sp_footer_creds_text' );
  304. function sp_footer_creds_text() {
  305. echo '<div class="credsmenu"><p>';
  306. echo ' <a href="/about">About</a> &middot; <a href="/contact/" title="Contact Me">Contact</a> &middot; <a href="/feed/" title="RSS">Subscribe</a>';
  307. echo '</p></div>';
  308. echo '<div class="creds"><p>';
  309. echo 'Copyright &copy; ';
  310. echo date('Y');
  311. echo ' &middot; <a href="http://www.geekdaily.co">Geek Daily</a> &middot; Built on the <a href="http://www.geekdaily.co/go/genesis/" title="Genesis Framework">Genesis Framework</a> &middot; And Hosted By <a href="http://getflywheel.com" title="Flywheel">Flywheel</a>';
  312. echo '</p></div>';
  313. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement