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

Replace release badge with playground badge #175

Merged
merged 2 commits into from
Aug 20, 2024
Merged

Conversation

jeffpaul
Copy link
Member

Description of the Change

Adds a badge linking to a WP Playground instance instead of the release version badge. Also adds badges for various GH Actions.

How to test the Change

Use GH markdown previewer.

Changelog Entry

n/a

Credits

Props @jeffpaul.

Checklist:

@jeffpaul jeffpaul added this to the 1.5.0 milestone Aug 14, 2024
@jeffpaul jeffpaul self-assigned this Aug 14, 2024
@jeffpaul jeffpaul requested a review from dkotter as a code owner August 14, 2024 02:17
@github-actions github-actions bot added the needs:code-review This requires code review. label Aug 14, 2024
@jeffpaul
Copy link
Member Author

Note that running this blueprint now gives an error:

Sorry, you are not allowed to access this page.

@dkotter
Copy link
Collaborator

dkotter commented Aug 14, 2024

Note that running this blueprint now gives an error:

Sorry, you are not allowed to access this page.

I am seeing the same thing. I thought maybe our settings URL had changed but that isn't the case.

What seems to be happening is we add a custom capability to the admin role that allows access to this page. This capability is added via the register_activation_hook function and on the admin_init hook. My assumption here is the register_activation_hook function never runs. If in the Playground you navigate to another admin URL and then back to the settings page, things work, as the admin_init hook will then fire. I think this is similar to an issue we reported that was impacting Publisher Media Kit (WordPress/wordpress-playground#911) though that did get fixed so assuming this is slightly different.

For now I've updated our blueprint to manually run the function that adds that custom capibility and things do work for me now. Can test that out with this link:

https://playground.wordpress.net/#{%22$schema%22:%22https://playground.wordpress.net/blueprint-schema.json%22,%22landingPage%22:%22/wp-admin/options-general.php?page=adstxt-settings%22,%22preferredVersions%22:{%22php%22:%227.4%22,%22wp%22:%22latest%22},%22phpExtensionBundles%22:[%22kitchen-sink%22],%22steps%22:[{%22step%22:%22login%22,%22username%22:%22admin%22,%22password%22:%22password%22},{%22step%22:%22setSiteOptions%22,%22options%22:{%22permalink_structure%22:%22/%25postname%25/%22}},{%22step%22:%22installPlugin%22,%22pluginZipFile%22:{%22resource%22:%22wordpress.org/plugins%22,%22slug%22:%22ads-txt%22},%22options%22:{%22activate%22:true}},{%22step%22:%22runPHP%22,%22code%22:%22%3C?php%20require_once%20'wordpress/wp-load.php';%20$adstxt_id%20=%20wp_insert_post(%20array(%20'post_title'%20=%3E%20'Ads.txt',%20'post_content'%20=%3E%20'#%20Example%20information\[email protected]\n\n#%20Example%20record\ngoogle.com,%20pub-1234567890,%20DIRECT,%20f08c47fec0942fa0',%20'post_status'%20=%3E%20'publish',%20'post_type'%20=%3E%20'adstxt'%20)%20);%20$app_adstxt_id%20=%20wp_insert_post(%20array(%20'post_title'%20=%3E%20'App-ads.txt',%20'post_content'%20=%3E%20'#%20Example%20information\[email protected]\n\n#%20Example%20record\ngoogle.com,%20pub-1234567890,%20DIRECT,%20f08c47fec0942fa0',%20'post_status'%20=%3E%20'publish',%20'post_type'%20=%3E%20'app-adstxt'%20)%20);%20if%20(%20!%20$adstxt_id%20instanceof%20WP_Error%20)%20{%20update_option(%20'adstxt_post',%20(int)%20$adstxt_id%20);%20}%20if%20(%20!%20$app_adstxt_id%20instanceof%20WP_Error%20)%20{%20update_option(%20'app_adstxt_post',%20(int)%20$app_adstxt_id%20);%20}%20\\AdsTxt\\add_capabilities();%22}]}

@jeffpaul
Copy link
Member Author

Seems then I need to update the link in the README.md badge from https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/10up/ads-txt/develop/.wordpress-org/blueprints/blueprint.json to the one you provided above @dkotter?

@dkotter
Copy link
Collaborator

dkotter commented Aug 14, 2024

I pushed a commit to this PR that updates the blueprint file, so once this PR is merged into develop that URL should work fine

@jeffpaul jeffpaul merged commit 87ba888 into develop Aug 20, 2024
14 checks passed
@jeffpaul jeffpaul deleted the add/playground branch August 20, 2024 18:08
@dkotter dkotter modified the milestones: 1.5.0, 1.4.5 Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs:code-review This requires code review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants