r/ProWordPress • • Dec 14 '21

TIL: Wordpress' plugin directory will no longer allow new plugins that let users execute Javascript or PHP

A little frustrated because I learned today that the Wordpress plugin directory is no longer accepting new plugins that allow users to execute their own Javascript code. This also applies to PHP code as well. Posting this here because as far as I can tell this isn't called out in their plugin directory documentation anywhere, and there are plenty of plugins already in the directory that allow this type of functionality.

I had as a part of my plugin the ability to allow a user to insert some Javascript if certain conditions were met, which I will now have to remove since they won't accept the plugin now due to these new rules. Posting this here so hopefully someone doesn't make the same mistake I did by trying to submit a plugin that lets users put in their own Javascript.

37 Upvotes

67 comments sorted by

4

u/DanielTrebuchet Developer Dec 14 '21

I'm struggling to understand what the big deal with this is. I'm not sure why you would be recreating the wheel and building a custom alternative to vanilla WP functionality, and if that's not what you're doing, I fail to see how you couldn't easily build a work around by adapting how the user is entering their data.

3

u/StrategicPlugins Dec 14 '21

My specific use case was that you could embed a script that would only show up for certain users who match specific criteria defined in the plugin. My intent was you could use it to embed a tracking script such as a custom GA parameter or Facebook tracker when a matching user was found, but I also want to leave it open enough that users can use it for use cases I haven't thought of and not have it limited to only one or two use cases / tracking scripts.

2

u/[deleted] Dec 14 '21

That sounds like a pretty cool tool. If this new rule sticks, maybe theres a way you can segment them into "integrations". Kinda like how an app might have plugins for Google Analytics, Facebook, etc.

To fix the "cases you haven't thought of," might just have to try and crowd source it. Offer support and let people suggest integrations they use that they want to add to it. Then you can add it, test it, and update the plugin with a new "integration"

1

u/StrategicPlugins Dec 15 '21

Maybe I'll do that, or maybe I'll segment that part of the plugin out into an add-on plugin separate from the main part of the plugin. Embedding a script was just one of a few actions I had in the plugin.

5

u/Odysseyan Dec 14 '21

users can use it for use cases I haven't thought of and not have it limited to only one or two use cases / tracking scripts.

But this is probably why Wordpress blocks it. Being able to execute ANYTHING without restrictions could become problematic if the user doesnt know what they are doing

5

u/DanielTrebuchet Developer Dec 14 '21

It's the use cases you haven't thought of that are the biggest concern. From a security standpoint that sounds super sketchy to me, at best. Seems like you could reasonably configure it to cover the vast majority of use cases while still setting it up in a way where the user doesn't have explicit control over the output.

2

u/chairmanbrando Dec 14 '21

They're blocking CSS inputs too according to another one of OP's comments. That means a plugin offering a box for per-post CSS would be rejected. That's pretty dumb.

3

u/DanielTrebuchet Developer Dec 14 '21

That's pretty dumb.

Not really. How much CSS are you adding on a per-post basis? Just use a Gutenberg HTML block or something. If you need more than that, then maybe the approach you're taking isn't the best route to begin with. Sure, having a style tag in the body isn't preferred, but it sounds like a use case that's already a bit janky as it is.

3

u/chairmanbrando Dec 14 '21

It's not for major things but for minor adjustments that don't need to apply to others pages. No need to mess with the tiny field in the customizer or fuck with body.xxx selectors. With a metadata field for CSS inputs you don't need to drop a style tag into the body; you can sniff it out beforehand and put it in the head.

1

u/DanielTrebuchet Developer Dec 14 '21

Right... I get how custom fields work.

Please give me one good real world use case where a user would need post-specific CSS that can't be easily achieved by built-in methods.

0

u/[deleted] Dec 14 '21

[deleted]

1

u/DanielTrebuchet Developer Dec 14 '21

How is pasting something into a Gutenberg block more annoying or less convenient than pasting the exact same thing into a custom field? The only difference for the user is the location of the cursor when they hit paste. I'm struggling to understand the big disparity here.

Again, I just need a specific real world use case to understand where you're coming from. That doesn't seem like an unreasonable request.

3

u/[deleted] Dec 14 '21

