České služby pro WordPress Shortcode

Below, you’ll find a detailed guide on how to add the České služby pro WordPress Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the České služby pro WordPress Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the České služby pro WordPress Plugin and the shortcodes it provides:

Plugin Icon
České služby pro WordPress

"České služby pro WordPress is a versatile plugin designed to optimize your WordPress site for the Czech market. It offers customization options and locale-specific features."

★★★★★ (19) Active Installs: 2000+ Tested with: 4.6.27 PHP Version: false
Included Shortcodes:
  • [heureka-recenze-obchodu]

České služby pro WordPress [heureka-recenze-obchodu] Shortcode

The Ceske Sluzby shortcode is designed to display customer reviews from Heureka. It retrieves reviews using an API key and displays them on your website. It supports a ‘limit’ attribute to control the number of reviews shown. If no reviews are available, it displays a default message.

Shortcode: [heureka-recenze-obchodu]

Examples and Usage

Basic example – The shortcode is used to display Heureka customer reviews. It retrieves reviews using an API key and displays them on the website.

[heureka-recenze-obchodu /]

Advanced examples

Using the shortcode to display a limited number of Heureka customer reviews. By setting the ‘limit’ parameter, you can control the number of reviews displayed on the website. In this example, only the first three reviews will be shown.

[heureka-recenze-obchodu limit=3 /]

Using the shortcode without an API key. In this case, the shortcode will display a message to the user, instructing them to enter the API key for Heureka customer reviews.

[heureka-recenze-obchodu /]

PHP Function Code

In case you have difficulties debugging what causing issues with [heureka-recenze-obchodu] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'heureka-recenze-obchodu', 'ceske_sluzby_heureka_recenze_obchodu' );

Shortcode PHP function:

function ceske_sluzby_heureka_recenze_obchodu( $atts ) {
  $output = '<p>Pro zobrazení recenzí musíte ještě zadat API klíč pro Ověřeno zákazníky.</p>';
  $api = get_option( 'wc_ceske_sluzby_heureka_overeno-api' );
  if ( ! empty( $api ) ) {
    if ( false === ( $source_xml = get_transient( 'ceske_sluzby_heureka_recenze_zakazniku' ) ) ) {
      $url = "http://www." . HEUREKA_URL . "/direct/dotaznik/export-review.php?key=" . $api;
      $source_xml = wp_remote_retrieve_body( wp_remote_get( $url ) );
      set_transient( 'ceske_sluzby_heureka_recenze_zakazniku', $source_xml, 24 * HOUR_IN_SECONDS );
    }

    $recenze_xml = simplexml_load_string( $source_xml, 'SimpleXMLElement', LIBXML_NOCDATA );
    $atributy = shortcode_atts( array( 'limit' => null ), $atts );
    $limit = $atributy['limit'];
    $i = 0;

    $output = '<div class="recenze-zakazniku">';
    if ( ! empty( $recenze_xml ) && ! is_scalar( $recenze_xml ) ) {
      foreach( $recenze_xml as $recenze ) {
        if ( ( ! empty ( $limit ) && $i < $limit ) || empty ( $limit ) ) {
          if ( ! empty ( $recenze->summary ) ) {
            $i = $i + 1;
            $output .= '<ul>';
            $output .= '<li>';
            $output .= '<strong>' . $recenze->summary . '</strong><br />';
            if ( ! empty ( $recenze->total_rating ) ) {
              $output .= 'Hodnocení: ' . $recenze->total_rating . '/5 | ';
            }
            $output .= 'Datum: před ' . human_time_diff( $recenze->unix_timestamp );
            if ( ! empty ( $recenze->name ) ) {
              $output .= ' | Autor: ' . $recenze->name;
            } 
            $output .= '</li>';
            $output .= '</ul>';
          }
        }
        else {
          break;
        }
      }
    }
    else {
      $output .= 'Zatím žádné hodnocení.';
    }
    $output .= '</div>';
  }
	return $output;
}

Code file location:

ceske-sluzby/ceske-sluzby/ceske-sluzby.php

Conclusion

Now that you’ve learned how to embed the České služby pro WordPress Plugin shortcode, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

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