functions.php 6.6 KB

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