functions.php 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <?php
  2. // Global variables define
  3. define('SPICE_SOFTWARE_DARK_PARENT_TEMPLATE_DIR_URI', get_template_directory_uri());
  4. define('SPICE_SOFTWARE_DARK_TEMPLATE_DIR_URI', get_stylesheet_directory_uri());
  5. define('SPICE_SOFTWARE_DARK_CHILD_TEMPLATE_DIR', trailingslashit(get_stylesheet_directory()));
  6. if (!function_exists('wp_body_open')) {
  7. function wp_body_open() {
  8. /**
  9. * Triggered after the opening <body> tag.
  10. */
  11. do_action('wp_body_open');
  12. }
  13. }
  14. add_action('after_setup_theme', 'spice_software_dark_setup');
  15. function spice_software_dark_setup() {
  16. load_theme_textdomain('spice-software-dark', SPICE_SOFTWARE_DARK_CHILD_TEMPLATE_DIR . '/languages');
  17. /*
  18. * Let WordPress manage the document title.
  19. */
  20. add_theme_support('title-tag');
  21. // Add default posts and comments RSS feed links to head.
  22. add_theme_support('automatic-feed-links');
  23. //About Theme
  24. if(!function_exists( 'spice_software_plus_activate' )) :
  25. $theme = wp_get_theme(); // gets the current theme
  26. if ( 'Spice Software Dark' == $theme->name)
  27. {
  28. if ( is_admin() )
  29. {
  30. require SPICE_SOFTWARE_DARK_CHILD_TEMPLATE_DIR . '/admin/admin-init.php';
  31. }
  32. }
  33. endif;
  34. }
  35. add_action('wp_enqueue_scripts', 'spice_software_dark_enqueue_styles',11);
  36. function spice_software_dark_enqueue_styles() {
  37. wp_enqueue_style('spice-software-dark-parent-style', SPICE_SOFTWARE_DARK_PARENT_TEMPLATE_DIR_URI . '/style.css', array('bootstrap'));
  38. wp_style_add_data('spice-software-dark-parent-style', 'rtl', 'replace' );
  39. wp_style_add_data('spice-software-dark-style', 'rtl', 'replace' );
  40. wp_dequeue_style( 'spice-software-default');
  41. if (get_theme_mod('custom_color_enable') == true) {
  42. spice_software_dark_custom_light();
  43. }
  44. else {
  45. wp_enqueue_style('spice-software-dark-default-style', SPICE_SOFTWARE_DARK_TEMPLATE_DIR_URI . '/assets/css/default.css');
  46. }
  47. wp_enqueue_style('spice-software-dark-css', SPICE_SOFTWARE_DARK_TEMPLATE_DIR_URI . '/assets/css/dark.css');
  48. }
  49. function spice_software_dark_sanitize_checkbox( $checked ) {
  50. // Boolean check.
  51. return ( ( isset( $checked ) && true == $checked ) ? true : false );
  52. }
  53. if ( ! function_exists( 'spice_software_plus_activate' ) ):
  54. function spic_software_dark_sidebar_enable_customizer($wp_customize) {
  55. $wp_customize->add_setting(
  56. 'apply_dark_content_enable',array(
  57. 'capability' => 'edit_theme_options',
  58. 'default' => false,
  59. 'sanitize_callback' => 'spice_software_dark_sanitize_checkbox',
  60. ));
  61. $wp_customize->add_control(
  62. 'apply_dark_content_enable',
  63. array(
  64. 'type' => 'checkbox',
  65. 'label' => esc_html__('Click here to apply these settings', 'spice-software-dark'),
  66. 'section' => 'content_color_settings',
  67. 'priority' => '1',
  68. )
  69. );
  70. // link color settings
  71. $wp_customize->add_setting('link_color', array(
  72. 'capability' => 'edit_theme_options',
  73. 'default' => '#D3A656',
  74. 'sanitize_callback' => 'sanitize_hex_color'
  75. ));
  76. $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize,'link_color',
  77. array(
  78. 'label' => esc_html__( 'Skin Color', 'spice-software-dark' ),
  79. 'section' => 'theme_style',
  80. 'settings' => 'link_color',
  81. ) ) );
  82. }
  83. add_action('customize_register', 'spic_software_dark_sidebar_enable_customizer',11);
  84. endif;
  85. function spice_software_dark_custom_style(){?>
  86. <style type="text/css">
  87. <?php if(get_theme_mod('apply_dark_content_enable',false)==true) : ?>
  88. /* Content */
  89. body h1,body.dark h1 {
  90. color: <?php echo esc_attr(get_theme_mod('h1_color', '#333333')); ?> ;
  91. }
  92. body .section-header h2:not(.testimonial h2, .funfact h2), body h2:not(.testimonial h2, .funfact h2),body.dark .section-header h2.section-title{
  93. color: <?php echo esc_attr(get_theme_mod('h2_color', '#333333')); ?>;
  94. }
  95. body h3,body.dark h3 {
  96. color: <?php echo esc_attr(get_theme_mod('h3_color', '#333333')); ?>;
  97. }
  98. body .entry-header h4 > a:not(.blog-title), body h4, .section-space.contact-detail .contact-area h4,.services h4.entry-title a,body.dark h4{
  99. color: <?php echo esc_attr(get_theme_mod('h4_color', '#727272')); ?>;
  100. }
  101. body .blog-author h5, body .comment-detail h5, body h5,body.dark h5,body.dark .section-header .section-subtitle{
  102. color: <?php echo esc_attr(get_theme_mod('h5_color', '#1c314c')); ?>;
  103. }
  104. .section-header h5.section-subtitle{
  105. color: <?php echo esc_attr(get_theme_mod('h5_color', '#777777')); ?>;
  106. }
  107. body .product-price h5 > a{
  108. color: <?php echo esc_attr(get_theme_mod('h5_color', '#00BFFF')); ?>;
  109. }
  110. body h6, .section-space.contact-detail .contact-area h6, body.dark h6{
  111. color: <?php echo esc_attr(get_theme_mod('h6_color', '#727272')); ?>;
  112. }
  113. p:not(.woocommerce-mini-cart__total, .slider-caption .description, .site-description, .testimonial p, .funfact p,.sidebar p,.footer-sidebar p){
  114. color: <?php echo esc_attr(get_theme_mod('p_color', '#777777')); ?>;
  115. }
  116. <?php endif;?>
  117. <?php if (get_theme_mod('header_clr_enable', false) == true) : ?>
  118. /* Site Title & Tagline */
  119. body .site-title a{
  120. color: <?php echo esc_attr(get_theme_mod('site_title_link_color', '#061018')); ?>;
  121. }
  122. <?php endif; ?>
  123. <?php if (get_theme_mod('apply_menu_clr_enable', false) == true) : ?>
  124. .navbar.custom .nav .nav-item:hover .nav-link, .navbar.custom .nav .nav-item.active .nav-link:hover {
  125. color: <?php echo esc_attr(get_theme_mod('menus_link_hover_color', '#00BFFF')); ?>!important;
  126. }
  127. <?php endif;?>
  128. <?php
  129. if (get_theme_mod('testimonial_image_overlay', true) != false) {
  130. $testimonial_overlay_section_color = get_theme_mod('testimonial_overlay_section_color', 'rgba(1, 7, 12, 0.8)');?>
  131. .testi-4:before {
  132. background-color: <?php echo esc_attr($testimonial_overlay_section_color); ?>;
  133. }
  134. <?php } ?>
  135. </style>
  136. <?php
  137. }
  138. add_action('wp_head','spice_software_dark_custom_style');
  139. function spice_software_dark_footer_section_hook() {
  140. ?>
  141. <footer class="site-footer">
  142. <div class="container">
  143. <?php if (is_active_sidebar('footer-sidebar-1') || is_active_sidebar('footer-sidebar-2') || is_active_sidebar('footer-sidebar-3') | is_active_sidebar('footer-sidebar-4')): ?>
  144. <?php get_template_part('sidebar', 'footer');
  145. endif;?>
  146. </div>
  147. <!-- Animation lines-->
  148. <div _ngcontent-kga-c2="" class="lines">
  149. <div _ngcontent-kga-c2="" class="line"></div>
  150. <div _ngcontent-kga-c2="" class="line"></div>
  151. <div _ngcontent-kga-c2="" class="line"></div>
  152. </div>
  153. <!--/ Animation lines-->
  154. <?php if (get_theme_mod('ftr_bar_enable', true) == true): ?>
  155. <div class="site-info text-center">
  156. <?php echo wp_kses_post(get_theme_mod('footer_copyright', '<span class="copyright">'.__( 'Proudly powered by <a href="https://wordpress.org">WordPress</a> | Theme: <a href="https://spicethemes.com/spice-software-dark-wordpress-theme" rel="nofollow">Spice Software Dark</a> by <a href="https://spicethemes.com" rel="nofollow">Spicethemes</a>', 'spice-software-dark').'</span>')); ?>
  157. </div>
  158. <?php endif; ?>
  159. </footer>
  160. <?php
  161. $scrolltotop_setting_enable = get_theme_mod('scrolltotop_setting_enable', true);
  162. if ($scrolltotop_setting_enable == true) {
  163. ?>
  164. <div class="scroll-up custom right"><a href="#totop"><i class="fa fa-arrow-up"></i></a></div>
  165. <?php }
  166. }
  167. add_action('spice_software_dark_footer_section_hook', 'spice_software_dark_footer_section_hook');
  168. //Add custom color function
  169. function spice_software_dark_custom_light() {
  170. $spice_software_dark_link_color = get_theme_mod('link_color','#D3A656');
  171. list($r, $g, $b) = sscanf($spice_software_dark_link_color, "#%02x%02x%02x");
  172. $r = $r - 50;
  173. $g = $g - 25;
  174. $b = $b - 40;
  175. if ( $spice_software_dark_link_color != '#ff0000' ) :?>
  176. <style type="text/css">
  177. .dark .entry-meta a:hover {
  178. color: <?php echo esc_attr($spice_software_dark_link_color); ?>;
  179. }
  180. .dark .widget .search-submit, .widget .search-field [type=submit], .wp-block-search__button:after,.wp-block-search__label,.sidebar .wp-block-search .wp-block-search__label, .sidebar .widget.widget_block h1, .sidebar .widget.widget_block h2, .sidebar .widget.widget_block h3, .sidebar .widget.widget_block h4, .sidebar .widget.widget_block h5, .sidebar .widget.widget_block h6{
  181. color: <?php echo esc_attr($spice_software_dark_link_color); ?>;
  182. }
  183. .widget .wp-block-tag-cloud a:hover {
  184. color: <?php echo esc_attr($spice_software_dark_link_color); ?>;
  185. }
  186. .widget_search button.wp-block-search__button{
  187. color: <?php echo esc_attr($spice_software_dark_link_color); ?>;
  188. }
  189. .pagination .page-numbers:hover{
  190. background-color:<?php echo esc_attr($spice_software_dark_link_color); ?>;
  191. }
  192. .services3 h4.entry-title a:hover{
  193. color: <?php echo esc_attr($spice_software_dark_link_color); ?>;
  194. }
  195. .dark .navbar .nav .dropdown-menu .text-dark,.dark .navbar .nav .dropdown-menu a.text-dark:focus,
  196. .dark .navbar .nav .dropdown-menu a.text-dark:hover{
  197. color: <?php echo esc_attr($spice_software_dark_link_color); ?>!important;
  198. }
  199. </style>
  200. <?php
  201. endif;
  202. }