acf-settings.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. // Hide ACF field group menu item
  3. add_filter('acf/settings/show_admin', '__return_false');
  4. // Customize ACF path
  5. add_filter('acf/settings/path', 'my_acf_settings_path');
  6. function my_acf_settings_path($path)
  7. {
  8. // update path
  9. $path = get_stylesheet_directory() . '/inc/acf/';
  10. // return
  11. return $path;
  12. }
  13. // Customize ACF dir
  14. add_filter('acf/settings/dir', 'my_acf_settings_dir');
  15. function my_acf_settings_dir($dir)
  16. {
  17. // update path
  18. $dir = get_stylesheet_directory_uri() . '/inc/acf/';
  19. // return
  20. return $dir;
  21. }
  22. // Save ACF field as JSON
  23. add_filter('acf/settings/save_json', 'my_acf_json_save_point');
  24. function my_acf_json_save_point($path)
  25. {
  26. // update path
  27. $path = get_stylesheet_directory() . '/inc/acf-json';
  28. // return
  29. return $path;
  30. }
  31. // Load ACF field from JSON
  32. add_filter('acf/settings/load_json', 'my_acf_json_load_point');
  33. function my_acf_json_load_point($paths)
  34. {
  35. // remove original path (optional)
  36. unset($paths[0]);
  37. // append path
  38. $paths[] = get_stylesheet_directory() . '/inc/acf-json';
  39. // return
  40. return $paths;
  41. }
  42. // add_filter('acf/settings/save_json', function() {
  43. // return get_stylesheet_directory() . '/acf-json';
  44. // });
  45. // add_filter('acf/settings/load_json', function($paths) {
  46. // // $paths will already include the result of get_stylesheet_directory ie. parent theme's acf-json
  47. // if(is_child_theme()) {
  48. // $paths[] = get_template_directory() . '/acf-json';
  49. // }
  50. // return $paths;
  51. // });
  52. // Theme Options
  53. if (function_exists('acf_add_options_page')) {
  54. acf_add_options_page(array(
  55. 'page_title' => 'Departmental Theme: General Settings',
  56. 'menu_title' => 'Theme Settings',
  57. 'menu_slug' => 'uiu-departmental-general-settings',
  58. 'capability' => 'edit_posts',
  59. 'position' => '10.5',
  60. 'redirect' => false
  61. ));
  62. acf_add_options_sub_page(array(
  63. 'page_title' => 'Departmental Theme: Menu Rich Contents',
  64. 'menu_title' => 'Menu Settings',
  65. 'slug' => 'uiu-departmental-menu-settings',
  66. 'parent_slug' => 'uiu-departmental-general-settings',
  67. ));
  68. acf_add_options_sub_page(array(
  69. 'page_title' => 'Departmental Theme: All Sliders',
  70. 'menu_title' => 'Slider Settings',
  71. 'parent_slug' => 'uiu-departmental-general-settings',
  72. ));
  73. acf_add_options_sub_page(array(
  74. 'page_title' => 'Departmental Theme: Recognitions',
  75. 'menu_title' => 'UIU Recognitions',
  76. 'parent_slug' => 'uiu-departmental-general-settings',
  77. ));
  78. acf_add_options_sub_page(array(
  79. 'page_title' => 'Departmental Theme: API Settings',
  80. 'menu_title' => 'API Settings',
  81. 'parent_slug' => 'uiu-departmental-general-settings',
  82. ));
  83. // acf_add_options_sub_page(array(
  84. // 'page_title' => 'Theme Footer Settings',
  85. // 'menu_title' => 'Footer',
  86. // 'parent_slug' => 'uiu-departmental-general-settings',
  87. // ));
  88. }