For more information about action and filter see the WordPress Plugin API in the codex.

Here there is a usefull plugin to see all hooks in your WordPress installation (also in the ItalyStrap framework), use it in your development enviroment, not in production site.

Most important about namespace:

The ItalyStrap framework uses php namespaces and in the example below you can see how to add/remove action/filter but first read the php documentation please.

Add action example:

With namespace:

<?php namespace ItalyStrap\Core;
/**
 * In this case the namespace is ItalyStrap\Core
 */
function display_breadcrumbs() {

    if ( ! function_exists( 'ItalyStrap\Core\breadcrumbs' ) ) {
        return;
    }

    $args = array(
        'home'    => '<span class="glyphicon glyphicon-home" aria-hidden="true"></span>',
    );

    breadcrumbs( $args );
}
/**
 * If you are in the same namespace
 */
add_action( 'italystrap_before_loop', __NAMESPACE__ . '\display_breadcrumbs' );
// or if you are in other namespace
add_action( 'italystrap_before_loop', 'ItalyStrap\Core\display_breadcrumbs' );

Without namespace:

<?php
/**
 * In this case there's no namespace
 */
function display_breadcrumbs( $args = array() ) {

    if ( ! function_exists( 'ItalyStrap\Core\breadcrumbs' ) ) {
        return;
    }

    $args = array(
        'home'    => '<span class="glyphicon glyphicon-home" aria-hidden="true"></span>',
    );

    breadcrumbs( $args );
}
add_action( 'italystrap_before_loop', 'display_breadcrumbs' );

Remove action example:

With namespace:

<?php
// If you are in the same namespace
remove_action( 'italystrap_before_loop', __NAMESPACE__ . '\display_breadcrumbs' );

// If you are not in the same namespace
remove_action( 'italystrap_before_loop', 'ItalyStrap\Core\display_breadcrumbs' );

Without namespace:

<?php
remove_action( 'italystrap_before_loop', 'display_breadcrumbs' );

Add filter example:

With namespace:

<?php
function add_class_btn( $attr ) {

    $attr['class'] = $attr['class'] . ' btn btn-default btn-block';

    return $attr;

}
// If you are in the same namespace
add_filter( 'italystrap_widget_post_read_more_attr', __NAMESPACE__ . '\add_class_btn' );
// If you are not in the same namespace
add_filter( 'italystrap_widget_post_read_more_attr', 'ItalyStrap\Core\add_class_btn' );

Without namespace:

<?php
function add_class_btn( $attr ) {

    $attr['class'] = $attr['class'] . ' btn btn-default btn-block';

    return $attr;

}
add_filter( 'italystrap_widget_post_read_more_attr', 'add_class_btn' );

Remove filter example:

With namespace:

// If you are in the same namespace
remove_filter( 'italystrap_widget_post_read_more_attr', __NAMESPACE__ . '\add_class_btn' );
// If you are not in the same namespace
remove_filter( 'italystrap_widget_post_read_more_attr', 'ItalyStrap\Core\add_class_btn' );

Without namespace:

remove_filter( 'italystrap_widget_post_read_more_attr', 'add_class_btn' );

Last edit:

There are no comments yet, why not be the first

Leave a Reply

Your email address will not be published. Required fields are marked *