Хуки

В плагине ABC Pagination добавлены фильтры (filter). С их помощью Вы можете изменять вывод или даже убирать какие-то блоки. Ниже идет описание фильтров и примеры их использования.

Лучше всего для этого использовать плагин ProFunctions, установите и добавьте в него нужный код.

abc_pagination/get_posts/args

A filter that allows you to modify the arguments for the called get_posts() function.

Фильтр, позволяющий модифицировать аргументы для вызываемой функции get_posts().

/**
 * Increase posts count
 */
add_filter('abc_pagination/get_posts/args', function ( $args ) {
    $args['numberposts'] = 2000;

    return $args;
} );

abc_pagination/locate_template/located

Filter that allows you to replace the template used by the plugin.

Фильтр, позволяющий заменить шаблон, используемый плагином.

/**
 * Add standard cards from Reboot
 */
add_filter( 'abc_pagination/locate_template/located', function ( $located, $template_name ) {
    if ( $template_name == 'post/card-default.php' ) {
        $located = TEMPLATEPATH . '/template-parts/post-card/standard.php';
    }

    return $located;
}, 10, 2 );

abc_pagination/meta_boxes/post_types

Filter that adds support for custom post types.

Фильтр, добавляющий поддержку кастомных типов постов.

/**
 * Extend supported post types
 */
add_filter( 'abc_pagination/meta_boxes/post_types', function ( $types ) {
    $types[] = 'product';

    return $types;
} );

abc_pagination/context/is_home

Filter to replace the function used to define the home page. Default used is_front_page().

Фильтр для замены функции, используемой для определения домашней страницы. По умолчанию используется is_front_page().

/**
 * Replacing the homepage detection logic
 */
add_filter( 'abc_pagination/context/is_home', 'is_home' );

abc_pagination/context/conditions

A filter that allows you to add additional checks to the context object.

Фильтр, позволяющий добавить в объект контекста дополнительные проверки.

/**
 * Add check if is product category page
 */
add_filter( 'abc_pagination/context/conditions', function ( $conditions ) {
    $conditions['is_product_category'] = is_product_category();

    return $conditions;
} );

A filter that allows you to replace the link generation logic for a letter.

Фильтр, позволяющий заменить логику формирования ссылки для буквы.

/**
 * Add letter to query params
 */
add_filter( 'abc_pagination/letters/letter_link', function ( $link ) {
    return add_query_arg( 'q', $link );
} );

abc_pagination/glossary/post_type

A filter that allows you to change glossary post type.

Фильтр, позволяющий поменять тип записи глоссария

add_filter( 'abc_pagination/glossary/post_type', function ( $link ) {
    return 'custom-glossary';
} );

abc_pagination/glossary/register_post_type_args

A filter that allows you to change arguments for register_post_type().

Фильтр, позволяющий поменять аргументы для register_post_type().

add_filter( 'abc_pagination/glossary/register_post_type_args', function ( $args ) {
    $args['supports'] = [ 'title', 'editor', 'author' ];

    return $args;
} );

abc_pagination/glossary/post_type_public

A filter that allows you to set public glossary post type.

Фильтр, позволяющий установить тип записи глоссарий публичным.

add_filter( 'abc_pagination/glossary/post_type_public', '__return_true' );

abc_pagination/virtual_tax/enabled

Filter to enable replacement of category content with an alphabetical index

Фильтр, позволяющий включить замену контента категории на алфавитный указатель

add_filter( 'abc_pagination/virtual_tax/enabled', function ( $result ) {
    $excluded_cats = [ 123 ];
    if ( is_category() && in_array( get_queried_object_id(), $excluded_cats ) ) {
        return false;
    }

    return $result;
} );

abc_pagination/functions/sort_title

Filter that modifies title used for sort, like "Auto BMW"

Фильтр, изменяющий заголовок, используемы для сортировки, на подобии "Auto BMW"

