Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Feature / Add edit in customizer buttons #140

Open
wants to merge 26 commits into
base: develop
Choose a base branch
from

Conversation

stuartshields
Copy link

@westonruter and @valendesigns here is the initial concept for adding the Edit in Customizer button to the Posts/Pages edit screens. As well as adding Edit in Customizer to both post_row_actions and page_row_actions. I moved the customize url into it's own function since we're calling it in two different functions now.

$rebuild_actions['edit_customizer'] = '<a href="' . esc_html( self::get_customize_url( $post ) ) . '">Edit in Customizer</a>';
$rebuild_actions['inline hide-if-no-js'] = $actions['inline hide-if-no-js'];
$rebuild_actions['trash'] = $actions['trash'];
$rebuild_actions['view'] = $actions['view'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about other plugins that add action links? I think an array_merge() is required.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@westonruter definitely.

* @return array $rebuild_actions
*/
public function add_edit_customizer_to_row_actions( $actions, $post ) {
if ( ! is_a( $post, 'WP_Post' ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's be consistent and use the same coding style. Other places in the plugin we would check if $post is an instance of WP_Post like this:

if ( ! ( $post instanceof WP_Post ) ) {
    return false;
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@valendesigns Thanks I've now fixed it.

* @return string $customize_url
*/
public function get_customize_url( $post = null ) {
if ( ! is_a( $post, 'WP_Post' ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one could also be updated.

@stuartshields
Copy link
Author

@westonruter and @valendesigns This is ready for another look at. Any comments/direction would be good. As far as I can tell this is working the way we want it to, however I'm open to making this work better.

@valendesigns
Copy link
Contributor

@stuartshields It appears you could just do away with the get_customize_url method altogether and use the static get_preview_post_link instead.

@stuartshields
Copy link
Author

@valendesigns I wasn't able to get rid of get_customize_url altogether as it still needs the other variables that are generated to work. Latest commit has the fix, if you wanted to have a look.

@valendesigns
Copy link
Contributor

@stuartshields The post object is all you need to generate the preview URL so you can totally replace the get_customize_url. What else do see as a requirement that get_preview_post_link doesn't offer?

@stuartshields
Copy link
Author

@valendesigns I guess I'm concerned about not using get_customize_url because of #34 ... Do we continue with #34 but not use it for this one?

@valendesigns
Copy link
Contributor

@stuartshields I've updated the PR a bit and resolved conflicts. All that's left is to add unit test coverage for the new methods.

@valendesigns valendesigns mentioned this pull request Jun 19, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants