BitofWP

functions.php Parallax Pro

Jan 20th, 2020
411
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.36 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.  
  14. add_action( 'after_switch_theme', 'init_theme_settings');
  15.  
  16. function init_theme_settings(){
  17. $genesis_settings = get_option('genesis-settings');
  18. $genesis_settings['site_layout'] = "content-sidebar";
  19. update_option('genesis-settings', $genesis_settings);
  20.  
  21. $theme_mod = get_theme_mod("nav_menu_locations");
  22. $theme_mod["secondary"] = 0;
  23. $theme_mod["primary"] = 0;
  24. set_theme_mod("nav_menu_locations", $theme_mod);
  25. }
  26.  
  27. function parallax_customizer(){
  28.  
  29. require_once( get_stylesheet_directory() . '/lib/customize.php' );
  30.  
  31. }
  32.  
  33. //* Include Section Image CSS
  34. include_once( get_stylesheet_directory() . '/lib/output.php' );
  35.  
  36. //* Child theme (do not remove)
  37. define( 'CHILD_THEME_NAME', 'Parallax Pro Theme' );
  38. define( 'CHILD_THEME_URL', 'http://my.studiopress.com/themes/parallax/' );
  39. define( 'CHILD_THEME_VERSION', '1.2' );
  40.  
  41. //* Enqueue scripts and styles
  42. add_action( 'wp_enqueue_scripts', 'parallax_enqueue_scripts_styles' );
  43. function parallax_enqueue_scripts_styles() {
  44.  
  45. wp_enqueue_script( 'parallax-responsive-menu', get_bloginfo( 'stylesheet_directory' ) . '/js/responsive-menu.js', array( 'jquery' ), '1.0.0' );
  46.  
  47. wp_enqueue_style( 'dashicons' );
  48. wp_enqueue_style( 'parallax-google-fonts', '//fonts.googleapis.com/css?family=Montserrat|Sorts+Mill+Goudy', array(), CHILD_THEME_VERSION );
  49.  
  50. }
  51.  
  52. //* Add HTML5 markup structure
  53. add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption' ) );
  54.  
  55. //* Add viewport meta tag for mobile browsers
  56. add_theme_support( 'genesis-responsive-viewport' );
  57.  
  58. //* Reposition the primary navigation menu
  59. remove_action( 'genesis_after_header', 'genesis_do_nav' );
  60. add_action( 'genesis_before_content_sidebar_wrap', 'genesis_do_nav' );
  61.  
  62. //* Reposition the secondary navigation menu
  63. remove_action( 'genesis_after_header', 'genesis_do_subnav' );
  64. add_action( 'genesis_footer', 'genesis_do_subnav', 7 );
  65.  
  66. //* Reduce the secondary navigation menu to one level depth
  67. add_filter( 'wp_nav_menu_args', 'parallax_secondary_menu_args' );
  68. function parallax_secondary_menu_args( $args ){
  69.  
  70. if( 'secondary' != $args['theme_location'] )
  71. return $args;
  72.  
  73. $args['depth'] = 1;
  74. return $args;
  75.  
  76. }
  77.  
  78. //* Unregister layout settings
  79. genesis_unregister_layout( 'content-sidebar-sidebar' );
  80. genesis_unregister_layout( 'sidebar-content-sidebar' );
  81. genesis_unregister_layout( 'sidebar-sidebar-content' );
  82.  
  83. //* Add support for additional color styles
  84. add_theme_support( 'genesis-style-selector', array(
  85. 'parallax-pro-blue' => __( 'Parallax Pro Blue', 'parallax' ),
  86. 'parallax-pro-green' => __( 'Parallax Pro Green', 'parallax' ),
  87. 'parallax-pro-orange' => __( 'Parallax Pro Orange', 'parallax' ),
  88. 'parallax-pro-pink' => __( 'Parallax Pro Pink', 'parallax' ),
  89. ) );
  90.  
  91. add_theme_support( 'custom-background' );
  92.  
  93. //* Unregister secondary sidebar
  94. unregister_sidebar( 'sidebar-alt' );
  95.  
  96. //* Add support for custom header
  97. add_theme_support( 'custom-header', array(
  98. 'width' => 360,
  99. 'height' => 70,
  100. 'header-selector' => '.site-title a',
  101. 'header-text' => false,
  102. ) );
  103.  
  104. //* Add support for structural wraps
  105. add_theme_support( 'genesis-structural-wraps', array(
  106. 'header',
  107. 'nav',
  108. 'subnav',
  109. 'footer-widgets',
  110. 'footer',
  111. ) );
  112.  
  113. //* Modify the size of the Gravatar in the author box
  114. add_filter( 'genesis_author_box_gravatar_size', 'parallax_author_box_gravatar' );
  115. function parallax_author_box_gravatar( $size ) {
  116.  
  117. return 176;
  118.  
  119. }
  120.  
  121. //* Modify the size of the Gravatar in the entry comments
  122. add_filter( 'genesis_comment_list_args', 'parallax_comments_gravatar' );
  123. function parallax_comments_gravatar( $args ) {
  124.  
  125. $args['avatar_size'] = 120;
  126.  
  127. return $args;
  128.  
  129. }
  130.  
  131. add_filter("widget_update_callback", "wid_update_function", 20, 4);
  132. add_filter( 'sidebar_admin_setup', 'wid_update_function', 20, 4);
  133. function wid_update_function($instance, $new_instance, $old_instance, $this){
  134. $section_base = "home-section-";
  135. for ($i=1; $i <= 5; $i++) {
  136. $index = $i-1;
  137. $parallax_settings = get_option("th_parallax_settings");
  138. if(is_active_sidebar($section_base.$i)){
  139. if(!$parallax_settings){
  140. $parallax_settings = array('max_blocks' => 5,
  141. 'blocks' => array(
  142. array('empty' => true),
  143. array('empty' => true),
  144. array('empty' => true),
  145. array('empty' => true),
  146. array('empty' => true)));
  147. $parallax_settings['blocks'][$index] = array('custom' => true);
  148. update_option("th_parallax_settings", $parallax_settings);
  149. }
  150. else{
  151. $parallax_settings['blocks'][$index] = array('custom' => true);
  152. update_option("th_parallax_settings", $parallax_settings);
  153. }
  154. }
  155. else{
  156. if(!$parallax_settings){
  157. $parallax_settings = array('max_blocks' => 5,
  158. 'blocks' => array(
  159. array('empty' => true),
  160. array('empty' => true),
  161. array('empty' => true),
  162. array('empty' => true),
  163. array('empty' => true)));
  164. update_option("th_parallax_settings", $parallax_settings);
  165. }
  166. else{
  167. if($parallax_settings['blocks'][$index]['custom']){
  168. $parallax_settings['blocks'][$index] = array('empty' => true);
  169. update_option("th_parallax_settings", $parallax_settings);
  170. }
  171. }
  172. }
  173. }
  174. return $instance;
  175. }
  176.  
  177.  
  178.  
  179. //* Add support for 3-column footer widgets
  180. add_theme_support( 'genesis-footer-widgets', 1 );
  181.  
  182. //* Add support for after entry widget
  183. add_theme_support( 'genesis-after-entry-widget-area' );
  184.  
  185. //* Relocate after entry widget
  186. remove_action( 'genesis_after_entry', 'genesis_after_entry_widget_area' );
  187. add_action( 'genesis_after_entry', 'genesis_after_entry_widget_area', 5 );
  188.  
  189. $parallax_settings = get_option("th_parallax_settings");
  190. if($parallax_settings){
  191. $parallax_settings["max_blocks"] = 5;
  192. }
  193. else{
  194. $home_page_id = get_option("page_on_front");
  195. $parallax_settings = array('max_blocks' => 5,
  196. 'blocks' => array(
  197. array('ID' => $home_page_id),
  198. array('empty' => true),
  199. array('empty' => true),
  200. array('empty' => true),
  201. array('empty' => true)));
  202. }
  203. update_option("th_parallax_settings", $parallax_settings);
  204.  
  205. //* Register widget areas
  206. genesis_register_sidebar( array(
  207. 'id' => 'home-section-1',
  208. 'name' => __( 'Home Section 1', 'parallax' ),
  209. 'description' => __( 'This is the home section 1 section.', 'parallax' ),
  210. ) );
  211. genesis_register_sidebar( array(
  212. 'id' => 'home-section-2',
  213. 'name' => __( 'Home Section 2', 'parallax' ),
  214. 'description' => __( 'This is the home section 2 section.', 'parallax' ),
  215. ) );
  216. genesis_register_sidebar( array(
  217. 'id' => 'home-section-3',
  218. 'name' => __( 'Home Section 3', 'parallax' ),
  219. 'description' => __( 'This is the home section 3 section.', 'parallax' ),
  220. ) );
  221. genesis_register_sidebar( array(
  222. 'id' => 'home-section-4',
  223. 'name' => __( 'Home Section 4', 'parallax' ),
  224. 'description' => __( 'This is the home section 4 section.', 'parallax' ),
  225. ) );
  226. genesis_register_sidebar( array(
  227. 'id' => 'home-section-5',
  228. 'name' => __( 'Home Section 5', 'parallax' ),
  229. 'description' => __( 'This is the home section 5 section.', 'parallax' ),
  230. ) );
  231.  
  232. /* Customize footer credits */
  233.  
  234. add_filter( 'genesis_footer_creds_text', 'custom_footer_creds_text' );
  235. function custom_footer_creds_text() {
  236. $address = str_replace( '</br>', '', get_option('th_company_address'));
  237. $name = get_option('blogname');
  238. echo '<div class="creds"><p>';
  239. echo 'Copyright &copy; ';
  240. echo date('Y');
  241. echo ' &middot; <a href="/">'.$name.'</a> &middot; '.$address.' &middot; Powered by <a href="http://www.wordpress.org" target="_new" title="ThriveHive" rel="nofollow">Wordpress</a>';
  242. echo '</p></div>';
  243. }
  244.  
  245. @add_theme_support( 'genesis-custom-header', array('flex-height' => true, 'width' => 300, 'height' => 88, 'header_image' => "http://www.www.site/wp-content/uploads/2025/12/image.png" ) );
Advertisement
Add Comment
Please, Sign In to add comment