Real3D Flipbook PDF Viewer Lite Shortcode

Below, you’ll find a detailed guide on how to add the Real3D Flipbook PDF Viewer Lite 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 Real3D Flipbook PDF Viewer Lite Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Real3D Flipbook PDF Viewer Lite Plugin and the shortcodes it provides:

Plugin Icon
Real3D Flipbook PDF Viewer Lite

"Real3D Flipbook PDF Viewer Lite is a user-friendly plugin that transforms your PDFs into interactive 3D flipbooks. Enhance your readers' experience with this visually appealing feature."

★★★★✩ (5) Active Installs: 3000+ Tested with: 6.3.2 PHP Version: false
Included Shortcodes:
  • [real3dflipbook]

Real3D Flipbook PDF Viewer Lite [real3dflipbook] Shortcode

The Real3D Flipbook Lite shortcode is responsible for rendering a 3D flipbook on your WordPress site. It accepts various parameters like ‘id’, ‘name’, ‘pdf’, ‘mode’, etc., to customize the flipbook’s appearance and functionality. The shortcode fetches the flipbook options from the database, merges them with the global options, and then outputs a div with the necessary data attributes. It also ensures the required scripts and styles are enqueued.

Shortcode: [real3dflipbook]

Parameters

Here is a list of all possible real3dflipbook shortcode parameters and attributes:

  • id – Unique identifier of the flipbook
  • name – Name of the flipbook
  • pdf – URL of the PDF file
  • mode – Sets the flipbook’s viewing mode
  • viewmode – Sets the initial view of the flipbook
  • lightboxopened – Controls if lightbox opens initially
  • lightboxfullscreen – Controls if lightbox opens in fullscreen
  • lightboxtext – Sets the lightbox button text
  • lightboxcssclass – Sets the CSS class for lightbox
  • class – Adds a custom CSS class to the flipbook
  • lightboxthumbnail – Controls if lightbox shows a thumbnail
  • lightboxthumbnailurl – URL of the lightbox thumbnail
  • hidemenu – Controls if menu is hidden initially
  • autoplayonstart – Controls if flipbook plays automatically
  • autoplayinterval – Sets interval for autoplay in seconds
  • autoplayloop – Controls if autoplay loops
  • zoom – Sets the initial zoom level
  • zoomdisabled – Controls if zoom is disabled
  • btndownloadpdfurl – URL for the “Download PDF” button
  • aspect – Sets the aspect ratio of the flipbook
  • thumb – URL of the thumbnail image
  • thumbcss – Adds custom CSS to the thumbnail
  • containercss – Adds custom CSS to the container
  • tilt – Sets the tilt value for 3D viewing
  • tiltmin – Sets the minimum tilt value
  • tiltmax – Sets the maximum tilt value
  • lights – Controls if lights are enabled in 3D view
  • shadows – Controls if shadows are enabled in 3D view
  • pageroughness – Sets the roughness of the page surface
  • pagemetalness – Sets the metalness of the page surface
  • pagehardness – Sets the hardness of the page
  • coverhardness – Sets the hardness of the cover
  • singlepage – Controls if only a single page is shown
  • startpage – Sets the page to start on
  • pagenumberoffset – Sets the offset for page numbers
  • deeplinkingprefix – Sets the prefix for deep linking
  • search – Controls if search functionality is enabled
  • loadpagesf – Sets the number of pages to load first
  • loadpagesb – Sets the number of pages to load back
  • pages – Sets the total number of pages
  • thumbs – Controls if thumbnails are enabled
  • thumbalt – Sets the alt text for the thumbnail
  • category – Sets the category for the flipbook
  • author – Sets the author of the flipbook
  • num – Sets the number of flipbooks to display
  • order – Sets the order of the flipbooks
  • orderby – Sets the parameter to order flipbooks by
  • pagerangestart – Sets the starting page of the range
  • pagerangeend – Sets the ending page of the range

Examples and Usage

Basic example – Display a specific flipbook using its ID.

[real3dflipbook id=1 /]

Advanced examples

Display a flipbook and specify the mode of display, whether it’s lightbox, fullscreen, or compact. The example below shows a flipbook in lightbox mode.

[real3dflipbook id=1 mode="lightbox" /]

Display a flipbook and specify the initial zoom level. The example below shows a flipbook with an initial zoom level of 2.

[real3dflipbook id=1 zoom="2" /]

Display a flipbook and specify whether the menu should be hidden or not. The example below shows a flipbook with the menu hidden.

[real3dflipbook id=1 hidemenu="true" /]

