functions.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <?php
  2. // Global variables define
  3. define('SPICE_SOFTWARE_TEMPLATE_DIR_URI', get_template_directory_uri());
  4. define('SPICE_SOFTWARE_TEMPLATE_DIR', get_template_directory());
  5. if ( ! function_exists( 'wp_body_open' ) ) {
  6. function wp_body_open() {
  7. /**
  8. * Triggered after the opening <body> tag.
  9. */
  10. do_action( 'wp_body_open' );
  11. }
  12. }
  13. //software plus sanitize callback
  14. require( SPICE_SOFTWARE_TEMPLATE_DIR . '/inc/font/fonts.php');
  15. require( SPICE_SOFTWARE_TEMPLATE_DIR . '/inc/scripts/script.php');
  16. require( SPICE_SOFTWARE_TEMPLATE_DIR . '/inc/menu/default_menu_walker.php');
  17. require( SPICE_SOFTWARE_TEMPLATE_DIR . '/inc/menu/spice_software_nav_walker.php');
  18. require( SPICE_SOFTWARE_TEMPLATE_DIR . '/inc/widgets/sidebars.php');
  19. // Adding customizer files
  20. require ( SPICE_SOFTWARE_TEMPLATE_DIR . '/inc/customizer/customizer.php' );
  21. require ( SPICE_SOFTWARE_TEMPLATE_DIR . '/inc/customizer/custom-control.php' );
  22. require ( SPICE_SOFTWARE_TEMPLATE_DIR . '/inc/customizer/helper-function.php');
  23. require ( SPICE_SOFTWARE_TEMPLATE_DIR . '/inc/customizer/customizer_sections_settings.php' );
  24. require ( SPICE_SOFTWARE_TEMPLATE_DIR . '/inc/customizer/single-blog-options.php' );
  25. require ( SPICE_SOFTWARE_TEMPLATE_DIR . '/inc/customizer/blog-options.php' );
  26. require_once SPICE_SOFTWARE_TEMPLATE_DIR . '/inc/customizer/customizer-slider/customizer-slider.php';
  27. require_once SPICE_SOFTWARE_TEMPLATE_DIR . '/inc/customizer/customizer-image-radio/customizer-image-radio.php';
  28. require_once SPICE_SOFTWARE_TEMPLATE_DIR . '/inc/class-tgm-plugin-activation.php';
  29. if ( ! function_exists( 'spice_software_plus_activate' ) ){
  30. require( SPICE_SOFTWARE_TEMPLATE_DIR . '/inc/breadcrumbs/breadcrumbs.php');
  31. require ( SPICE_SOFTWARE_TEMPLATE_DIR . '/inc/customizer/customizer-pro-feature.php' );
  32. require ( SPICE_SOFTWARE_TEMPLATE_DIR . '/inc/customizer/customizer_theme_style.php' );
  33. require( SPICE_SOFTWARE_TEMPLATE_DIR . '/inc/customizer/general-settings.php');
  34. require ( SPICE_SOFTWARE_TEMPLATE_DIR . '/inc/customizer/customizer-recommended-plugin.php');
  35. require ( SPICE_SOFTWARE_TEMPLATE_DIR . '/inc/customizer/blog-page-options.php' );
  36. require( SPICE_SOFTWARE_TEMPLATE_DIR . '/inc/custom-style/custom-css.php');
  37. require( SPICE_SOFTWARE_TEMPLATE_DIR . '/inc/customizer/customizer_color_back_settings.php');
  38. require( SPICE_SOFTWARE_TEMPLATE_DIR . '/inc/customizer/customizer_typography.php');
  39. }
  40. // Theme title
  41. if (!function_exists('spice_software_head_title')) {
  42. function spice_software_head_title($title, $sep) {
  43. global $paged, $page;
  44. if (is_feed())
  45. return $title;
  46. // Add the site name
  47. $title .= get_bloginfo('name');
  48. // Add the site description for the home / front page
  49. $site_description = get_bloginfo('description');
  50. if ($site_description && ( is_home() || is_front_page() ))
  51. $title = "$title $sep $site_description";
  52. // Add a page number if necessary.
  53. if (( $paged >= 2 || $page >= 2 ) && !is_404())
  54. $title = "$title $sep " . sprintf(esc_html__('Page', 'spice-software' ), max($paged, $page));
  55. return $title;
  56. }
  57. }
  58. add_filter('wp_title', 'spice_software_head_title', 10, 2);
  59. if (!function_exists('spice_software_theme_setup')) :
  60. function spice_software_theme_setup() {
  61. /*
  62. * Make theme available for translation.
  63. * Translations can be filed in the /languages/ directory.
  64. */
  65. load_theme_textdomain('spice-software' , SPICE_SOFTWARE_TEMPLATE_DIR . '/languages');
  66. // Add default posts and comments RSS feed links to head.
  67. add_theme_support('automatic-feed-links');
  68. //Add selective refresh for sidebar widget
  69. add_theme_support('customize-selective-refresh-widgets');
  70. /*
  71. * Let WordPress manage the document title.
  72. */
  73. add_theme_support('title-tag');
  74. // supports featured image
  75. add_theme_support('post-thumbnails');
  76. // This theme uses wp_nav_menu() in two locations.
  77. register_nav_menus(array(
  78. 'spice-software-primary' => esc_html__('Primary', 'spice-software' ),
  79. ));
  80. //Custom background support
  81. add_theme_support('custom-background');
  82. // woocommerce support
  83. add_theme_support('woocommerce');
  84. add_theme_support('wc-product-gallery-zoom');
  85. add_theme_support('wc-product-gallery-lightbox');
  86. add_theme_support('wc-product-gallery-slider');
  87. //Custom logo
  88. add_theme_support('custom-logo', array(
  89. 'height' => 31,
  90. 'width' => 156,
  91. 'flex-width' => true,
  92. 'flex-height' => true,
  93. 'header-text' => array('site-title', 'site-description'),
  94. ));
  95. // set default content width
  96. if (!isset($content_width)) {
  97. $content_width = 696;
  98. }
  99. //About Theme
  100. if(!function_exists( 'spice_software_plus_activate' )) :
  101. $spice_software_theme = wp_get_theme(); // gets the current theme
  102. if ('Spice Software' == $spice_software_theme->name) {
  103. if (is_admin()) {
  104. require SPICE_SOFTWARE_TEMPLATE_DIR . '/admin/admin-init.php';
  105. }
  106. }
  107. endif;
  108. }
  109. endif;
  110. add_action('after_setup_theme', 'spice_software_theme_setup');
  111. add_action( 'admin_init', 'spice_software_customizer_css' );
  112. function spice_software_customizer_css()
  113. {
  114. wp_enqueue_style( 'spice-software-pro-info', SPICE_SOFTWARE_TEMPLATE_DIR_URI . '/assets/css/pro-details.css' );
  115. }
  116. function spice_software_logo_class($html) {
  117. $html = str_replace('custom-logo-link', 'navbar-brand custom-logo', $html);
  118. return $html;
  119. }
  120. add_filter('get_custom_logo', 'spice_software_logo_class');
  121. function spice_software_new_content_more($more) {
  122. global $post;
  123. return '<p><a href="' . esc_url(get_permalink()) . "#more-{$post->ID}\" class=\"more-link btn-ex-small btn-border\">" . esc_html__('Read More', 'spice-software' ) . "</a></p>";
  124. }
  125. add_filter('the_content_more_link', 'spice_software_new_content_more');
  126. if ( ! function_exists( 'spice_software_plus_activate' ) ){
  127. add_action( 'tgmpa_register', 'spice_software_register_required_plugins' );
  128. /**
  129. * Register the required plugins for this theme.
  130. *
  131. * In this example, we register five plugins:
  132. * - one included with the TGMPA library
  133. * - two from an external source, one from an arbitrary source, one from a GitHub repository
  134. * - two from the .org repo, where one demonstrates the use of the `is_callable` argument
  135. *
  136. * The variables passed to the `tgmpa()` function should be:
  137. * - an array of plugin arrays;
  138. * - optionally a configuration array.
  139. * If you are not changing anything in the configuration array, you can remove the array and remove the
  140. * variable from the function call: `tgmpa( $plugins );`.
  141. * In that case, the TGMPA default settings will be used.
  142. *
  143. * This function is hooked into `tgmpa_register`, which is fired on the WP `init` action on priority 10.
  144. */
  145. function spice_software_register_required_plugins() {
  146. /*
  147. * Array of plugin arrays. Required keys are name and slug.
  148. * If the source is NOT from the .org repo, then source is also required.
  149. */
  150. $plugins = array(
  151. // This is an example of how to include a plugin from the WordPress Plugin Repository.
  152. array(
  153. 'name' => esc_html__('Contact Form 7', 'spice-software' ),
  154. 'slug' => 'contact-form-7',
  155. 'required' => false,
  156. ),
  157. array(
  158. 'name' => esc_html__('Spice Box', 'spice-software' ),
  159. 'slug' => 'spicebox',
  160. 'required' => false,
  161. ),
  162. array(
  163. 'name' => esc_html__('Unique Headers','spice-software'),
  164. 'slug' => 'unique-headers',
  165. 'required' => false,
  166. ),
  167. array(
  168. 'name' => esc_html__('Yoast SEO','spice-software'),
  169. 'slug' => 'wordpress-seo',
  170. 'required' => false,
  171. ),
  172. array(
  173. 'name' => esc_html__('Spice Post Slider','spice-software'),
  174. 'slug' => 'spice-post-slider',
  175. 'required' => false,
  176. ),
  177. array(
  178. 'name' => esc_html__('Spice Social Share', 'spice-software'),
  179. 'slug' => 'spice-social-share',
  180. 'required' => false,
  181. ),
  182. array(
  183. 'name' => esc_html__('Seo Optimized Images', 'spice-software'),
  184. 'slug' => 'seo-optimized-images',
  185. 'required' => false,
  186. )
  187. );
  188. /*
  189. * Array of configuration settings. Amend each line as needed.
  190. *
  191. * TGMPA will start providing localized text strings soon. If you already have translations of our standard
  192. * strings available, please help us make TGMPA even better by giving us access to these translations or by
  193. * sending in a pull-request with .po file(s) with the translations.
  194. *
  195. * Only uncomment the strings in the config array if you want to customize the strings.
  196. */
  197. $config = array(
  198. 'id' => 'tgmpa', // Unique ID for hashing notices for multiple instances of TGMPA.
  199. 'default_path' => '', // Default absolute path to bundled plugins.
  200. 'menu' => 'tgmpa-install-plugins', // Menu slug.
  201. 'has_notices' => true, // Show admin notices or not.
  202. 'dismissable' => true, // If false, a user cannot dismiss the nag message.
  203. 'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag.
  204. 'is_automatic' => false, // Automatically activate plugins after installation or not.
  205. 'message' => '', // Message to output right before the plugins table.
  206. );
  207. tgmpa( $plugins, $config );
  208. }
  209. }
  210. function spice_software_modify_read_more_link() {
  211. $blog_button = get_theme_mod('spice_software_blog_button_title', 'Read More');
  212. if (empty($blog_button)) {
  213. return;
  214. }
  215. return '<p><a href = "' . esc_url(get_the_permalink()) . '" class="more-link">' . esc_html($blog_button) . ' <i class="fa fa-long-arrow-right"></i></a></p>';
  216. }
  217. add_filter( 'the_content_more_link', 'spice_software_modify_read_more_link' );
  218. //spice software sanitize checkbox
  219. function spice_software_sanitize_checkbox($checked) {
  220. // Boolean check.
  221. return ( ( isset($checked) && true == $checked ) ? true : false );
  222. }
  223. //spice software sanitize text
  224. function spice_software_sanitize_text($input) {
  225. return wp_kses_post(force_balance_tags($input));
  226. }