Make WordPress Core

Ticket #59043: 59043.2.diff

File 59043.2.diff, 1.1 KB (added by rajinsharwar, 7 months ago)

Checking for AJAX calls

  • packages/block-library/src/post-excerpt/index.php

    From 59c7e71585d7932ba784a5ca32fbfdabbf7d85eb Mon Sep 17 00:00:00 2001
    From: Rajinsharwar <rajinsharwar@gmail.com>
    Date: Fri, 11 Aug 2023 19:55:01 +0600
    Subject: [PATCH] Checking if it's an ajax call
    
    ---
     .../block-library/src/post-excerpt/index.php    | 17 +++++++++--------
     1 file changed, 9 insertions(+), 8 deletions(-)
    
    diff --git a/packages/block-library/src/post-excerpt/index.php b/packages/block-library/src/post-excerpt/index.php
    index 4ed4edab95..4f349dddd2 100644
    a b add_action( 'init', 'register_block_core_post_excerpt' ); 
    8484 * Returns 100 because 100 is the max length in the setting.
    8585 */
    8686if ( is_admin() ||
    87         defined( 'REST_REQUEST' ) && REST_REQUEST ) {
    88         add_filter(
    89                 'excerpt_length',
    90                 static function() {
    91                         return 100;
    92                 },
    93                 PHP_INT_MAX
    94         );
     87     defined( 'REST_REQUEST' ) && REST_REQUEST ||
     88     ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
     89    add_filter(
     90        'excerpt_length',
     91        static function() {
     92            return 100;
     93        },
     94        PHP_INT_MAX
     95    );
    9596}