filters – Stop Gutenberg editor from automatically converting HTML entities

I’ve got a problem in my WordPress blog. The modsecurity on my server is turned on, and one of the things it catches is potential PHP code leakages. My blog talks about coding, so it’s unavoidable that we will write some PHP code on there from time to time.

Right now, modsecurity is catching fopen on one of my <pre> snippets in my blog. My workaround is to express fopen as #107;open. The problem is that Gutenberg automatically converts my HTML code to the character right after I deselect the editable textarea! Is there a filter that I can use to disable this functionality?

magento2 – Magento 2.4 | Filters are no longer seen with Elasticsuite

I have updated Magento to version 2.4.2 and have also activated Elasticsuite as the default search engine.

Elasticsuite installation went smoothly and the module is correctly installed. The search bar works fine but in the category page you can no longer see the Magento default filters, namely Color and Size. The price filter, on the other hand, is there but does not show prices correctly.

Before I installed Elasticsuite:

enter image description here

After installing Elasticsuite:

enter image description here

I have already run all the commands to reindex and update Magento but the problem persists.

How can I do?

images – How to create ‘Local’ filters for WordPress srcset sizes in template parts?

I’ve read a bunch of tutorials on how to create filters for srcsets and srcset sizes, but they all appear to be applied globally, with a fixed width or set of widths for sizes.

The trouble is, I pull in content from posts and pages in template parts throughout my sites, and these typically display the featured image in a much smaller context.

So although it’s properly using WordPress’s responsive images, the width by default is set to 100vw, so even if it’s never displayed at larger than 1/3rd of the screen width, it’ll still be loading a srcset intended for full-width screens.

How can I create individual filters (or any other appropriate method), for each template part so I can control more precisely the sizes in my srcsets?

plugins – Using FacetWP without combining the filters

I’m using the plugin FacetWP for filtering trough WordPress posts. For a custom post type I have 3 different filter options (Search, Dropdown, Alphabetic).

The general process is: If I for example search for a specific value, the select box shows me only the options who matches for the search value. All others disappears and cannot be selected anymore.

My needed process is the following: If the user use the filters, I don’t want a combined process. Each filter should reset all others. FacetWP should always show all possible filter possibility without combining each with another.

Do you know a good way to handle this? I’ve checked the Javascript events combined with the FWP.reset() function, but I cannot achieve what I need.

Thanks in advance for your answers 🙂

usability – Step shaped visual layout of cascading filters

I find this layout of cascading filters:

enter image description here

much more intuitive and much more “welcoming” to use, over the traditional, horizontal axis layout:

enter image description here


I am trying to explain to myself why this is so. I would presume that the step-shaped layout:

  • is easier on the eyes to get what is on the screen, given that the eyes move in specific patterns and linear layouts are not the most ergonomic for those natural eye movements (Types of Eye Movements and Their Functions)

  • the step-shaped pattern emphasizes mental association with hierarchy, making it even easier to get around what should be clicked first and what next.


What do you think? How would you explain the the difference in the perception of how easy it is to go through the filters by science?


Related questions:
Ellipse-shape arrangement of menu items

Are UV filters required for shooting film?

The light sensitive goodies in photographic film are naturally only sensitive to ultraviolet, violet, and blue light. These blue only sensitive films yield images that sometimes appear strange. Red objects like lipstick lips and rouged cheeks reproduce dark gray, maybe even black. Photo scientist learned to add dye to the film emulsion. These change the color of silver salts forcing them to absorb green and red light. First came orthochromatic (blue & green sensitive) followed by panchromatic (red – green – blue sensitive. Such treated films never lose their sensitivity to the blue regions of the spectrum.

Under ordinary conditions, the fact that films are highly sensitive to UV, are of no consequence. This is because most camera lenses are made of glass. Glass blocks a high percentage of the UV energy. There are situations when a UV filter can be quite helpful. We are talking about the specialty of imaging objects that exhibit fluorescence when illuminated with UV light. Additionally, mounting a UV filter when doing high-altitude aerial photography. This is because, at high- altitude, the air that normally absorbs UV is scant.

In everyday photography, mounting a UV filter works to cut the distant haze present in mountain vistas. Let me add, the UV filter is not effective for distances under several miles.

In recent times the UV filter has been pushed as insurance against accidental scratching and other perils. This concept gives piece of mind however it mainly serves to line the pockets of suppliers of camera paraphernalia.
Modern digital cameras are less susceptible to the effects of UV energy. These too use glass lenses plus the protective cover glass that overlays the image sensor blocks UV and IR radiation.

Let me add, good filters must be optically flat. From a technical viewpoint, making an optical flat is quite difficult. In other words, we mount filters only when the benefit outweighs the bad.

search – Automatically applying filters

I’m looking for some guidance regarding automatically applying filters on behalf of the user. The project I’m working on is a simple graduate job search website. The search results page is very simple, which allows a user to enter a keyword and a location. Currently, there are only 3 filters (Full-time, Part-time, Flexi).

Behaviour 1) If a user enters a keyword, such as Part-time Accountant, and runs a search, the Part-time filter is not automatically enabled.