Display a flipbook and specify whether it should autoplay on start, the autoplay interval, and whether it should loop. The example below shows a flipbook that autoplays on start, with an autoplay interval of 5 seconds, and loops.

[real3dflipbook id=1 autoplayonstart="true" autoplayinterval="5" autoplayloop="true" /]

Display a flipbook and specify the page range to be displayed. The example below shows a flipbook displaying pages 1 to 5.

[real3dflipbook id=1 pagerangestart="1" pagerangeend="5" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'real3dflipbook', array($this, 'on_shortcode') );

Shortcode PHP function:

function on_shortcode($atts, $content=null) {

		$args = shortcode_atts( 
			array(
				'id'   => '-1',
				'name' => '-1',
				'pdf' => '-1',
				'mode' => '-1',
				'viewmode' => '-1',
				'lightboxopened' => '-1',
				'lightboxfullscreen' => '-1',
				'lightboxtext' => '-1',
				'lightboxcssclass' => '-1',
				'class' => '-1',
				'lightboxthumbnail' => '-1',
				'lightboxthumbnailurl' => '-1',
				'hidemenu' => '-1',
				'autoplayonstart' => '-1',
				'autoplayinterval' => '-1',
				'autoplayloop' => '-1',
				'zoom' => '-1',
				'zoomdisabled' => '-1',
				'btndownloadpdfurl' => '-1',
				'aspect' => '-1',

				'thumb' => '-1',
				'thumbcss' => '-1',
				'containercss' => '-1',

				'tilt' => '-1',
				'tiltmin' => '-1',
				'tiltmax' => '-1',
				'lights' => '-1',
				'shadows' => '-1',
				'pageroughness' => '-1',
				'pagemetalness' => '-1',
				'pagehardness' => '-1',
				'coverhardness' => '-1',

				'singlepage' => '-1',
				'startpage' => '-1',
				'pagenumberoffset' => '-1',

				'deeplinkingprefix' => '-1',

				'search' => '-1',

				'loadpagesf' => '-1',
				'loadpagesb' => '-1',

				'pages' => '-1',
				'thumbs' => '-1',

				'thumbalt' => '-1',

				'category' => '-1',
				'author' => '-1',
				'num' => '-1',

				'order' => '-1',
				'orderby' => '-1',

				'pagerangestart' => '-1',
				'pagerangeend' => '-1',
			), 
			$atts
		);

		$id = (int) $args['id'];
		$name = $args['name'];

		$flipbook = get_option('real3dflipbook_'.$id);
			$bookId = $id .'_'.uniqid();

		foreach ($args as $key => $val) {
			if($val != -1){

				if($key == 'mode') $key = 'mode';
				$flipbook[$key] = $val;
			}
		}

		$flipbook['rootFolder'] = $this->PLUGIN_DIR_URL;
		$flipbook['version'] = $this->PLUGIN_VERSION;
		$flipbook['uniqueId'] = $bookId;

		if(!isset($flipbook['date']) && isset($flipbook['post_id']))
			$flipbook['date'] = get_the_date( 'Y-m-d', get_post($flipbook['post_id']));

		$defaults = r3dfb_getDefaults();

		$flipbook_global_options = get_option("real3dflipbook_global", array());

		$flipbook_global_options = r3d_array_merge_deep($defaults, $flipbook_global_options);

		$flipbook = r3d_array_merge_deep($flipbook_global_options, $flipbook);

		$output = '<div class="real3dflipbook" id="'.$bookId.'" style="position:absolute;" data-flipbook-options="'.htmlspecialchars(json_encode($flipbook)).'"></div>';

		if (!wp_script_is( 'real3d-flipbook', 'enqueued' )) {
	     	wp_enqueue_script("real3d-flipbook");
	     }

	     if (!wp_script_is( 'real3d-flipbook-embed', 'enqueued' )) {
	     	wp_enqueue_script("real3d-flipbook-embed");

			 wp_localize_script( 'real3d-flipbook-embed', 'r3d',
			 array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
	     }

	     // wp_localize_script('real3d-flipbook-embed', 'real3dflipbook_'.$bookId, array(htmlspecialchars(json_encode($flipbook))));

	     if (!wp_style_is( 'real3d-flipbook-style', 'enqueued' )) {
	     	wp_enqueue_style("real3d-flipbook-style");
	     }

		return $output;
	}

Code file location:

real3d-flipbook-lite/real3d-flipbook-lite/includes/Real3DFlipbook.php

Conclusion

Now that you’ve learned how to embed the Real3D Flipbook PDF Viewer Lite 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 *