| 1 |
<?php |
| 2 |
|
| 3 |
function flamingo_contact_submit_meta_box( $post ) { |
| 4 |
?> |
| 5 |
<div class="submitbox" id="submitlink"> |
| 6 |
<div id="major-publishing-actions"> |
| 7 |
|
| 8 |
<div id="delete-action"> |
| 9 |
<?php |
| 10 |
if ( current_user_can( 'flamingo_delete_contact', $post->id() ) ) { |
| 11 |
$delete_link = wp_nonce_url( |
| 12 |
add_query_arg( |
| 13 |
array( |
| 14 |
'post' => $post->id(), |
| 15 |
'action' => 'delete', |
| 16 |
), |
| 17 |
menu_page_url( 'flamingo', false ) |
| 18 |
), |
| 19 |
'flamingo-delete-contact_' . $post->id() |
| 20 |
); |
| 21 |
|
| 22 |
echo sprintf( |
| 23 |
'<a class="submitdelete deletion" href="%1$s">%2$s</a>', |
| 24 |
esc_url( $delete_link ), |
| 25 |
esc_html( __( 'Delete', 'flamingo' ) ) |
| 26 |
); |
| 27 |
} |
| 28 |
?> |
| 29 |
</div> |
| 30 |
|
| 31 |
<div id="publishing-action"> |
| 32 |
<span class="spinner"></span> |
| 33 |
<?php if ( ! empty( $post->id() ) ) : ?> |
| 34 |
<input name="save" type="submit" class="button-primary" id="publish" tabindex="4" accesskey="p" value="<?php echo esc_attr( __( 'Update contact', 'flamingo' ) ); ?>" /> |
| 35 |
<?php else : ?> |
| 36 |
<input name="save" type="submit" class="button-primary" id="publish" tabindex="4" accesskey="p" value="<?php echo esc_attr( __( 'Add contact', 'flamingo' ) ); ?>" /> |
| 37 |
<?php endif; ?> |
| 38 |
</div> |
| 39 |
|
| 40 |
<div class="clear"></div> |
| 41 |
</div><!-- #major-publishing-actions --> |
| 42 |
|
| 43 |
<div class="clear"></div> |
| 44 |
</div> |
| 45 |
<?php |
| 46 |
} |
| 47 |
|
| 48 |
function flamingo_contact_tags_meta_box( $post ) { |
| 49 |
$taxonomy = get_taxonomy( Flamingo_Contact::contact_tag_taxonomy ); |
| 50 |
|
| 51 |
if ( ! $taxonomy ) { |
| 52 |
return; |
| 53 |
} |
| 54 |
|
| 55 |
$tags = wp_get_post_terms( $post->id(), $taxonomy->name ); |
| 56 |
$tag_names = $tag_ids = array(); |
| 57 |
|
| 58 |
if ( ! empty( $tags ) and ! is_wp_error( $tags ) ) { |
| 59 |
foreach( $tags as $tag ) { |
| 60 |
$tag_names[] = $tag->name; |
| 61 |
$tag_ids[] = $tag->term_id; |
| 62 |
} |
| 63 |
} |
| 64 |
|
| 65 |
$tag_names = implode( ', ', $tag_names ); |
| 66 |
|
| 67 |
$most_used_tags = get_terms( array( |
| 68 |
'taxonomy' => Flamingo_Contact::contact_tag_taxonomy, |
| 69 |
'orderby' => 'count', |
| 70 |
'order' => 'DESC', |
| 71 |
'number' => 10, |
| 72 |
'exclude' => $tag_ids, |
| 73 |
'fields' => 'names', |
| 74 |
) ); |
| 75 |
|
| 76 |
if ( is_wp_error( $most_used_tags ) ) { |
| 77 |
$most_used_tags = array(); |
| 78 |
} |
| 79 |
|
| 80 |
?> |
| 81 |
<div class="tagsdiv" id="<?php echo esc_attr( $taxonomy->name ); ?>"> |
| 82 |
<textarea name="<?php echo esc_attr( "tax_input[{$taxonomy->name}]" ); ?>" rows="3" cols="20" class="the-tags" id="<?php echo esc_attr( "tax-input-{$taxonomy->name}" ); ?>"><?php echo esc_textarea( $tag_names ); ?></textarea> |
| 83 |
|
| 84 |
<p class="howto"><?php echo esc_html( __( 'Separate tags with commas', 'flamingo' ) ); ?></p> |
| 85 |
|
| 86 |
<?php if ( $most_used_tags ) : ?> |
| 87 |
<p class="howto"><?php echo esc_html( __( 'Choose from the most used tags', 'flamingo' ) ); ?> |
| 88 |
<br /> |
| 89 |
|
| 90 |
<?php foreach ( $most_used_tags as $tag ) { |
| 91 |
echo '<a href="#" class="append-this-to-contact-tags" onclick="appendTag( this.text )">' . esc_html( $tag ) . '</a> '; |
| 92 |
} ?> |
| 93 |
</p> |
| 94 |
<script> |
| 95 |
const appendTag = ( tag ) => { |
| 96 |
const tagsInput = document.querySelector( |
| 97 |
'#tax-input-<?php echo esc_js( $taxonomy->name ); ?>' |
| 98 |
); |
| 99 |
|
| 100 |
const tags = tagsInput.value.split( /\s*,\s*/ ); |
| 101 |
tags.push( tag ); |
| 102 |
tagsInput.value = tags.filter( tag => '' !== tag ).join( ', ' ); |
| 103 |
|
| 104 |
return false; |
| 105 |
}; |
| 106 |
</script> |
| 107 |
<?php endif; ?> |
| 108 |
</div> |
| 109 |
<?php |
| 110 |
} |
| 111 |
|
| 112 |
function flamingo_inbound_submit_meta_box( $post ) { |
| 113 |
?> |
| 114 |
<div class="submitbox" id="submitinbound"> |
| 115 |
<div id="minor-publishing"> |
| 116 |
<div id="misc-publishing-actions"> |
| 117 |
<fieldset class="misc-pub-section" id="comment-status-radio"> |
| 118 |
<legend class="screen-reader-text"><?php echo esc_html( __( 'Inbound message status', 'flamingo' ) ); ?></legend> |
| 119 |
<label><input type="radio"<?php checked( $post->spam, true ); ?> name="inbound[status]" value="spam" /><?php echo esc_html( __( 'Spam', 'flamingo' ) ); ?></label><br /> |
| 120 |
<label><input type="radio"<?php checked( $post->spam, false ); ?> name="inbound[status]" value="ham" /><?php echo esc_html( __( 'Not spam', 'flamingo' ) ); ?></label> |
| 121 |
</fieldset> |
| 122 |
|
| 123 |
<div class="misc-pub-section curtime misc-pub-curtime"> |
| 124 |
<span class="dashicons-before dashicons-calendar"> |
| 125 |
<?php |
| 126 |
$submitted_timestamp = get_post_timestamp( $post->id() ); |
| 127 |
|
| 128 |
$submitted_on = sprintf( |
| 129 |
/* translators: Publish box date string. 1: Date, 2: Time. */ |
| 130 |
__( '%1$s at %2$s', 'flamingo' ), |
| 131 |
wp_date( |
| 132 |
/* translators: Publish box date format, see https://www.php.net/date */ |
| 133 |
_x( 'M j, Y', 'publish box date format', 'flamingo' ), |
| 134 |
$submitted_timestamp |
| 135 |
), |
| 136 |
wp_date( |
| 137 |
/* translators: Publish box time format, see https://www.php.net/date */ |
| 138 |
_x( 'H:i', 'publish box time format', 'flamingo' ), |
| 139 |
$submitted_timestamp |
| 140 |
) |
| 141 |
); |
| 142 |
|
| 143 |
echo wp_kses_data( sprintf( |
| 144 |
/* translators: %s: Message submission date. */ |
| 145 |
__( 'Submitted on: <b>%s</b>', 'flamingo' ), |
| 146 |
$submitted_on |
| 147 |
) ); |
| 148 |
?> |
| 149 |
</span> |
| 150 |
</div> |
| 151 |
<?php |
| 152 |
if ( ! empty( $post->submission_status ) ) { |
| 153 |
echo '<div class="misc-pub-section submission-status">', "\n"; |
| 154 |
|
| 155 |
echo sprintf( |
| 156 |
'<span class="dashicons-before %1$s"> %2$s</span>', |
| 157 |
in_array( $post->submission_status, array( 'mail_failed', 'spam' ) ) |
| 158 |
? 'dashicons-no' : 'dashicons-yes', |
| 159 |
wp_kses_data( sprintf( |
| 160 |
/* translators: %s: Result of the submission. */ |
| 161 |
__( 'Submission result: <b>%s</b>', 'flamingo' ), |
| 162 |
$post->submission_status |
| 163 |
) ) |
| 164 |
); |
| 165 |
|
| 166 |
echo '</div>', "\n"; |
| 167 |
} |
| 168 |
|
| 169 |
foreach ( (array) $post->spam_log as $log ) { |
| 170 |
echo '<div class="misc-pub-section spam-log">'; |
| 171 |
|
| 172 |
echo sprintf( |
| 173 |
'<span class="dashicons-before dashicons-shield %1$s"> %2$s</span>', |
| 174 |
esc_attr( $log['agent'] ?? '' ), |
| 175 |
wp_kses_data( sprintf( |
| 176 |
/* translators: %s: reason why this message is regarded as spam */ |
| 177 |
__( 'Spam log: %s', 'flamingo' ), |
| 178 |
$log['reason'] ?? '' |
| 179 |
) ) |
| 180 |
); |
| 181 |
|
| 182 |
echo '</div>'; |
| 183 |
} |
| 184 |
?> |
| 185 |
</div><!-- #misc-publishing-actions --> |
| 186 |
|
| 187 |
<div class="clear"></div> |
| 188 |
</div><!-- #minor-publishing --> |
| 189 |
|
| 190 |
<div id="major-publishing-actions"> |
| 191 |
<div id="delete-action"> |
| 192 |
<?php |
| 193 |
if ( current_user_can( 'flamingo_delete_inbound_message', $post->id() ) ) { |
| 194 |
if ( ! EMPTY_TRASH_DAYS ) { |
| 195 |
$delete_text = __( 'Delete permanently', 'flamingo' ); |
| 196 |
} else { |
| 197 |
$delete_text = __( 'Move to trash', 'flamingo' ); |
| 198 |
} |
| 199 |
|
| 200 |
$delete_link = add_query_arg( |
| 201 |
array( |
| 202 |
'post' => $post->id(), |
| 203 |
'action' => 'trash', |
| 204 |
), |
| 205 |
menu_page_url( 'flamingo_inbound', false ) |
| 206 |
); |
| 207 |
|
| 208 |
$delete_link = wp_nonce_url( |
| 209 |
$delete_link, |
| 210 |
'flamingo-trash-inbound-message_' . $post->id() |
| 211 |
); |
| 212 |
|
| 213 |
echo sprintf( '<a href="%1$s" class="submitdelete deletion">%2$s</a>', |
| 214 |
esc_url( $delete_link ), |
| 215 |
esc_html( $delete_text ) |
| 216 |
); |
| 217 |
} |
| 218 |
?> |
| 219 |
</div> |
| 220 |
|
| 221 |
<div id="publishing-action"> |
| 222 |
<?php |
| 223 |
submit_button( __( 'Update', 'flamingo' ), 'primary large', 'save', false ); |
| 224 |
?> |
| 225 |
</div> |
| 226 |
|
| 227 |
<div class="clear"></div> |
| 228 |
</div><!-- #major-publishing-actions --> |
| 229 |
</div> |
| 230 |
<?php |
| 231 |
} |
| 232 |
|
| 233 |
function flamingo_contact_name_meta_box( $post ) { |
| 234 |
?> |
| 235 |
<table class="form-table"> |
| 236 |
<tbody> |
| 237 |
|
| 238 |
<tr class="contact-prop"> |
| 239 |
<th><label for="contact_name"><?php echo esc_attr( __( 'Full name', 'flamingo' ) ); ?></th> |
| 240 |
<td><input type="text" name="contact[name]" id="contact_name" value="<?php echo esc_attr( $post->get_prop( 'name' ) ); ?>" class="widefat" /></td> |
| 241 |
</tr> |
| 242 |
|
| 243 |
<tr class="contact-prop"> |
| 244 |
<th><label for="contact_first_name"><?php echo esc_attr( __( 'First name', 'flamingo' ) ); ?></th> |
| 245 |
<td><input type="text" name="contact[first_name]" id="contact_first_name" value="<?php echo esc_attr( $post->get_prop( 'first_name' ) ); ?>" class="widefat" /></td> |
| 246 |
</tr> |
| 247 |
|
| 248 |
<tr class="contact-prop"> |
| 249 |
<th><label for="contact_last_name"><?php echo esc_attr( __( 'Last name', 'flamingo' ) ); ?></th> |
| 250 |
<td><input type="text" name="contact[last_name]" id="contact_last_name" value="<?php echo esc_attr( $post->get_prop( 'last_name' ) ); ?>" class="widefat" /></td> |
| 251 |
</tr> |
| 252 |
|
| 253 |
</tbody> |
| 254 |
</table> |
| 255 |
<?php |
| 256 |
} |
| 257 |
|
| 258 |
function flamingo_inbound_fields_meta_box( $post ) { |
| 259 |
?> |
| 260 |
<table class="widefat message-fields striped"> |
| 261 |
<tbody> |
| 262 |
|
| 263 |
<?php foreach ( (array) $post->fields as $key => $value ) : ?> |
| 264 |
<tr> |
| 265 |
<td class="field-title"><?php echo esc_html( $key ); ?></td> |
| 266 |
<td class="field-value"><?php echo wp_kses_post( flamingo_htmlize( $value ) ); ?></td> |
| 267 |
</tr> |
| 268 |
<?php endforeach; ?> |
| 269 |
|
| 270 |
</tbody> |
| 271 |
</table> |
| 272 |
<?php |
| 273 |
} |
| 274 |
|
| 275 |
function flamingo_inbound_consent_meta_box( $post ) { |
| 276 |
$consent = $post->consent; |
| 277 |
|
| 278 |
if ( empty( $consent ) ) { |
| 279 |
return; |
| 280 |
} |
| 281 |
|
| 282 |
?> |
| 283 |
<table class="widefat message-fields striped"> |
| 284 |
<tbody> |
| 285 |
|
| 286 |
<?php foreach ( (array) $consent as $key => $value ) : ?> |
| 287 |
<tr> |
| 288 |
<td class="field-title"><?php echo esc_html( $key ); ?></td> |
| 289 |
<td class="field-value"><?php echo wp_kses( $value, wp_kses_allowed_html( 'data' ) ); ?></td> |
| 290 |
</tr> |
| 291 |
<?php endforeach; ?> |
| 292 |
|
| 293 |
</tbody> |
| 294 |
</table> |
| 295 |
<?php |
| 296 |
} |
| 297 |
|
| 298 |
function flamingo_inbound_recaptcha_meta_box( $post ) { |
| 299 |
?> |
| 300 |
<table class="widefat message-fields striped"> |
| 301 |
<tbody> |
| 302 |
|
| 303 |
<?php foreach ( (array) $post->recaptcha as $key => $value ) : ?> |
| 304 |
<tr> |
| 305 |
<td class="field-title"><?php echo esc_html( $key ); ?></td> |
| 306 |
<td class="field-value"><?php echo esc_html( wp_json_encode( $value, JSON_PRETTY_PRINT ) ); ?></td> |
| 307 |
</tr> |
| 308 |
<?php endforeach; ?> |
| 309 |
|
| 310 |
</tbody> |
| 311 |
</table> |
| 312 |
<?php |
| 313 |
} |
| 314 |
|
| 315 |
function flamingo_inbound_meta_meta_box( $post ) { |
| 316 |
?> |
| 317 |
<table class="widefat message-fields striped"> |
| 318 |
<tbody> |
| 319 |
|
| 320 |
<?php foreach ( (array) $post->meta as $key => $value ) : ?> |
| 321 |
<tr> |
| 322 |
<td class="field-title"><?php echo esc_html( $key ); ?></td> |
| 323 |
<td class="field-value"><?php echo wp_kses_post( flamingo_htmlize( $value ) ); ?></td> |
| 324 |
</tr> |
| 325 |
<?php endforeach; ?> |
| 326 |
|
| 327 |
</tbody> |
| 328 |
</table> |
| 329 |
<?php |
| 330 |
} |
| 331 |
|