Behaviour 2) If a user runs a search for Developer, then actively applies the Part-time filter, this filter will remain selected for every subsquent search. So, if the user changes the keyword from Developer to Chef, the Part-time filter will remain checked.

I want to test automatically setting the Part-time filer if a user enters a keyword such as Part-time Accountant, but I’m not sure what should happen to that filter if the user then changes their keyword.

Example:

  1. User runs a search for Part-time cleaner: The system automatically enables the Part-time filter.
  2. User then changes their keyword to Cleaner

In this case, should the system automatically uncheck the filter, as it was the system that checked the filter, not the user? However, doing this would break the exisiting behaviour outlined above (Behaviour 2). My concern is that if the system automatically checks that filter, the user might not realise, so on subsequent searches that filter would always be applied, which could lead the system to serve irrelevant results to the user.

filters – wp_calculate_image_sizes() not updating sizes on website

I’m trying to get a better understanding of WordPress’ responsive image functionality, but can’t get the correct images to show on mobile screen sizes (using Chrome inspect).

I think my main problem is that the $sizes is not updating after adding the appropriate code in my functions.php file.

Example, before I started, my tag looked like this:

<img width="640" height="320" src="https://wppi/wp-content/uploads/image-640x320.jpg" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="Image" loading="lazy" srcset="http://wppi/wp-content/uploads/image-640x320.jpg 640w, http://wppi/wp-content/uploads/image-300x150.jpg 300w, http://wppi/wp-content/uploads/image-768x384.jpg 768w, http://wppi/wp-content/uploads/nutritional-support-for-leopard-geckos-1024x512.jpg 1024w, http://wppi/wp-content/uploads/image-360x180.jpg 360w, http://wppi/wp-content/uploads/image-480x240.jpg 480w, http://wppi/wp-content/uploads/image-1200x600.jpg 1200w, http://wppi/wp-content/uploads/image.jpg 1536w" sizes="(max-width: 640px) 100vw, 640px">

my functions.php file looks as follows:

if ( ! isset( $content_width ) ) {
    $content_width = 640;
}

function lg_add_image_size() {
  add_image_size( 'featured-quarter', 360, 180, true );
  add_image_size( 'featured-quarter2', 480, 240, true );
  add_image_size( 'featured-half', 640, 160, true );
  add_image_size( 'featured-ideal', 1200, 628, true );
  add_image_size( 'featured-ideal-4by3', 1200, 900, true );
  add_image_size( 'featured-ideal-2by1', 1200, 600, true );
  add_image_size( 'featured-ideal-16by9', 1200, 675, true );
  add_image_size( 'featured-ideal-4by1', 900, 225, true );
}
add_action( 'after_setup_theme', 'lg_add_image_size' );

// Add image sizes to Media sections dropdown menu.
function lg_custom_image_sizes( $sizes ) {
    return array_merge( $sizes, array(
        'medium_large' => __('768px wide'),  
    )
  );
}
add_filter( 'image_size_names_choose', 'lg_custom_image_sizes' );

// Remove built-in image sizes.
function lg_remove_image_size() {
  remove_image_size( '1536x1536' );
  remove_image_size( '2048x2048' );
}
add_action( 'after_setup_theme', 'lg_remove_image_size' );

