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