GET FREE VERSION GET THE PRO VERSION

Hooks Reference

Overview of available plugin hooks.

HookTypeDescription
sti_buttons_arrayfilterFilter sharing buttons that must be displayed
sti_exclude_current_pagefilterExclude or not current page from sharing
sti_js_custom_datafilterCustom data to use inside js
sti_js_plugin_datafilterFilter plugin settings for JS
sti_shortcode_outputfilterFilter output of the image shortcode
sti_buttons_shortcode_paramsfilterFilter sharing data for buttons shortcode
sti_buttons_shortcode_outputfilterFilter html output of buttons shortcode
sti_svg_iconsfilterFilter svg icons
sti_all_optionsfilterFilter plugin options for the settings page

 

sti_buttons_array

apply_filters( 'sti_buttons_array', (array) $buttons );

Filter sharing buttons that must be displayed for each image on the page.

Changelog

  • Added in version 1.38

Parameters

  • $buttons (array) Array of sharing button for desktop and mobile

Example

Let's show different sharing buttons for the Shop page.

add_filter( 'sti_buttons_array', 'my_sti_buttons_array' );
function my_sti_buttons_array( $buttons ) {
    if ( is_shop() ) {
        $buttons['desktop'] = array( "facebook", "twitter", "linkedin" );
        $buttons['mobile'] = array( "telegram", "facebook", "twitter" );
    }
    return $buttons;
}

 

sti_exclude_current_page

apply_filters( 'sti_exclude_current_page', (bool) $exclude );

Choose to exclude or not current page from the sharing.

Changelog

  • Added in version 1.48

Parameters

  • $exclude (bool) Exclude or not current page

Example

Exclude from sharing all images on page with ID 7901

add_filter( 'sti_exclude_current_page', 'my_sti_exclude_current_page' );
function my_sti_exclude_current_page( $exclude ) {
    if ( get_queried_object_id() === 7901 ) {
        return true;
    }
    return $exclude;
}

 

sti_js_custom_data

apply_filters( 'sti_js_custom_data', (array) $custom_data );

Custom data to use inside js. For example, can be used to change social buttons icons or customize shared content.

Changelog

  • Added in version 1.46

Parameters

  • $custom_data (array) Array of custom data

Example

Change default icon for Facebook sharing with the custom one.

add_filter( 'sti_js_custom_data', 'my_sti_js_custom_data' );
function my_sti_js_custom_data( $custom_data ) {
    $custom_data['buttons']['facebook'] = array(
        'icon' => '<svg aria-hidden="true" focusable="false" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"&gt;&lt;path fill="currentColor" d="M275.9 330.7H171.3V480H17V32h109.5v104.5l305.1 85.6V480H275.9z"&gt;&lt;/path&gt;&lt;/svg>;',
    );
    return $custom_data;
}

 

sti_js_plugin_data

apply_filters( 'sti_js_plugin_data', (array) $sti_vars );

Filter plugin settings for JS. Can be used to change the settings that are specified from the plugin settings page.

Changelog

  • Added in version 1.50

Parameters

  • $sti_vars (array) Array of plugin settings for JS scripts

Example

Let's change buttons default position for mobile devices.

add_filter( 'sti_js_plugin_data', 'my_sti_js_plugin_data' );
function my_sti_js_plugin_data( $sti_vars ) {
    if ( wp_is_mobile() ) {
        $sti_vars['mobile_icon'] = false;
        $sti_vars['position'] = 'after';
    }
    return $sti_vars;
}

 

sti_shortcode_output

apply_filters( 'sti_shortcode_output', (string) $output, (array) $atts );

Filter output of the sti_image shortcode.

Changelog

  • Added in version 1.50

Parameters

  • $output (string) HTML output
  • $atts (array) Shortcode parameters

Example

Wrap output with .wrapper div block.

add_filter( 'sti_shortcode_output', 'my_sti_shortcode_output', 10, 2 );
function my_sti_shortcode_output( $output, $atts ) {
    $output = '<div class="wrapper">' . $output . '</div>';
    return $output;
}

 

sti_buttons_shortcode_params

apply_filters( 'sti_buttons_shortcode_params', (array) $params, (array) $atts );

Filter sharing data for sti_buttons shortcode.

Changelog

  • Added in version 1.52

Parameters

  • $params (array) Array of sharing data. Contains image, title, description and url that will be shared.
  • $atts (array) Shortcode parameters

Example

For specific image my_image.png set sharing title to My custom title

add_filter( 'sti_buttons_shortcode_params', 'my_sti_buttons_shortcode_params', 10, 2 );
function my_sti_buttons_shortcode_params( $params, $atts ) {
    if ( $atts['image'] === 'my_image.png' ) {
        $params['data-title'] = 'My custom title';
    }
    return $params;
}

 

sti_buttons_shortcode_output

apply_filters( 'sti_buttons_shortcode_output', (string) $output, (array) $atts );

Filter output of the sti_buttons shortcode.

Changelog

  • Added in version 1.52

Parameters

  • $output (string) HTML output
  • $atts (array) Shortcode parameters

Example

Wrap output with .wrapper div block.

add_filter( 'sti_buttons_shortcode_output', 'my_sti_buttons_shortcode_output', 10, 2 );
function my_sti_buttons_shortcode_output( $output, $atts ) {
    $output = '<div class="wrapper">' . $output . '</div>';
    return $output;
}

 

sti_svg_icons

apply_filters( 'sti_svg_icons', (array) $icons );

Filter svg icons that are used inside the admin settings page.

Changelog

  • Added in version 1.46

Parameters

  • $icons (array) SVG icons array

Example

Change default icon for Facebook sharing with the custom one.

add_filter( 'sti_svg_icons', 'my_sti_svg_icons' );
function my_sti_svg_icons( $icons ) {
    $icons['facebook'] = '<svg aria-hidden="true" focusable="false" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"&gt;&lt;path fill="currentColor" d="M275.9 330.7H171.3V480H17V32h109.5v104.5l305.1 85.6V480H275.9z"&gt;&lt;/path&gt;&lt;/svg>;';
    return $icons;
}

 

sti_all_options

apply_filters( 'sti_all_options', (array) $options );

Filter plugin options that are used for the settings page. Options array is divided by settings tabs ( general, content, ... ).

Changelog

  • Added in version 1.46

Parameters

  • $options (array) Options array

Example

Add Instagram button and Instagram account options for the plugin settings page.

add_filter( 'sti_all_options', 'my_sti_all_options' );
function my_sti_all_options( $options ) {

    foreach ( $options as $tab_name => $tab_options ) {
        if ( 'general' === $tab_name ) {
            foreach( $tab_options as $tab_option_key => $tab_option ) {
                if ( isset( $tab_option['id'] ) && $tab_option['id'] === 'buttons' ) {
                    $options[$tab_name][$tab_option_key]['choices']['instagram'] = array(
                        'name'    => __( "Instagram", "share-this-image" ),
                        'desktop' => 'true',
                        'mobile'  => 'true'
                    );
                }
            }
        }
    }

    $options['general'][] =  array(
        "name"  => __( "Instagram account", "share-this-image" ),
        "desc"  => __( "Set instagram account name.", "share-this-image" ),
        "id"    => "instagram_account",
        "value" => '',
        "type"  => "text"
    );

    return $options;

}