Yasr Filters and Actions

ACTIONS

File: lib/yasr-ajax-functions.php

This is called before save the Overall Rating
do_action('yasr_action_on_overall_rating', $post_id, $rating);

This add new tabs in the Yasr Shortcode Creator
do_action( 'yasr_add_tabs_on_tinypopupform');

Add content for Yasr Shortcode Creator
do_action( 'yasr_add_content_on_tinypopupform')

Called before saving the visitor vote
do_action('yasr_action_on_visitor_vote', $post_id, $rating);

File: lib/yasr-functions.php

Run after default css are loaded
do_action( 'yasr_add_front_script_css' );

Run after yasr-front.js is loaded
do_action('yasr_add_front_script_js');

For admin side: run before yasr-admin.css is loaded
do_action('yasr_add_admin_scripts_begin');

For admin side: run after yasr-admin.css is loaded
do_action('yasr_add_admin_scripts_end' );

File: yasr-settings-functions.php

Add settings field in Aspect & Style page
do_action('yasr_style_options_add_settings_field', $style_options);

File: yasr-settings-page.php

Add new tab in the Yasr Settings
do_action( 'yasr_add_settings_tab', $active_tab )

Add content here for new page, the callback function must begin with
if ($active_tab == ‘YOURNEWPAGE’) {
do_action( 'yasr_settings_check_active_tab', $active_tab );

File: yasr-metabox-top-right.php

Add content at the bottom of the top right metabox used in the edit screen
do_action( 'yasr_add_content_bottom_topright_metabox', $post_id );

FILTERS

File: lib/yasr-functions.php

Use this filter to use your own rich snippets
$filtered_schema = apply_filters( 'yasr_filter_schema_jsonld', $review_choosen );

Filter the store ip address
yasr_filter_ip

File: yasr-settings-functions.php
Add content to the array $style_options used in the Aspect & Styles tab
apply_filters('yasr_filter_style_options', $style_options);

What do you think about this?
[Total: 43 Average: 3.9]

9 thoughts on “Yasr Filters and Actions

  • Hey Dario,

    just figured out that on the structured data part there is the author information missing if you choose recipie 🙂

    And I also got an question, when i try to add some more structured data information (like recipie categorie for example) via the filter, it always keeps replacing the information, is there any possibility (besides to change your lines of code) to add more information?

    Thnx in advance,
    Andy

    • Hi Andy,
      Yes, the recipe type will be enhanced soon

      2) Not for now, it return the new schema, replacing the default one.

      Best,
      Dario

  • Hey Dario,

    i am using remove_filter('the_content', 'yasr_auto_insert_shortcode_callback'); and remove_filter('the_content', 'yasr_add_schema'); and after changing to my richsnippet
    add_filter('the_content', 'yasr_auto_insert_shortcode_callback', 3); and add_filter('the_content', 'yasr_add_schema', 3); to filter the output.

    After the last update the scheme is shown twice on the pages;)
    https://www.all4hardware4u.de/platinenherstellung/bestueckungsdruck/

    What have i to change?

    Best regards,
    Harry

  • Could I request that you add another action in yasr-ajax-functions.php, after saving the visitor vote?

    In yasr_insert_visitor_votes_callback (), just above the die(), can you add:

    do_action(‘yasr_action_after_visitor_vote’, $post_id, $number_of_votes, $medium_rating);

    Thanks!

  • Another plugin on my site prohibits the use of shortcodes at the location where I want to show the YASR rating. Is there an action I can use to get the same result as the [yasr_overall_rating] shortcode?

    • No sorry.
      If you need to disable shortcodes just in few pages, I use this code for this website, (added in the child theme)

      add_filter('the_content', 'yasr_website_remove_shortcode');

      function yasr_website_remove_shortcode ($content) {

      $exluded_ids = array(258, 13, 25);

      $post_id = get_the_ID();

      if (in_array($post_id, $exluded_ids)) {

      remove_all_shortcodes();

      }

      return $content;

      }

Leave a Reply

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