functions.php 7.0 KB

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