function lg_adjust_image_sizes_attr( $sizes, $size ) {
  $width = $size(0);
  if ( $width < 480 ) {
      return '(max-width: 360px) 360px, (max-width: 481px) 480px, 640px';
  } else {
      return $sizes;
  }
}
add_filter( 'wp_calculate_image_sizes', 'lg_adjust_image_sizes_attr', 10 , 2 );

I’m expecting the sizes attribute to be updated from:

sizes="(max-width: 640px) 100vw, 640px"

to

sizes="(max-width: 360px) 360px, (max-width: 481px) 480px, 640px"

The problem is that this code does not update the sizes attribute in the tag. It remains the same as the initial tag.

I’ve tried changing the priority of the wp_calculate_image_sizes filter without success.

Is there something wrong with my code or reasoning?
Is something overwriting the filter?
Am I not overwriting the initial code?

filters – Gutenberg – Add align controls to a custom block

I want to add align controls to a custom block.

I wrote this code thad adds the code that adds the default block alignment toolbar to the block, but I select and change the align, I get an the following error:

react-dom.min.js?ver=16.13.1:32 Uncaught TypeError: n is not a function
    at Object.controls.l.map.w.onClick (block-editor.min.js?ver=ee2642fa39827fa8f0de00446089caf1:12)
    at onClick (components.min.js?ver=acda7ed704a5cd88b3f144fad5e2edec:7)
    at Object.ki (react-dom.min.js?ver=16.13.1:176)
    at ji (react-dom.min.js?ver=16.13.1:13)
    at mi (react-dom.min.js?ver=16.13.1:13)
    at lf (react-dom.min.js?ver=16.13.1:13)
    at wi (react-dom.min.js?ver=16.13.1:187)
    at Kd (react-dom.min.js?ver=16.13.1:32)
    at pc (react-dom.min.js?ver=16.13.1:32)
    at Wf (react-dom.min.js?ver=16.13.1:34)
Object.controls.l.map.w.onClick @ block-editor.min.js?ver=ee2642fa39827fa8f0de00446089caf1:12
onClick @ components.min.js?ver=acda7ed704a5cd88b3f144fad5e2edec:7
ki @ react-dom.min.js?ver=16.13.1:176
ji @ react-dom.min.js?ver=16.13.1:13
mi @ react-dom.min.js?ver=16.13.1:13
lf @ react-dom.min.js?ver=16.13.1:13
wi @ react-dom.min.js?ver=16.13.1:187
Kd @ react-dom.min.js?ver=16.13.1:32
pc @ react-dom.min.js?ver=16.13.1:32
Wf @ react-dom.min.js?ver=16.13.1:34
(anonymous) @ react-dom.min.js?ver=16.13.1:236
uf @ react-dom.min.js?ver=16.13.1:15
Qd @ react-dom.min.js?ver=16.13.1:42
sc @ react-dom.min.js?ver=16.13.1:41
unstable_runWithPriority @ react.min.js?ver=16.13.1:25
Da @ react-dom.min.js?ver=16.13.1:60
mk.Events.current @ react-dom.min.js?ver=16.13.1:236
Ei @ react-dom.min.js?ver=16.13.1:41

My code:

const CustomButtonsToolbar = () => {
    const currentBlock = useSelect(
        select => select('core/editor').getSelectedBlock()
    );
    if(!currentBlock){
        return <BlockControls/>
    }

    const currentBlockIsSmallCta = currentBlock.name ==='create-block/my-custom-button'
    if(currentBlockIsSmallCta){
        return (
            <BlockControls>
                <ToolbarGroup>
                    <BlockAlignmentToolbar/>
                </ToolbarGroup>
            </BlockControls>
        );
    } else {
        return <BlockControls/>
    }

}

registerPlugin(
    'custom-buttons-toolbar-mods',
    {
        render: CustomButtonsToolbar
    }
);

I want to save the alignment as an attribute “block_alignment”

What is the correct way to add align toolbar to a custom block?

real time – Do 1:1 mobile video call face filters belong on Client or Server?

I am drafting architecture for 1:1 video calling mobile app with face filters (face recognition).

I could use p2p e.g. WebRTC because more savings less complexity. However, continuous face rec during a video call on cheap phones becomes more expensive for the device.

Is this cost increase generally significant enough to warrant routing the traffic through a server?