| @@ -214,9 +214,9 @@ | ||
| 214 | 214 | * |
| 215 | 215 | * @param string $column_name |
| 216 | 216 | * @param integer $object_id |
| 217 | 217 | */ |
| 218 | -function automatorwp_manage_logs_custom_column( $column_name, $object_id ) { | |
| 218 | +function automatorwp_manage_logs_custom_column( $column_name, $object_id ) { | |
| 219 | 219 | |
| 220 | 220 | // Setup vars |
| 221 | 221 | $log = ct_get_object( $object_id ); |
| 222 | 222 | |
| @@ -333,11 +333,9 @@ | ||
| 333 | 333 | $date = date( 'Y/m/d', strtotime( $log->date ) ); |
| 334 | 334 | $time = date( 'H:i:s', strtotime( $log->date ) ); |
| 335 | 335 | ?> |
| 336 | 336 | |
| 337 | - <span class="automatorwp-log-date"><?php echo $date; ?></span> | |
| 338 | - <br> | |
| 339 | - <span class="automatorwp-log-time"><?php echo $time; ?></span> | |
| 337 | + <span class="automatorwp-log-date"><?php echo $date; ?></span> <span class="automatorwp-log-time"><?php echo $time; ?></span> | |
| 340 | 338 | |
| 341 | 339 | <?php |
| 342 | 340 | break; |
| 343 | 341 | } |
| @@ -385,11 +383,11 @@ | ||
| 385 | 383 | * Render the log details meta box |
| 386 | 384 | * |
| 387 | 385 | * @since 1.0.0 |
| 388 | 386 | * |
| 389 | - * @param stdClass $object The current object | |
| 387 | + * @param stdClass $log The current log | |
| 390 | 388 | */ |
| 391 | -function automatorwp_log_details_meta_box( $object = null ) { | |
| 389 | +function automatorwp_log_details_meta_box( $log = null ) { | |
| 392 | 390 | |
| 393 | 391 | global $ct_table; |
| 394 | 392 | |
| 395 | 393 | // Setup vars |
| @@ -402,13 +400,13 @@ | ||
| 402 | 400 | |
| 403 | 401 | <div id="misc-publishing-actions"> |
| 404 | 402 | |
| 405 | 403 | <div class="misc-pub-section misc-pub-post-status"> |
| 406 | - <?php echo __( 'Type:', 'automatorwp' ); ?> <span id="post-status-display"><?php echo isset( $log_types[$object->type] ) ? $log_types[$object->type] : esc_html( $object->type ) ; ?></span> | |
| 404 | + <?php echo __( 'Type:', 'automatorwp' ); ?> <span id="post-status-display"><?php echo isset( $log_types[$log->type] ) ? $log_types[$log->type] : esc_html( $log->type ) ; ?></span> | |
| 407 | 405 | </div> |
| 408 | 406 | |
| 409 | 407 | <div class="misc-pub-section misc-pub-post-user" id="user"> |
| 410 | - <?php $user = get_userdata( $object->user_id ); ?> | |
| 408 | + <?php $user = get_userdata( $log->user_id ); ?> | |
| 411 | 409 | <?php echo __( 'User:', 'automatorwp' ); ?> <span id="post-user-display"><?php |
| 412 | 410 | if( $user ) { |
| 413 | 411 | if( current_user_can( 'edit_users' ) ) { |
| 414 | 412 | ?> |
| @@ -421,12 +419,13 @@ | ||
| 421 | 419 | } |
| 422 | 420 | } else { |
| 423 | 421 | echo ''; |
| 424 | 422 | } ?></span> |
| 423 | + <?php do_action( 'automatorwp_log_details_meta_box_after_user', $log ); ?> | |
| 425 | 424 | </div> |
| 426 | 425 | |
| 427 | 426 | <div class="misc-pub-section curtime misc-pub-curtime"> |
| 428 | - <span id="timestamp"><?php echo __( 'Date:', 'automatorwp' ); ?> <b><?php echo date( 'Y/m/d H:i:s', strtotime( $object->date ) ); ?></b></span> | |
| 427 | + <span id="timestamp"><?php echo __( 'Date:', 'automatorwp' ); ?> <b><?php echo date( 'Y/m/d H:i:s', strtotime( $log->date ) ); ?></b></span> | |
| 429 | 428 | </div> |
| 430 | 429 | |
| 431 | 430 | </div> |
| 432 | 431 | |
| @@ -437,14 +436,14 @@ | ||
| 437 | 436 | <div id="delete-action"> |
| 438 | 437 | <?php |
| 439 | 438 | printf( |
| 440 | 439 | '<a href="%s" class="submitdelete deletion" onclick="%s" aria-label="%s">%s</a>', |
| 441 | - ct_get_delete_link( $ct_table->name, $object->id ), | |
| 440 | + ct_get_delete_link( $ct_table->name, $log->id ), | |
| 442 | 441 | "return confirm('" . |
| 443 | 442 | esc_attr( __( "Are you sure you want to delete this item?\\n\\nClick \\'Cancel\\' to go back, \\'OK\\' to confirm the delete." ) ) . |
| 444 | 443 | "');", |
| 445 | - esc_attr( __( 'Delete permanently' ) ), | |
| 446 | - __( 'Delete Permanently' ) | |
| 444 | + esc_attr( __( 'Delete', 'automatorwp' ) ), | |
| 445 | + __( 'Delete', 'automatorwp' ) | |
| 447 | 446 | ); |
| 448 | 447 | ?> |
| 449 | 448 | </div> |
| 450 | 449 | |
| @@ -493,8 +492,15 @@ | ||
| 493 | 492 | } |
| 494 | 493 | |
| 495 | 494 | $field['attributes']['type'] = 'hidden'; |
| 496 | 495 | |
| 496 | + // Update to use tooltips | |
| 497 | + if( isset( $field['desc'] ) && $field['type'] !== 'title' ) { | |
| 498 | + $field['tooltip'] = $field['desc']; | |
| 499 | + $field['label_cb'] = 'cmb_tooltip_label_cb'; | |
| 500 | + unset( $field['desc'] ); | |
| 501 | + } | |
| 502 | + | |
| 497 | 503 | // Add the field to the form |
| 498 | 504 | $cmb2->add_field( $field ); |
| 499 | 505 | |
| 500 | 506 | } |
| @@ -598,8 +604,33 @@ | ||
| 598 | 604 | 'type' => 'text', |
| 599 | 605 | ); |
| 600 | 606 | |
| 601 | 607 | /** |
| 608 | + * Filter to override the log if needed | |
| 609 | + * | |
| 610 | + * @since 6.0.0 | |
| 611 | + * | |
| 612 | + * @param stdClass $log The log object | |
| 613 | + * @param stdClass $object The trigger/action/automation object attached to the log | |
| 614 | + * | |
| 615 | + * @return stdClass | |
| 616 | + */ | |
| 617 | + $log = apply_filters( 'automatorwp_log_fields_log', $log, $object ); | |
| 618 | + | |
| 619 | + /** | |
| 620 | + * Filter to override the object if needed | |
| 621 | + * | |
| 622 | + * @since 6.0.0 | |
| 623 | + * | |
| 624 | + * @param stdClass $object The trigger/action/automation object attached to the log | |
| 625 | + * @param stdClass $log The log object | |
| 626 | + * | |
| 627 | + * @return stdClass | |
| 628 | + */ | |
| 629 | + $object = apply_filters( 'automatorwp_log_fields_object', $object, $log ); | |
| 630 | + | |
| 631 | + | |
| 632 | + /** | |
| 602 | 633 | * Filter to set custom log fields |
| 603 | 634 | * |
| 604 | 635 | * @since 1.0.0 |
| 605 | 636 | * |
| @@ -833,8 +864,82 @@ | ||
| 833 | 864 | return $value; |
| 834 | 865 | |
| 835 | 866 | } |
| 836 | 867 | add_filter( 'automatorwp_log_post_id_field_value_display', 'automatorwp_log_post_id_field_display', 10, 4 ); |
| 868 | + | |
| 869 | +/** | |
| 870 | + * User id field display | |
| 871 | + * | |
| 872 | + * @since 1.0.0 | |
| 873 | + * | |
| 874 | + * @param string $value Field value | |
| 875 | + * @param array $field_args Field parameters | |
| 876 | + * @param CMB2_Field $field Field object | |
| 877 | + * @param stdClass $log Log object | |
| 878 | + * | |
| 879 | + * @return string | |
| 880 | + */ | |
| 881 | +function automatorwp_log_user_id_field_display( $value, $field_args, $field, $log ) { | |
| 882 | + | |
| 883 | + ct_setup_table( 'automatorwp_logs' ); | |
| 884 | + $value = ct_get_object_meta( $log->id, 'user_id', true ); | |
| 885 | + ct_reset_setup_table(); | |
| 886 | + | |
| 887 | + $user = get_userdata( $value ); | |
| 888 | + | |
| 889 | + if( $user ) { | |
| 890 | + | |
| 891 | + if( current_user_can( 'edit_user', $user->ID ) ) { | |
| 892 | + $value = '<a href="' . get_edit_user_link( $user->ID ) . '">' . $user->display_name . '</a>'; | |
| 893 | + } else { | |
| 894 | + $value = $user->display_name; | |
| 895 | + } | |
| 896 | + | |
| 897 | + } else { | |
| 898 | + $value = __( '(No user assigned)', 'automatorwp' ); | |
| 899 | + } | |
| 900 | + | |
| 901 | + return $value; | |
| 902 | + | |
| 903 | +} | |
| 904 | +add_filter( 'automatorwp_log_user_id_field_value_display', 'automatorwp_log_user_id_field_display', 10, 4 ); | |
| 905 | + | |
| 906 | +/** | |
| 907 | + * User id (from log meta "user_id") field display | |
| 908 | + * | |
| 909 | + * @since 1.0.0 | |
| 910 | + * | |
| 911 | + * @param string $value Field value | |
| 912 | + * @param array $field_args Field parameters | |
| 913 | + * @param CMB2_Field $field Field object | |
| 914 | + * @param stdClass $log Log object | |
| 915 | + * | |
| 916 | + * @return string | |
| 917 | + */ | |
| 918 | +function automatorwp_log_user_id_meta_field_display( $value, $field_args, $field, $log ) { | |
| 919 | + | |
| 920 | + ct_setup_table( 'automatorwp_logs' ); | |
| 921 | + $value = ct_get_object_meta( $log->id, 'user_id', true ); | |
| 922 | + ct_reset_setup_table(); | |
| 923 | + | |
| 924 | + $user = get_userdata( $value ); | |
| 925 | + | |
| 926 | + if( $user ) { | |
| 927 | + | |
| 928 | + if( current_user_can( 'edit_user', $user->ID ) ) { | |
| 929 | + $value = '<a href="' . get_edit_user_link( $user->ID ) . '">' . $user->display_name . '</a>'; | |
| 930 | + } else { | |
| 931 | + $value = $user->display_name; | |
| 932 | + } | |
| 933 | + | |
| 934 | + } else { | |
| 935 | + $value = __( '(No user assigned)', 'automatorwp' ); | |
| 936 | + } | |
| 937 | + | |
| 938 | + return $value; | |
| 939 | + | |
| 940 | +} | |
| 941 | +add_filter( 'automatorwp_log_user_id_meta_field_value_display', 'automatorwp_log_user_id_meta_field_display', 10, 4 ); | |
| 837 | 942 | |
| 838 | 943 | /** |
| 839 | 944 | * Automation field display |
| 840 | 945 | * |