Refactor custom status module views#736
Conversation
| $description = ( isset( $_POST['description'] ) ) ? wp_strip_all_tags( $_POST['description'] ) : $custom_status->description; | ||
| } | ||
|
|
||
| include __DIR__ . '/views/edit-status.php'; |
There was a problem hiding this comment.
Unless it's a shared/common view file, I usually default to using include_once to ensure no one accidentally include the file elsewhere. Would that fit the scenario here?
There was a problem hiding this comment.
I like that, better to not keep including it again and again.
| } else { | ||
| $custom_status_list_table = new EF_Custom_Status_List_Table(); | ||
| $custom_status_list_table->prepare_items(); | ||
| include __DIR__ . '/views/configure.php'; |
There was a problem hiding this comment.
I like that, better to not keep including it again and again.
| <form class="basic-settings" action="<?php echo esc_url( $this->get_link( array( 'action' => 'change-options' ) ) ); ?>" method="post"> | ||
| <?php settings_fields( $this->module->options_group_name ); ?> | ||
| <?php do_settings_sections( $this->module->options_group_name ); ?> | ||
| <?php echo '<input id="edit_flow_module_name" name="edit_flow_module_name" type="hidden" value="' . esc_attr( $this->module->name ) . '" />'; ?> |
There was a problem hiding this comment.
I think we can avoid echoing out the entire input field if we instead just echo out the module name.
Like this:
| <?php echo '<input id="edit_flow_module_name" name="edit_flow_module_name" type="hidden" value="' . esc_attr( $this->module->name ) . '" />'; ?> | |
| <input id="edit_flow_module_name" name="edit_flow_module_name" type="hidden" value="<?php echo esc_attr( $this->module->name ); ?>" /> |
| </div> | ||
|
|
||
| <?php wp_nonce_field( 'custom-status-add-nonce' ); ?> | ||
| <?php echo '<input id="action" name="action" type="hidden" value="add-new" />'; ?> |
There was a problem hiding this comment.
Not really necessary to echo this line out I think
| <?php echo '<input id="action" name="action" type="hidden" value="add-new" />'; ?> | |
| <input id="action" name="action" type="hidden" value="add-new" /> |
hanifn
left a comment
There was a problem hiding this comment.
Code changes looks good to me and everything seems to be working as expected 👍
🚢
Description
This PR is currently based on @ingeniumed's work in #734. Please review after that PR has been merged.
Some cleanup for the custom status module, as initial work to extend it. There were a few main changes:
The
print_configure_view()function had a lot of responsibilities, embedded HTML, and indentation. I moved the two HTML sections (configure page, edit status page) into separate view files and simplified the function.Fixed some PHPCS warnings from using
$_GETand$_POSTvariables inprint_configure_view()with some rewrites and somephpcs:ignores.Updated i18n functions to their escaped versions (
_e()→esc_html_e()) where appropriate.Moved one string (
ef_confirm_delete_status_string) from an embeded<script>tag towp_localize_script().Updated all
array()s in the file to short syntax ([]). I did this automatically with PHP-CS-Fixer:php-cs-fixer fix modules/custom-status/custom-status.php --rules='{"array_syntax": {"syntax": "short"}}'A lot of whitespace alignment changes were automatically made by my editor.
Steps to Test