functions.php 6.8 KB

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