acf-pro.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <?php
  2. if ( ! class_exists( 'acf_pro' ) ) :
  3. class acf_pro {
  4. /*
  5. * __construct
  6. *
  7. *
  8. *
  9. * @type function
  10. * @date 23/06/12
  11. * @since 5.0.0
  12. *
  13. * @param N/A
  14. * @return N/A
  15. */
  16. function __construct() {
  17. // constants
  18. acf()->define( 'ACF_PRO', true );
  19. // update setting
  20. acf_update_setting( 'pro', true );
  21. acf_update_setting( 'name', __( 'Advanced Custom Fields PRO', 'acf' ) );
  22. // includes
  23. acf_include( 'pro/blocks.php' );
  24. acf_include( 'pro/options-page.php' );
  25. acf_include( 'pro/updates.php' );
  26. if ( is_admin() ) {
  27. acf_include( 'pro/admin/admin-options-page.php' );
  28. acf_include( 'pro/admin/admin-updates.php' );
  29. }
  30. // actions
  31. add_action( 'init', array( $this, 'register_assets' ) );
  32. add_action( 'acf/include_field_types', array( $this, 'include_field_types' ), 5 );
  33. add_action( 'acf/include_location_rules', array( $this, 'include_location_rules' ), 5 );
  34. add_action( 'acf/input/admin_enqueue_scripts', array( $this, 'input_admin_enqueue_scripts' ) );
  35. add_action( 'acf/field_group/admin_enqueue_scripts', array( $this, 'field_group_admin_enqueue_scripts' ) );
  36. }
  37. /**
  38. * Includes any files necessary for field types.
  39. *
  40. * @date 21/10/2015
  41. * @since 5.2.3
  42. */
  43. function include_field_types() {
  44. acf_include( 'pro/fields/class-acf-repeater-table.php' );
  45. acf_include( 'pro/fields/class-acf-field-repeater.php' );
  46. acf_include( 'pro/fields/class-acf-field-flexible-content.php' );
  47. acf_include( 'pro/fields/class-acf-field-gallery.php' );
  48. acf_include( 'pro/fields/class-acf-field-clone.php' );
  49. }
  50. /*
  51. * include_location_rules
  52. *
  53. * description
  54. *
  55. * @type function
  56. * @date 10/6/17
  57. * @since 5.6.0
  58. *
  59. * @param $post_id (int)
  60. * @return $post_id (int)
  61. */
  62. function include_location_rules() {
  63. acf_include( 'pro/locations/class-acf-location-block.php' );
  64. acf_include( 'pro/locations/class-acf-location-options-page.php' );
  65. }
  66. /*
  67. * register_assets
  68. *
  69. * description
  70. *
  71. * @type function
  72. * @date 4/11/2013
  73. * @since 5.0.0
  74. *
  75. * @param $post_id (int)
  76. * @return $post_id (int)
  77. */
  78. function register_assets() {
  79. // vars
  80. $version = acf_get_setting( 'version' );
  81. $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
  82. // register scripts
  83. wp_register_script( 'acf-pro-input', acf_get_url( "assets/build/js/pro/acf-pro-input{$min}.js" ), array( 'acf-input' ), $version );
  84. wp_register_script( 'acf-pro-field-group', acf_get_url( "assets/build/js/pro/acf-pro-field-group{$min}.js" ), array( 'acf-field-group' ), $version );
  85. // register styles
  86. wp_register_style( 'acf-pro-input', acf_get_url( 'assets/build/css/pro/acf-pro-input.css' ), array( 'acf-input' ), $version );
  87. wp_register_style( 'acf-pro-field-group', acf_get_url( 'assets/build/css/pro/acf-pro-field-group.css' ), array( 'acf-input' ), $version );
  88. }
  89. /*
  90. * input_admin_enqueue_scripts
  91. *
  92. * description
  93. *
  94. * @type function
  95. * @date 4/11/2013
  96. * @since 5.0.0
  97. *
  98. * @param $post_id (int)
  99. * @return $post_id (int)
  100. */
  101. function input_admin_enqueue_scripts() {
  102. wp_enqueue_script( 'acf-pro-input' );
  103. wp_enqueue_style( 'acf-pro-input' );
  104. }
  105. /*
  106. * field_group_admin_enqueue_scripts
  107. *
  108. * description
  109. *
  110. * @type function
  111. * @date 4/11/2013
  112. * @since 5.0.0
  113. *
  114. * @param $post_id (int)
  115. * @return $post_id (int)
  116. */
  117. function field_group_admin_enqueue_scripts() {
  118. wp_enqueue_script( 'acf-pro-field-group' );
  119. wp_enqueue_style( 'acf-pro-field-group' );
  120. }
  121. }
  122. // instantiate
  123. new acf_pro();
  124. // end class
  125. endif;