PluginProbe ʕ •ᴥ•ʔ
Advanced Custom Fields: Extended / 0.9.2.7
Advanced Custom Fields: Extended v0.9.2.7
0.9.2.7 0.9.2.6 0.9.2.5 0.8.6 0.8.6.1 0.8.6.3 0.8.6.5 0.8.6.6 0.8.6.7 0.8.6.8 0.8.6.9 0.8.7 0.8.7.1 0.8.7.2 0.8.7.3 0.8.7.4 0.8.7.5 0.8.7.6 0.8.8 0.8.8.1 0.8.8.10 0.8.8.11 0.8.8.2 0.8.8.3 0.8.8.4 0.8.8.5 0.8.8.6 0.8.8.7 0.8.8.8 0.8.8.9 0.8.9 0.8.9.1 0.8.9.2 0.8.9.3 0.8.9.4 0.8.9.5 0.9 0.9.0.1 0.9.0.2 0.9.0.3 0.9.0.4 0.9.0.5 0.9.0.6 0.9.0.7 0.9.0.8 0.9.0.9 0.9.1 0.9.1.1 0.9.2 0.9.2.1 0.9.2.2 0.9.2.3 0.9.2.4 trunk 0.5 0.5.1 0.5.2 0.5.2.1 0.5.2.3 0.5.5 0.5.5.1 0.5.8 0.5.8.1 0.6 0.6.0.1 0.6.0.2 0.6.1 0.6.3 0.6.5 0.6.7 0.6.7.2 0.7 0.7.0.3 0.7.5 0.7.5.5 0.7.8 0.7.9 0.7.9.3 0.7.9.4 0.7.9.9.8 0.7.9.9.9 0.8 0.8.1 0.8.2 0.8.3 0.8.3.1 0.8.4 0.8.4.1 0.8.4.5 0.8.4.6 0.8.5 0.8.5.5
acf-extended / includes / screen.php
acf-extended / includes Last commit date
admin 3 months ago field-groups 3 months ago fields 1 week ago fields-settings 3 months ago forms 3 months ago locations 3 months ago modules 1 week ago screens 3 months ago acfe-deprecated-functions.php 2 years ago acfe-field-functions.php 3 months ago acfe-field-group-functions.php 3 months ago acfe-file-functions.php 1 year ago acfe-form-functions.php 3 months ago acfe-helper-array-functions.php 3 months ago acfe-helper-functions.php 3 months ago acfe-helper-multi-functions.php 3 months ago acfe-helper-string-functions.php 3 months ago acfe-meta-functions.php 3 months ago acfe-post-functions.php 3 months ago acfe-screen-functions.php 3 months ago acfe-template-functions.php 3 months ago acfe-term-functions.php 3 months ago acfe-user-functions.php 3 months ago acfe-wp-functions.php 3 years ago assets.php 3 months ago compatibility-acf-5.8.php 4 months ago compatibility-acf-5.9.php 3 months ago compatibility-acf-6.5.php 3 months ago compatibility-acf-6.8.6.php 1 week ago compatibility.php 3 months ago field-extend.php 4 months ago field.php 4 months ago hooks.php 3 months ago init.php 3 months ago local-meta.php 3 years ago media.php 3 months ago module-acf.php 3 months ago module-db.php 3 months ago module-l10n.php 3 months ago module-legacy.php 3 years ago module-manager.php 4 months ago module-post.php 3 months ago module-posts.php 4 months ago module-upgrades.php 3 years ago module.php 3 months ago multilang.php 3 months ago revisions.php 4 months ago screen.php 3 months ago settings.php 3 months ago template-tags.php 3 months ago third-party.php 3 years ago upgrades.php 3 months ago
screen.php
142 lines
1 <?php
2
3 if(!defined('ABSPATH')){
4 exit;
5 }
6
7 if(!class_exists('acfe_screen')):
8
9 class acfe_screen{
10
11 var $data = array();
12
13 /**
14 * construct
15 */
16 function __construct(){
17
18 // form data
19 add_filter('acf/location/screen', array($this, 'acf_location_screen'), 99);
20 add_action('acf/input/form_data', array($this, 'acf_form_data'));
21 add_action('acf/validate_save_post', array($this, 'acf_validate_save_post'), 0);
22 add_action('acf/save_post', array($this, 'acf_save_post'), 0);
23
24 }
25
26
27 /**
28 * acf_location_screen
29 *
30 * acf/location/screen:99
31 *
32 * @param $screen
33 *
34 * @return mixed
35 */
36 function acf_location_screen($screen){
37
38 // clone var
39 $location = $screen;
40
41 // remove vars
42 acf_extract_vars($location, array('lang', 'ajax'));
43
44 // set form data for later use
45 acf_set_form_data('location', $location);
46
47 // return
48 return $screen;
49
50 }
51
52
53 /**
54 * acf_form_data
55 *
56 * acf/input/form_data
57 */
58 function acf_form_data($data){
59
60 // retrieve location from screen filter
61 $location = acf_get_form_data('location');
62
63 // prepare data to encrypt
64 $encrypt = array(
65 'screen' => acfe_get($data, 'screen', 'post'),
66 'post_id' => acfe_get($data, 'post_id', 0),
67 'location' => $location ?: false,
68 );
69
70 // render input
71 acf_hidden_input(array(
72 'id' => "_acfe_data",
73 'name' => "_acfe_data",
74 'value' => acf_encrypt(json_encode($encrypt))
75 ));
76
77 }
78
79
80 /**
81 * acf_save_post_form_data
82 *
83 * acf/validate_save_post:0
84 */
85 function acf_validate_save_post(){
86
87 // get data
88 $data = acf_maybe_get_POST('_acfe_data');
89 if(empty($data)){
90 return;
91 }
92
93 // decrypt data
94 $decrypt = json_decode(acf_decrypt($data), true);
95 if(empty($decrypt) || !is_array($decrypt)){
96 return;
97 }
98
99 // default
100 $decrypt = wp_parse_args($decrypt, array(
101 'screen' => 'post',
102 'post_id' => 0,
103 'location' => false,
104 ));
105
106 // store data for later use in acf/save_post
107 $this->data = $decrypt;
108
109 // loop allowed keys
110 foreach($decrypt as $key => $value){
111 acf_set_form_data($key, $value);
112 }
113
114 }
115
116
117 /**
118 * acf_save_post
119 *
120 * Update the post_id form data again because ACF manually set it in acf_save_post()
121 * This is problematic for front-end submission where acfe_form() make a dry-save with acf_save_post(false) to upload files
122 *
123 * acf/save_post:0
124 *
125 * @param $post_id
126 *
127 * @return void
128 */
129 function acf_save_post($post_id){
130
131 // bail early if no data
132 if(!empty($this->data)){
133 acf_set_form_data('post_id', acfe_get($this->data, 'post_id', 0));
134 }
135
136 }
137
138 }
139
140 acf_new_instance('acfe_screen');
141
142 endif;