Make WordPress Core

Opened 10 years ago

Last modified 6 years ago

#32469 new enhancement

Create wp-include/views directory

Reported by: jacobsantos's profile jacobsantos Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: template Cc:

Description

HTML/JS/CSS is currently combined with PHP code. So, this is bad practice.

I realize that this is currently used in the entire WordPress code base. Excepting themes, which are loaded on the front-end. Most of the view code is displayed on the admin I believe.

Having views part of the PHP increases the function or method size and is confusing since some parts are evaluated after some parts of the view is displayed, so to process what the code is doing, you need to comprehend both the HTML output along with the PHP execution.

Furthermore, doing this should allow for customizing even the hardcoded view code in functions and methods.

I also propose a helper function that pulls in the views from wp-includes that could probably be extended later to include the current theme file matching the view file name.

While ABSPATH . 'wp-includes/views/{filename}.php' would be simple, it wouldn't allow future modifications without again modifying all of the view paths. It should be done once and allow for the future modification of accepting another location for changing the views.

Attachments (2)

wp-view.patch (3.1 KB) - added by jacobsantos 10 years ago.
Add wp_view() function and wp-includes/views directory.
wp-editor-editor.patch (7.5 KB) - added by jacobsantos 10 years ago.
Changes WP_Editor::editor() method to use a view instead of displaying directly.

Download all attachments as: .zip

Change History (4)

#1 @jacobsantos
10 years ago

Also, some methods and functions echo, which is also bad, since now you have an output issue.

I would also recommend modifications to the core contributor handbook with the suggestion that views are added to the directory and referenced using the helper function.

It would also be nice to have a wp-admin/includes/views or wp-admin/views for wp-admin as well, but I'm more worried about wp-includes and wp-admin is a bit more advanced with how view refactoring should be handled.

@jacobsantos
10 years ago

Add wp_view() function and wp-includes/views directory.

@jacobsantos
10 years ago

Changes WP_Editor::editor() method to use a view instead of displaying directly.

This ticket was mentioned in Slack in #core by jacobsantos. View the logs.


10 years ago

Note: See TracTickets for help on using tickets.