Coder Social home page Coder Social logo

Comments (9)

mor10 avatar mor10 commented on May 5, 2024 2

The jetlag fog has lifted a bit and this makes sense. Unless @bamadesigner has any objections I'm recommending merge.

from wprig.

mor10 avatar mor10 commented on May 5, 2024

$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.

hellofromtonya avatar hellofromtonya commented on May 5, 2024

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:

  1. Get it to work as it's designed, meaning if it's set, use it; else, use the default.
  2. Make it like _s for commonality.
  3. 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 avatar hellofromtonya commented on May 5, 2024

@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.

bamadesigner avatar bamadesigner commented on May 5, 2024

I have it on my list to check out tomorrow. 👍🏻

from wprig.

bamadesigner avatar bamadesigner commented on May 5, 2024

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.

mor10 avatar mor10 commented on May 5, 2024

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.

hellofromtonya avatar hellofromtonya commented on May 5, 2024

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.

hellofromtonya avatar hellofromtonya commented on May 5, 2024

The only enhancement I'd offer is to type hint the incoming $dimensions parameter.

from wprig.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.