-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can avoid echo
ing 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
$_GET
and$_POST
variables inprint_configure_view()
with some rewrites and somephpcs:ignore
s.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