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

Classic Theme Helper: Copy Social Links code to Classic Theme Helper package #38593

Merged
merged 11 commits into from
Aug 1, 2024

Conversation

coder-karen
Copy link
Contributor

@coder-karen coder-karen commented Jul 29, 2024

Fixes https://github.com/Automattic/vulcan/issues/431

Proposed changes:

  • Moved the main file social-links.php.
  • In order to avoid any issues if the package file happens to load just before the module file (as the package file is being read in my local tests), I've commented out the class initialization from the package file for now, and will modify this when requiring the package in the next PR.
  • Added some Phan suppressions and attempted some Phan suggested fixes related to adding class / function checks, but these won't be tested until requiring this feature via the package (in the next PR).
  • There is no WebPack build added, as there is none in the Jetpack plugin either for this feature.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

https://github.com/Automattic/vulcan/issues/431

Does this pull request change what data or activity we track or use?

No.

Testing instructions:

  • Technically the package isn't being used yet, and no build is happening, so a code check is the main thing.
  • However in testing I did come across a fatal and had to make a few changes to make sure the package version didn't try to initialize the class as the file was being read, so we should make sure functionality is not affected. To do so:

Self-hosted and Atomic:

  • On a test site, add a theme that includes support for Jetpack's social-links. The only theme I could find is 'Syntax'.
  • Otherwise, make sure you have a classic (not block) theme, such as Twenty Nineteen, and add the following snippet with a functionality plugin (like 'Code Snippets'):
add_action( 'after_setup_theme', function () {
	add_theme_support( 'social-links', array(
		'facebook', 'twitter', 'linkedin', 'tumblr',
	) );
} );
  • Enable Social sharing - /wp-admin/admin.php?page=jetpack#/sharing and add a connection.
  • You can add a Facebook page by using the Gmail username and pw for credsflow.... in the SS (internal only).
  • Visit the Customizer, and you should see a 'Connect' menu item, that allows you to select your newly added connection.
  • This should work both on trunk and with this PR applied.
  • On Atomic make sure to test with the PR checked out for both Jetpack and WPcom Features, and each individually.

Simple:

  • Add a social connection at https://wordpress.com/marketing/connections/yoursite.com
  • Add a theme which includes support for Jetpack's social-links - Syntax for example.
  • Visit the Customizer and you should see the 'Connect' menu item allowing you to connect your new social connection.
  • This should work both with and without the patches applied - see testing comment below (and also one at a time to replicate Jetpack only and Mu Wpcom only).

@coder-karen coder-karen self-assigned this Jul 29, 2024
@github-actions github-actions bot added [Feature] Theme Tools [Package] Classic Theme Helper [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ labels Jul 29, 2024
Copy link
Contributor

github-actions bot commented Jul 29, 2024

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WordPress.com Simple site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin, and enable the add/social-links-to-classic-theme-helper-package branch.

    • For jetpack-mu-wpcom changes, also add define( 'JETPACK_MU_WPCOM_LOAD_VIA_BETA_PLUGIN', true ); to your wp-config.php file.
  • To test on Simple, run the following command on your sandbox:

    bin/jetpack-downloader test jetpack add/social-links-to-classic-theme-helper-package
    
    bin/jetpack-downloader test jetpack-mu-wpcom-plugin add/social-links-to-classic-theme-helper-package
    

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@Automattic Automattic deleted a comment from github-actions bot Jul 30, 2024
Copy link
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Once your PR is ready for review, check one last time that all required checks appearing at the bottom of this PR are passing or skipped.
Then, add the "[Status] Needs Team Review" label and ask someone from your team review the code. Once reviewed, it can then be merged.
If you need an extra review from someone familiar with the codebase, you can update the labels from "[Status] Needs Team Review" to "[Status] Needs Review", and in that case Jetpack Approvers will do a final review of your PR.


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen daily.
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly. The next release is scheduled for August 6, 2024 (scheduled code freeze on August 5, 2024).

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@coder-karen coder-karen marked this pull request as ready for review July 30, 2024 11:20
@coder-karen coder-karen added [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. and removed [Status] In Progress labels Jul 30, 2024
@coder-karen coder-karen requested a review from a team July 30, 2024 12:23

// @phan-suppress-next-line PhanUndeclaredFunction -- Function checked with function_exists - see https://github.com/phan/phan/issues/1204.
$this->publicize = function_exists( 'publicize_init' ) ? publicize_init() : null;
$publicize_services = $this->publicize->get_services( 'connected' );
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens here if $this->publicize is null?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question. I've no idea at this stage, but I'll make sure to look into that when requiring the package in the next PR.

Copy link
Contributor

@darssen darssen left a comment

Choose a reason for hiding this comment

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

Thanks for working on this one @coder-karen!

Changes look sensible to me before testing.

As of now, there is only two things that I can think of that might need changes.

  1. I'm not sure how much sense does all of the logic if Publicize or publicize_init don't exist. I see there is a wrapper inside customize_register( checking it, but I feel like maybe it would need to be early on. Should it be even before that? Maybe return early in the constructor? I have added an inline comment in a place where I think the absence of Publicize will create a Fatal
  2. I would change is the filename projects/packages/classic-theme-helper/src/social-links.php to projects/packages/classic-theme-helper/src/class-social-links.php.

@coder-karen
Copy link
Contributor Author

Thanks for testing @darssen !

I'm not sure how much sense does all of the logic if Publicize or publicize_init don't exist.

Good questions, thanks! What I'll do is make sure to investigate that when requiring the package in the next PR. None of that moved functionality should be running here, only the existing functionality.

I'll add a note to the issue for the next step: https://github.com/Automattic/vulcan/issues/432

I would change is the filename projects/packages/classic-theme-helper/src/social-links.php to projects/packages/classic-theme-helper/src/class-social-links.php.

Yes, I did initially try that, and it resulted in some issues for me (a fatal error). I had added that as something to try and rename in the next PR - added in the above issue. The issue seemed related to the Jetpack autoloader. Had you come across this before? I know Featured Content was also in a class so I was looking at what was done there originally.

Copy link
Contributor

@monsieur-z monsieur-z left a comment

Choose a reason for hiding this comment

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

This tested well with all types of sites.

@coder-karen coder-karen merged commit d6c1bb6 into trunk Aug 1, 2024
58 of 59 checks passed
@coder-karen coder-karen deleted the add/social-links-to-classic-theme-helper-package branch August 1, 2024 07:24
@github-actions github-actions bot removed the [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. label Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Theme Tools [Package] Classic Theme Helper [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants