PluginProbe ʕ •ᴥ•ʔ
Secure Custom Fields / 6.9.4
Secure Custom Fields v6.9.4
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 / includes / ajax / class-acf-ajax-check-screen.php
secure-custom-fields / includes / ajax Last commit date
class-acf-ajax-check-screen.php 2 months ago class-acf-ajax-local-json-diff.php 1 year ago class-acf-ajax-query-users.php 4 months ago class-acf-ajax-query.php 5 months ago class-acf-ajax-upgrade.php 2 months ago class-acf-ajax-user-setting.php 1 year ago class-acf-ajax.php 1 year ago index.php 1 year ago
class-acf-ajax-check-screen.php
117 lines
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit; // Exit if accessed directly
5 }
6
7 if ( ! class_exists( 'ACF_Ajax_Check_Screen' ) ) :
8
9 class ACF_Ajax_Check_Screen extends ACF_Ajax {
10
11 /** @var string The AJAX action name. */
12 var $action = 'acf/ajax/check_screen';
13
14 /** @var boolean Prevents access for non-logged in users. */
15 var $public = false;
16
17 /**
18 * Returns the response data to sent back.
19 *
20 * @since ACF 5.7.2.7.2
21 *
22 * @param array $request The request args.
23 * @return array|WP_Error The response data or WP_Error.
24 */
25 public function get_response( $request ) {
26 $args = wp_parse_args(
27 $this->request,
28 array(
29 'screen' => '',
30 'post_id' => 0,
31 'ajax' => true,
32 'exists' => array(),
33 )
34 );
35
36 if ( ! acf_current_user_can_edit_post( (int) $args['post_id'] ) ) {
37 return new WP_Error( 'acf_invalid_permissions', __( 'Sorry, you do not have permission to do that.', 'secure-custom-fields' ) );
38 }
39
40 $response = array(
41 'results' => array(),
42 'style' => '',
43 );
44
45 // get field groups
46 $field_groups = acf_get_field_groups( $args );
47
48 // loop through field groups
49 if ( $field_groups ) {
50 foreach ( $field_groups as $i => $field_group ) {
51
52 // vars
53 $item = array(
54 'id' => esc_attr( 'acf-' . $field_group['key'] ),
55 'key' => esc_attr( $field_group['key'] ),
56 'title' => acf_esc_html( acf_get_field_group_title( $field_group ) ),
57 'position' => esc_attr( $field_group['position'] ),
58 'classes' => postbox_classes( 'acf-' . $field_group['key'], $args['screen'] ),
59 'style' => esc_attr( $field_group['style'] ),
60 'label' => esc_attr( $field_group['label_placement'] ),
61 'edit' => esc_url( acf_get_field_group_edit_link( $field_group['ID'] ) ),
62 'html' => '',
63 );
64
65 $hidden_metaboxes = get_hidden_meta_boxes( $args['screen'] );
66
67 if ( is_array( $hidden_metaboxes ) && in_array( $item['id'], $hidden_metaboxes ) ) {
68 $item['classes'] = trim( $item['classes'] . ' hide-if-js' );
69 }
70
71 $item['classes'] = esc_attr( $item['classes'] );
72
73 // append html if doesnt already exist on page
74 if ( ! in_array( $field_group['key'], $args['exists'] ) ) {
75
76 // load fields
77 $fields = acf_get_fields( $field_group );
78
79 // get field HTML
80 ob_start();
81
82 // render
83 acf_render_fields( $fields, $args['post_id'], 'div', $field_group['instruction_placement'] );
84
85 $item['html'] = ob_get_clean();
86 }
87
88 // append
89 $response['results'][] = $item;
90 }
91
92 // Get style from first field group.
93 $response['style'] = acf_get_field_group_style( $field_groups[0] );
94 }
95
96 // Custom metabox order.
97 if ( $this->get( 'screen' ) == 'post' ) {
98 $response['sorted'] = get_user_option( 'meta-box-order_' . $this->get( 'post_type' ) );
99 }
100
101 /**
102 * Filters the check_screen response, allowing extensions to attach
103 * extra data tied to the screen.
104 *
105 * @since ACF 6.8.1
106 *
107 * @param array $response The response array.
108 * @param array $field_groups The field groups returned for this screen.
109 * @param array $args The check_screen request args.
110 */
111 return apply_filters( 'acf/ajax/check_screen/response', $response, $field_groups, $args );
112 }
113 }
114
115 acf_new_instance( 'ACF_Ajax_Check_Screen' );
116 endif; // class_exists check
117