@@ -17,118 +17,118 @@ |
||
17 | 17 | */ |
18 | 18 | abstract class AbstractLogger implements LoggerInterface |
19 | 19 | { |
20 | - /** |
|
21 | - * System is unusable. |
|
22 | - * |
|
23 | - * @param string $message |
|
24 | - * @param mixed[] $context |
|
25 | - * |
|
26 | - * @return void |
|
27 | - */ |
|
28 | - public function emergency($message, array $context = array()) |
|
29 | - { |
|
30 | - $this->log(LogLevel::EMERGENCY, $message, $context); |
|
31 | - } |
|
20 | + /** |
|
21 | + * System is unusable. |
|
22 | + * |
|
23 | + * @param string $message |
|
24 | + * @param mixed[] $context |
|
25 | + * |
|
26 | + * @return void |
|
27 | + */ |
|
28 | + public function emergency($message, array $context = array()) |
|
29 | + { |
|
30 | + $this->log(LogLevel::EMERGENCY, $message, $context); |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * Action must be taken immediately. |
|
35 | - * |
|
36 | - * Example: Entire website down, database unavailable, etc. This should |
|
37 | - * trigger the SMS alerts and wake you up. |
|
38 | - * |
|
39 | - * @param string $message |
|
40 | - * @param mixed[] $context |
|
41 | - * |
|
42 | - * @return void |
|
43 | - */ |
|
44 | - public function alert($message, array $context = array()) |
|
45 | - { |
|
46 | - $this->log(LogLevel::ALERT, $message, $context); |
|
47 | - } |
|
33 | + /** |
|
34 | + * Action must be taken immediately. |
|
35 | + * |
|
36 | + * Example: Entire website down, database unavailable, etc. This should |
|
37 | + * trigger the SMS alerts and wake you up. |
|
38 | + * |
|
39 | + * @param string $message |
|
40 | + * @param mixed[] $context |
|
41 | + * |
|
42 | + * @return void |
|
43 | + */ |
|
44 | + public function alert($message, array $context = array()) |
|
45 | + { |
|
46 | + $this->log(LogLevel::ALERT, $message, $context); |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * Critical conditions. |
|
51 | - * |
|
52 | - * Example: Application component unavailable, unexpected exception. |
|
53 | - * |
|
54 | - * @param string $message |
|
55 | - * @param mixed[] $context |
|
56 | - * |
|
57 | - * @return void |
|
58 | - */ |
|
59 | - public function critical($message, array $context = array()) |
|
60 | - { |
|
61 | - $this->log(LogLevel::CRITICAL, $message, $context); |
|
62 | - } |
|
49 | + /** |
|
50 | + * Critical conditions. |
|
51 | + * |
|
52 | + * Example: Application component unavailable, unexpected exception. |
|
53 | + * |
|
54 | + * @param string $message |
|
55 | + * @param mixed[] $context |
|
56 | + * |
|
57 | + * @return void |
|
58 | + */ |
|
59 | + public function critical($message, array $context = array()) |
|
60 | + { |
|
61 | + $this->log(LogLevel::CRITICAL, $message, $context); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * Runtime errors that do not require immediate action but should typically |
|
66 | - * be logged and monitored. |
|
67 | - * |
|
68 | - * @param string $message |
|
69 | - * @param mixed[] $context |
|
70 | - * |
|
71 | - * @return void |
|
72 | - */ |
|
73 | - public function error($message, array $context = array()) |
|
74 | - { |
|
75 | - $this->log(LogLevel::ERROR, $message, $context); |
|
76 | - } |
|
64 | + /** |
|
65 | + * Runtime errors that do not require immediate action but should typically |
|
66 | + * be logged and monitored. |
|
67 | + * |
|
68 | + * @param string $message |
|
69 | + * @param mixed[] $context |
|
70 | + * |
|
71 | + * @return void |
|
72 | + */ |
|
73 | + public function error($message, array $context = array()) |
|
74 | + { |
|
75 | + $this->log(LogLevel::ERROR, $message, $context); |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * Exceptional occurrences that are not errors. |
|
80 | - * |
|
81 | - * Example: Use of deprecated APIs, poor use of an API, undesirable things |
|
82 | - * that are not necessarily wrong. |
|
83 | - * |
|
84 | - * @param string $message |
|
85 | - * @param mixed[] $context |
|
86 | - * |
|
87 | - * @return void |
|
88 | - */ |
|
89 | - public function warning($message, array $context = array()) |
|
90 | - { |
|
91 | - $this->log(LogLevel::WARNING, $message, $context); |
|
92 | - } |
|
78 | + /** |
|
79 | + * Exceptional occurrences that are not errors. |
|
80 | + * |
|
81 | + * Example: Use of deprecated APIs, poor use of an API, undesirable things |
|
82 | + * that are not necessarily wrong. |
|
83 | + * |
|
84 | + * @param string $message |
|
85 | + * @param mixed[] $context |
|
86 | + * |
|
87 | + * @return void |
|
88 | + */ |
|
89 | + public function warning($message, array $context = array()) |
|
90 | + { |
|
91 | + $this->log(LogLevel::WARNING, $message, $context); |
|
92 | + } |
|
93 | 93 | |
94 | - /** |
|
95 | - * Normal but significant events. |
|
96 | - * |
|
97 | - * @param string $message |
|
98 | - * @param mixed[] $context |
|
99 | - * |
|
100 | - * @return void |
|
101 | - */ |
|
102 | - public function notice($message, array $context = array()) |
|
103 | - { |
|
104 | - $this->log(LogLevel::NOTICE, $message, $context); |
|
105 | - } |
|
94 | + /** |
|
95 | + * Normal but significant events. |
|
96 | + * |
|
97 | + * @param string $message |
|
98 | + * @param mixed[] $context |
|
99 | + * |
|
100 | + * @return void |
|
101 | + */ |
|
102 | + public function notice($message, array $context = array()) |
|
103 | + { |
|
104 | + $this->log(LogLevel::NOTICE, $message, $context); |
|
105 | + } |
|
106 | 106 | |
107 | - /** |
|
108 | - * Interesting events. |
|
109 | - * |
|
110 | - * Example: User logs in, SQL logs. |
|
111 | - * |
|
112 | - * @param string $message |
|
113 | - * @param mixed[] $context |
|
114 | - * |
|
115 | - * @return void |
|
116 | - */ |
|
117 | - public function info($message, array $context = array()) |
|
118 | - { |
|
119 | - $this->log(LogLevel::INFO, $message, $context); |
|
120 | - } |
|
107 | + /** |
|
108 | + * Interesting events. |
|
109 | + * |
|
110 | + * Example: User logs in, SQL logs. |
|
111 | + * |
|
112 | + * @param string $message |
|
113 | + * @param mixed[] $context |
|
114 | + * |
|
115 | + * @return void |
|
116 | + */ |
|
117 | + public function info($message, array $context = array()) |
|
118 | + { |
|
119 | + $this->log(LogLevel::INFO, $message, $context); |
|
120 | + } |
|
121 | 121 | |
122 | - /** |
|
123 | - * Detailed debug information. |
|
124 | - * |
|
125 | - * @param string $message |
|
126 | - * @param mixed[] $context |
|
127 | - * |
|
128 | - * @return void |
|
129 | - */ |
|
130 | - public function debug($message, array $context = array()) |
|
131 | - { |
|
132 | - $this->log(LogLevel::DEBUG, $message, $context); |
|
133 | - } |
|
122 | + /** |
|
123 | + * Detailed debug information. |
|
124 | + * |
|
125 | + * @param string $message |
|
126 | + * @param mixed[] $context |
|
127 | + * |
|
128 | + * @return void |
|
129 | + */ |
|
130 | + public function debug($message, array $context = array()) |
|
131 | + { |
|
132 | + $this->log(LogLevel::DEBUG, $message, $context); |
|
133 | + } |
|
134 | 134 | } |
@@ -13,12 +13,12 @@ |
||
13 | 13 | */ |
14 | 14 | interface LoggerAwareInterface |
15 | 15 | { |
16 | - /** |
|
17 | - * Sets a logger instance on the object. |
|
18 | - * |
|
19 | - * @param LoggerInterface $logger |
|
20 | - * |
|
21 | - * @return void |
|
22 | - */ |
|
23 | - public function setLogger(LoggerInterface $logger); |
|
16 | + /** |
|
17 | + * Sets a logger instance on the object. |
|
18 | + * |
|
19 | + * @param LoggerInterface $logger |
|
20 | + * |
|
21 | + * @return void |
|
22 | + */ |
|
23 | + public function setLogger(LoggerInterface $logger); |
|
24 | 24 | } |
@@ -62,92 +62,92 @@ |
||
62 | 62 | */ |
63 | 63 | class TestLogger extends AbstractLogger |
64 | 64 | { |
65 | - /** |
|
66 | - * @var array |
|
67 | - */ |
|
68 | - public $records = []; |
|
65 | + /** |
|
66 | + * @var array |
|
67 | + */ |
|
68 | + public $records = []; |
|
69 | 69 | |
70 | - public $recordsByLevel = []; |
|
70 | + public $recordsByLevel = []; |
|
71 | 71 | |
72 | - /** |
|
73 | - * @inheritdoc |
|
74 | - */ |
|
75 | - public function log($level, $message, array $context = []) |
|
76 | - { |
|
77 | - $record = [ |
|
78 | - 'level' => $level, |
|
79 | - 'message' => $message, |
|
80 | - 'context' => $context, |
|
81 | - ]; |
|
72 | + /** |
|
73 | + * @inheritdoc |
|
74 | + */ |
|
75 | + public function log($level, $message, array $context = []) |
|
76 | + { |
|
77 | + $record = [ |
|
78 | + 'level' => $level, |
|
79 | + 'message' => $message, |
|
80 | + 'context' => $context, |
|
81 | + ]; |
|
82 | 82 | |
83 | - $this->recordsByLevel[$record['level']][] = $record; |
|
84 | - $this->records[] = $record; |
|
85 | - } |
|
83 | + $this->recordsByLevel[$record['level']][] = $record; |
|
84 | + $this->records[] = $record; |
|
85 | + } |
|
86 | 86 | |
87 | - public function hasRecords($level) |
|
88 | - { |
|
89 | - return isset($this->recordsByLevel[$level]); |
|
90 | - } |
|
87 | + public function hasRecords($level) |
|
88 | + { |
|
89 | + return isset($this->recordsByLevel[$level]); |
|
90 | + } |
|
91 | 91 | |
92 | - public function hasRecord($record, $level) |
|
93 | - { |
|
94 | - if (is_string($record)) { |
|
95 | - $record = ['message' => $record]; |
|
96 | - } |
|
97 | - return $this->hasRecordThatPasses(function ($rec) use ($record) { |
|
98 | - if ($rec['message'] !== $record['message']) { |
|
99 | - return false; |
|
100 | - } |
|
101 | - if (isset($record['context']) && $rec['context'] !== $record['context']) { |
|
102 | - return false; |
|
103 | - } |
|
104 | - return true; |
|
105 | - }, $level); |
|
106 | - } |
|
92 | + public function hasRecord($record, $level) |
|
93 | + { |
|
94 | + if (is_string($record)) { |
|
95 | + $record = ['message' => $record]; |
|
96 | + } |
|
97 | + return $this->hasRecordThatPasses(function ($rec) use ($record) { |
|
98 | + if ($rec['message'] !== $record['message']) { |
|
99 | + return false; |
|
100 | + } |
|
101 | + if (isset($record['context']) && $rec['context'] !== $record['context']) { |
|
102 | + return false; |
|
103 | + } |
|
104 | + return true; |
|
105 | + }, $level); |
|
106 | + } |
|
107 | 107 | |
108 | - public function hasRecordThatContains($message, $level) |
|
109 | - { |
|
110 | - return $this->hasRecordThatPasses(function ($rec) use ($message) { |
|
111 | - return strpos($rec['message'], $message) !== false; |
|
112 | - }, $level); |
|
113 | - } |
|
108 | + public function hasRecordThatContains($message, $level) |
|
109 | + { |
|
110 | + return $this->hasRecordThatPasses(function ($rec) use ($message) { |
|
111 | + return strpos($rec['message'], $message) !== false; |
|
112 | + }, $level); |
|
113 | + } |
|
114 | 114 | |
115 | - public function hasRecordThatMatches($regex, $level) |
|
116 | - { |
|
117 | - return $this->hasRecordThatPasses(function ($rec) use ($regex) { |
|
118 | - return preg_match($regex, $rec['message']) > 0; |
|
119 | - }, $level); |
|
120 | - } |
|
115 | + public function hasRecordThatMatches($regex, $level) |
|
116 | + { |
|
117 | + return $this->hasRecordThatPasses(function ($rec) use ($regex) { |
|
118 | + return preg_match($regex, $rec['message']) > 0; |
|
119 | + }, $level); |
|
120 | + } |
|
121 | 121 | |
122 | - public function hasRecordThatPasses(callable $predicate, $level) |
|
123 | - { |
|
124 | - if (!isset($this->recordsByLevel[$level])) { |
|
125 | - return false; |
|
126 | - } |
|
127 | - foreach ($this->recordsByLevel[$level] as $i => $rec) { |
|
128 | - if (call_user_func($predicate, $rec, $i)) { |
|
129 | - return true; |
|
130 | - } |
|
131 | - } |
|
132 | - return false; |
|
133 | - } |
|
122 | + public function hasRecordThatPasses(callable $predicate, $level) |
|
123 | + { |
|
124 | + if (!isset($this->recordsByLevel[$level])) { |
|
125 | + return false; |
|
126 | + } |
|
127 | + foreach ($this->recordsByLevel[$level] as $i => $rec) { |
|
128 | + if (call_user_func($predicate, $rec, $i)) { |
|
129 | + return true; |
|
130 | + } |
|
131 | + } |
|
132 | + return false; |
|
133 | + } |
|
134 | 134 | |
135 | - public function __call($method, $args) |
|
136 | - { |
|
137 | - if (preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches) > 0) { |
|
138 | - $genericMethod = $matches[1] . ('Records' !== $matches[3] ? 'Record' : '') . $matches[3]; |
|
139 | - $level = strtolower($matches[2]); |
|
140 | - if (method_exists($this, $genericMethod)) { |
|
141 | - $args[] = $level; |
|
142 | - return call_user_func_array([$this, $genericMethod], $args); |
|
143 | - } |
|
144 | - } |
|
145 | - throw new \BadMethodCallException('Call to undefined method ' . get_class($this) . '::' . $method . '()'); |
|
146 | - } |
|
135 | + public function __call($method, $args) |
|
136 | + { |
|
137 | + if (preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches) > 0) { |
|
138 | + $genericMethod = $matches[1] . ('Records' !== $matches[3] ? 'Record' : '') . $matches[3]; |
|
139 | + $level = strtolower($matches[2]); |
|
140 | + if (method_exists($this, $genericMethod)) { |
|
141 | + $args[] = $level; |
|
142 | + return call_user_func_array([$this, $genericMethod], $args); |
|
143 | + } |
|
144 | + } |
|
145 | + throw new \BadMethodCallException('Call to undefined method ' . get_class($this) . '::' . $method . '()'); |
|
146 | + } |
|
147 | 147 | |
148 | - public function reset() |
|
149 | - { |
|
150 | - $this->records = []; |
|
151 | - $this->recordsByLevel = []; |
|
152 | - } |
|
148 | + public function reset() |
|
149 | + { |
|
150 | + $this->records = []; |
|
151 | + $this->recordsByLevel = []; |
|
152 | + } |
|
153 | 153 | } |
@@ -17,8 +17,8 @@ |
||
17 | 17 | */ |
18 | 18 | class DummyTest |
19 | 19 | { |
20 | - public function __toString() |
|
21 | - { |
|
22 | - return 'DummyTest'; |
|
23 | - } |
|
20 | + public function __toString() |
|
21 | + { |
|
22 | + return 'DummyTest'; |
|
23 | + } |
|
24 | 24 | } |
@@ -13,12 +13,12 @@ |
||
13 | 13 | */ |
14 | 14 | class LogLevel |
15 | 15 | { |
16 | - const EMERGENCY = 'emergency'; |
|
17 | - const ALERT = 'alert'; |
|
18 | - const CRITICAL = 'critical'; |
|
19 | - const ERROR = 'error'; |
|
20 | - const WARNING = 'warning'; |
|
21 | - const NOTICE = 'notice'; |
|
22 | - const INFO = 'info'; |
|
23 | - const DEBUG = 'debug'; |
|
16 | + const EMERGENCY = 'emergency'; |
|
17 | + const ALERT = 'alert'; |
|
18 | + const CRITICAL = 'critical'; |
|
19 | + const ERROR = 'error'; |
|
20 | + const WARNING = 'warning'; |
|
21 | + const NOTICE = 'notice'; |
|
22 | + const INFO = 'info'; |
|
23 | + const DEBUG = 'debug'; |
|
24 | 24 | } |
@@ -250,14 +250,14 @@ discard block |
||
250 | 250 | /** |
251 | 251 | * update_approved function. |
252 | 252 | * |
253 | - * @since 1.18 Moved to GravityView_Entry_Approval::update_approved |
|
253 | + * @since 1.18 Moved to GravityView_Entry_Approval::update_approved |
|
254 | 254 | * @see GravityView_Entry_Approval::update_approved |
255 | - * |
|
255 | + * |
|
256 | 256 | * @param int $entry_id (default: 0) |
257 | 257 | * @param int $approved (default: 0) |
258 | 258 | * @param int $form_id (default: 0) |
259 | 259 | * @param int $approvedcolumn (default: 0) |
260 | - * |
|
260 | + * |
|
261 | 261 | * @return boolean True: It worked; False: it failed |
262 | 262 | */ |
263 | 263 | public static function update_approved( $entry_id = 0, $approved = 0, $form_id = 0, $approvedcolumn = 0) { |
@@ -267,9 +267,9 @@ discard block |
||
267 | 267 | /** |
268 | 268 | * Calculate the approve field.input id |
269 | 269 | * |
270 | - * @since 1.18 Moved to GravityView_Entry_Approval::get_approved_column |
|
271 | - * @see GravityView_Entry_Approval::get_approved_column |
|
272 | - * |
|
270 | + * @since 1.18 Moved to GravityView_Entry_Approval::get_approved_column |
|
271 | + * @see GravityView_Entry_Approval::get_approved_column |
|
272 | + * |
|
273 | 273 | * @param mixed $form GF Form or Form ID |
274 | 274 | * @return false|null|string Returns the input ID of the approved field. Returns NULL if no approved fields were found. Returns false if $form_id wasn't set. |
275 | 275 | */ |
@@ -394,37 +394,37 @@ discard block |
||
394 | 394 | 'bulk_actions' => GravityView_Bulk_Actions::get_bulk_actions( $form_id ), |
395 | 395 | 'bulk_message' => $this->bulk_update_message, |
396 | 396 | 'unapprove_title' => GravityView_Entry_Approval_Status::get_title_attr('unapproved'), |
397 | - 'approve_title' => GravityView_Entry_Approval_Status::get_title_attr('disapproved'), |
|
397 | + 'approve_title' => GravityView_Entry_Approval_Status::get_title_attr('disapproved'), |
|
398 | 398 | 'disapprove_title' => GravityView_Entry_Approval_Status::get_title_attr('approved'), |
399 | 399 | 'column_title' => __( 'Show entry in directory view?', 'gravityview'), |
400 | 400 | 'column_link' => esc_url( $this->get_sort_link() ), |
401 | - 'status_popover_template' => GravityView_Entry_Approval::get_popover_template(), |
|
401 | + 'status_popover_template' => GravityView_Entry_Approval::get_popover_template(), |
|
402 | 402 | 'status_popover_placement' => GravityView_Entry_Approval::get_popover_placement(), |
403 | 403 | ) ); |
404 | 404 | |
405 | 405 | } |
406 | 406 | |
407 | 407 | /** |
408 | - * Generate a link to sort by approval status |
|
409 | - * |
|
410 | - * Note: Sorting by approval will never be great because it's not possible currently to declare the sorting as |
|
411 | - * numeric, but it does group the approved entries together. |
|
412 | - * |
|
413 | - * @since 2.0.14 Remove need for approval field for sorting by approval status |
|
414 | - * |
|
408 | + * Generate a link to sort by approval status |
|
409 | + * |
|
410 | + * Note: Sorting by approval will never be great because it's not possible currently to declare the sorting as |
|
411 | + * numeric, but it does group the approved entries together. |
|
412 | + * |
|
413 | + * @since 2.0.14 Remove need for approval field for sorting by approval status |
|
414 | + * |
|
415 | 415 | * @param int $form_id [NO LONGER USED] |
416 | 416 | * |
417 | 417 | * @return string Sorting link |
418 | 418 | */ |
419 | 419 | private function get_sort_link( $form_id = 0 ) { |
420 | 420 | |
421 | - $args = array( |
|
422 | - 'orderby' => 'is_approved', |
|
423 | - 'order' => ( 'desc' === \GV\Utils::_GET( 'order' ) ) ? 'asc' : 'desc', |
|
424 | - ); |
|
421 | + $args = array( |
|
422 | + 'orderby' => 'is_approved', |
|
423 | + 'order' => ( 'desc' === \GV\Utils::_GET( 'order' ) ) ? 'asc' : 'desc', |
|
424 | + ); |
|
425 | 425 | |
426 | 426 | return add_query_arg( $args ); |
427 | - } |
|
427 | + } |
|
428 | 428 | |
429 | 429 | /** |
430 | 430 | * Should the Approve/Reject Entry column be shown in the GF Entries page? |
@@ -62,28 +62,28 @@ discard block |
||
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
65 | - * When on the Add/Edit View screen, suggest most popular articles related to that |
|
66 | - * |
|
65 | + * When on the Add/Edit View screen, suggest most popular articles related to that |
|
66 | + * |
|
67 | 67 | * @param array $localization_data Data to be passed to the Support Port JS |
68 | 68 | * |
69 | 69 | * @return array |
70 | 70 | */ |
71 | 71 | function suggest_support_articles( $localization_data = array() ) { |
72 | 72 | |
73 | - if( ! gravityview()->request->is_view() ) { |
|
74 | - return $localization_data; |
|
75 | - } |
|
73 | + if( ! gravityview()->request->is_view() ) { |
|
74 | + return $localization_data; |
|
75 | + } |
|
76 | 76 | |
77 | 77 | $localization_data['suggest'] = array( |
78 | - '57ef23539033602e61d4a560', |
|
79 | - '54c67bb9e4b0512429885513', |
|
80 | - '54c67bb9e4b0512429885512', |
|
81 | - '54c67bbbe4b07997ea3f3f6b', |
|
82 | - '54d1a33ae4b086c0c0964ce9', |
|
83 | - '57ef253c9033602e61d4a563', |
|
84 | - '552355bfe4b0221aadf2572b', |
|
85 | - '54c67bcde4b051242988553e', |
|
86 | - ); |
|
78 | + '57ef23539033602e61d4a560', |
|
79 | + '54c67bb9e4b0512429885513', |
|
80 | + '54c67bb9e4b0512429885512', |
|
81 | + '54c67bbbe4b07997ea3f3f6b', |
|
82 | + '54d1a33ae4b086c0c0964ce9', |
|
83 | + '57ef253c9033602e61d4a563', |
|
84 | + '552355bfe4b0221aadf2572b', |
|
85 | + '54c67bcde4b051242988553e', |
|
86 | + ); |
|
87 | 87 | |
88 | 88 | return $localization_data; |
89 | 89 | } |
@@ -229,11 +229,11 @@ discard block |
||
229 | 229 | |
230 | 230 | if( 'form_list' === GFForms::get_page() ) { |
231 | 231 | $priority = 790; |
232 | - } |
|
232 | + } |
|
233 | 233 | |
234 | 234 | if( empty( $connected_views ) ) { |
235 | 235 | |
236 | - $menu_items['gravityview'] = array( |
|
236 | + $menu_items['gravityview'] = array( |
|
237 | 237 | 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
238 | 238 | 'icon' => '<i class="fa fa-lg gv-icon-astronaut-head gv-icon"></i>', // Only appears in GF pre-2.5 |
239 | 239 | 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
@@ -265,13 +265,13 @@ discard block |
||
265 | 265 | // If there were no items added, then let's create the parent menu |
266 | 266 | if( $sub_menu_items ) { |
267 | 267 | |
268 | - $sub_menu_items[] = array( |
|
269 | - 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
|
270 | - 'icon' => '<span class="dashicons dashicons-plus"></span>', |
|
271 | - 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
|
272 | - 'url' => admin_url( 'post-new.php?post_type=gravityview&form_id=' . $id ), |
|
273 | - 'capabilities' => array( 'edit_gravityviews' ), |
|
274 | - ); |
|
268 | + $sub_menu_items[] = array( |
|
269 | + 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
|
270 | + 'icon' => '<span class="dashicons dashicons-plus"></span>', |
|
271 | + 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
|
272 | + 'url' => admin_url( 'post-new.php?post_type=gravityview&form_id=' . $id ), |
|
273 | + 'capabilities' => array( 'edit_gravityviews' ), |
|
274 | + ); |
|
275 | 275 | |
276 | 276 | // Make sure Gravity Forms uses the submenu; if there's only one item, it uses a link instead of a dropdown |
277 | 277 | $sub_menu_items[] = array( |
@@ -668,16 +668,16 @@ discard block |
||
668 | 668 | /** |
669 | 669 | * Render html for displaying available fields based on a Form ID |
670 | 670 | * |
671 | - * @see GravityView_Ajax::get_available_fields_html() Triggers `gravityview_render_available_fields` action |
|
671 | + * @see GravityView_Ajax::get_available_fields_html() Triggers `gravityview_render_available_fields` action |
|
672 | 672 | * |
673 | 673 | * @param int $form Gravity Forms Form ID (default: '') |
674 | 674 | * @param string $context (default: 'single') |
675 | - * |
|
675 | + * |
|
676 | 676 | * @return void |
677 | 677 | */ |
678 | 678 | function render_available_fields( $form = 0, $context = 'single' ) { |
679 | 679 | |
680 | - // Determine if form is a preset and convert it to an array with fields |
|
680 | + // Determine if form is a preset and convert it to an array with fields |
|
681 | 681 | $form = ( is_string( $form ) && preg_match( '/^preset_/', $form ) ) ? GravityView_Ajax::pre_get_form_fields( $form ) : $form; |
682 | 682 | |
683 | 683 | /** |
@@ -695,7 +695,7 @@ discard block |
||
695 | 695 | |
696 | 696 | if ( ! is_array( $blocklist_field_types ) ) { |
697 | 697 | |
698 | - gravityview()->log->error( '$blocklist_field_types is not an array', array( 'data' => print_r( $blocklist_field_types, true ) ) ); |
|
698 | + gravityview()->log->error( '$blocklist_field_types is not an array', array( 'data' => print_r( $blocklist_field_types, true ) ) ); |
|
699 | 699 | |
700 | 700 | $blocklist_field_types = array(); |
701 | 701 | } |
@@ -953,9 +953,9 @@ discard block |
||
953 | 953 | |
954 | 954 | $joined_forms = gravityview_get_joined_forms( $post->ID ); |
955 | 955 | |
956 | - foreach ( $joined_forms as $form ) { |
|
957 | - $available_items[ $form->ID ] = $this->get_available_fields( $form->ID, $zone ); |
|
958 | - } |
|
956 | + foreach ( $joined_forms as $form ) { |
|
957 | + $available_items[ $form->ID ] = $this->get_available_fields( $form->ID, $zone ); |
|
958 | + } |
|
959 | 959 | } else { |
960 | 960 | $available_items[ $form ] = \GV\Widget::registered(); |
961 | 961 | } |
@@ -994,9 +994,9 @@ discard block |
||
994 | 994 | |
995 | 995 | if ( $form_id ) { |
996 | 996 | $original_item = isset( $available_items[ $form_id ] [ $field['id'] ] ) ? $available_items[ $form_id ] [ $field['id'] ] : false ; |
997 | - } else { |
|
997 | + } else { |
|
998 | 998 | $original_item = isset( $available_items[ $field['id'] ] ) ? $available_items[ $field['id'] ] : false ; |
999 | - } |
|
999 | + } |
|
1000 | 1000 | |
1001 | 1001 | if ( !$original_item ) { |
1002 | 1002 | gravityview()->log->error( 'An item was not available when rendering the output; maybe it was added by a plugin that is now de-activated.', array(' data' => array('available_items' => $available_items, 'field' => $field ) ) ); |
@@ -1246,7 +1246,7 @@ discard block |
||
1246 | 1246 | } |
1247 | 1247 | |
1248 | 1248 | // Add the GV font (with the Astronaut) |
1249 | - wp_enqueue_style( 'gravityview_global', plugins_url('assets/css/admin-global.css', GRAVITYVIEW_FILE), array(), \GV\Plugin::$version ); |
|
1249 | + wp_enqueue_style( 'gravityview_global', plugins_url('assets/css/admin-global.css', GRAVITYVIEW_FILE), array(), \GV\Plugin::$version ); |
|
1250 | 1250 | wp_register_style( 'gravityview_views_styles', plugins_url( 'assets/css/admin-views.css', GRAVITYVIEW_FILE ), array( 'dashicons', 'wp-jquery-ui-dialog' ), \GV\Plugin::$version ); |
1251 | 1251 | |
1252 | 1252 | wp_register_script( 'gravityview-jquery-cookie', plugins_url('assets/lib/jquery.cookie/jquery.cookie.min.js', GRAVITYVIEW_FILE), array( 'jquery' ), \GV\Plugin::$version, true ); |
@@ -1254,46 +1254,46 @@ discard block |
||
1254 | 1254 | if( GFForms::get_page() === 'form_list' ) { |
1255 | 1255 | wp_enqueue_style( 'gravityview_views_styles' ); |
1256 | 1256 | return; |
1257 | - } |
|
1257 | + } |
|
1258 | 1258 | |
1259 | 1259 | // Don't process any scripts below here if it's not a GravityView page. |
1260 | 1260 | if( ! gravityview()->request->is_admin( $hook, 'single' ) && ! $is_widgets_page ) { |
1261 | - return; |
|
1261 | + return; |
|
1262 | 1262 | } |
1263 | 1263 | |
1264 | 1264 | wp_enqueue_code_editor( array( 'type' => 'text/html' ) ); |
1265 | 1265 | |
1266 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
1267 | - |
|
1268 | - wp_enqueue_style( 'gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), \GV\Plugin::$version ); |
|
1269 | - |
|
1270 | - // Enqueue scripts |
|
1271 | - wp_enqueue_script( 'gravityview_views_scripts', plugins_url( 'assets/js/admin-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery-ui-tabs', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'jquery-ui-dialog', 'gravityview-jquery-cookie', 'jquery-ui-datepicker', 'underscore' ), \GV\Plugin::$version ); |
|
1272 | - |
|
1273 | - wp_localize_script('gravityview_views_scripts', 'gvGlobals', array( |
|
1274 | - 'cookiepath' => COOKIEPATH, |
|
1275 | - 'admin_cookiepath' => ADMIN_COOKIE_PATH, |
|
1276 | - 'passed_form_id' => (bool) \GV\Utils::_GET( 'form_id' ), |
|
1277 | - 'nonce' => wp_create_nonce( 'gravityview_ajaxviews' ), |
|
1278 | - 'label_viewname' => __( 'Enter View name here', 'gravityview' ), |
|
1279 | - 'label_reorder_search_fields' => __( 'Reorder Search Fields', 'gravityview' ), |
|
1280 | - 'label_add_search_field' => __( 'Add Search Field', 'gravityview' ), |
|
1281 | - 'label_remove_search_field' => __( 'Remove Search Field', 'gravityview' ), |
|
1282 | - 'label_close' => __( 'Close', 'gravityview' ), |
|
1283 | - 'label_cancel' => __( 'Cancel', 'gravityview' ), |
|
1284 | - 'label_continue' => __( 'Continue', 'gravityview' ), |
|
1285 | - 'label_ok' => __( 'Ok', 'gravityview' ), |
|
1286 | - 'label_publisherror' => __( 'Error while creating the View for you. Check the settings or contact GravityView support.', 'gravityview' ), |
|
1287 | - 'loading_text' => esc_html__( 'Loading…', 'gravityview' ), |
|
1288 | - 'loading_error' => esc_html__( 'There was an error loading dynamic content.', 'gravityview' ), |
|
1289 | - 'field_loaderror' => __( 'Error while adding the field. Please try again or contact GravityView support.', 'gravityview' ), |
|
1290 | - 'remove_all_fields' => __( 'Would you like to remove all fields in this zone?', 'gravityview' ), |
|
1291 | - )); |
|
1266 | + wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
1267 | + |
|
1268 | + wp_enqueue_style( 'gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), \GV\Plugin::$version ); |
|
1269 | + |
|
1270 | + // Enqueue scripts |
|
1271 | + wp_enqueue_script( 'gravityview_views_scripts', plugins_url( 'assets/js/admin-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery-ui-tabs', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'jquery-ui-dialog', 'gravityview-jquery-cookie', 'jquery-ui-datepicker', 'underscore' ), \GV\Plugin::$version ); |
|
1272 | + |
|
1273 | + wp_localize_script('gravityview_views_scripts', 'gvGlobals', array( |
|
1274 | + 'cookiepath' => COOKIEPATH, |
|
1275 | + 'admin_cookiepath' => ADMIN_COOKIE_PATH, |
|
1276 | + 'passed_form_id' => (bool) \GV\Utils::_GET( 'form_id' ), |
|
1277 | + 'nonce' => wp_create_nonce( 'gravityview_ajaxviews' ), |
|
1278 | + 'label_viewname' => __( 'Enter View name here', 'gravityview' ), |
|
1279 | + 'label_reorder_search_fields' => __( 'Reorder Search Fields', 'gravityview' ), |
|
1280 | + 'label_add_search_field' => __( 'Add Search Field', 'gravityview' ), |
|
1281 | + 'label_remove_search_field' => __( 'Remove Search Field', 'gravityview' ), |
|
1282 | + 'label_close' => __( 'Close', 'gravityview' ), |
|
1283 | + 'label_cancel' => __( 'Cancel', 'gravityview' ), |
|
1284 | + 'label_continue' => __( 'Continue', 'gravityview' ), |
|
1285 | + 'label_ok' => __( 'Ok', 'gravityview' ), |
|
1286 | + 'label_publisherror' => __( 'Error while creating the View for you. Check the settings or contact GravityView support.', 'gravityview' ), |
|
1287 | + 'loading_text' => esc_html__( 'Loading…', 'gravityview' ), |
|
1288 | + 'loading_error' => esc_html__( 'There was an error loading dynamic content.', 'gravityview' ), |
|
1289 | + 'field_loaderror' => __( 'Error while adding the field. Please try again or contact GravityView support.', 'gravityview' ), |
|
1290 | + 'remove_all_fields' => __( 'Would you like to remove all fields in this zone?', 'gravityview' ), |
|
1291 | + )); |
|
1292 | 1292 | |
1293 | 1293 | wp_enqueue_style( 'gravityview_views_styles' ); |
1294 | 1294 | |
1295 | - // Enqueue scripts needed for merge tags |
|
1296 | - self::enqueue_gravity_forms_scripts(); |
|
1295 | + // Enqueue scripts needed for merge tags |
|
1296 | + self::enqueue_gravity_forms_scripts(); |
|
1297 | 1297 | |
1298 | 1298 | // 2.5 changed how Merge Tags are enqueued |
1299 | 1299 | if ( is_callable( array( 'GFCommon', 'output_hooks_javascript') ) ) { |
@@ -1303,24 +1303,24 @@ discard block |
||
1303 | 1303 | |
1304 | 1304 | /** |
1305 | 1305 | * Enqueue Gravity Forms scripts, needed for Merge Tags |
1306 | - * |
|
1307 | - * @since 1.0.5-beta |
|
1308 | - * |
|
1309 | - * @return void |
|
1306 | + * |
|
1307 | + * @since 1.0.5-beta |
|
1308 | + * |
|
1309 | + * @return void |
|
1310 | 1310 | */ |
1311 | 1311 | static function enqueue_gravity_forms_scripts() { |
1312 | 1312 | GFForms::register_scripts(); |
1313 | 1313 | |
1314 | 1314 | $scripts = array( |
1315 | - 'sack', |
|
1316 | - 'gform_gravityforms', |
|
1317 | - 'gform_forms', |
|
1318 | - 'gform_form_admin', |
|
1319 | - 'jquery-ui-autocomplete' |
|
1315 | + 'sack', |
|
1316 | + 'gform_gravityforms', |
|
1317 | + 'gform_forms', |
|
1318 | + 'gform_form_admin', |
|
1319 | + 'jquery-ui-autocomplete' |
|
1320 | 1320 | ); |
1321 | 1321 | |
1322 | 1322 | if ( wp_is_mobile() ) { |
1323 | - $scripts[] = 'jquery-touch-punch'; |
|
1323 | + $scripts[] = 'jquery-touch-punch'; |
|
1324 | 1324 | } |
1325 | 1325 | |
1326 | 1326 | wp_enqueue_script( $scripts ); |
@@ -316,12 +316,12 @@ discard block |
||
316 | 316 | } |
317 | 317 | |
318 | 318 | /** |
319 | - * @hack |
|
320 | - * In case of email/email confirmation, the input for email has the same id as the parent field |
|
321 | - */ |
|
319 | + * @hack |
|
320 | + * In case of email/email confirmation, the input for email has the same id as the parent field |
|
321 | + */ |
|
322 | 322 | if( 'email' === $field['type'] && false === strpos( $input['id'], '.' ) ) { |
323 | - continue; |
|
324 | - } |
|
323 | + continue; |
|
324 | + } |
|
325 | 325 | $fields["{$input['id']}"] = array( |
326 | 326 | 'label' => \GV\Utils::get( $input, 'label' ), |
327 | 327 | 'customLabel' => \GV\Utils::get( $input, 'customLabel' ), |
@@ -1421,7 +1421,7 @@ discard block |
||
1421 | 1421 | ), |
1422 | 1422 | ); |
1423 | 1423 | |
1424 | - $fields = $date_created + $fields; |
|
1424 | + $fields = $date_created + $fields; |
|
1425 | 1425 | |
1426 | 1426 | $blocklist_field_types = $blocklist; |
1427 | 1427 | |
@@ -1453,13 +1453,13 @@ discard block |
||
1453 | 1453 | |
1454 | 1454 | } |
1455 | 1455 | |
1456 | - /** |
|
1457 | - * @filter `gravityview/common/sortable_fields` Filter the sortable fields |
|
1458 | - * @since 1.12 |
|
1459 | - * @param array $fields Sub-set of GF form fields that are sortable |
|
1460 | - * @param int $formid The Gravity Forms form ID that the fields are from |
|
1461 | - */ |
|
1462 | - $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); |
|
1456 | + /** |
|
1457 | + * @filter `gravityview/common/sortable_fields` Filter the sortable fields |
|
1458 | + * @since 1.12 |
|
1459 | + * @param array $fields Sub-set of GF form fields that are sortable |
|
1460 | + * @param int $formid The Gravity Forms form ID that the fields are from |
|
1461 | + */ |
|
1462 | + $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); |
|
1463 | 1463 | |
1464 | 1464 | return $fields; |
1465 | 1465 | } |
@@ -1752,26 +1752,26 @@ discard block |
||
1752 | 1752 | } |
1753 | 1753 | |
1754 | 1754 | |
1755 | - /** |
|
1756 | - * Display updated/error notice |
|
1757 | - * |
|
1758 | - * @since 1.19.2 Added $cap and $object_id parameters |
|
1759 | - * |
|
1760 | - * @param string $notice text/HTML of notice |
|
1761 | - * @param string $class CSS class for notice (`updated` or `error`) |
|
1762 | - * @param string $cap [Optional] Define a capability required to show a notice. If not set, displays to all caps. |
|
1763 | - * |
|
1764 | - * @return string |
|
1765 | - */ |
|
1766 | - public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) { |
|
1767 | - |
|
1768 | - // If $cap is defined, only show notice if user has capability |
|
1769 | - if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
1770 | - return ''; |
|
1771 | - } |
|
1772 | - |
|
1773 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1774 | - } |
|
1755 | + /** |
|
1756 | + * Display updated/error notice |
|
1757 | + * |
|
1758 | + * @since 1.19.2 Added $cap and $object_id parameters |
|
1759 | + * |
|
1760 | + * @param string $notice text/HTML of notice |
|
1761 | + * @param string $class CSS class for notice (`updated` or `error`) |
|
1762 | + * @param string $cap [Optional] Define a capability required to show a notice. If not set, displays to all caps. |
|
1763 | + * |
|
1764 | + * @return string |
|
1765 | + */ |
|
1766 | + public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) { |
|
1767 | + |
|
1768 | + // If $cap is defined, only show notice if user has capability |
|
1769 | + if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
1770 | + return ''; |
|
1771 | + } |
|
1772 | + |
|
1773 | + return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1774 | + } |
|
1775 | 1775 | |
1776 | 1776 | /** |
1777 | 1777 | * Inspired on \GFCommon::encode_shortcodes, reverse the encoding by replacing the ascii characters by the shortcode brackets |
@@ -102,10 +102,10 @@ discard block |
||
102 | 102 | |
103 | 103 | /** |
104 | 104 | * ID of the current post. May also be ID of the current View. |
105 | - * |
|
106 | - * @since 2.0.13 |
|
107 | 105 | * |
108 | - * @var int |
|
106 | + * @since 2.0.13 |
|
107 | + * |
|
108 | + * @var int |
|
109 | 109 | */ |
110 | 110 | public $post_id; |
111 | 111 | |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | */ |
190 | 190 | public function prevent_maybe_process_form() { |
191 | 191 | |
192 | - if( ! $this->is_edit_entry_submission() ) { |
|
192 | + if( ! $this->is_edit_entry_submission() ) { |
|
193 | 193 | return; |
194 | 194 | } |
195 | 195 | |
@@ -228,14 +228,14 @@ discard block |
||
228 | 228 | * When Edit entry view is requested setup the vars |
229 | 229 | */ |
230 | 230 | private function setup_vars() { |
231 | - global $post; |
|
231 | + global $post; |
|
232 | 232 | |
233 | 233 | $gravityview_view = GravityView_View::getInstance(); |
234 | 234 | |
235 | 235 | |
236 | 236 | $entries = $gravityview_view->getEntries(); |
237 | - self::$original_entry = $entries[0]; |
|
238 | - $this->entry = $entries[0]; |
|
237 | + self::$original_entry = $entries[0]; |
|
238 | + $this->entry = $entries[0]; |
|
239 | 239 | |
240 | 240 | self::$original_form = GFAPI::get_form( $this->entry['form_id'] ); |
241 | 241 | $this->form = self::$original_form; |
@@ -380,8 +380,8 @@ discard block |
||
380 | 380 | |
381 | 381 | GFFormsModel::save_lead( $form, $this->entry ); |
382 | 382 | |
383 | - // Delete the values for hidden inputs |
|
384 | - $this->unset_hidden_field_values(); |
|
383 | + // Delete the values for hidden inputs |
|
384 | + $this->unset_hidden_field_values(); |
|
385 | 385 | |
386 | 386 | $this->entry['date_created'] = $date_created; |
387 | 387 | |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | // Perform actions normally performed after updating a lead |
395 | 395 | $this->after_update(); |
396 | 396 | |
397 | - /** |
|
397 | + /** |
|
398 | 398 | * Must be AFTER after_update()! |
399 | 399 | * @see https://github.com/gravityview/GravityView/issues/764 |
400 | 400 | */ |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | |
403 | 403 | /** |
404 | 404 | * @action `gravityview/edit_entry/after_update` Perform an action after the entry has been updated using Edit Entry |
405 | - * @since 2.1 Added $gv_data parameter |
|
405 | + * @since 2.1 Added $gv_data parameter |
|
406 | 406 | * @param array $form Gravity Forms form array |
407 | 407 | * @param string $entry_id Numeric ID of the entry that was updated |
408 | 408 | * @param GravityView_Edit_Entry_Render $this This object |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | * @return void |
427 | 427 | */ |
428 | 428 | private function unset_hidden_field_values() { |
429 | - global $wpdb; |
|
429 | + global $wpdb; |
|
430 | 430 | |
431 | 431 | /** |
432 | 432 | * @filter `gravityview/edit_entry/unset_hidden_field_values` Whether to delete values of fields hidden by conditional logic |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
451 | 451 | } |
452 | 452 | |
453 | - foreach ( $this->entry as $input_id => $field_value ) { |
|
453 | + foreach ( $this->entry as $input_id => $field_value ) { |
|
454 | 454 | |
455 | 455 | if ( ! is_numeric( $input_id ) ) { |
456 | 456 | continue; |
@@ -460,8 +460,8 @@ discard block |
||
460 | 460 | continue; |
461 | 461 | } |
462 | 462 | |
463 | - // Reset fields that are or would be hidden |
|
464 | - if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), $this->entry ) ) { |
|
463 | + // Reset fields that are or would be hidden |
|
464 | + if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), $this->entry ) ) { |
|
465 | 465 | |
466 | 466 | $empty_value = $field->get_value_save_entry( |
467 | 467 | is_array( $field->get_entry_inputs() ) ? array() : '', |
@@ -473,16 +473,16 @@ discard block |
||
473 | 473 | $empty_value = ''; |
474 | 474 | } |
475 | 475 | |
476 | - $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
476 | + $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
477 | 477 | |
478 | - GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
478 | + GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
479 | 479 | |
480 | - // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
480 | + // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
481 | 481 | // after submission |
482 | - $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
483 | - $_POST[ $post_input_id ] = ''; |
|
484 | - } |
|
485 | - } |
|
482 | + $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
483 | + $_POST[ $post_input_id ] = ''; |
|
484 | + } |
|
485 | + } |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | /** |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | |
638 | 638 | $form = $this->filter_conditional_logic( $this->form ); |
639 | 639 | |
640 | - /** @type GF_Field $field */ |
|
640 | + /** @type GF_Field $field */ |
|
641 | 641 | foreach( $form['fields'] as $k => &$field ) { |
642 | 642 | |
643 | 643 | /** |
@@ -652,7 +652,7 @@ discard block |
||
652 | 652 | |
653 | 653 | if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
654 | 654 | foreach( $field->inputs as $key => $input ) { |
655 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
655 | + $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
656 | 656 | } |
657 | 657 | } |
658 | 658 | } |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | |
693 | 693 | $inputs = $field->get_entry_inputs(); |
694 | 694 | if ( is_array( $inputs ) ) { |
695 | - foreach ( $inputs as $input ) { |
|
695 | + foreach ( $inputs as $input ) { |
|
696 | 696 | list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 ); |
697 | 697 | |
698 | 698 | if ( 'product' === $field->type ) { |
@@ -711,7 +711,7 @@ discard block |
||
711 | 711 | } |
712 | 712 | |
713 | 713 | GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] ); |
714 | - } |
|
714 | + } |
|
715 | 715 | } else { |
716 | 716 | // Set to what it previously was if it's not editable |
717 | 717 | if ( ! in_array( $field->id, $allowed_fields ) ) { |
@@ -757,7 +757,7 @@ discard block |
||
757 | 757 | $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
758 | 758 | |
759 | 759 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
760 | - $ary = stripslashes_deep( $ary ); |
|
760 | + $ary = stripslashes_deep( $ary ); |
|
761 | 761 | $img_url = \GV\Utils::get( $ary, 0 ); |
762 | 762 | |
763 | 763 | $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
@@ -830,7 +830,7 @@ discard block |
||
830 | 830 | private function maybe_update_post_fields( $form ) { |
831 | 831 | |
832 | 832 | if( empty( $this->entry['post_id'] ) ) { |
833 | - gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
833 | + gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
834 | 834 | return; |
835 | 835 | } |
836 | 836 | |
@@ -865,49 +865,49 @@ discard block |
||
865 | 865 | |
866 | 866 | switch( $field->type ) { |
867 | 867 | |
868 | - case 'post_title': |
|
869 | - $post_title = $value; |
|
870 | - if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
871 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
872 | - } |
|
873 | - $updated_post->post_title = $post_title; |
|
874 | - $updated_post->post_name = $post_title; |
|
875 | - unset( $post_title ); |
|
876 | - break; |
|
877 | - |
|
878 | - case 'post_content': |
|
879 | - $post_content = $value; |
|
880 | - if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
881 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
882 | - } |
|
883 | - $updated_post->post_content = $post_content; |
|
884 | - unset( $post_content ); |
|
885 | - break; |
|
886 | - case 'post_excerpt': |
|
887 | - $updated_post->post_excerpt = $value; |
|
888 | - break; |
|
889 | - case 'post_tags': |
|
890 | - wp_set_post_tags( $post_id, $value, false ); |
|
891 | - break; |
|
892 | - case 'post_category': |
|
893 | - break; |
|
894 | - case 'post_custom_field': |
|
868 | + case 'post_title': |
|
869 | + $post_title = $value; |
|
870 | + if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
871 | + $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
872 | + } |
|
873 | + $updated_post->post_title = $post_title; |
|
874 | + $updated_post->post_name = $post_title; |
|
875 | + unset( $post_title ); |
|
876 | + break; |
|
877 | + |
|
878 | + case 'post_content': |
|
879 | + $post_content = $value; |
|
880 | + if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
881 | + $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
882 | + } |
|
883 | + $updated_post->post_content = $post_content; |
|
884 | + unset( $post_content ); |
|
885 | + break; |
|
886 | + case 'post_excerpt': |
|
887 | + $updated_post->post_excerpt = $value; |
|
888 | + break; |
|
889 | + case 'post_tags': |
|
890 | + wp_set_post_tags( $post_id, $value, false ); |
|
891 | + break; |
|
892 | + case 'post_category': |
|
893 | + break; |
|
894 | + case 'post_custom_field': |
|
895 | 895 | if ( is_array( $value ) && ( floatval( $field_id ) !== floatval( $field->id ) ) ) { |
896 | 896 | $value = $value[ $field_id ]; |
897 | 897 | } |
898 | 898 | |
899 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
900 | - $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
901 | - } |
|
899 | + if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
900 | + $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
901 | + } |
|
902 | 902 | |
903 | 903 | $value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry ); |
904 | 904 | |
905 | - update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
906 | - break; |
|
905 | + update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
906 | + break; |
|
907 | 907 | |
908 | - case 'post_image': |
|
909 | - $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
910 | - break; |
|
908 | + case 'post_image': |
|
909 | + $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
910 | + break; |
|
911 | 911 | |
912 | 912 | } |
913 | 913 | |
@@ -1077,14 +1077,14 @@ discard block |
||
1077 | 1077 | ?><h2 class="gv-edit-entry-title"> |
1078 | 1078 | <span><?php |
1079 | 1079 | |
1080 | - /** |
|
1081 | - * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
1082 | - * @param string $edit_entry_title Modify the "Edit Entry" title |
|
1083 | - * @param GravityView_Edit_Entry_Render $this This object |
|
1084 | - */ |
|
1085 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
1080 | + /** |
|
1081 | + * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
1082 | + * @param string $edit_entry_title Modify the "Edit Entry" title |
|
1083 | + * @param GravityView_Edit_Entry_Render $this This object |
|
1084 | + */ |
|
1085 | + $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
1086 | 1086 | |
1087 | - echo esc_attr( $edit_entry_title ); |
|
1087 | + echo esc_attr( $edit_entry_title ); |
|
1088 | 1088 | ?></span> |
1089 | 1089 | </h2> |
1090 | 1090 | |
@@ -1150,13 +1150,13 @@ discard block |
||
1150 | 1150 | ); |
1151 | 1151 | |
1152 | 1152 | /** |
1153 | - * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
1154 | - * @since 1.16.3 |
|
1155 | - * @param array $labels Default button labels associative array |
|
1156 | - * @param array $form The Gravity Forms form |
|
1157 | - * @param array $entry The Gravity Forms entry |
|
1158 | - * @param int $view_id The current View ID |
|
1159 | - */ |
|
1153 | + * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
1154 | + * @since 1.16.3 |
|
1155 | + * @param array $labels Default button labels associative array |
|
1156 | + * @param array $form The Gravity Forms form |
|
1157 | + * @param array $entry The Gravity Forms entry |
|
1158 | + * @param int $view_id The current View ID |
|
1159 | + */ |
|
1160 | 1160 | $labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id ); |
1161 | 1161 | |
1162 | 1162 | $this->is_paged_submitted = \GV\Utils::_POST( 'save' ) === $labels['submit']; |
@@ -1276,13 +1276,13 @@ discard block |
||
1276 | 1276 | ); |
1277 | 1277 | |
1278 | 1278 | /** |
1279 | - * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
1280 | - * @since 1.16.3 |
|
1281 | - * @param array $labels Default button labels associative array |
|
1282 | - * @param array $form The Gravity Forms form |
|
1283 | - * @param array $entry The Gravity Forms entry |
|
1284 | - * @param int $view_id The current View ID |
|
1285 | - */ |
|
1279 | + * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
1280 | + * @since 1.16.3 |
|
1281 | + * @param array $labels Default button labels associative array |
|
1282 | + * @param array $form The Gravity Forms form |
|
1283 | + * @param array $entry The Gravity Forms entry |
|
1284 | + * @param int $view_id The current View ID |
|
1285 | + */ |
|
1286 | 1286 | $labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id ); |
1287 | 1287 | |
1288 | 1288 | GFFormDisplay::$submission[ $this->form['id'] ][ 'form' ] = $this->form; |
@@ -1328,7 +1328,7 @@ discard block |
||
1328 | 1328 | |
1329 | 1329 | ob_get_clean(); |
1330 | 1330 | |
1331 | - remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
1331 | + remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
1332 | 1332 | remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
1333 | 1333 | remove_filter( 'gform_next_button', array( $this, 'render_form_buttons' ) ); |
1334 | 1334 | remove_filter( 'gform_previous_button', array( $this, 'render_form_buttons' ) ); |
@@ -1388,7 +1388,7 @@ discard block |
||
1388 | 1388 | |
1389 | 1389 | // for now we don't support Save and Continue feature. |
1390 | 1390 | if( ! self::$supports_save_and_continue ) { |
1391 | - unset( $form['save'] ); |
|
1391 | + unset( $form['save'] ); |
|
1392 | 1392 | } |
1393 | 1393 | |
1394 | 1394 | $form = $this->unselect_default_values( $form ); |
@@ -1415,30 +1415,30 @@ discard block |
||
1415 | 1415 | return $field_content; |
1416 | 1416 | } |
1417 | 1417 | |
1418 | - $message = null; |
|
1418 | + $message = null; |
|
1419 | 1419 | |
1420 | - // First, make sure they have the capability to edit the post. |
|
1421 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1420 | + // First, make sure they have the capability to edit the post. |
|
1421 | + if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1422 | 1422 | |
1423 | - /** |
|
1424 | - * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
1425 | - * @param string $message The existing "You don't have permission..." text |
|
1426 | - */ |
|
1427 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1423 | + /** |
|
1424 | + * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
1425 | + * @param string $message The existing "You don't have permission..." text |
|
1426 | + */ |
|
1427 | + $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1428 | 1428 | |
1429 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1430 | - /** |
|
1431 | - * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
1432 | - * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
1433 | - */ |
|
1434 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1435 | - } |
|
1429 | + } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1430 | + /** |
|
1431 | + * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
1432 | + * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
1433 | + */ |
|
1434 | + $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1435 | + } |
|
1436 | 1436 | |
1437 | - if( $message ) { |
|
1438 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1439 | - } |
|
1437 | + if( $message ) { |
|
1438 | + $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1439 | + } |
|
1440 | 1440 | |
1441 | - return $field_content; |
|
1441 | + return $field_content; |
|
1442 | 1442 | } |
1443 | 1443 | |
1444 | 1444 | /** |
@@ -1466,7 +1466,7 @@ discard block |
||
1466 | 1466 | || ! empty( $field_content ) |
1467 | 1467 | || in_array( $field->type, array( 'honeypot' ) ) |
1468 | 1468 | ) { |
1469 | - return $field_content; |
|
1469 | + return $field_content; |
|
1470 | 1470 | } |
1471 | 1471 | |
1472 | 1472 | // SET SOME FIELD DEFAULTS TO PREVENT ISSUES |
@@ -1474,24 +1474,24 @@ discard block |
||
1474 | 1474 | |
1475 | 1475 | $field_value = $this->get_field_value( $field ); |
1476 | 1476 | |
1477 | - // Prevent any PHP warnings, like undefined index |
|
1478 | - ob_start(); |
|
1477 | + // Prevent any PHP warnings, like undefined index |
|
1478 | + ob_start(); |
|
1479 | 1479 | |
1480 | - $return = null; |
|
1480 | + $return = null; |
|
1481 | 1481 | |
1482 | 1482 | /** @var GravityView_Field $gv_field */ |
1483 | 1483 | if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
1484 | 1484 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
1485 | 1485 | } else { |
1486 | - $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
1487 | - } |
|
1486 | + $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
1487 | + } |
|
1488 | 1488 | |
1489 | - // If there was output, it's an error |
|
1490 | - $warnings = ob_get_clean(); |
|
1489 | + // If there was output, it's an error |
|
1490 | + $warnings = ob_get_clean(); |
|
1491 | 1491 | |
1492 | - if( !empty( $warnings ) ) { |
|
1493 | - gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
1494 | - } |
|
1492 | + if( !empty( $warnings ) ) { |
|
1493 | + gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
1494 | + } |
|
1495 | 1495 | |
1496 | 1496 | return $return; |
1497 | 1497 | } |
@@ -1526,8 +1526,8 @@ discard block |
||
1526 | 1526 | $input_id = strval( $input['id'] ); |
1527 | 1527 | |
1528 | 1528 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
1529 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1530 | - $allow_pre_populated = false; |
|
1529 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1530 | + $allow_pre_populated = false; |
|
1531 | 1531 | } |
1532 | 1532 | |
1533 | 1533 | } |
@@ -1551,7 +1551,7 @@ discard block |
||
1551 | 1551 | if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
1552 | 1552 | $categories = array(); |
1553 | 1553 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
1554 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1554 | + $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1555 | 1555 | } |
1556 | 1556 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
1557 | 1557 | } |
@@ -1561,25 +1561,25 @@ discard block |
||
1561 | 1561 | // if value is empty get the default value if defined |
1562 | 1562 | $field_value = $field->get_value_default_if_empty( $field_value ); |
1563 | 1563 | |
1564 | - /** |
|
1565 | - * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
1566 | - * @since 1.11 |
|
1567 | - * @since 1.20 Added third param |
|
1568 | - * @param mixed $field_value field value used to populate the input |
|
1569 | - * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
1570 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
1571 | - */ |
|
1572 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
1573 | - |
|
1574 | - /** |
|
1575 | - * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
1576 | - * @since 1.17 |
|
1577 | - * @since 1.20 Added third param |
|
1578 | - * @param mixed $field_value field value used to populate the input |
|
1579 | - * @param GF_Field $field Gravity Forms field object |
|
1580 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
1581 | - */ |
|
1582 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1564 | + /** |
|
1565 | + * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
1566 | + * @since 1.11 |
|
1567 | + * @since 1.20 Added third param |
|
1568 | + * @param mixed $field_value field value used to populate the input |
|
1569 | + * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
1570 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
1571 | + */ |
|
1572 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
1573 | + |
|
1574 | + /** |
|
1575 | + * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
1576 | + * @since 1.17 |
|
1577 | + * @since 1.20 Added third param |
|
1578 | + * @param mixed $field_value field value used to populate the input |
|
1579 | + * @param GF_Field $field Gravity Forms field object |
|
1580 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
1581 | + */ |
|
1582 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1583 | 1583 | |
1584 | 1584 | return $field_value; |
1585 | 1585 | } |
@@ -1606,7 +1606,7 @@ discard block |
||
1606 | 1606 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
1607 | 1607 | // expects certain field array items to be set. |
1608 | 1608 | foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) { |
1609 | - $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
1609 | + $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
1610 | 1610 | } |
1611 | 1611 | |
1612 | 1612 | switch( RGFormsModel::get_input_type( $field ) ) { |
@@ -1620,31 +1620,31 @@ discard block |
||
1620 | 1620 | */ |
1621 | 1621 | case 'fileupload': |
1622 | 1622 | |
1623 | - // Set the previous value |
|
1624 | - $entry = $this->get_entry(); |
|
1623 | + // Set the previous value |
|
1624 | + $entry = $this->get_entry(); |
|
1625 | 1625 | |
1626 | - $input_name = 'input_'.$field->id; |
|
1627 | - $form_id = $form['id']; |
|
1626 | + $input_name = 'input_'.$field->id; |
|
1627 | + $form_id = $form['id']; |
|
1628 | 1628 | |
1629 | - $value = NULL; |
|
1629 | + $value = NULL; |
|
1630 | 1630 | |
1631 | - // Use the previous entry value as the default. |
|
1632 | - if( isset( $entry[ $field->id ] ) ) { |
|
1633 | - $value = $entry[ $field->id ]; |
|
1634 | - } |
|
1631 | + // Use the previous entry value as the default. |
|
1632 | + if( isset( $entry[ $field->id ] ) ) { |
|
1633 | + $value = $entry[ $field->id ]; |
|
1634 | + } |
|
1635 | 1635 | |
1636 | - // If this is a single upload file |
|
1637 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1638 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1639 | - $value = $file_path['url']; |
|
1636 | + // If this is a single upload file |
|
1637 | + if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1638 | + $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1639 | + $value = $file_path['url']; |
|
1640 | 1640 | |
1641 | - } else { |
|
1641 | + } else { |
|
1642 | 1642 | |
1643 | - // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
1644 | - // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
1645 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1643 | + // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
1644 | + // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
1645 | + $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1646 | 1646 | |
1647 | - } |
|
1647 | + } |
|
1648 | 1648 | |
1649 | 1649 | if ( \GV\Utils::get( $field, 'multipleFiles' ) ) { |
1650 | 1650 | // If there are fresh uploads, process and merge them. |
@@ -1665,17 +1665,17 @@ discard block |
||
1665 | 1665 | GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
1666 | 1666 | } |
1667 | 1667 | |
1668 | - $this->entry[ $input_name ] = $value; |
|
1669 | - $_POST[ $input_name ] = $value; |
|
1668 | + $this->entry[ $input_name ] = $value; |
|
1669 | + $_POST[ $input_name ] = $value; |
|
1670 | 1670 | |
1671 | - break; |
|
1671 | + break; |
|
1672 | 1672 | |
1673 | 1673 | case 'number': |
1674 | - // Fix "undefined index" issue at line 1286 in form_display.php |
|
1675 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1676 | - $_POST['input_'.$field->id ] = NULL; |
|
1677 | - } |
|
1678 | - break; |
|
1674 | + // Fix "undefined index" issue at line 1286 in form_display.php |
|
1675 | + if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1676 | + $_POST['input_'.$field->id ] = NULL; |
|
1677 | + } |
|
1678 | + break; |
|
1679 | 1679 | } |
1680 | 1680 | |
1681 | 1681 | } |
@@ -1796,7 +1796,7 @@ discard block |
||
1796 | 1796 | |
1797 | 1797 | // count uploaded files and existent entry files |
1798 | 1798 | $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) + |
1799 | - ( is_array( $value ) ? count( $value ) : 0 ); |
|
1799 | + ( is_array( $value ) ? count( $value ) : 0 ); |
|
1800 | 1800 | |
1801 | 1801 | if ( $count_files > $field->maxFiles ) { |
1802 | 1802 | $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
@@ -1818,47 +1818,47 @@ discard block |
||
1818 | 1818 | |
1819 | 1819 | switch ( $field_type ) { |
1820 | 1820 | |
1821 | - // Captchas don't need to be re-entered. |
|
1822 | - case 'captcha': |
|
1821 | + // Captchas don't need to be re-entered. |
|
1822 | + case 'captcha': |
|
1823 | 1823 | |
1824 | - // Post Image fields aren't editable, so we un-fail them. |
|
1825 | - case 'post_image': |
|
1826 | - $field->failed_validation = false; |
|
1827 | - unset( $field->validation_message ); |
|
1828 | - break; |
|
1824 | + // Post Image fields aren't editable, so we un-fail them. |
|
1825 | + case 'post_image': |
|
1826 | + $field->failed_validation = false; |
|
1827 | + unset( $field->validation_message ); |
|
1828 | + break; |
|
1829 | 1829 | |
1830 | 1830 | } |
1831 | 1831 | |
1832 | 1832 | // You can't continue inside a switch, so we do it after. |
1833 | 1833 | if( empty( $field->failed_validation ) ) { |
1834 | - continue; |
|
1834 | + continue; |
|
1835 | 1835 | } |
1836 | 1836 | |
1837 | 1837 | // checks if the No Duplicates option is not validating entry against itself, since |
1838 | 1838 | // we're editing a stored entry, it would also assume it's a duplicate. |
1839 | 1839 | if( !empty( $field->noDuplicates ) ) { |
1840 | 1840 | |
1841 | - $entry = $this->get_entry(); |
|
1841 | + $entry = $this->get_entry(); |
|
1842 | 1842 | |
1843 | - // If the value of the entry is the same as the stored value |
|
1844 | - // Then we can assume it's not a duplicate, it's the same. |
|
1845 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1846 | - //if value submitted was not changed, then don't validate |
|
1847 | - $field->failed_validation = false; |
|
1843 | + // If the value of the entry is the same as the stored value |
|
1844 | + // Then we can assume it's not a duplicate, it's the same. |
|
1845 | + if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1846 | + //if value submitted was not changed, then don't validate |
|
1847 | + $field->failed_validation = false; |
|
1848 | 1848 | |
1849 | - unset( $field->validation_message ); |
|
1849 | + unset( $field->validation_message ); |
|
1850 | 1850 | |
1851 | - gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
1851 | + gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
1852 | 1852 | |
1853 | - continue; |
|
1854 | - } |
|
1853 | + continue; |
|
1854 | + } |
|
1855 | 1855 | } |
1856 | 1856 | |
1857 | 1857 | // if here then probably we are facing the validation 'At least one field must be filled out' |
1858 | 1858 | if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
1859 | - unset( $field->validation_message ); |
|
1859 | + unset( $field->validation_message ); |
|
1860 | 1860 | $field->failed_validation = false; |
1861 | - continue; |
|
1861 | + continue; |
|
1862 | 1862 | } |
1863 | 1863 | |
1864 | 1864 | $gv_valid = false; |
@@ -1922,8 +1922,8 @@ discard block |
||
1922 | 1922 | // Hide fields depending on admin settings |
1923 | 1923 | $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
1924 | 1924 | |
1925 | - // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
1926 | - $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
1925 | + // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
1926 | + $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
1927 | 1927 | |
1928 | 1928 | /** |
1929 | 1929 | * @filter `gravityview/edit_entry/form_fields` Modify the fields displayed in Edit Entry form |
@@ -2014,11 +2014,11 @@ discard block |
||
2014 | 2014 | // The edit tab has been configured, so we loop through to configured settings |
2015 | 2015 | foreach ( $configured_fields as $configured_field ) { |
2016 | 2016 | |
2017 | - /** @var GF_Field $field */ |
|
2018 | - foreach ( $fields as $field ) { |
|
2017 | + /** @var GF_Field $field */ |
|
2018 | + foreach ( $fields as $field ) { |
|
2019 | 2019 | if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
2020 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
2021 | - break; |
|
2020 | + $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
2021 | + break; |
|
2022 | 2022 | } |
2023 | 2023 | |
2024 | 2024 | } |
@@ -2074,28 +2074,28 @@ discard block |
||
2074 | 2074 | */ |
2075 | 2075 | private function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) { |
2076 | 2076 | |
2077 | - /** |
|
2077 | + /** |
|
2078 | 2078 | * @filter `gravityview/edit_entry/use_gf_admin_only_setting` When Edit tab isn't configured, should the Gravity Forms "Admin Only" field settings be used to control field display to non-admins? Default: true |
2079 | - * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
2080 | - * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
2081 | - * @since 1.9.1 |
|
2082 | - * @param boolean $use_gf_adminonly_setting True: Hide field if set to Admin Only in GF and the user is not an admin. False: show field based on GV permissions, ignoring GF permissions. |
|
2083 | - * @param array $form GF Form array |
|
2084 | - * @param int $view_id View ID |
|
2085 | - */ |
|
2086 | - $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
2087 | - |
|
2088 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
2079 | + * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
2080 | + * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
2081 | + * @since 1.9.1 |
|
2082 | + * @param boolean $use_gf_adminonly_setting True: Hide field if set to Admin Only in GF and the user is not an admin. False: show field based on GV permissions, ignoring GF permissions. |
|
2083 | + * @param array $form GF Form array |
|
2084 | + * @param int $view_id View ID |
|
2085 | + */ |
|
2086 | + $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
2087 | + |
|
2088 | + if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
2089 | 2089 | foreach( $fields as $k => $field ) { |
2090 | 2090 | if( $field->adminOnly ) { |
2091 | - unset( $fields[ $k ] ); |
|
2091 | + unset( $fields[ $k ] ); |
|
2092 | 2092 | } |
2093 | 2093 | } |
2094 | 2094 | return array_values( $fields ); |
2095 | 2095 | } |
2096 | 2096 | |
2097 | - foreach( $fields as &$field ) { |
|
2098 | - $field->adminOnly = false; |
|
2097 | + foreach( $fields as &$field ) { |
|
2098 | + $field->adminOnly = false; |
|
2099 | 2099 | } |
2100 | 2100 | |
2101 | 2101 | return $fields; |
@@ -2115,13 +2115,13 @@ discard block |
||
2115 | 2115 | */ |
2116 | 2116 | private function unselect_default_values( $form ) { |
2117 | 2117 | |
2118 | - foreach ( $form['fields'] as &$field ) { |
|
2118 | + foreach ( $form['fields'] as &$field ) { |
|
2119 | 2119 | |
2120 | 2120 | if ( empty( $field->choices ) ) { |
2121 | - continue; |
|
2121 | + continue; |
|
2122 | 2122 | } |
2123 | 2123 | |
2124 | - foreach ( $field->choices as &$choice ) { |
|
2124 | + foreach ( $field->choices as &$choice ) { |
|
2125 | 2125 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
2126 | 2126 | $choice['isSelected'] = false; |
2127 | 2127 | } |
@@ -2158,36 +2158,36 @@ discard block |
||
2158 | 2158 | |
2159 | 2159 | if( 'checkbox' === $field->type ) { |
2160 | 2160 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
2161 | - $input_id = $input['id']; |
|
2162 | - $choice = $field->choices[ $key ]; |
|
2163 | - $value = \GV\Utils::get( $this->entry, $input_id ); |
|
2164 | - $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
2165 | - if( $match ) { |
|
2166 | - $field->choices[ $key ]['isSelected'] = true; |
|
2167 | - } |
|
2161 | + $input_id = $input['id']; |
|
2162 | + $choice = $field->choices[ $key ]; |
|
2163 | + $value = \GV\Utils::get( $this->entry, $input_id ); |
|
2164 | + $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
2165 | + if( $match ) { |
|
2166 | + $field->choices[ $key ]['isSelected'] = true; |
|
2167 | + } |
|
2168 | 2168 | } |
2169 | 2169 | } else { |
2170 | 2170 | |
2171 | 2171 | // We need to run through each field to set the default values |
2172 | 2172 | foreach ( $this->entry as $field_id => $field_value ) { |
2173 | 2173 | |
2174 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
2174 | + if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
2175 | 2175 | |
2176 | - if( 'list' === $field->type ) { |
|
2177 | - $list_rows = maybe_unserialize( $field_value ); |
|
2176 | + if( 'list' === $field->type ) { |
|
2177 | + $list_rows = maybe_unserialize( $field_value ); |
|
2178 | 2178 | |
2179 | - $list_field_value = array(); |
|
2180 | - foreach ( (array) $list_rows as $row ) { |
|
2181 | - foreach ( (array) $row as $column ) { |
|
2182 | - $list_field_value[] = $column; |
|
2183 | - } |
|
2184 | - } |
|
2179 | + $list_field_value = array(); |
|
2180 | + foreach ( (array) $list_rows as $row ) { |
|
2181 | + foreach ( (array) $row as $column ) { |
|
2182 | + $list_field_value[] = $column; |
|
2183 | + } |
|
2184 | + } |
|
2185 | 2185 | |
2186 | - $field->defaultValue = serialize( $list_field_value ); |
|
2187 | - } else { |
|
2188 | - $field->defaultValue = $field_value; |
|
2189 | - } |
|
2190 | - } |
|
2186 | + $field->defaultValue = serialize( $list_field_value ); |
|
2187 | + } else { |
|
2188 | + $field->defaultValue = $field_value; |
|
2189 | + } |
|
2190 | + } |
|
2191 | 2191 | } |
2192 | 2192 | } |
2193 | 2193 | } |
@@ -2248,7 +2248,7 @@ discard block |
||
2248 | 2248 | foreach ( $form['fields'] as &$field ) { |
2249 | 2249 | foreach ( $remove_conditions_rule as $_remove_conditions_r ) { |
2250 | 2250 | |
2251 | - list( $rule_field_id, $rule_i ) = $_remove_conditions_r; |
|
2251 | + list( $rule_field_id, $rule_i ) = $_remove_conditions_r; |
|
2252 | 2252 | |
2253 | 2253 | if ( $field['id'] == $rule_field_id ) { |
2254 | 2254 | unset( $field->conditionalLogic['rules'][ $rule_i ] ); |
@@ -2299,7 +2299,7 @@ discard block |
||
2299 | 2299 | return $has_conditional_logic; |
2300 | 2300 | } |
2301 | 2301 | |
2302 | - /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
2302 | + /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
2303 | 2303 | return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form ); |
2304 | 2304 | } |
2305 | 2305 | |
@@ -2366,14 +2366,14 @@ discard block |
||
2366 | 2366 | |
2367 | 2367 | if( $echo && $error !== true ) { |
2368 | 2368 | |
2369 | - $error = esc_html( $error ); |
|
2369 | + $error = esc_html( $error ); |
|
2370 | 2370 | |
2371 | - /** |
|
2372 | - * @since 1.9 |
|
2373 | - */ |
|
2374 | - if ( ! empty( $this->entry ) ) { |
|
2375 | - $error .= ' ' . gravityview_get_link( '#', _x('Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
2376 | - } |
|
2371 | + /** |
|
2372 | + * @since 1.9 |
|
2373 | + */ |
|
2374 | + if ( ! empty( $this->entry ) ) { |
|
2375 | + $error .= ' ' . gravityview_get_link( '#', _x('Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
2376 | + } |
|
2377 | 2377 | |
2378 | 2378 | echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
2379 | 2379 | } |