functions.php 6.7 KB

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