functions.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php
  2. /**
  3. * Blank Canvas functions and definitions
  4. *
  5. * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
  6. *
  7. * @package WordPress
  8. * @subpackage Blank Canvas
  9. * @since 1.0
  10. */
  11. if ( ! function_exists( 'blank_canvas_setup' ) ) :
  12. /**
  13. * Sets up theme defaults and registers support for various WordPress features.
  14. *
  15. * Note that this function is hooked into the after_setup_theme hook, which
  16. * runs before the init hook. The init hook is too late for some features, such
  17. * as indicating support for post thumbnails.
  18. */
  19. function blank_canvas_setup() {
  20. // Add support for editor styles.
  21. add_theme_support( 'editor-styles' );
  22. // Enqueue editor styles.
  23. add_editor_style( 'variables.css' );
  24. // Editor color palette.
  25. $colors_theme_mod = get_theme_mod( 'custom_colors_active' );
  26. $primary = ( ! empty( $colors_theme_mod ) && 'default' === $colors_theme_mod || empty( get_theme_mod( 'seedlet_--global--color-primary' ) ) ) ? '#000000' : get_theme_mod( 'seedlet_--global--color-primary' );
  27. $secondary = ( ! empty( $colors_theme_mod ) && 'default' === $colors_theme_mod || empty( get_theme_mod( 'seedlet_--global--color-secondary' ) ) ) ? '#007cba' : get_theme_mod( 'seedlet_--global--color-secondary' );
  28. $foreground = ( ! empty( $colors_theme_mod ) && 'default' === $colors_theme_mod || empty( get_theme_mod( 'seedlet_--global--color-foreground' ) ) ) ? '#333333' : get_theme_mod( 'seedlet_--global--color-foreground' );
  29. $tertiary = ( ! empty( $colors_theme_mod ) && 'default' === $colors_theme_mod || empty( get_theme_mod( 'seedlet_--global--color-tertiary' ) ) ) ? '#FAFAFA' : get_theme_mod( 'seedlet_--global--color-tertiary' );
  30. $background = ( ! empty( $colors_theme_mod ) && 'default' === $colors_theme_mod || empty( get_theme_mod( 'seedlet_--global--color-background' ) ) ) ? '#FFFFFF' : get_theme_mod( 'seedlet_--global--color-background' );
  31. add_theme_support(
  32. 'editor-color-palette',
  33. array(
  34. array(
  35. 'name' => __( 'Primary', 'blank-canvas' ),
  36. 'slug' => 'primary',
  37. 'color' => $primary,
  38. ),
  39. array(
  40. 'name' => __( 'Secondary', 'blank-canvas' ),
  41. 'slug' => 'secondary',
  42. 'color' => $secondary,
  43. ),
  44. array(
  45. 'name' => __( 'Foreground', 'blank-canvas' ),
  46. 'slug' => 'foreground',
  47. 'color' => $foreground,
  48. ),
  49. array(
  50. 'name' => __( 'Tertiary', 'blank-canvas' ),
  51. 'slug' => 'tertiary',
  52. 'color' => $tertiary,
  53. ),
  54. array(
  55. 'name' => __( 'Background', 'blank-canvas' ),
  56. 'slug' => 'background',
  57. 'color' => $background,
  58. ),
  59. )
  60. );
  61. }
  62. endif;
  63. add_action( 'after_setup_theme', 'blank_canvas_setup', 11 );
  64. /**
  65. * Remove Seedlet theme features.
  66. */
  67. function blank_canvas_remove_parent_theme_features() {
  68. // Theme Support
  69. remove_theme_support( 'custom-header' );
  70. remove_theme_support( 'custom-logo' );
  71. remove_theme_support( 'customize-selective-refresh-widgets' );
  72. // Navigation Areas
  73. unregister_nav_menu( 'primary' );
  74. unregister_nav_menu( 'footer' );
  75. unregister_nav_menu( 'social' );
  76. }
  77. add_action( 'after_setup_theme', 'blank_canvas_remove_parent_theme_features', 10 );
  78. function blank_canvas_dequeue_parent_scripts() {
  79. // Naviation assets
  80. wp_dequeue_script( 'seedlet-primary-navigation-script' );
  81. wp_dequeue_style( 'seedlet-style-navigation' );
  82. }
  83. add_action( 'wp_enqueue_scripts', 'blank_canvas_dequeue_parent_scripts', 11 );
  84. /**
  85. * Remove Meta Footer Items.
  86. */
  87. if ( ! function_exists( 'seedlet_entry_meta_footer' ) ) :
  88. /**
  89. * Prints HTML with meta information for the categories, tags and comments.
  90. */
  91. function seedlet_entry_meta_footer() {
  92. // Edit post link.
  93. edit_post_link(
  94. sprintf(
  95. wp_kses(
  96. /* translators: %s: Name of current post. Only visible to screen readers. */
  97. __( 'Edit <span class="screen-reader-text">%s</span>', 'seedlet' ),
  98. array(
  99. 'span' => array(
  100. 'class' => array(),
  101. ),
  102. )
  103. ),
  104. get_the_title()
  105. ),
  106. '<span class="edit-link">' . seedlet_get_icon_svg( 'edit', 16 ),
  107. '</span>'
  108. );
  109. }
  110. endif;
  111. /**
  112. * Enqueue scripts and styles.
  113. */
  114. function blank_canvas_enqueue() {
  115. wp_enqueue_style( 'blank-canvas-styles', get_stylesheet_uri() );
  116. }
  117. add_action( 'wp_enqueue_scripts', 'blank_canvas_enqueue', 11 );