Guest User

Untitled

a guest
Jun 6th, 2015
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.51 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. //* Include Google Fonts
  19. add_action( 'wp_enqueue_scripts', 'add_google_fonts' );
  20.  
  21. function add_google_fonts() {
  22. wp_enqueue_style( 'minimum-google-fonts', '//fonts.googleapis.com/css?family=Roboto:400,700', array() );
  23. }
  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.  
  46. }
  47.  
  48. //* Add featured image into the feed
  49. add_filter( 'the_content', 'featured_image_in_feed' );
  50. function featured_image_in_feed( $content ) {
  51. global $post;
  52. if( is_feed() ) {
  53. if ( has_post_thumbnail( $post->ID ) ){
  54. $output = get_the_post_thumbnail( $post->ID, 'large', array( 'style' => 'float:right; margin:0 0 10px 10px;' ) );
  55. $content = $output . $content;
  56. }
  57. }
  58. return $content;
  59. }
  60.  
  61. //* Add HTML5 markup structure
  62. add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list' ) );
  63.  
  64. //* Add viewport meta tag for mobile browsers
  65. add_theme_support( 'genesis-responsive-viewport' );
  66.  
  67. //* Add support for 3-column footer widgets
  68. add_theme_support( 'genesis-footer-widgets', 1 );
  69.  
  70. //* Reposition the primary navigation menu
  71. remove_action( 'genesis_after_header', 'genesis_do_nav' );
  72. add_action( 'genesis_before_content_sidebar_wrap', 'genesis_do_nav' );
  73.  
  74. //* Reposition the secondary navigation menu
  75. remove_action( 'genesis_after_header', 'genesis_do_subnav' );
  76. add_action( 'genesis_footer', 'genesis_do_subnav', 7 );
  77.  
  78. //* Reduce the secondary navigation menu to one level depth
  79. add_filter( 'wp_nav_menu_args', 'parallax_secondary_menu_args' );
  80. function parallax_secondary_menu_args( $args ){
  81.  
  82. if( 'secondary' != $args['theme_location'] )
  83. return $args;
  84.  
  85. $args['depth'] = 1;
  86. return $args;
  87.  
  88. }
  89.  
  90. //* Unregister layout settings
  91. genesis_unregister_layout( 'content-sidebar-sidebar' );
  92. genesis_unregister_layout( 'sidebar-content-sidebar' );
  93. genesis_unregister_layout( 'sidebar-sidebar-content' );
  94.  
  95. //* Add support for additional color styles
  96. add_theme_support( 'genesis-style-selector', array(
  97. 'parallax-pro-blue' => __( 'Parallax Pro Blue', 'parallax' ),
  98. 'parallax-pro-green' => __( 'Parallax Pro Green', 'parallax' ),
  99. 'parallax-pro-orange' => __( 'Parallax Pro Orange', 'parallax' ),
  100. 'parallax-pro-pink' => __( 'Parallax Pro Pink', 'parallax' ),
  101. ) );
  102.  
  103. //* Unregister secondary sidebar
  104. unregister_sidebar( 'sidebar-alt' );
  105.  
  106. //* Add support for custom header
  107. add_theme_support( 'custom-header', array(
  108. 'width' => 360,
  109. 'height' => 70,
  110. 'header-selector' => '.site-title a',
  111. 'header-text' => false,
  112. ) );
  113.  
  114. //* Add support for structural wraps
  115. add_theme_support( 'genesis-structural-wraps', array(
  116. 'header',
  117. 'nav',
  118. 'subnav',
  119. 'footer-widgets',
  120. 'footer',
  121. ) );
  122.  
  123. //* Hook after post widget after the entry content
  124. add_action( 'genesis_after_entry', 'parallax_after_entry', 5 );
  125. function parallax_after_entry() {
  126.  
  127. if ( is_singular( 'post' ) )
  128. genesis_widget_area( 'after-entry', array(
  129. 'before' => '<div class="after-entry widget-area">',
  130. 'after' => '</div>',
  131. ) );
  132.  
  133. }
  134.  
  135. //* Register widget areas
  136. genesis_register_sidebar( array(
  137. 'id' => 'home-section-1',
  138. 'name' => __( 'Home Section 1', 'parallax' ),
  139. 'description' => __( 'This is the home section 1 section.', 'parallax' ),
  140. ) );
  141. genesis_register_sidebar( array(
  142. 'id' => 'home-section-2',
  143. 'name' => __( 'Home Section 2', 'parallax' ),
  144. 'description' => __( 'This is the home section 2 section.', 'parallax' ),
  145. ) );
  146. genesis_register_sidebar( array(
  147. 'id' => 'home-section-3',
  148. 'name' => __( 'Home Section 3', 'parallax' ),
  149. 'description' => __( 'This is the home section 3 section.', 'parallax' ),
  150. ) );
  151. genesis_register_sidebar( array(
  152. 'id' => 'home-section-4',
  153. 'name' => __( 'Home Section 4', 'parallax' ),
  154. 'description' => __( 'This is the home section 4 section.', 'parallax' ),
  155. ) );
  156. genesis_register_sidebar( array(
  157. 'id' => 'home-section-5',
  158. 'name' => __( 'Home Section 5', 'parallax' ),
  159. 'description' => __( 'This is the home section 5 section.', 'parallax' ),
  160. ) );
  161. genesis_register_sidebar( array(
  162. 'id' => 'after-entry',
  163. 'name' => __( 'After Entry', 'parallax' ),
  164. 'description' => __( 'This is the after entry widget area.', 'parallax' ),
  165. ) );
  166.  
  167. //* Customize the post info function
  168. add_filter( 'genesis_post_info', 'sp_post_info_filter' );
  169. function sp_post_info_filter($post_info) {
  170. if ( !is_page() ) {
  171. $post_info = 'Posted on [post_date] by [post_author_posts_link] [post_comments] [post_edit]';
  172. return $post_info;
  173. }}
  174.  
  175. //* Relocate Post Title and Post Info
  176. add_action( 'genesis_after_header', 'sk_relocate_post_title_info');
  177. function sk_relocate_post_title_info() {
  178.  
  179. if ( is_singular('post' ) ) {
  180.  
  181. remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 );
  182. remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 );
  183. remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
  184. remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
  185.  
  186.  
  187. echo '<div class="featured-single"><div class="wrap">';
  188. genesis_entry_header_markup_open();
  189. genesis_do_post_title();
  190. genesis_post_info();
  191. genesis_entry_header_markup_close();
  192. echo '</div></div>';
  193.  
  194. }
  195.  
  196. }
  197.  
  198. //* Enqueue site-wide scripts
  199. add_action( 'wp_enqueue_scripts', 'custom_load_scripts' );
  200. function custom_load_scripts() {
  201.  
  202. if ( wp_is_mobile() ) {
  203. return;
  204. }
  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 setting the height of 'Featured Single' section so its background fills the viewport, adding the down arrow, and setting smooth scrolling speed
  229. wp_enqueue_script( 'singular', get_bloginfo( 'stylesheet_directory' ) . '/js/singular-scripts.js', array( 'jquery' ), '1.0.0', true );
  230.  
  231. }
  232.  
  233. }
  234.  
  235. //* Add an ID to .site-inner
  236. add_filter( 'genesis_attr_site-inner', 'custom_attributes_content' );
  237. function custom_attributes_content( $attributes ) {
  238.  
  239. if ( is_singular('post' ) ) {
  240. $attributes['id'] = 'site-inner';
  241. }
  242. return $attributes;
  243.  
  244. }
  245.  
  246. add_image_size( 'homepage-image', 1140, 450, TRUE );
  247.  
  248. add_image_size( 'custom-square-thumbnail', 800, 450, TRUE );
  249.  
  250. /**
  251. * Template Redirect
  252. * Use custom-archive.php for specified archives.
  253. * Props: Bill Erickson
  254. */
  255. add_filter( 'template_include', 'sk_template_redirect' );
  256. function sk_template_redirect( $template ) {
  257.  
  258. if ( is_category() || is_tag() )
  259. $template = get_query_template( 'custom-archive' );
  260. return $template;
  261.  
  262. }
  263.  
  264. //* Customize the credits
  265. add_filter( 'genesis_footer_creds_text', 'sp_footer_creds_text' );
  266. function sp_footer_creds_text() {
  267. echo '<div class="credsmenu"><p>';
  268. echo ' <a href="/about">About</a> &middot; <a href="/contact/" title="Contact Me">Contact</a> &middot; <a href="/feed/" title="RSS">Subscribe</a>';
  269. echo '</p></div>';
  270. echo '<div class="creds"><p>';
  271. echo 'Copyright &copy; ';
  272. echo date('Y');
  273. 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>';
  274. echo '</p></div>';
  275. }
  276.  
  277. //* Add social buttons after 1st paragraph
  278. function ads_added_above_last_p( $text ) {
  279. if( is_single() ) :
  280. $ads_text = '<div class="a" style="text-align: left;"><div class="opt-social_paragraph vertical-paragraph-top">
  281. <a class="opt-social_paragraph_link facebook" href="https://www.facebook.com/sharer/sharer.php" onclick="var sharerFb = \'https://www.facebook.com/sharer/sharer.php?u=\'; window.open(sharerFb + location.href, \'sharerFb\', \'width=626,height=436\'); return false;">Share</a>
  282. <a class="opt-social_paragraph_link twitter" href="https://twitter.com/share" onclick="var sharerTw = \'https://twitter.com/share?url=\'; window.open(sharerTw + location.href, \'sharerTw\', \'width=550,height=520\'); return false;">Tweet</a>
  283. <a class="opt-social_paragraph_link google" href="https://plus.google.com/share" onclick="var sharerGp = \'https://plus.google.com/share?url=\'; window.open(sharerGp + location.href, \'sharerGp\', \'width=840,height=464\'); return false;">+1</a>
  284. <a class="opt-social_paragraph_link reddit" href="http://www.reddit.com/submit" onclick="var sharerRd = \'http://www.reddit.com/submit?url=\'; window.open(sharerRd + location.href, \'sharerRd\', \'width=840,height=464\'); return false;">Submit</a>
  285. </div></div>';
  286. if( $pos1 = strpos( $text, '<p>', strpos( $text, '<p>' ) + 3 ) ){
  287. $text1 = substr( $text, 0, $pos1 );
  288. $text2 = substr( $text, $pos1 );
  289. $text = $text1 . $ads_text . $text2;
  290. }
  291. endif;
  292. return $text;
  293. }
  294. add_filter( 'the_content', 'ads_added_above_last_p' );
  295.  
  296. //* Helps to remove ? content for pageload
  297. function _remove_script_version( $src ){
  298. $parts = explode( '?ver', $src );
  299. return $parts[0];
  300. }
  301. add_filter( 'script_loader_src', '_remove_script_version', 15, 1 );
  302. add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );
  303.  
  304. //* Customize the post meta function
  305. add_filter( 'genesis_post_meta', 'sp_post_meta_filter' );
  306. function sp_post_meta_filter($post_meta) {
  307. if ( !is_page() ) {
  308. $post_meta = '[post_categories before="Filed Under: "] [post_tags before="Tagged: "]';
  309. return $post_meta;
  310. }}
Add Comment
Please, Sign In to add comment