functions.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?php
  2. namespace {
  3. /**
  4. * Enfold Child Theme - Starter
  5. *
  6. * @since Enfold Starter 1.0
  7. *
  8. * Add your own functions here. You can also copy some of the theme functions into this file.
  9. * Wordpress will use those functions instead of the original functions then.
  10. *
  11. * @link http://www.kriesi.at/documentation/enfold/using-a-child-theme/
  12. */
  13. /**
  14. * Add filter to add or replace Enfold ALB shortcodes with new folder contents
  15. *
  16. * Note that the shortcodes must be in the same format as those in
  17. * enfold/config-templatebuilder/avia-shortcodes
  18. *
  19. * @link http://www.kriesi.at/documentation/enfold/add-new-or-replace-advanced-layout-builder-elements-from-child-theme/
  20. */
  21. add_filter('avia_load_shortcodes', 'avia_include_shortcode_template', 15, 1);
  22. function avia_include_shortcode_template($paths)
  23. {
  24. $template_url = get_stylesheet_directory();
  25. array_unshift($paths, $template_url.'/shortcodes/');
  26. return $paths;
  27. }
  28. /**
  29. * Turn on Custom CSS Class field for all Avia Layout Builder elements
  30. * @link http://www.kriesi.at/documentation/enfold/turn-on-custom-css-field-for-all-alb-elements/
  31. */
  32. add_theme_support('avia_template_builder_custom_css');
  33. }
  34. namespace ITSociaal\Themes\Houtgrutter
  35. {
  36. const LIBDIR = __DIR__ . "/lib";
  37. const SRCDIR = __DIR__ . "/src";
  38. require_once LIBDIR . '/Autoloader.php';
  39. class_alias("Paulyg\\Autoloader", __NAMESPACE__ . "\\Autoloader");
  40. function do_autoloader($namespaces)
  41. {
  42. return array_map(
  43. 'call_user_func_array',
  44. array_fill(
  45. 0,
  46. count($namespaces),
  47. [new Autoloader, "addPsr4"]
  48. ),
  49. $namespaces
  50. );
  51. }
  52. function theme_root_path()
  53. {
  54. $ret = __DIR__;
  55. if (defined("STYLESHEETPATH")) {
  56. assert(constant("STYLESHEETPATH") === $ret);
  57. }
  58. return $ret;
  59. }
  60. do_autoloader([
  61. [__NAMESPACE__, SRCDIR],
  62. ["ErrorDumper", LIBDIR . "/error-dumper/src"],
  63. //["Cypress\\Curry", LIBDIR . "/php-curry"],
  64. ]);
  65. if (defined("WP_DEBUG") && constant("WP_DEBUG")) {
  66. if (!is_admin() && (PHP_SAPI != "cli")) {
  67. \ErrorDumper\Magic::registerErrorDumper();
  68. }
  69. error_reporting(~0);
  70. }
  71. if (!isset($_REQUEST["page"])) {
  72. $_REQUEST["page"] = "";
  73. }
  74. \add_filter("posts_results", function($posts) {
  75. // Fix for wp_query with virtual pages
  76. if (isset($posts[0])
  77. && isset($posts[0]->ID)
  78. && (0 == $posts[0]->ID)
  79. ) {
  80. // Set to some unregistered type to prevent errors
  81. $posts[0]->post_type =
  82. strtolower(array_reverse(explode("\\", __NAMESPACE__))[0]);
  83. }
  84. return $posts;
  85. }, 32767);
  86. \add_filter("kriesi_backlink", F::always(""));
  87. \add_filter("avf_google_fontlist", F::always(
  88. "Titillium+Web:600,600italic|Ubuntu:400,400italic"
  89. ));
  90. \add_action("wp_enqueue_scripts", function() {
  91. wp_deregister_script("avia-compat");
  92. wp_deregister_script("avia-default");
  93. wp_deregister_script("avia-shortcodes");
  94. wp_deregister_script("avia-popup");
  95. $base_uri = \get_stylesheet_directory_uri();
  96. wp_enqueue_script("avia-compat", "$base_uri/assets/avia-compat.js", ["jquery"], 2, false );
  97. wp_enqueue_script("avia-default", "$base_uri/assets/avia.js", ["jquery"], 3, false);
  98. wp_enqueue_script("avia-shortcodes", "$base_uri/assets/shortcodes.js", ["jquery"], 3, false);
  99. }, 1024);
  100. \add_action("ava_after_main_title", function() {
  101. if (is_shopp_catalog_frontpage ())
  102. TemplateController::main("laura/advertentie");
  103. }, 1024);
  104. \add_action("wp_head", function() {
  105. $uri = \get_stylesheet_directory_uri() . "/assets/ie9.css";
  106. ?>
  107. <!--[if IE lte 9]>
  108. <link rel="stylesheet" href="<?=$uri?>" type="text/css"/>
  109. <![endif]-->
  110. <?php
  111. });
  112. }
  113. /* vi:set ts=4 sw=4 noet: */