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

WordAds: Add inline ads within post content #37170

Merged
merged 5 commits into from
May 7, 2024
Merged

Conversation

cphilleo
Copy link
Contributor

@cphilleo cphilleo commented May 2, 2024

Proposed changes:

  • Adds inline ads within post content
  • Adds option to enable/disable inline ads

Screenshot 2024-05-01 at 5 56 40 PM

Screenshot 2024-05-01 at 5 56 57 PM

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

No

Testing instructions:

  • Enabled WordAds on your test site
  • Visit a post with a length that is at least 2x the window view height and includes multiple paragraphs of text
  • Validate that an ad appears inline within the content
  • You can append wordads-logging=true to the URL to enable detailed logging in the browser console
  • Toggle the inline ad feature off
  • Validate that inline ads no longer appear in the content

@cphilleo cphilleo self-assigned this May 2, 2024
@github-actions github-actions bot added [Feature] Ad [Package] Sync [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Tests] Includes Tests Admin Page React-powered dashboard under the Jetpack menu labels May 2, 2024
Copy link
Contributor

github-actions bot commented May 2, 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/wordads-blaze 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/wordads-blaze
    
    bin/jetpack-downloader test jetpack-mu-wpcom-plugin add/wordads-blaze
    

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

Copy link
Contributor

github-actions bot commented May 2, 2024

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 June 4, 2024 (scheduled code freeze on May 27, 2024).

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


Backup plugin:

  • Next scheduled release: June 4, 2024.
  • Scheduled code freeze: May 27, 2024.

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


Boost plugin:

  • Next scheduled release: June 4, 2024.
  • Scheduled code freeze: May 27, 2024.

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


Search plugin:

  • Next scheduled release: June 4, 2024.
  • Scheduled code freeze: May 27, 2024.

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


Social plugin:

  • Next scheduled release: June 4, 2024.
  • Scheduled code freeze: May 27, 2024.

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


Starter Plugin plugin:

  • Next scheduled release: June 4, 2024.
  • Scheduled code freeze: May 27, 2024.

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


Protect plugin:

  • Next scheduled release: June 4, 2024.
  • Scheduled code freeze: May 27, 2024.

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


Videopress plugin:

  • Next scheduled release: June 4, 2024.
  • Scheduled code freeze: May 27, 2024.

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


Migration plugin:

  • Next scheduled release: June 4, 2024.
  • Scheduled code freeze: May 27, 2024.

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


Mu Wpcom plugin:

  • Next scheduled release: June 4, 2024.
  • Scheduled code freeze: May 27, 2024.

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


Automattic For agencies client plugin:

  • Next scheduled release: June 4, 2024.
  • Scheduled code freeze: May 27, 2024.

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

Copy link
Contributor

@diogoca diogoca left a comment

Choose a reason for hiding this comment

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

Great job here! I've added minor comments.

Working as expected, I was able to see the inline ads injected between the post paragraphs.

image

Turning the placement off I got no logs or adflow requests in Network tab as expected:

image image

Note: In order to see the inline ad feature under the Monetize section I had to build wordads package and the jetpack plugin again, jetpack build.

@Alameen688
Copy link
Contributor

LGTM! This works as expected. I was able to see inline ads
inline ads works

Not sure if this is related to the PR but I saw an error in the console a couple of times before the ads started showing

Cannot read properties of undefined (reading 'fire')
at e. onreadystatechange watl.js:1
unrelated error error

@github-actions github-actions bot added [Plugin] Automattic For Agencies Client [Plugin] Backup A plugin that allows users to save every change and get back online quickly with one-click restores. [Plugin] Boost A feature to speed up the site and improve performance. [Plugin] Migration [Plugin] mu wpcom jetpack-mu-wpcom plugin [Plugin] Protect A plugin with features to protect a site: brute force protection, security scanning, and a WAF. [Plugin] Search A plugin to add an instant search modal to your site to help visitors find content faster. [Plugin] Social Issues about the Jetpack Social plugin [Plugin] Starter Plugin [Plugin] VideoPress A standalone plugin to add high-quality VideoPress videos to your site. labels May 2, 2024
diogoca
diogoca previously approved these changes May 3, 2024
Copy link
Contributor

