Няма описание

functions.php 8.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <?php
  2. /**
  3. * XShop functions and definitions
  4. *
  5. * @link https://developer.wordpress.org/themes/basics/theme-functions/
  6. *
  7. * @package XShop
  8. */
  9. if ( ! defined( 'XSHOP_VERSION' ) ) {
  10. $xshop_theme = wp_get_theme();
  11. define( 'XSHOP_VERSION', $xshop_theme->get( 'Version' ) );
  12. }
  13. if ( ! function_exists( 'xshop_setup' ) ) :
  14. /**
  15. * Sets up theme defaults and registers support for various WordPress features.
  16. *
  17. * Note that this function is hooked into the after_setup_theme hook, which
  18. * runs before the init hook. The init hook is too late for some features, such
  19. * as indicating support for post thumbnails.
  20. */
  21. function xshop_setup() {
  22. /*
  23. * Make theme available for translation.
  24. * Translations can be filed in the /languages/ directory.
  25. * If you're building a theme based on XShop, use a find and replace
  26. * to change 'xshop' to the name of your theme in all the template files.
  27. */
  28. load_theme_textdomain( 'xshop', get_template_directory() . '/languages' );
  29. // Add default posts and comments RSS feed links to head.
  30. add_theme_support( 'automatic-feed-links' );
  31. /*
  32. * Let WordPress manage the document title.
  33. * By adding theme support, we declare that this theme does not use a
  34. * hard-coded <title> tag in the document head, and expect WordPress to
  35. * provide it for us.
  36. */
  37. add_theme_support( 'title-tag' );
  38. /*
  39. * Enable support for Post Thumbnails on posts and pages.
  40. *
  41. * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
  42. */
  43. add_theme_support( 'post-thumbnails' );
  44. // This theme uses wp_nav_menu() in one location.
  45. register_nav_menus(
  46. array(
  47. 'main-menu' => esc_html__( 'Main Menu', 'xshop' ),
  48. )
  49. );
  50. /*
  51. * Switch default core markup for search form, comment form, and comments
  52. * to output valid HTML5.
  53. */
  54. add_theme_support(
  55. 'html5',
  56. array(
  57. 'search-form',
  58. 'comment-form',
  59. 'comment-list',
  60. 'gallery',
  61. 'caption',
  62. 'style',
  63. 'script',
  64. )
  65. );
  66. // Set up the WordPress core custom background feature.
  67. add_theme_support(
  68. 'custom-background',
  69. apply_filters(
  70. 'xshop_custom_background_args',
  71. array(
  72. 'default-color' => 'ffffff',
  73. 'default-image' => '',
  74. )
  75. )
  76. );
  77. // Add theme support for selective refresh for widgets.
  78. add_theme_support( 'customize-selective-refresh-widgets' );
  79. // Add support for Block Styles.
  80. add_theme_support( 'wp-block-styles' );
  81. // Add support for full and wide align images.
  82. add_theme_support( 'align-wide' );
  83. add_theme_support( "responsive-embeds" );
  84. /**
  85. * Add support for core custom logo.
  86. *
  87. * @link https://codex.wordpress.org/Theme_Logo
  88. */
  89. add_theme_support(
  90. 'custom-logo',
  91. array(
  92. 'height' => 250,
  93. 'width' => 250,
  94. 'flex-width' => true,
  95. 'flex-height' => true,
  96. )
  97. );
  98. add_editor_style( array( xshop_fonts_url() ) );
  99. }
  100. endif;
  101. add_action( 'after_setup_theme', 'xshop_setup' );
  102. /**
  103. * Set the content width in pixels, based on the theme's design and stylesheet.
  104. *
  105. * Priority 0 to make it available to lower priority callbacks.
  106. *
  107. * @global int $content_width
  108. */
  109. function xshop_content_width() {
  110. $GLOBALS['content_width'] = apply_filters( 'xshop_content_width', 1170 );
  111. }
  112. add_action( 'after_setup_theme', 'xshop_content_width', 0 );
  113. /**
  114. * Register widget area.
  115. *
  116. * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
  117. */
  118. function xshop_widgets_init() {
  119. register_sidebar(
  120. array(
  121. 'name' => esc_html__( 'Sidebar', 'xshop' ),
  122. 'id' => 'sidebar-1',
  123. 'description' => esc_html__( 'Add widgets here.', 'xshop' ),
  124. 'before_widget' => '<section id="%1$s" class="widget shadow mb-4 p-3 %2$s">',
  125. 'after_widget' => '</section>',
  126. 'before_title' => '<h2 class="widget-title">',
  127. 'after_title' => '</h2>',
  128. )
  129. );
  130. register_sidebar(
  131. array(
  132. 'name' => esc_html__( 'Footer Widget', 'xshop' ),
  133. 'id' => 'footer-widget',
  134. 'description' => esc_html__( 'Add Footer widgets here.', 'xshop' ),
  135. 'before_widget' => '<section id="%1$s" class="widget footer-widget mb-4 p-3 %2$s">',
  136. 'after_widget' => '</section>',
  137. 'before_title' => '<h2 class="widget-title footer-widget-title">',
  138. 'after_title' => '</h2>',
  139. )
  140. );
  141. }
  142. add_action( 'widgets_init', 'xshop_widgets_init' );
  143. /**
  144. * Register custom fonts.
  145. */
  146. function xshop_fonts_url() {
  147. $fonts_url = '';
  148. $font_families = array();
  149. $font_families[] = 'Brygada 1918:400,400i,700,700i';
  150. $font_families[] = 'Roboto Slab:400,400i,700,700i';
  151. $query_args = array(
  152. 'family' => urlencode( implode( '|', $font_families ) ),
  153. 'subset' => urlencode( 'latin,latin-ext' ),
  154. );
  155. $fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
  156. return esc_url_raw( $fonts_url );
  157. }
  158. /**
  159. * Enqueue scripts and styles.
  160. */
  161. function xshop_scripts() {
  162. wp_enqueue_style( 'xshop-google-font', xshop_fonts_url(), array(), null );
  163. wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/assets/css/bootstrap.css', array(),'5.0.1','all' );
  164. wp_enqueue_style( 'slicknav', get_template_directory_uri() . '/assets/css/slicknav.css', array(),'1.0.10','all' );
  165. wp_enqueue_style( 'fontawesome', get_template_directory_uri() . '/assets/css/all.css', array(), '5.15.3' );
  166. wp_enqueue_style( 'xshop-block-style', get_template_directory_uri() . '/assets/css/block.css', array(), XSHOP_VERSION );
  167. wp_enqueue_style( 'xshop-default-style', get_template_directory_uri() . '/assets/css/default-style.css', array(), XSHOP_VERSION );
  168. wp_enqueue_style( 'xshop-main-style', get_template_directory_uri() . '/assets/css/main.css', array(), XSHOP_VERSION );
  169. wp_enqueue_style( 'xshop-style', get_stylesheet_uri(), array(), XSHOP_VERSION );
  170. wp_enqueue_style( 'xshop-responsive-style', get_template_directory_uri() . '/assets/css/responsive.css', array(), XSHOP_VERSION );
  171. wp_enqueue_script( 'masonry' );
  172. wp_enqueue_script( 'bootstrap', get_template_directory_uri() . '/assets/js/bootstrap.js', array(), '5.0.1', true );
  173. wp_enqueue_script( 'xshop-navigation', get_template_directory_uri() . '/assets/js/navigation.js', array(), XSHOP_VERSION, true );
  174. wp_enqueue_script( 'slicknav', get_template_directory_uri() . '/assets/js/jquery.slicknav.js', array('jquery'), '1.0.10', true );
  175. wp_enqueue_script( 'xshop-scripts', get_template_directory_uri() . '/assets/js/scripts.js', array('jquery'), XSHOP_VERSION, true );
  176. if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
  177. wp_enqueue_script( 'comment-reply' );
  178. }
  179. }
  180. add_action( 'wp_enqueue_scripts', 'xshop_scripts' );
  181. function xshop_gb_block_style() {
  182. wp_enqueue_style( 'xshop-gb-block', get_theme_file_uri( '/assets/css/admin-block.css' ), false, '1.0', 'all' );
  183. wp_enqueue_style( 'xshop-admin-google-font', xshop_fonts_url(), array(), null );
  184. }
  185. add_action( 'enqueue_block_assets', 'xshop_gb_block_style' );
  186. /**
  187. * Implement the Custom Header feature.
  188. */
  189. require get_template_directory() . '/inc/custom-header.php';
  190. /**
  191. * Custom template tags for this theme.
  192. */
  193. require get_template_directory() . '/inc/template-tags.php';
  194. /**
  195. * Functions which enhance the theme by hooking into WordPress.
  196. */
  197. require get_template_directory() . '/inc/template-functions.php';
  198. /**
  199. * Customizer additions.
  200. */
  201. require get_template_directory() . '/inc/customizer.php';
  202. /**
  203. * Customizer pro info .
  204. */
  205. require get_template_directory() . '/inc/info/class-customize.php';
  206. /**
  207. * Add tem plugin activation
  208. */
  209. require get_template_directory() . '/inc/class-tgm-plugin-activation.php';
  210. require get_template_directory() . '/inc/recomended-plugin.php';
  211. /**
  212. * Load Jetpack compatibility file.
  213. */
  214. if ( defined( 'JETPACK__VERSION' ) ) {
  215. require get_template_directory() . '/inc/jetpack.php';
  216. }
  217. // Load all actions file
  218. require get_template_directory() . '/actions/header-actions.php';
  219. if(class_exists('WooCommerce')){
  220. require get_template_directory() . '/inc/woo-items/xshop-woocommerce.php';
  221. }
  222. $xshop_theme = wp_get_theme();
  223. $xshop_slug = $xshop_theme->get( 'TextDomain' );
  224. if ( is_admin() ) {
  225. require_once trailingslashit( get_template_directory() ) . 'inc/about/about.php';
  226. }