This repository has been archived by the owner on Dec 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
[WIP] Post editor enhancements #222
Open
mohdsayed
wants to merge
6
commits into
develop
Choose a base branch
from
post-editor-enhancements
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
989cc6d
Allow button text to be changed by params
mohdsayed e4a33eb
Move editor control related methods to its own class
mohdsayed e4cd75d
Remove unused class-wp-customize-editor-control
mohdsayed 7173100
Move editor related exports to its own class
mohdsayed 2757e06
Resolve conflict with develop
mohdsayed 49c6ed5
Give option to disable editor buttons
mohdsayed File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@sayedwp Actually, maybe you should switch back to using the non-
static
enqueue()
method, but then have astatic
class variable to capture whether the enqueue has been called:Then you can avoid
WP_Customize_Posts
from having direct awareness of this class's methods and so could remove: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.
@westonruter
enqueue
method never executes until we add control usingadd_control
. So currentlyenqueue
is just sitting there and not doing anything, we are enqueueing the script as a dependency fromregister_scripts
inCustomize_Posts_Plugin
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.
OK, good point. I'd consider this a deficiency in the
WP_Customize_Manager::register_control_type()
that it doesn't call theenqueue
method.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 that's because when we register the control type, it just renders the template
https://github.com/WordPress/WordPress/blob/master/wp-includes/class-wp-customize-manager.php#L1517-L1543
However the actual enqueue method is called when we use
add_control
ofWP_Customize_Manager
https://github.com/WordPress/WordPress/blob/master/wp-includes/class-wp-customize-manager.php#L1633-L1636
https://github.com/WordPress/WordPress/blob/master/wp-includes/class-wp-customize-manager.php#L1471-L1479
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.
Also we should be able to use
customize_controls_enqueue_scripts
from inside theWP_Customize_Post_Editor_Control
construct but we cannot do that becauserender_control_template
is hooked intocustomize_controls_print_footer_scripts
which is at the footer andcustomize_controls_enqueue_scripts
is in the header, so already late.https://github.com/WordPress/WordPress/blob/master/wp-includes/class-wp-customize-manager.php#L301
https://github.com/WordPress/WordPress/blob/master/wp-admin/customize.php#L63-L185
However if we use
add_control
I think then it should be working because its hooked intocustomize_register
.