add_filter( 'abc_pagination/functions/sort_title', $fn = function ( $title ) {
    return trim( str_replace( 'Auto', '', $title ) );
} );

abc_pagination/functions/combine_letter_e

Filter that specifies to treat the letters "е" and "ё" as the same

Фильтр, который указывает считать буквы "е" и "ё" одинаковыми

add_filter( 'abc_pagination/functions/combine_letter_e', '__return_false' );

abc_pagination/functions/strict_match_alphabet

If an alphabet attribute is specified in the shortcode, only the characters specified in the attribute will be output. To output all others, pass false.

Если в шорткоде указан атрибут alphabet, то будут выводиться только символы, которые указаны в атрибуте. Чтобы вывести все остальные, передайте false.

/**
 * Output all characters that are not specified in the alphabet attribute
 * Выводим все символы, которые не указаны в атрибуте alphabet 
 */
add_filter( 'abc_pagination/functions/strict_match_alphabet', '__return_false' );

abc_pagination/functions/wrong_chars (since 1.2.0)

Filter that specifies a list of characters to be removed when sorting and outputting letters.

Фильтр, задающий список символов, которые нужно удалить при сортировке и выводе букв.

/**
 * Remove wrong charts from post titles 
 */
add_filter( 'abc_pagination/functions/wrong_chars', function ( $result ) {
    return $result . '?&*';
} );

abc_pagination/post-card/thumbnail_size (since 1.2.0)

Filter to set the image size for post cards.

Фильтр, позволяющий задать размер изображение для карточек постов.

/**
 * Add image size for custom post cards 
 */
add_image_size( 'custom_img_size', 100, 100, true );
add_filter( 'abc_pagination/post-card/thumbnail_size', function () {
    return 'custom_img_size';
} ); 

abc_pagination/post-list/show_search (since 1.2.0)

A filter that allows you to disable the search.

Фильтр, позволяющий отключить поиск.

/**
 * Disable search on turbo feed 
 */
add_filter( 'abc_pagination/post-list/show_search', function ( $result ) {
    if ( is_feed( 'turbo' ) ) {
        return false;
    }
    return $result;
} );

abc_pagination/shortcode/do_output

A filter that allows you to disable the output of the shortcode.

Фильтр, позволяющий отключать вывод шорктода.

/**
 * Disable abc-pagination on search page 
 */
add_filter( 'abc_pagination/shortcode/do_output', function ( $result, $atts, $context ) {
    /** @var $context \Wpshop\AbcPagination\Context */
    if ( $context->is_search ) {
        return false;
    }
    return $result;
}, 10, 3 ); 

abc_pagination/shortcode/atts (since 1.2.0)

A filter that allows you to change the attributes of a shortcode.

Фильтр, позволяющий менять атрибуты шорткода.

/**
 * Limit show posts on home page 
 */
add_filter( 'abc_pagination/shortcode/atts', function ( $atts ) {
    /** @var $context \Wpshop\AbcPagination\Context */
    if ( $context->is_home ) {
        $atts['show_posts_limit'] = 10;
    }
    return $atts;
}, 10, 2 ); 

abc_pagination/shortcode/do_output_ajax (since 1.2.0)

Filter that allows you to disable ajax loading, despite the shortcode parameter.

Фильтр, позволяющий отключить аяксовую подгрузку, несмотря на параметр шорткода.

/**
 * Disable ajax load on turbo pages 
 */
add_filter( 'abc_pagination/shortcode/do_output_ajax', function ( $result ) {
    if ( is_feed( 'turbo' ) ) {
        return false;
    }
    return $result;
} ); 

abc_pagination/post_list/show_more_text (since 1.2.0)

A filter that allows you to change the text of the "show more" link.

Фильтр, позволяющий поменять текст ссылки "показать еще".

/**
 * Change show more text
 */
add_filter( 'abc_pagination/post_list/show_more_text', function () {
    return 'more...';
} );