PluginProbe ʕ •ᴥ•ʔ
Secure Custom Fields / 6.4.0-beta2
Secure Custom Fields v6.4.0-beta2
6.9.5 6.9.4 6.9.3 6.9.2 6.9.1 6.9.0 6.8.9 6.8.7 6.8.8 6.8.6 6.8.4 6.8.5 trunk 6.4.0-beta1 6.4.0-beta2 6.4.1 6.4.1-beta3 6.4.1-beta4 6.4.1-beta5 6.4.1-beta6 6.4.1-beta7 6.4.2 6.5.0 6.5.1 6.5.2 6.5.3 6.5.4 6.5.5 6.5.6 6.5.7 6.6.0 6.7.0 6.7.1 6.8.0 6.8.1 6.8.2 6.8.3
secure-custom-fields / pro / acf-pro.php
secure-custom-fields / pro Last commit date
admin 1 year ago fields 1 year ago locations 1 year ago post-types 1 year ago acf-pro.php 1 year ago acf-ui-options-page-functions.php 1 year ago blocks.php 1 year ago index.php 1 year ago options-page.php 1 year ago
acf-pro.php
170 lines
1 <?php
2
3 if ( ! class_exists( 'acf_pro' ) ) :
4
5 /**
6 * The main ACF PRO class.
7 */
8 class acf_pro {
9
10 /**
11 * Main ACF PRO constructor
12 *
13 * @since 5.0.0
14 */
15 public function __construct() {
16 // constants
17 acf()->define( 'ACF_PRO', true );
18
19 // update setting
20 acf_update_setting( 'pro', true );
21
22 // includes
23 acf_include( 'pro/blocks.php' );
24 acf_include( 'pro/options-page.php' );
25 acf_include( 'pro/acf-ui-options-page-functions.php' );
26
27 if ( is_admin() ) {
28 acf_include( 'pro/admin/admin-options-page.php' );
29 }
30
31 // actions
32 add_action( 'init', array( $this, 'register_assets' ) );
33 add_action( 'acf/init_internal_post_types', array( $this, 'register_ui_options_pages' ) );
34 add_action( 'acf/include_fields', array( $this, 'include_options_pages' ) );
35 add_action( 'acf/include_field_types', array( $this, 'include_field_types' ), 5 );
36 add_action( 'acf/include_location_rules', array( $this, 'include_location_rules' ), 5 );
37 add_action( 'acf/input/admin_enqueue_scripts', array( $this, 'input_admin_enqueue_scripts' ) );
38 add_action( 'acf/field_group/admin_enqueue_scripts', array( $this, 'field_group_admin_enqueue_scripts' ) );
39
40 // Add filters.
41 add_filter( 'posts_where', array( $this, 'posts_where' ), 10, 2 );
42 }
43
44 /**
45 * Registers the `acf-ui-options-page` post type and initializes the UI.
46 *
47 * @since 6.2
48 */
49 public function register_ui_options_pages() {
50 if ( ! acf_get_setting( 'enable_options_pages_ui' ) ) {
51 return;
52 }
53
54 acf_include( 'pro/post-types/acf-ui-options-page.php' );
55 }
56
57 /**
58 * Action to include JSON options pages.
59 *
60 * @since 6.2
61 */
62 public function include_options_pages() {
63 /**
64 * Fires during initialization. Used to add JSON options pages.
65 *
66 * @since 6.2
67 *
68 * @param int ACF_MAJOR_VERSION The major version of ACF.
69 */
70 do_action( 'acf/include_options_pages', ACF_MAJOR_VERSION );
71 }
72
73 /**
74 * Includes any files necessary for field types.
75 *
76 * @since 5.2.3
77 *
78 * @return void
79 */
80 public function include_field_types() {
81 acf_include( 'pro/fields/class-acf-repeater-table.php' );
82 acf_include( 'pro/fields/class-acf-field-repeater.php' );
83 acf_include( 'pro/fields/class-acf-field-flexible-content.php' );
84 acf_include( 'pro/fields/class-acf-field-gallery.php' );
85 acf_include( 'pro/fields/class-acf-field-clone.php' );
86 }
87
88 /**
89 * Includes location rules for ACF PRO.
90 *
91 * @since 5.6.0
92 *
93 * @return void
94 */
95 public function include_location_rules() {
96 acf_include( 'pro/locations/class-acf-location-block.php' );
97 acf_include( 'pro/locations/class-acf-location-options-page.php' );
98 }
99
100 /**
101 * Registers styles and scripts used by ACF PRO.
102 *
103 * @since 5.0.0
104 */
105 public function register_assets() {
106 $version = acf_get_setting( 'version' );
107 $min = defined( 'SCF_DEVELOPMENT_MODE' ) && SCF_DEVELOPMENT_MODE ? '' : '.min';
108
109 // Register scripts.
110 wp_register_script( 'acf-pro-input', acf_get_url( "assets/build/js/pro/acf-pro-input{$min}.js" ), array( 'acf-input' ), $version );
111 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 );
112 wp_register_script( 'acf-pro-ui-options-page', acf_get_url( "assets/build/js/pro/acf-pro-ui-options-page{$min}.js" ), array( 'acf-input' ), $version );
113
114 // Register styles.
115 wp_register_style( 'acf-pro-input', acf_get_url( 'assets/build/css/pro/acf-pro-input.css' ), array( 'acf-input' ), $version );
116 wp_register_style( 'acf-pro-field-group', acf_get_url( 'assets/build/css/pro/acf-pro-field-group.css' ), array( 'acf-input' ), $version );
117 }
118
119 /**
120 * Enqueue the PRO admin screen scripts and styles
121 *
122 * @since 5.0.0
123 */
124 public function input_admin_enqueue_scripts() {
125 wp_enqueue_script( 'acf-pro-input' );
126 wp_enqueue_script( 'acf-pro-ui-options-page' );
127 wp_enqueue_style( 'acf-pro-input' );
128 }
129
130 /**
131 * Enqueue the PRO field group scripts and styles
132 *
133 * @since 5.0.0
134 */
135 public function field_group_admin_enqueue_scripts() {
136 wp_enqueue_script( 'acf-pro-field-group' );
137 wp_enqueue_style( 'acf-pro-field-group' );
138 }
139
140 /**
141 * Filters the $where clause allowing for custom WP_Query args.
142 *
143 * @since 6.2
144 *
145 * @param string $where The WHERE clause.
146 * @param WP_Query $wp_query The query object.
147 * @return string
148 */
149 public function posts_where( $where, $wp_query ) {
150 global $wpdb;
151
152 $options_page_key = $wp_query->get( 'acf_ui_options_page_key' );
153
154 // Add custom "acf_options_page_key" arg.
155 if ( $options_page_key ) {
156 $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_name = %s", $options_page_key );
157 }
158
159 return $where;
160 }
161 }
162
163
164 // instantiate
165 new acf_pro();
166
167
168 // end class
169 endif;
170