Advertisement
Guest User

functions.php

a guest
Sep 21st, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.42 KB | None | 0 0
  1. <?php
  2. /**
  3. * Sets up theme defaults and registers support for various WordPress features.
  4. *
  5. * Note that this function is hooked into the after_setup_theme hook, which
  6. * runs before the init hook. The init hook is too late for some features, such
  7. * as indicating support for post thumbnails.
  8. */
  9. if ( ! function_exists( 'illdy_setup' ) ) {
  10. add_action( 'after_setup_theme', 'illdy_setup' );
  11. function illdy_setup() {
  12.  
  13. // Extras
  14. require_once trailingslashit( get_template_directory() ) . 'inc/extras.php';
  15.  
  16. // Customizer
  17. require_once trailingslashit( get_template_directory() ) . 'inc/customizer/customizer.php';
  18.  
  19. // JetPack
  20. require_once trailingslashit( get_template_directory() ) . 'inc/jetpack.php';
  21.  
  22. // Components
  23. require_once trailingslashit( get_template_directory() ) . 'inc/components/entry-meta/class-illdy-entry-meta-output.php';
  24. require_once trailingslashit( get_template_directory() ) . 'inc/components/author-box/class-illdy-author-box-output.php';
  25. require_once trailingslashit( get_template_directory() ) . 'inc/components/related-posts/class-illdy-related-posts-output.php';
  26.  
  27. // Load Theme Textdomain
  28. load_theme_textdomain( 'illdy', get_template_directory() . '/languages' );
  29.  
  30. // Add Theme Support
  31. add_theme_support( 'woocommerce' );
  32. add_theme_support( 'wc-product-gallery-zoom' );
  33. add_theme_support( 'wc-product-gallery-lightbox' );
  34. add_theme_support( 'wc-product-gallery-slider' );
  35.  
  36. add_theme_support( 'automatic-feed-links' );
  37. add_theme_support( 'title-tag' );
  38. add_theme_support( 'post-thumbnails' );
  39. add_theme_support( 'custom-logo', array(
  40. 'height' => 75,
  41. 'flex-height' => false,
  42. 'flex-width' => true,
  43. ) );
  44. add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption' ) );
  45. add_theme_support( 'custom-header', array(
  46. 'default-image' => esc_url( get_template_directory_uri() . '/layout/images/blog/blog-header.png' ),
  47. 'width' => 1920,
  48. 'height' => 532,
  49. 'flex-height' => true,
  50. 'flex-width' => true,
  51. 'random-default' => true,
  52. 'header-text' => false,
  53. ) );
  54. add_theme_support( 'customize-selective-refresh-widgets' );
  55. register_default_headers( array(
  56. 'default' => array(
  57. 'url' => '%s/layout/images/blog/blog-header.png',
  58. 'thumbnail_url' => '%s/layout/images/blog/blog-header.png',
  59. 'description' => __( 'Coffe', 'illdy' ),
  60. ),
  61. ) );
  62.  
  63. // Add Image Size
  64. add_image_size( 'illdy-blog-list', 750, 500, true );
  65. add_image_size( 'illdy-widget-recent-posts', 70, 70, true );
  66. add_image_size( 'illdy-blog-post-related-articles', 240, 206, true );
  67. add_image_size( 'illdy-front-page-latest-news', 250, 213, true );
  68. add_image_size( 'illdy-front-page-testimonials', 127, 127, true );
  69. add_image_size( 'illdy-front-page-projects', 476, 476, true );
  70. add_image_size( 'illdy-front-page-person', 125, 125, true );
  71.  
  72. // Register Nav Menus
  73. register_nav_menus( array(
  74. 'primary-menu' => __( 'Primary Menu', 'illdy' ),
  75. ) );
  76.  
  77. /**
  78. * Back compatible
  79. */
  80. require get_template_directory() . '/inc/back-compatible.php';
  81.  
  82. /*******************************************/
  83. /************* Welcome screen *************/
  84. /*******************************************/
  85.  
  86. }
  87.  
  88. // Add Editor Style
  89. add_editor_style( 'illdy-google-fonts' );
  90.  
  91. }// End if().
  92.  
  93. if ( ! function_exists( 'illdy_is_not_latest_posts' ) ) {
  94. function illdy_is_not_latest_posts() {
  95. return ( 'page' == get_option( 'show_on_front' ) ? true : false );
  96. }
  97. }
  98.  
  99. if ( ! function_exists( 'illdy_is_not_imported' ) ) {
  100. function illdy_is_not_imported() {
  101.  
  102. if ( defined( 'ILLDY_COMPANION' ) ) {
  103. $illdy_show_required_actions = get_option( 'illdy_show_required_actions' );
  104. if ( isset( $illdy_show_required_actions['illdy-req-import-content'] ) ) {
  105. return true;
  106. } else {
  107. return false;
  108. }
  109. } else {
  110. return true;
  111. }
  112.  
  113. }
  114. }
  115.  
  116.  
  117. /**
  118. * Set the content width in pixels, based on the theme's design and stylesheet.
  119. *
  120. * Priority 0 to make it available to lower priority callbacks.
  121. *
  122. * @global int $content_width
  123. */
  124. if ( ! function_exists( 'illdy_content_width' ) ) {
  125. add_action( 'after_setup_theme', 'illdy_content_width', 0 );
  126. function illdy_content_width() {
  127. $GLOBALS['content_width'] = apply_filters( 'illdy_content_width', 640 );
  128. }
  129. }
  130.  
  131. /**
  132. * WP Enqueue Stylesheets
  133. */
  134. if ( ! function_exists( 'illdy_enqueue_stylesheets' ) ) {
  135. add_action( 'wp_enqueue_scripts', 'illdy_enqueue_stylesheets' );
  136.  
  137. function illdy_enqueue_stylesheets() {
  138.  
  139. // Google Fonts
  140. $google_fonts_args = array(
  141. 'family' => 'Source+Sans+Pro:400,900,700,300,300italic|Lato:300,400,700,900|Poppins:300,400,500,600,700',
  142. );
  143.  
  144. // WP Register Style
  145. wp_register_style( 'illdy-google-fonts', add_query_arg( $google_fonts_args, 'https://fonts.googleapis.com/css' ), array(), null );
  146.  
  147. // WP Enqueue Style
  148. if ( 1 == get_theme_mod( 'illdy_preloader_enable', 1 ) && ! is_customize_preview() ) {
  149. wp_enqueue_style( 'illdy-pace', get_template_directory_uri() . '/layout/css/pace.min.css', array(), '', 'all' );
  150. }
  151.  
  152. wp_enqueue_style( 'illdy-google-fonts' );
  153. wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/layout/css/bootstrap.min.css', array(), '3.3.6', 'all' );
  154. wp_enqueue_style( 'bootstrap-theme', get_template_directory_uri() . '/layout/css/bootstrap-theme.min.css', array(), '3.3.6', 'all' );
  155. wp_enqueue_style( 'font-awesome', get_template_directory_uri() . '/layout/css/font-awesome.min.css', array(), '4.5.0', 'all' );
  156. wp_enqueue_style( 'owl-carousel', get_template_directory_uri() . '/layout/css/owl-carousel.min.css', array(), '2.0.0', 'all' );
  157. if ( get_theme_mod( 'illdy_projects_lightbox', 0 ) == 1 ) {
  158. wp_enqueue_style( 'illdy-fancybox', get_template_directory_uri() . '/layout/css/jquery.fancybox.css', array(), '', 'all' );
  159. }
  160. wp_enqueue_style( 'illdy-main', get_template_directory_uri() . '/layout/css/main.min.css', array(), '', 'all' );
  161. wp_enqueue_style( 'illdy-custom', get_template_directory_uri() . '/layout/css/custom.min.css', array(), '', 'all' );
  162. wp_enqueue_style( 'illdy-style', get_stylesheet_uri(), array(), '1.0.16', 'all' );
  163. }
  164. }
  165.  
  166.  
  167. /**
  168. * WP Enqueue JavaScripts
  169. */
  170. if ( ! function_exists( 'illdy_enqueue_javascripts' ) ) {
  171. add_action( 'wp_enqueue_scripts', 'illdy_enqueue_javascripts' );
  172.  
  173. function illdy_enqueue_javascripts() {
  174. if ( get_theme_mod( 'illdy_preloader_enable', 1 ) == 1 ) {
  175. wp_enqueue_script( 'illdy-pace', get_template_directory_uri() . '/layout/js/pace/pace.min.js', array( 'jquery' ), '', false );
  176. $pace_options = array(
  177. 'restartOnRequestAfter' => 0,
  178. 'restartOnPushState' => 0,
  179. );
  180. wp_localize_script( 'illdy-pace', 'paceOptions', $pace_options );
  181. }
  182. wp_enqueue_script( 'jquery-ui-progressbar', '', array( 'jquery' ), '', true );
  183. wp_enqueue_script( 'illdy-bootstrap', get_template_directory_uri() . '/layout/js/bootstrap/bootstrap.min.js', array( 'jquery' ), '3.3.6', true );
  184. wp_enqueue_script( 'illdy-owl-carousel', get_template_directory_uri() . '/layout/js/owl-carousel/owl-carousel.min.js', array( 'jquery' ), '2.0.0', true );
  185. wp_enqueue_script( 'illdy-count-to', get_template_directory_uri() . '/layout/js/count-to/count-to.min.js', array( 'jquery' ), '', true );
  186. wp_enqueue_script( 'illdy-visible', get_template_directory_uri() . '/layout/js/visible/visible.min.js', array( 'jquery' ), '', true );
  187. if ( get_theme_mod( 'illdy_projects_lightbox', 0 ) == 1 ) {
  188. wp_enqueue_script( 'illdy-fancybox', get_template_directory_uri() . '/layout/js/jquery.fancybox.js', array( 'jquery' ), '', true );
  189. wp_add_inline_script( 'illdy-fancybox', 'jQuery(".fancybox").fancybox();' );
  190. }
  191. wp_enqueue_script( 'illdy-parallax', get_template_directory_uri() . '/layout/js/parallax/parallax.min.js', array( 'jquery' ), '1.0.16', true );
  192. wp_enqueue_script( 'illdy-plugins', get_template_directory_uri() . '/layout/js/plugins.min.js', array( 'jquery' ), '1.0.16', true );
  193. wp_enqueue_script( 'illdy-scripts', get_template_directory_uri() . '/layout/js/scripts.min.js', array( 'jquery' ), '1.0.16', true );
  194. if ( is_front_page() ) {
  195. wp_add_inline_script( 'illdy-scripts', 'if( jQuery(\'.blog-carousel > .illdy-blog-post\').length > 3 ){jQuery(\'.blog-carousel\').owlCarousel({\'items\': 3,\'loop\': true,\'dots\': false,\'nav\' : true, \'navText\':[\'<i class="fa fa-angle-left" aria-hidden="true"></i>\',\'<i class="fa fa-angle-right" aria-hidden="true"></i>\'], responsive : { 0 : { items : 1 }, 480 : { items : 2 }, 900 : { items : 3 } }});}' );
  196. $jumbotron_type = get_theme_mod( 'illdy_jumbotron_background_type', 'image' );
  197. if ( 'video' == $jumbotron_type ) {
  198. wp_enqueue_script( 'wp-custom-header' );
  199. wp_localize_script( 'wp-custom-header', '_wpCustomHeaderSettings', illdy_get_video_settings() );
  200. }
  201. }
  202.  
  203. if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
  204. wp_enqueue_script( 'comment-reply' );
  205. }
  206. }
  207. }
  208.  
  209.  
  210. /**
  211. * Widgets
  212. */
  213. if ( ! function_exists( 'illdy_widgets' ) ) {
  214. add_action( 'widgets_init', 'illdy_widgets' );
  215.  
  216. function illdy_widgets() {
  217.  
  218. // Blog Sidebar
  219. register_sidebar( array(
  220. 'name' => __( 'Blog Sidebar', 'illdy' ),
  221. 'id' => 'blog-sidebar',
  222. 'description' => __( 'The widgets added in this sidebar will appear in blog page.', 'illdy' ),
  223. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  224. 'after_widget' => '</div>',
  225. 'before_title' => '<div class="widget-title"><h5>',
  226. 'after_title' => '</h5></div>',
  227. ) );
  228.  
  229. // Page Sidebar
  230. register_sidebar( array(
  231. 'name' => __( 'Page Sidebar', 'illdy' ),
  232. 'id' => 'page-sidebar',
  233. 'description' => __( 'The widgets added in this sidebar will appear on single pages.', 'illdy' ),
  234. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  235. 'after_widget' => '</div>',
  236. 'before_title' => '<div class="widget-title"><h5>',
  237. 'after_title' => '</h5></div>',
  238. ) );
  239.  
  240. // Footer Sidebar 1
  241. register_sidebar( array(
  242. 'name' => __( 'Footer Sidebar 1', 'illdy' ),
  243. 'id' => 'footer-sidebar-1',
  244. 'description' => __( 'The widgets added in this sidebar will appear in first block from footer.', 'illdy' ),
  245. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  246. 'after_widget' => '</div>',
  247. 'before_title' => '<div class="widget-title"><h5>',
  248. 'after_title' => '</h5></div>',
  249. ) );
  250.  
  251. // Footer Sidebar 2
  252. register_sidebar( array(
  253. 'name' => __( 'Footer Sidebar 2', 'illdy' ),
  254. 'id' => 'footer-sidebar-2',
  255. 'description' => __( 'The widgets added in this sidebar will appear in second block from footer.', 'illdy' ),
  256. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  257. 'after_widget' => '</div>',
  258. 'before_title' => '<div class="widget-title"><h5>',
  259. 'after_title' => '</h5></div>',
  260. ) );
  261.  
  262. // Footer Sidebar 3
  263. register_sidebar( array(
  264. 'name' => __( 'Footer Sidebar 3', 'illdy' ),
  265. 'id' => 'footer-sidebar-3',
  266. 'description' => __( 'The widgets added in this sidebar will appear in third block from footer.', 'illdy' ),
  267. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  268. 'after_widget' => '</div>',
  269. 'before_title' => '<div class="widget-title"><h5>',
  270. 'after_title' => '</h5></div>',
  271. ) );
  272.  
  273. // Footer Sidebar 4
  274. register_sidebar( array(
  275. 'name' => __( 'Footer Sidebar 4', 'illdy' ),
  276. 'id' => 'footer-sidebar-4',
  277. 'description' => __( 'The widgets added in this sidebar will appear in fourth block from footer.', 'illdy' ),
  278. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  279. 'after_widget' => '</div>',
  280. 'before_title' => '<div class="widget-title"><h5>',
  281. 'after_title' => '</h5></div>',
  282. ) );
  283.  
  284. // About Sidebar
  285. register_sidebar( array(
  286. 'name' => __( 'Front page - About Sidebar', 'illdy' ),
  287. 'id' => 'front-page-about-sidebar',
  288. 'description' => __( 'The widgets added in this sidebar will appear in about section from front page.', 'illdy' ),
  289. 'before_widget' => '<div id="%1$s" class="col-sm-4 col-sm-offset-0 col-xs-10 col-xs-offset-1 col-lg-4 col-lg-offset-0 %2$s">',
  290. 'after_widget' => '</div>',
  291. 'before_title' => '',
  292. 'after_title' => '',
  293. ) );
  294.  
  295. // Projects Sidebar
  296. register_sidebar( array(
  297. 'name' => __( 'Front page - Projects Sidebar', 'illdy' ),
  298. 'id' => 'front-page-projects-sidebar',
  299. 'description' => __( 'The widgets added in this sidebar will appear in projects section from front page.', 'illdy' ),
  300. 'before_widget' => '<div id="%1$s" class="col-sm-3 col-xs-6 no-padding %2$s">',
  301. 'after_widget' => '</div>',
  302. 'before_title' => '',
  303. 'after_title' => '',
  304. ) );
  305.  
  306. // Services Sidebar
  307. register_sidebar( array(
  308. 'name' => __( 'Front page - Services Sidebar', 'illdy' ),
  309. 'id' => 'front-page-services-sidebar',
  310. 'description' => __( 'The widgets added in this sidebar will appear in services section from front page.', 'illdy' ),
  311. 'before_widget' => '<div id="%1$s" class="col-sm-4 %2$s">',
  312. 'after_widget' => '</div>',
  313. 'before_title' => '',
  314. 'after_title' => '',
  315. ) );
  316.  
  317. // Counter Sidebar
  318. register_sidebar( array(
  319. 'name' => __( 'Front page - Counter Sidebar', 'illdy' ),
  320. 'id' => 'front-page-counter-sidebar',
  321. 'description' => __( 'The widgets added in this sidebar will appear in counter section from front page.', 'illdy' ),
  322. 'before_widget' => '<div id="%1$s" class="col-sm-4 col-xs-12 %2$s">',
  323. 'after_widget' => '</div>',
  324. 'before_title' => '',
  325. 'after_title' => '',
  326. ) );
  327.  
  328. // Team Sidebar
  329. register_sidebar( array(
  330. 'name' => __( 'Front page - Team Sidebar', 'illdy' ),
  331. 'id' => 'front-page-team-sidebar',
  332. 'description' => __( 'The widgets added in this sidebar will appear in team section from front page.', 'illdy' ),
  333. 'before_widget' => '<div id="%1$s" class="col-sm-4 col-sm-offset-0 col-xs-10 col-xs-offset-1 %2$s">',
  334. 'after_widget' => '</div>',
  335. 'before_title' => '',
  336. 'after_title' => '',
  337. ) );
  338.  
  339. // Full Width
  340. register_sidebar( array(
  341. 'name' => __( 'Front page - Full Width Section', 'illdy' ),
  342. 'id' => 'front-page-full-width-sidebar',
  343. 'description' => __( 'The widgets added in this sidebar will appear in full width section from front page.', 'illdy' ),
  344. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  345. 'after_widget' => '</div>',
  346. 'before_title' => '<div class="widget-title"><h5>',
  347. 'after_title' => '</h5></div>',
  348. ) );
  349.  
  350. // Testimonial Sidebar
  351. register_sidebar( array(
  352. 'name' => __( 'Front page - Testimonials Sidebar', 'illdy' ),
  353. 'id' => 'front-page-testimonials-sidebar',
  354. 'description' => __( 'The widgets added in this sidebar will appear in testimonials section from front page.', 'illdy' ),
  355. 'before_widget' => '<div id="%1$s" class="%2$s">',
  356. 'after_widget' => '</div>',
  357. 'before_title' => '',
  358. 'after_title' => '',
  359. ) );
  360.  
  361. // WooCommerce Sidebar
  362. if ( class_exists( 'WooCommerce' ) ) {
  363. register_sidebar( array(
  364. 'name' => __( 'WooCommerce Sidebar', 'illdy' ),
  365. 'id' => 'woocommerce-sidebar',
  366. 'description' => __( 'The widgets added in this sidebar will appear in WooCommerce pages.', 'illdy' ),
  367. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  368. 'after_widget' => '</div>',
  369. 'before_title' => '<div class="widget-title"><h5>',
  370. 'after_title' => '</h5></div>',
  371. ) );
  372. }
  373. }
  374. }// End if().
  375.  
  376.  
  377. /**
  378. * Checkbox helper function
  379. */
  380. if ( ! function_exists( 'illdy_value_checkbox_helper' ) ) {
  381. function illdy_value_checkbox_helper( $value ) {
  382. if ( 1 == $value ) {
  383. return 1;
  384. } else {
  385. return 0;
  386. }
  387. }
  388. }
  389.  
  390. add_action( 'illdy_after_content_above_footer', 'illdy_pagination', 1 );
  391.  
  392. function illdy_pagination() {
  393. the_posts_pagination( array(
  394. 'prev_text' => '<i class="fa fa-angle-left"></i>',
  395. 'next_text' => '<i class="fa fa-angle-right"></i>',
  396. 'screen_reader_text' => '',
  397. ) );
  398. }
  399.  
  400.  
  401. if ( ! function_exists( 'illdy_get_random_featured_image' ) ) {
  402. function illdy_get_random_featured_image() {
  403. $featured_image_list = array(
  404. 'random-blog-post-1.jpg',
  405. 'random-blog-post-2.jpg',
  406. 'random-blog-post-3.jpg',
  407. 'random-blog-post-4.jpg',
  408. 'random-blog-post-5.jpg',
  409. );
  410. $number = rand( 0,4 );
  411. return get_template_directory_uri() . '/layout/images/blog/' . $featured_image_list[ $number ];
  412. }
  413. }
  414.  
  415. if ( ! function_exists( 'illdy_get_recommended_actions_url' ) ) {
  416. function illdy_get_recommended_actions_url() {
  417. return self_admin_url( 'themes.php?page=illdy-welcome&tab=recommended_actions' );
  418. }
  419. }
  420.  
  421. function logo_size_change(){
  422. remove_theme_support( 'custom-logo' );
  423. add_theme_support( 'custom-logo', array(
  424. 'height' => 100,
  425. 'width' => 400,
  426. 'flex-height' => false,
  427. 'flex-width' => false,
  428. ) );
  429. }
  430.  
  431. add_action( 'after_setup_theme', 'logo_size_change', 11
  432.  
  433. // Include theme files
  434. require get_template_directory() . '/inc/libraries/epsilon-framework/class-epsilon-autoloader.php';
  435. require get_template_directory() . '/inc/class-mt-notify-system.php';
  436. require get_template_directory() . '/inc/libraries/welcome-screen/class-epsilon-welcome-screen.php';
  437. require get_template_directory() . '/inc/class-illdy.php';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement