functions.php 7.1 KB

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