Skip to content
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

Issue 313: Create new connector for Theme Editor #341

Merged
merged 48 commits into from
Apr 1, 2014
Merged

Conversation

powelski
Copy link

Fix #313

editor log

return;
}

if ( ! isset( $_POST['action'] ) || 'update' !== $_POST['action'] ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@powelski Nice opportunity to use wp_stream_filter_input() here:

'update' !== wp_stream_filter_input( INPUT_POST, 'action' )

And elsewhere throughout this method...

@@ -312,7 +312,7 @@ public static function callback_pre_set_site_transient_update_plugins( $value )
}

public static function callback_wp_redirect( $location ) {
if ( ! preg_match( '#(plugin|theme)-editor.php#', $location, $match ) ) {
if ( ! preg_match( '#(plugin)-editor.php#', $location, $match ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@powelski Shouldn't we then also include an update routine to fix past entries? Otherwise we will not be maintaining proper backwards compatibility. The old entries should be changed to the new Theme Editor connector with the proper context being the theme name.

Copy link
Author

Choose a reason for hiding this comment

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

@fjarrett We can update summaries, but it's not possible to provide action links as I did here, because we don't have theme's slug in meta, only the name. Unless we do trick, like fetching available themes and adding theme slug meta for all matches. Not perfect, but worth consideration.

Copy link
Contributor

Choose a reason for hiding this comment

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

@powelski I'm more concerned about just updating the Summary, Connector and Context more than the action links.

Copy link
Author

Choose a reason for hiding this comment

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

@fjarrett Okay, I developed the updater. I tested it carefully. This how it works:

  1. It updates summary, connector, context and action for all previous file editions
  2. It tries to find a theme by name and if one is found, theme slug is saved in meta
  3. If we have theme slug in meta, we are able to display action links: Edit File and Edit Theme. Otherwise they are not present.

What I need to confirm is that connectors classes are available when WP_Stream_Install::update() is called (https://github.com/x-team/wp-stream/blob/issue-313/includes/install.php#L207-L211), because I tested it by calling Editor's updater directly.

Copy link
Contributor

Choose a reason for hiding this comment

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

@powelski This is why we introduced the wp_stream_after_connectors_registration filter and place all migration methods directly inside the WP_Stream_Install class.

See: https://github.com/x-team/wp-stream/blob/28e583ae303576849e3ff7d844a73488a256610e/includes/install.php#L201-L238

We should use this same approach and keep all migration logic in the same place.

Copy link
Contributor

Choose a reason for hiding this comment

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

@powelski bump 😺

Copy link
Author

Choose a reason for hiding this comment

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

@fjarrett So you mean that this functionality should be moved from Editor's class to updater directly, is this correct?

Copy link
Contributor

Choose a reason for hiding this comment

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

@powelski To the WP_Stream_Install class, yes. And we can run it after all connectors have registered.

@frankiejarrett
Copy link
Contributor

@powelski I've created a method for the migration in 6562d1b so we can run it after the connectors have been registered. However, it doesn't appear to be working for me yet.

@powelski
Copy link
Author

powelski commented Apr 1, 2014

@fjarrett wp_stream_after_connectors_registration is action, not filter.

@@ -201,7 +201,13 @@ public static function update( $db_version, $current ) {
// If version is lower than 1.3.0, do the update routine for site options
// Backward settings compatibility for old version plugins
if ( version_compare( $db_version, '1.3.0', '<' ) ) {
add_filter( 'wp_stream_after_connectors_registration', 'WP_Stream_Install::migrate_old_options_to_exclude_tab' );
add_action( 'wp_stream_after_connectors_registration', 'WP_Stream_Install::migrate_old_options_to_exclude_tab' );
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh noes! That means the migration of old options wasn't working. Could have been the culprit for this forum thread.

Copy link
Author

Choose a reason for hiding this comment

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

@fjarrett Yikes! 😺

frankiejarrett added a commit that referenced this pull request Apr 1, 2014
Issue 313: Create new connector for Theme Editor
@frankiejarrett frankiejarrett merged commit 536bc1a into develop Apr 1, 2014
@frankiejarrett frankiejarrett deleted the issue-313 branch April 1, 2014 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create new connector for Theme Editor
2 participants