What about changing the plug-in to let people upload a script file, and then choose to include/enqueue the file per user type? Your instructions could tell them how.

2

u/StrategicPlugins Dec 15 '21

I suspect since this would also let users run arbitrary Javascript it would also be denied. Plus, it adds more to be concerned with because now you have to worry about file uploads too.

4

u/[deleted] Dec 14 '21

Wouldn't that be a security vulnerability allowing users to run scripts? My guess as to why theyd block it.

4

u/[deleted] Dec 14 '21

Most decent themes let users paste in GA or GTM code. I seriously doubt WP is blocking this.

2

u/StrategicPlugins Dec 14 '21

I'm not sure if the rules are different for themes. Seems the new way of doing this is instead of pasting in your GA code they would want you to build your interface so that the user only pastes in their GA ID, then your plugin adds the ID to the embedded script.

I think they are only enforcing for new submissions and I'm not sure if it's the same for themes as plugins either.

6

u/[deleted] Dec 14 '21

Thousands of platforms use JS for integration, I can't see how they can possibly implement this. No-one's going to build a UI for every platform integration. Can you post a screenshot of your email by any chance?

5

u/StrategicPlugins Dec 14 '21

0

u/[deleted] Dec 14 '21

[deleted]

4

u/joeyoungblood Dec 15 '21 edited Dec 15 '21

If you read my discussion with Otto (plugin review team) below you'll see they apparently don't call these "rules" but "points". They also make changes to these points constantly but never publish them anywhere, so developers are always in the dark on what may or may not get approved.

I've contended that the process is clearly broken and getting worse, among my concerns are that the plugin review team can apparently block a submission if the reviewer simply doesn't like the name of a plugin and that when changes are made to this process they should at the very least be documented somewhere.

Otto contends that the process is fine, everything is transparent and in the handbook, anyone complaining is just a troll, that documenting the myriad of changes to the review process would be too laborious and therefore none of it is documented or included in the handbook (seriously), that all developers have to do is comply with the demands of the reviewer no matter what they are, and that you can't use "WP" as a prefix for a plugin anymore because it is dumb and the team has the right to only allow names they don't think are dumb to be listed.

1

u/otto4242 Core Contributor Dec 15 '21 edited Dec 15 '21

It really isn't. This is the same message we've been giving to plugin authors for like 3 years? It almost never comes up, and most authors see the point and create better interfaces. You saw one small part of the email chain. The actual thread is much longer.

Having a field in your plugin where users can paste any arbitrary nonsense and have that go direct into the code, unfiltered.. yeah, not usually a good idea.

There also was no recent "wp-" rule change. The rules didn't change. Our ability to filter things grows when we find reasons to grow it. This isn't a change to the "rules", because we don't have any rules. We have guidelines only. They are flexible.

-1

u/joeyoungblood Dec 14 '21 edited Dec 15 '21

Yup.

edited

-1

u/otto4242 Core Contributor Dec 15 '21

The core team has nothing to do with it. The plugin review team does. I feel like many of you are not getting how this works at a fundamental level here...

Feel free to ask questions. Happy to answer them.

3

u/joeyoungblood Dec 15 '21

The issue isn't whatever team making a decision, it's the lack of knowing that the decisions are being made. We sunk thousands of dollars into securing names for plugins, building websites, and writing code only to be rejected by a rule that isn't even published anywhere. In OPs case they built a plugin they thought would be useful and found out a new rule was applied.

Whoever is in charge of this we just want some transparency and communication, that's all the community is asking for.

-1

u/otto4242 Core Contributor Dec 15 '21

No, he didn't. He posted half of an email from a long conversation where the reviewer was trying to work with him to provide him better solutions.

There is no "rule" being applied to him or anybody else. His plugin was not even rejected, it's still "pending" while he works with the reviewer to fix the various issues in it.

You're working from a faulty set of assumptions here. The review process involves working with the reviewer to fix the issues they find in your plugin. It's not a rubber stamp process. You're trading emails with a real live person. You can ask them questions. They will answer them.

→ More replies (0)

1

u/Odysseyan Dec 14 '21

let users paste in GA

Yep but most let the user only paste the ID of Google Analytics, not the whole <script> tag itself

2

u/[deleted] Dec 14 '21 edited Dec 14 '21

Dedicated GA plugins, sure. But think about all the platforms that do integration via a JS snippet. There are thousands of them. They're all going to be forced to create plugins that essentially just inject a JS snippet.

1

u/Odysseyan Dec 14 '21

Or you could just put that code into the themes functions.php.

Of if going with a page builder, use the HTML block.

Or if theme or HTML block are no option, just take an empty plugin template and put your code there. There are a lot of ways to include it already.

And if one doesn't know how to put custom code inside a theme/plugin, maybe they shouldn't add it in the first place.

1

u/StrategicPlugins Dec 14 '21

Yeah, it could be, although I think the risk of allowing an admin to embed a script to their site is minimal assuming the plugin properly checks permissions to ensure only authorized users can embed scripts.

2

u/OliverJonesNBPT Jan 01 '22

Uh-oh. I use the Snippets plugin to get WooCommerce tweaked out and doing what I want. Almost all my snippets put a php function behind a hook. They do stuff like "don't show products in the 'out-of-print' category to visitors."

What's the recommended alternative? "Edit functions.php" is a non-starter for well-known reasons.

I suppose I could create a custom one-off non-repo plugin for each site I tweak.

1

u/StrategicPlugins Jan 01 '22

It's my understanding that existing plugins are ok for now, they just won't allow new plugins to be added to the official Wordpress repo that let users run arbitrary PHP code.

I did get the impression from the communications I had with the Wordpress plugin reviewer though that eventually even existing plugins that allow running arbitrary PHP / JS / CSS will have to be modified / phased out, however I am not sure of Wordpress' plans if that will actually come to fruition or what sort of timeline there may be on this.

Your safest bet would likely be a private plugin, as that would mitigate any long term changes Wordpress may make to the rules of what is allowed in their directory.

3

u/OliverJonesNBPT Jan 02 '22

There's a nice little opportunity for somebody to create a plugin-generator package, "Hello Snippy" maybe. :-)

0

u/[deleted] Dec 14 '21

[deleted]

10

u/StrategicPlugins Dec 14 '21

Source is the email I received from [email protected] when I went to submit my plugin for review. They said they are no longer allowing new plugins that let users add their own custom Javascript or PHP. They recommend that if you are letting a user add something like a tracking script, rather than pasting the tracking script directly, the user should paste their tracking id and then the plugin embeds the hard coded script with the ID replaced.

Re-reading the email they sent me, looks like they also will not allow any plugins that let users insert custom CSS, as the Wordpress customizer can already handle this. It seems if stock Wordpress can handle it, they're not letting it in anymore with a plugin.

It looks like this only affects new submissions and not items already approved in their directory.

15

u/Odysseyan Dec 14 '21

It is probably for security reasons. Allowing to execute javascript or php could lead to malicious attacks.

In the end though, when someone needs to execute javascript or php and knows what they are doing, the correct way is to add them to a custom plugin(not the WP plugin repo) or just include the code into the theme itself.

So it doesn't really restrict developers but it helps non tech-savy users to not fuck up their site by executing random code. It's like granting someone who never worked with Wordpress access to the server terminal itself.

8

u/Lana-Lana-LANAAAAA Developer Dec 14 '21

100% agreed on this. I had a less-than-savvy client install a "write your own PHP" type plugin a while back...

They then proceeded to literally cut n' paste something from a question on Stack Overflow (not the answer, the question) and promptly brick their site. Then were upset when I had the nerve to charge to restore it (spoiler alert, missing semi-colon).

Good call, as long as it's not applied retrospectively to existing plugins (which it likely won't be).

0

u/[deleted] Dec 14 '21

[deleted]

2

u/dirtyoldbastard77 Dec 14 '21

If its just for adding a little bit of css it really does work fine. Anything more should be added to a css file anyways

0

u/[deleted] Dec 14 '21

[deleted]

1

u/dirtyoldbastard77 Dec 15 '21

Are you saying you use a plugin to add css and such? 😳

Btw - I am pretty sure you can see the effect of the changes in the "extra css" field live as you add them. I dont use it that much (usually just move anything from there to style.css), so cant say for sure, but I think it was like that the last time I used it