functions.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <?php
  2. /**
  3. * UIU CSE functions and definitions
  4. *
  5. * @link https://developer.wordpress.org/themes/basics/theme-functions/
  6. *
  7. * @package UIU_CSE
  8. */
  9. if ( ! defined( '_S_VERSION' ) ) {
  10. // Replace the version number of the theme on each release.
  11. define( '_S_VERSION', '1.0.0' );
  12. }
  13. /**
  14. * Sets up theme defaults and registers support for various WordPress features.
  15. *
  16. * Note that this function is hooked into the after_setup_theme hook, which
  17. * runs before the init hook. The init hook is too late for some features, such
  18. * as indicating support for post thumbnails.
  19. */
  20. function uiu_cse_setup() {
  21. /*
  22. * Make theme available for translation.
  23. * Translations can be filed in the /languages/ directory.
  24. * If you're building a theme based on UIU CSE, use a find and replace
  25. * to change 'uiu-cse' to the name of your theme in all the template files.
  26. */
  27. load_theme_textdomain( 'uiu-cse', get_template_directory() . '/languages' );
  28. // Add default posts and comments RSS feed links to head.
  29. add_theme_support( 'automatic-feed-links' );
  30. /*
  31. * Let WordPress manage the document title.
  32. * By adding theme support, we declare that this theme does not use a
  33. * hard-coded <title> tag in the document head, and expect WordPress to
  34. * provide it for us.
  35. */
  36. add_theme_support( 'title-tag' );
  37. /*
  38. * Enable support for Post Thumbnails on posts and pages.
  39. *
  40. * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
  41. */
  42. add_theme_support( 'post-thumbnails' );
  43. // This theme uses wp_nav_menu() in one location.
  44. register_nav_menus(
  45. array(
  46. 'menu-1' => esc_html__( 'Primary', 'uiu-cse' ),
  47. )
  48. );
  49. /*
  50. * Switch default core markup for search form, comment form, and comments
  51. * to output valid HTML5.
  52. */
  53. add_theme_support(
  54. 'html5',
  55. array(
  56. 'search-form',
  57. 'comment-form',
  58. 'comment-list',
  59. 'gallery',
  60. 'caption',
  61. 'style',
  62. 'script',
  63. )
  64. );
  65. // Set up the WordPress core custom background feature.
  66. add_theme_support(
  67. 'custom-background',
  68. apply_filters(
  69. 'uiu_cse_custom_background_args',
  70. array(
  71. 'default-color' => 'ffffff',
  72. 'default-image' => '',
  73. )
  74. )
  75. );
  76. // Add theme support for selective refresh for widgets.
  77. add_theme_support( 'customize-selective-refresh-widgets' );
  78. /**
  79. * Add support for core custom logo.
  80. *
  81. * @link https://codex.wordpress.org/Theme_Logo
  82. */
  83. add_theme_support(
  84. 'custom-logo',
  85. array(
  86. 'height' => 250,
  87. 'width' => 250,
  88. 'flex-width' => true,
  89. 'flex-height' => true,
  90. )
  91. );
  92. }
  93. add_action( 'after_setup_theme', 'uiu_cse_setup' );
  94. /**
  95. * Set the content width in pixels, based on the theme's design and stylesheet.
  96. *
  97. * Priority 0 to make it available to lower priority callbacks.
  98. *
  99. * @global int $content_width
  100. */
  101. function uiu_cse_content_width() {
  102. $GLOBALS['content_width'] = apply_filters( 'uiu_cse_content_width', 640 );
  103. }
  104. add_action( 'after_setup_theme', 'uiu_cse_content_width', 0 );
  105. /**
  106. * Register widget area.
  107. *
  108. * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
  109. */
  110. function uiu_cse_widgets_init() {
  111. register_sidebar(
  112. array(
  113. 'name' => esc_html__( 'Sidebar', 'uiu-cse' ),
  114. 'id' => 'sidebar-1',
  115. 'description' => esc_html__( 'Add widgets here.', 'uiu-cse' ),
  116. 'before_widget' => '<section id="%1$s" class="widget %2$s">',
  117. 'after_widget' => '</section>',
  118. 'before_title' => '<h2 class="widget-title">',
  119. 'after_title' => '</h2>',
  120. )
  121. );
  122. }
  123. add_action( 'widgets_init', 'uiu_cse_widgets_init' );
  124. /**
  125. * Enqueue scripts and styles.
  126. */
  127. function uiu_cse_scripts() {
  128. wp_enqueue_style( 'uiu-cse-style', get_stylesheet_uri(), array(), _S_VERSION );
  129. wp_style_add_data( 'uiu-cse-style', 'rtl', 'replace' );
  130. wp_enqueue_script( 'uiu-cse-navigation', get_template_directory_uri() . '/js/navigation.js', array(), _S_VERSION, true );
  131. if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
  132. wp_enqueue_script( 'comment-reply' );
  133. }
  134. }
  135. add_action( 'wp_enqueue_scripts', 'uiu_cse_scripts' );
  136. /**
  137. * Implement the Custom Header feature.
  138. */
  139. require get_template_directory() . '/inc/custom-header.php';
  140. /**
  141. * Custom template tags for this theme.
  142. */
  143. require get_template_directory() . '/inc/template-tags.php';
  144. /**
  145. * Functions which enhance the theme by hooking into WordPress.
  146. */
  147. require get_template_directory() . '/inc/template-functions.php';
  148. /**
  149. * Customizer additions.
  150. */
  151. require get_template_directory() . '/inc/customizer.php';
  152. /**
  153. * Load Jetpack compatibility file.
  154. */
  155. if ( defined( 'JETPACK__VERSION' ) ) {
  156. require get_template_directory() . '/inc/jetpack.php';
  157. }