Comments (9)
The jetlag fog has lifted a bit and this makes sense. Unless @bamadesigner has any objections I'm recommending merge.
from wprig.
$cpmtent_width is a royal pain. has been for a long time.
This is how it's currently handled at _s where they've been debating it for years:
https://github.com/Automattic/_s/blob/master/functions.php#L86-L99
On top of that comes Gutenberg which renders this feature more or less obsolete / requires it to change completely. Two relevant tickets:
WordPress/gutenberg#5650
WordPress/gutenberg#6177
I'm inclined to do nothing until Gutenberg sorts itself out because I have a feeling we might get a total rewrite of this entire feature. That said, I'm open to arguments to the contrary.
@hellofromtonya can you refactor your PR to be verbose? The ternary operator is clean, but it's also hard to understand for new/inexperienced developers. If/else statement would be better from a "what is going on here" standpoint.
from wprig.
I'm inclined to do nothing until Gutenberg sorts itself out because I have a feeling we might get a total rewrite of this entire feature.
Definitely could happen.
That said, I'm open to arguments to the contrary.
Right now, the code doesn't work as it is. Why? The global isn't being used at all. It'll just be a point of confusion for those who build off of this theme.
That means we have a few of choices:
- Get it to work as it's designed, meaning if it's set, use it; else, use the default.
- Make it like _s for commonality.
- Or get rid of the global all together.
Thinking it through, it seems to me there is a reason why for the original design, i.e. to use the global if it was set. Therefore, I'd vote:
[x] we get it working
[x] Then when Gutenberg solidifies, we can revisit if we need to change it.
@mor10 What do you think?
from wprig.
@hellofromtonya can you refactor your PR to be verbose? The ternary operator is clean, but it's also hard to understand for new/inexperienced developers. If/else statement would be better from a "what is going on here" standpoint.
@mor10 Done. You can view it here in PR #13.
from wprig.
I have it on my list to check out tomorrow. 👍🏻
from wprig.
So, in core, the only place this global is used is in setting the embed width in wp_embed_defaults()
.
So the more standard approach to solving this problem is simply to filter the 'embed_defaults' filter that's inside that function and set the width inside that filter, e.g.:
function wprig_embed_dimensions( $dimensions ) {
$dimensions['width'] = 720;
return $dimensions;
}
add_filter( 'embed_defaults', 'wprig_embed_dimensions', 10 );
Really, then we don't need the "wprig_content_width" filter because people can also use the 'embed_defaults' filter to achieve the same goal. Or we can move that filter here:
function wprig_embed_dimensions( $dimensions ) {
$dimensions['width'] = apply_filters( 'wprig_content_width', 720 );
return $dimensions;
}
add_filter( 'embed_defaults', 'wprig_embed_dimensions', 10 );
from wprig.
That makes a lot of sense @bamadesigner. It may also help us work around the inevitable Gutenberg mess which is coming down the track. What say you @hellofromtonya? Can you update your PR to do this new thing?
from wprig.
Excellent point, @bamadesigner! You are correct that we don't need a separate filter for the width and nor do we need to directly interact with the global either.
I'll update the PR.
from wprig.
The only enhancement I'd offer is to type hint the incoming $dimensions
parameter.
from wprig.
Related Issues (20)
- theme.json HOT 1
- Can't extend any core classes HOT 2
- Integrate Theme.Json into WP-Rig HOT 2
- Bug blank page editor with 5.9 .. HOT 4
- Styles task hangs and never seems to complete HOT 1
- Inline SVG undefined properties HOT 1
- Change out colors to use block theme colors HOT 4
- Mobile menu obscures content when toggled off HOT 2
- Running production version changes part of string to 'undefined' HOT 3
- Update Deprecated Node Modules HOT 5
- Help instalation HOT 25
- PHP Fatal error on fresh install (`WP_Rig\WP_Rig\JavaScript\Component`) HOT 1
- Why is it so hard (read impossible) to change the color of the mobile menu toggle? HOT 1
- Upgrade Babel and eslint
- I installed but it stays in scripts HOT 3
- watch process freezes after "Finished 'editorStyles'.... " HOT 2
- mobile menu clickable under text when hamburger menu is folded up HOT 4
- Seemingly incomplete collapsible sub menu items feature in mobile nav
- Use intersection observer to swap the submenu direction so items do not go offscreen
- Version not updating when running production bundle due to mismatch in constants.js
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wprig.