@diogoca diogoca left a comment

Choose a reason for hiding this comment

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

I've tested again with the last changes, worked as expected. LGTM!

*
* @return string The URL.
*/
private function get_config_url(): string {
Copy link
Member

Choose a reason for hiding this comment

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

Jetpack still requires PHP 7.0, so I'm afraid we won't be able to rely on type declarations just yet.
https://github.com/Automattic/jetpack/blob/trunk/.github/versions.sh#L8

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 is ok in PHP 7.0. https://www.php.net/manual/en/language.types.declarations.php has decent coverage of which things were added in later versions.

Copy link
Member

Choose a reason for hiding this comment

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

TIL, thank you!

*
* @return void
*/
public function init( WordAds_Params $params ) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm afraid type definitions are not an option yet in the Jetpack codebase, since we still require PHP 7.0 for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

A class type on a parameter like this is ok even back to PHP 5.0.

Copy link
Member

Choose a reason for hiding this comment

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

That's good to know, thanks!

return;
}

// Don't run on not found pages.
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to ensure those don't get added to RSS feeds and embeds too, where JS will not be available?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For now, I'm going to stick with the same checks that our existing ads are using, but I'll look into this further. The side effect if no JS is available would be an extra invisible <span> at the end of the post content—so not too disruptive.

@jeherve jeherve added [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! and removed [Status] Needs Team Review labels May 3, 2024
@cphilleo cphilleo added [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. and removed [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels May 7, 2024
@cphilleo
Copy link
Contributor Author

cphilleo commented May 7, 2024

@jeherve, I'm pretty confident in the changes I made for this patch, but I'm less confident in the changes that are here because of having to run fixup-project-versions.sh to fix build errors. Can you verify that those changes won't hurt anything?

@cphilleo cphilleo requested a review from jeherve May 7, 2024 17:44
@jeherve
Copy link
Member

jeherve commented May 7, 2024

I'm less confident in the changes that are here because of having to run fixup-project-versions.sh to fix build errors.

These are safe. 👍 The script automatically bumps versions of packages that will include your changes, and updates the lock files accordingly.

Copy link
Contributor

@diogoca diogoca left a comment

Choose a reason for hiding this comment

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

I tested again with the last changes, and it is working as expected. 👍🏽

@cphilleo cphilleo merged commit 812a87a into trunk May 7, 2024
72 checks passed
@cphilleo cphilleo deleted the add/wordads-blaze branch May 7, 2024 20:46
@github-actions github-actions bot removed the [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. label May 7, 2024
pkuliga pushed a commit that referenced this pull request May 9, 2024
* Add support for inline Blaze ads with IPONWEB fallback

* changelog

* Minor fixes

* Run fixup-project-versions.sh

* Make WordAds_Smart a singleton
@Aurorum
Copy link
Contributor

Aurorum commented May 22, 2024

Hi all, there's been an issue opened in Automattic/wp-calypso#90997 about these settings not existing in the Calypso ads dashboard. I couldn't find any PR related to this on the Calypso side, so I've proposed bringing parity between this addition and Calypso in Automattic/wp-calypso#91006.

Would be very grateful if you wouldn't mind reviewing it! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Admin Page React-powered dashboard under the Jetpack menu [Feature] Ad [Feature] WordAds [Package] Sync [Plugin] Automattic For Agencies Client [Plugin] Backup A plugin that allows users to save every change and get back online quickly with one-click restores. [Plugin] Boost A feature to speed up the site and improve performance. [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Migration [Plugin] mu wpcom jetpack-mu-wpcom plugin [Plugin] Protect A plugin with features to protect a site: brute force protection, security scanning, and a WAF. [Plugin] Search A plugin to add an instant search modal to your site to help visitors find content faster. [Plugin] Social Issues about the Jetpack Social plugin [Plugin] Starter Plugin [Plugin] VideoPress A standalone plugin to add high-quality VideoPress videos to your site. [Tests] Includes Tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants