functions.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <?php
  2. include 'inc/function.php';
  3. // use Twig\Environment;
  4. // use Twig\Extensions\IntlExtension;
  5. //
  6. // $twig = new Environment($loader);
  7. // $twig->addExtension(new IntlExtension());
  8. // CUSTOM FUNCTION
  9. // include custom jQuery
  10. function includejquery() {
  11. wp_deregister_script('jquery');
  12. wp_enqueue_script( 'jquery',
  13. get_template_directory_uri() . '/src/assets/js/jquery-3.5.1.min.js',array() );
  14. }
  15. add_action('wp_footer', 'includejquery');
  16. function flickity(){
  17. wp_enqueue_script( 'flick',
  18. get_template_directory_uri() . '/src/assets/js/flickity.pkgd.min.js', array() );
  19. }
  20. add_action( 'wp_footer', 'flickity' );
  21. function isotope(){
  22. wp_enqueue_script( 'isotope',
  23. get_template_directory_uri() . '/src/assets/js/isotope.pkgd.min.js', array() );
  24. }
  25. add_action( 'wp_footer', 'isotope' );
  26. function imgLoad(){
  27. wp_enqueue_script( 'imagesloaded.pkgd.min.js',
  28. get_template_directory_uri() . '/src/assets/js/imagesloaded.pkgd.min.js', array() );
  29. }
  30. add_action( 'wp_footer', 'imgLoad' );
  31. function rellax(){
  32. wp_enqueue_script( 'rellax',
  33. get_template_directory_uri() . '/src/assets/js/rellax.pkgd.min.js', array() );
  34. }
  35. add_action( 'wp_footer', 'rellax' );
  36. function jquery_ui(){
  37. wp_enqueue_script( 'jquery-ui',
  38. get_template_directory_uri() . '/src/assets/js/jquery-ui.js', array() );
  39. }
  40. add_action( 'wp_footer', 'jquery_ui' );
  41. function customJs(){
  42. wp_enqueue_script( 'script',
  43. get_template_directory_uri() . '/src/assets/js/scripts.js', array() );
  44. }
  45. add_action( 'wp_footer', 'customJs' );
  46. // ADD OPTION PAGES
  47. if( function_exists('acf_add_options_page') ) {
  48. acf_add_options_page(array(
  49. 'page_title' => 'Information',
  50. 'menu_title' => 'Information',
  51. 'menu_slug' => 'information',
  52. 'capability' => 'edit_posts',
  53. 'redirect' => false
  54. ));
  55. acf_add_options_sub_page(array(
  56. 'page_title' => 'Partenaires',
  57. 'menu_title' => 'Partenaires',
  58. 'parent_slug' => 'information',
  59. ));
  60. }
  61. add_filter( 'timber_context', 'options_footer' );
  62. function options_footer( $context ) {
  63. $context['options'] = get_fields('option');
  64. return $context;
  65. }
  66. function post_temps_forts() {
  67. $labels = array(
  68. 'name' => _x('Les temps forts', 'Post Type General Name', 'la_mine'),
  69. 'singular_name' => _x('Temps fort', 'Post Type Singular Name', 'la_mine'),
  70. 'menu_name' => __('Les temps forts', 'la_mine'),
  71. 'name_admin_bar' => __('Les temps forts', 'la_mine'),
  72. 'parent_item_colon' => __('Parent Item:', 'la_mine'),
  73. 'all_items' => __('All temps forts', 'la_mine'),
  74. 'add_new_item' => __('Add New temps forts', 'la_mine'),
  75. 'add_new' => __('Add temps fort', 'la_mine'),
  76. 'new_item' => __('New temps fort', 'la_mine' ),
  77. 'edit_item' => __('Edit temps fort', 'la_mine'),
  78. 'update_item' => __('Update temps fort', 'la_mine'),
  79. 'view_item' => __('View temps fort', 'la_mine'),
  80. 'search_items' => __('Search temps fort', 'la_mine'),
  81. 'not_found' => __('Not found', 'la_mine'),
  82. 'not_found_in_trash' => __('Not found in Trash', 'la_mine'),
  83. );
  84. $rewrite = array(
  85. 'slug' => _x('les-temps-forts', 'les-temps-forts', 'la_mine'),
  86. 'with_front' => true,
  87. 'pages' => true,
  88. 'feeds' => false,
  89. );
  90. $args = array(
  91. 'label' => __('les-temps-forts', 'la_mine'),
  92. 'description' => __('Les temps forts', 'la_mine'),
  93. 'labels' => $labels,
  94. 'supports' => array('title', 'thumbnail', 'custom-fields'),
  95. 'taxonomies' => array('temps_forts_type'),
  96. 'hierarchical' => false,
  97. 'public' => true,
  98. 'show_ui' => true,
  99. 'show_in_menu' => true,
  100. 'menu_position' => 5,
  101. 'menu_icon' => 'dashicons-megaphone',
  102. 'show_in_admin_bar' => true,
  103. 'show_in_nav_menus' => true,
  104. 'can_export' => true,
  105. 'has_archive' => false,
  106. 'exclude_from_search' => false,
  107. 'publicly_queryable' => true,
  108. 'query_var' => 'temps_forts',
  109. 'rewrite' => $rewrite,
  110. 'capability_type' => 'page',
  111. );
  112. register_post_type('les-temps-forts', $args);
  113. }
  114. add_action('init', 'post_temps_forts', 10);
  115. function post_projets() {
  116. $labels = array(
  117. 'name' => _x('Les projets', 'Post Type General Name', 'la_mine'),
  118. 'singular_name' => _x('Projet', 'Post Type Singular Name', 'la_mine'),
  119. 'menu_name' => __('Les projets', 'la_mine'),
  120. 'name_admin_bar' => __('Les projets', 'la_mine'),
  121. 'parent_item_colon' => __('Parent Item:', 'la_mine'),
  122. 'all_items' => __('All projets', 'la_mine'),
  123. 'add_new_item' => __('Add New projet', 'la_mine'),
  124. 'add_new' => __('Add projet', 'la_mine'),
  125. 'new_item' => __('New projet', 'la_mine' ),
  126. 'edit_item' => __('Edit projet', 'la_mine'),
  127. 'update_item' => __('Update projet', 'la_mine'),
  128. 'view_item' => __('View projet', 'la_mine'),
  129. 'search_items' => __('Search projet', 'la_mine'),
  130. 'not_found' => __('Not found', 'la_mine'),
  131. 'not_found_in_trash' => __('Not found in Trash', 'la_mine'),
  132. );
  133. $rewrite = array(
  134. 'slug' => _x('les-projets', 'les-projets', 'la_mine'),
  135. 'with_front' => true,
  136. 'pages' => true,
  137. 'feeds' => false,
  138. );
  139. $args = array(
  140. 'label' => __('les-projets', 'la_mine'),
  141. 'description' => __('Les projets', 'la_mine'),
  142. 'labels' => $labels,
  143. 'supports' => array('title', 'thumbnail', 'custom-fields'),
  144. 'taxonomies' => array('les_projets_type'),
  145. 'hierarchical' => false,
  146. 'public' => true,
  147. 'show_ui' => true,
  148. 'show_in_menu' => true,
  149. 'menu_position' => 6,
  150. 'menu_icon' => 'dashicons-hammer',
  151. 'show_in_admin_bar' => true,
  152. 'show_in_nav_menus' => true,
  153. 'can_export' => true,
  154. 'has_archive' => false,
  155. 'exclude_from_search' => false,
  156. 'publicly_queryable' => true,
  157. 'query_var' => 'les_projets',
  158. 'rewrite' => $rewrite,
  159. 'capability_type' => 'page',
  160. );
  161. register_post_type('les-projets', $args);
  162. }
  163. add_action('init', 'post_projets', 10);
  164. add_action( 'init', 'cp_change_post_object' );
  165. // Change dashboard Posts to News
  166. function cp_change_post_object() {
  167. $get_post_type = get_post_type_object('post');
  168. $labels = $get_post_type->labels;
  169. $labels->name = 'Évenements';
  170. $labels->singular_name = 'Évenements';
  171. $labels->add_new = 'Add Évenements';
  172. $labels->add_new_item = 'Add Évenements';
  173. $labels->edit_item = 'Edit Évenements';
  174. $labels->new_item = 'Évenements';
  175. $labels->view_item = 'View Évenements';
  176. $labels->search_items = 'Search Évenements';
  177. $labels->not_found = 'No Évenements found';
  178. $labels->not_found_in_trash = 'No Évenements found in Trash';
  179. $labels->all_items = 'All Évenements';
  180. $labels->menu_name = 'Évenements';
  181. $labels->name_admin_bar = 'Évenements';
  182. }
  183. ?>