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:
"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."
- [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 flipbookname
– Name of the flipbookpdf
– URL of the PDF filemode
– Sets the flipbook’s viewing modeviewmode
– Sets the initial view of the flipbooklightboxopened
– Controls if lightbox opens initiallylightboxfullscreen
– Controls if lightbox opens in fullscreenlightboxtext
– Sets the lightbox button textlightboxcssclass
– Sets the CSS class for lightboxclass
– Adds a custom CSS class to the flipbooklightboxthumbnail
– Controls if lightbox shows a thumbnaillightboxthumbnailurl
– URL of the lightbox thumbnailhidemenu
– Controls if menu is hidden initiallyautoplayonstart
– Controls if flipbook plays automaticallyautoplayinterval
– Sets interval for autoplay in secondsautoplayloop
– Controls if autoplay loopszoom
– Sets the initial zoom levelzoomdisabled
– Controls if zoom is disabledbtndownloadpdfurl
– URL for the “Download PDF” buttonaspect
– Sets the aspect ratio of the flipbookthumb
– URL of the thumbnail imagethumbcss
– Adds custom CSS to the thumbnailcontainercss
– Adds custom CSS to the containertilt
– Sets the tilt value for 3D viewingtiltmin
– Sets the minimum tilt valuetiltmax
– Sets the maximum tilt valuelights
– Controls if lights are enabled in 3D viewshadows
– Controls if shadows are enabled in 3D viewpageroughness
– Sets the roughness of the page surfacepagemetalness
– Sets the metalness of the page surfacepagehardness
– Sets the hardness of the pagecoverhardness
– Sets the hardness of the coversinglepage
– Controls if only a single page is shownstartpage
– Sets the page to start onpagenumberoffset
– Sets the offset for page numbersdeeplinkingprefix
– Sets the prefix for deep linkingsearch
– Controls if search functionality is enabledloadpagesf
– Sets the number of pages to load firstloadpagesb
– Sets the number of pages to load backpages
– Sets the total number of pagesthumbs
– Controls if thumbnails are enabledthumbalt
– Sets the alt text for the thumbnailcategory
– Sets the category for the flipbookauthor
– Sets the author of the flipbooknum
– Sets the number of flipbooks to displayorder
– Sets the order of the flipbooksorderby
– Sets the parameter to order flipbooks bypagerangestart
– Sets the starting page of the rangepagerangeend
– 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.
Leave a Reply