Skip to content

Site Icon: Start using core's Site Icon#2402

Merged
dereksmart merged 13 commits intomasterfrom
fix/site-icon-use-core
Jul 19, 2015
Merged

Site Icon: Start using core's Site Icon#2402
dereksmart merged 13 commits intomasterfrom
fix/site-icon-use-core

Conversation

@dereksmart
Copy link
Copy Markdown
Contributor

This is meant to be a seamless under-the-hood transition to deprecating Jetpack's site icon in favor of core.

  • If user already has Jetpack Site Icon set, this will take that icon, transfer it to core's version, and deactivate Jetpack's Site Icon.
  • Modifies the Module list on the Jetpack Settings page so Site Icon cannot be activated. Instead, we tell them about Core's new Site Icon and a link to configure it.
  • Makes sure that core's site icon also gets synced back to wpcom

My thinking is that we'll leave it like this until 4.3 is the minimum supported WP version. Then we can remove the module completely.

This includes @kraftbj's commits from #2328 as well, so that PR can be discarded.

fixes #2326

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe instead of using an id, we could use a more generic class, like 'module-deprecated' so that we can use it for other deprecated modules.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The only real purpose of the ID in this case is a target for the genericon, so making this reusable wouldn't really work for other modules.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah. Thanks for the clarification.

@enejb
Copy link
Copy Markdown
Member

enejb commented Jul 15, 2015

It doesn't seem to be working as expected.

See:
image

I am expecting to not see the icon any more. The site icon module is still active, I think we should disable it and only expose.

We should also depreciate the jetpack_site_icon_url and jetpack_get_site_icon and jetpack_has_site_icon functions in favour of the new WP 3.6 functions.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this part doesn't make so much sense to me.
Since we should just not load the module anymore if the user is running 3.6 not just if the user has an site icon or not.

And this part needs to be tested from both ways. If the user is running jetpack WP 4.2 and then upgrade to WP 4.3 and the latest jetpack or if the user is on jetpack 3.5 and upgrades to jetpack 3.6 and is running WP 4.3.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If you continue reading this function, the module should be disabled whether or not there is a core icon set. I did it here early bc if one is already set then the rest of the code is unnecessary overhead. This function runs on admin_init, so I'm curious how you're experiencing the module not deactivating in your comment above.

If upgrading from WP 4.2 -> 4.3, this function will run on admin_init, transfer the icon to core then deactivate the module. Or if no icon is set, it will just deactivate the module.

Same with upgrading from JP 3.5 -> 3.6.1

@zinigor
Copy link
Copy Markdown
Contributor

zinigor commented Jul 16, 2015

Read the code, tested the transition between 4.2.2 and trunk, everything works as expected.

@zinigor zinigor added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review This PR is ready for review. labels Jul 16, 2015
@enejb
Copy link
Copy Markdown
Member

enejb commented Jul 16, 2015

So it turned out that not all the code was update on the servers. This PR fixes the issue that I reported earlier about seeing 2 Site Icon forms.

@enejb
Copy link
Copy Markdown
Member

enejb commented Jul 16, 2015

We need to make sure that when the user updates the site icon in 4.3 that we sync the data .com right away not just on the heartbeat.

@zinigor
Copy link
Copy Markdown
Contributor

zinigor commented Jul 17, 2015

@dereksmart
Copy link
Copy Markdown
Contributor Author

@enejb the hook that Igor pointed out does the trick. It's using add_option instead of update_option because Core's process for uploading a site icon is to first delete the option entirely, then add a new one.

@enejb
Copy link
Copy Markdown
Member

enejb commented Jul 17, 2015

@zinigor and @dereksmart I think we might also need do something like:
add_action( "delete_option_site_icon", , array( $this, 'jetpack_sync_core_icon' ) ); add_action( "update_option_site_icon", , array( $this, 'jetpack_sync_core_icon' ) ); add_action( "add_option_site_icon", , array( $this, 'jetpack_sync_core_icon' ) );
to capture all the cases. :)

@dereksmart
Copy link
Copy Markdown
Contributor Author

delete_option_site_icon is a good idea. I first tried update_option_site_icon instead of add, but it wasn't working for me. I think it's because the process of adding/updating an icon in core is to first delete, then update the option (thus adding a new option), therefore the update_option hook never fires.

Guess it wouldn't hurt to add though.

@dereksmart dereksmart force-pushed the fix/site-icon-use-core branch from 12eb908 to 14e9ebd Compare July 17, 2015 17:17
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there a better hook than admin_init? Or a better place to call it, like in Jetpack_Site_icon itself?
Currently it would add that callback for every admin page load for(almost)ever.

@dereksmart dereksmart force-pushed the fix/site-icon-use-core branch 3 times, most recently from f71dc45 to 7e52cc3 Compare July 17, 2015 18:08
@jeffgolenski
Copy link
Copy Markdown
Member

Alright I tided up some markup and made the deprecated setting look decent / functional on mobile devices. I moved the checkbox back in and just disabled it to maintain visual cohesion. Disable is pretty well supported all around.

Also important to note. I made "Configure" capitalized to match the others, just made that change after the screenshots were taken.

screen shot 2015-07-17 at 4 00 10 pm

screen shot 2015-07-17 at 3 56 33 pm

@zinigor zinigor force-pushed the fix/site-icon-use-core branch from 2031347 to 29a9b8a Compare July 17, 2015 21:32
kraftbj and others added 12 commits July 17, 2015 17:50
New function will return true if core's site icon is available.  It will also convert Jetpack's site icon to Core's version if one is set.  It will disable Jetpack's site icon module no matter what.
Don't allow activation and point config link to core's site icon
We need to sync core's site icon to use in wpcom.  This will allow the icon to be synced when it's uploaded to core.

Also run a check on `jetpack_heartbeat` action in case core icon was set before Jetpack was installed
Cleaned up a few things for the newly deprecated Site Icon. Also made
it look decent / function on mobile devices.
@dereksmart dereksmart force-pushed the fix/site-icon-use-core branch from 29a9b8a to f5b5525 Compare July 17, 2015 21:55
No need to run this on every admin page.
dereksmart added a commit that referenced this pull request Jul 19, 2015
Site Icon: Begin the deprecation of Jetpack's Site Icon in favor of Core
@dereksmart dereksmart merged commit db913ea into master Jul 19, 2015
@dereksmart dereksmart removed the [Status] Ready to Merge Go ahead, you can push that green button! label Jul 19, 2015
@dereksmart dereksmart deleted the fix/site-icon-use-core branch July 19, 2015 15:46
@dereksmart dereksmart restored the fix/site-icon-use-core branch July 19, 2015 15:47
@dereksmart
Copy link
Copy Markdown
Contributor Author

Keeping this branch open in case there's any more discussion. Will delete after 3.6.1 is released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adjust site icon to work with 4.3

7 participants