Comments for WordPress Developer Resources | Developer.WordPress.org https://developer.wordpress.org Official WordPress Developer Resources Thu, 13 Mar 2025 06:02:15 +0000 hourly 1 https://wordpress.org/?v=6.8-alpha-59827 Comment on esc_html_e() by Mehraz Morshed https://developer.wordpress.org/reference/functions/esc_html_e/#comment-7289 Thu, 13 Mar 2025 06:02:15 +0000 http://developer.wordpress.org/reference/functions/esc_html_e/#comment-7289 esc_html() is for escaping.
esc_html__() is for translating and escaping.
esc_html_e() is for translating, escaping and directly echoing

]]>
Comment on esc_html() by Mehraz Morshed https://developer.wordpress.org/reference/functions/esc_html/#comment-7288 Thu, 13 Mar 2025 06:01:38 +0000 http://developer.wordpress.org/reference/functions/esc_html/#comment-7288 esc_html() is for escaping.
esc_html__() is for translating and escaping.
esc_html_e() is for translating, escaping and directly echoing

]]>
Comment on esc_html__() by Mehraz Morshed https://developer.wordpress.org/reference/functions/esc_html__/#comment-7287 Thu, 13 Mar 2025 06:00:21 +0000 http://developer.wordpress.org/reference/functions/esc_html__/#comment-7287 esc_html() is for escaping.
esc_html__() is for translating and escaping.
esc_html_e() is for translating, escaping and directly echoing.

]]>
Comment on big_image_size_threshold by cazuma https://developer.wordpress.org/reference/hooks/big_image_size_threshold/#comment-7284 Thu, 06 Mar 2025 03:22:12 +0000 https://developer.wordpress.org/reference/hooks/big_image_size_threshold/#comment-7284 // as of 2025, I had to specify lower priority for return false version to work
add_filter( 'big_image_size_threshold', '__return_false', 100, 1 );

]]>
Comment on remove_action() by geigel https://developer.wordpress.org/reference/functions/remove_action/#comment-7270 Fri, 07 Feb 2025 17:43:19 +0000 http://developer.wordpress.org/reference/functions/remove_action/#comment-7270 It seems (for the moment) like there is no easy way to specifically target an action for removal that relies on an anonymous function. A blanket removal will remove it if using the default priority, but it also wipes out other actions that have hooked into it. Additional discussion regarding some solutions people have been able to put together is found here: https://wordpress.stackexchange.com/questions/137688/remove-actions-filters-added-via-anonymous-functions

]]>
Comment on unregister_post_type() by Alen Joseph https://developer.wordpress.org/reference/functions/unregister_post_type/#comment-7269 Thu, 06 Feb 2025 10:00:51 +0000 #comment-7269 Unregister or Disable One or More Custom Post Types with Clean and Optimized Code

function disable_oraiste_custom_post_types() {
$post_types = [‘clients’, ‘portfolio’, ‘team’, ‘testimonial’];

foreach ($post_types as $post_type) {
if (post_type_exists($post_type)) {
unregister_post_type($post_type);
}
}
}
add_action(‘init’, ‘disable_oraiste_custom_post_types’, 20);

]]>
Comment on wp_get_image_editor() by Hyppolite T. https://developer.wordpress.org/reference/functions/wp_get_image_editor/#comment-7266 Fri, 31 Jan 2025 15:56:42 +0000 http://developer.wordpress.org/reference/functions/wp_get_image_editor/#comment-7266 Example: Check a broken image

$image = wp_get_image_editor( 'my_image.jpg' );
if ( is_wp_error( $image ) ) {
  //do some action, like add image path and name to an array of broken images.
}
]]>
Comment on wp_robots_no_robots() by Rolf Allard van Hagen https://developer.wordpress.org/reference/functions/wp_robots_no_robots/#comment-7265 Thu, 30 Jan 2025 23:47:56 +0000 https://developer.wordpress.org/reference/functions/wp_robots_no_robots/#comment-7265 Two examples, both adding noindex to all Post Format archives:

add_action( 
    'wp_head',
    function() {
        is_tax( 'post_format' ) && add_filter( 'wp_robots', 'wp_robots_no_robots' );
    },
    0
);

(Note: a priority of 0 otherwise the action runs too late.)

add_filter(
    'wp_robots',
    function ( array $robots ) {
        if ( is_tax( 'post_format' ) ) {
            return wp_robots_no_robots( $robots );
        }
        return $robots;
    }
);
]]>
Comment on big_image_size_threshold by brasofilo https://developer.wordpress.org/reference/hooks/big_image_size_threshold/#comment-7264 Thu, 30 Jan 2025 15:19:47 +0000 https://developer.wordpress.org/reference/hooks/big_image_size_threshold/#comment-7264 In reply to squarecandy.

PNG images are excluded from scaling after upload See ticket #48736. From the core: // Do not scale (large) PNG images. // May result in sub-sizes that have greater file size than the original. if ('image/png' !== $imagesize['mime']) { /* filter applied here */ }

]]>
Comment on wp_enqueue_style() by Jan Prazak https://developer.wordpress.org/reference/functions/wp_enqueue_style/#comment-7260 Tue, 21 Jan 2025 09:45:56 +0000 http://developer.wordpress.org/reference/functions/wp_enqueue_style/#comment-7260 In reply to Rob W.

The last parameter (false) is wrong, no boolean value accepted, it’s the “string $media” parameter, so either leave it out completely or define it properly.

]]>