WPFTS Pro Main Site WPFTS Community Forum
    • Recent
    • Tags
    • Popular
    • Register
    • Login
    Get WPFTS Pro today with 25% discount!

    [Solved] Search PDF by content in Real3D FlipBook Plugin

    Scheduled Pinned Locked Moved Recipes and Known Solutions
    searchpdfreal3d flipbookpdfviewer
    1 Posts 1 Posters 992 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • EpsilonAdminE Offline
      EpsilonAdmin
      last edited by

      Recently we faced a great plugin to display PDF files in a fancy way - like a paper magazine! It's the Real3D Flipbook plugin, which is awesome! However it also has the same problem - users are not possible to search PDF documents uploaded to the Real3D FlipBook by the content.

      Fortunately, it is also simple to fix with the WPFTS Pro.

      add_filter('wpfts_index_post', function($index, $p)
      {
              global $wpdb, $wpfts_core;
              
              if (in_array($p->post_type, array('post', 'page'))) {
                      global $post;
                      
                      if (preg_match_all('~\[real3dflipbook((\s+[^\]]*)|(\]))\]~sU', $p->post_content, $zz, PREG_OFFSET_CAPTURE)) {
      					// 1 is a shortcode params
      					// 0 is a whole shortcode tag
      					require_once $wpfts_core->root_dir.'/includes/wpfts_utils.class.php';
      
      					$sum = '';
      
      					foreach ($zz[1] as $k => $d) {
      					
      						if (isset($d[0])) {
      							$zz2 = array();
      							if (preg_match('~id=[\x22\x27]?(\d+)~', $d[0], $zz2)) {
      
      								$bookid = $zz2[1];
      
      								// Look for data
      								$ff = get_option('real3dflipbook_'.$bookid);
      								if ($ff && (is_array($ff))) {
      
      									if (isset($ff['pdfUrl'])) {
      
      										$url = trim($ff['pdfUrl']);
      
      										if (strlen($url) > 0) {
      											$ret = WPFTS_Utils::GetCachedFileContent_ByLocalLink($url);
      
      											$sum .= (isset($ret['post_content']) ? trim($ret['post_content']) : '').' ';	
      										}
      									}
      								}
      							}
      						}
      					
      					}
      
      					$index['real3dflipbook_content'] .= $sum;
      
      					/*
      					$content = $p->post_content;
      					// Remove the pdfviewer shortcodes
      
      					for ($ii = count($zz[0]) - 1; $ii >= 0; $ii --) {
      						$content = substr($content, 0, $zz[0][$ii][1]).substr($content, $zz[0][$ii][1] + strlen($zz[0][$ii][0]));
      					}
      
      					$index['post_content'] = $content;
      					*/
      	
      					global $shortcode_tags;
      
      					$removed_tmp = array();
      					
      					$shortcode_list = array('real3dflipbook');
      
      					foreach ($shortcode_list as $dd) {
      						if (isset($shortcode_tags[$dd])) {
      							$removed_tmp[$dd] = $shortcode_tags[$dd];	// Save shortcode function
      							unset($shortcode_tags[$dd]);
      						} else {
      							$removed_tmp[$dd] = false;
      						}
      						add_shortcode($dd, function(){ return ''; });	// Dummy function to render empty string for shortcode
      					}
      
      					$post = get_post($p->ID);
      					setup_postdata($post);
                      
      					ob_start();
      					the_content();
                      
      					$r = ob_get_clean();
      					$r = strip_tags(str_replace('<', ' <', $r));
      				
      					// Okay, we need to restore shortcodes
      					foreach ($removed_tmp as $k => $d) {
      						if ($d) {
      							$shortcode_tags[$k] = $removed_tmp[$k];
      						} else {
      							unset($shortcode_tags[$k]);
      						}
      					}
      
      					wp_reset_postdata();
                      
      					$index['post_content'] = $r;
      				}
      		}
              
              return $index;
      }, 3, 2);
      

      Well, the code is not that simple, but if you just want to have it works,
      download the ready addon!

      https://fulltextsearch.org/wpfts-addon-real3dflipbook-1.0.0.zip

      https://e-wm.org

      1 Reply Last reply Reply Quote 0
      • First post
        Last post

      Suggested Topics

      • EpsilonAdminE

        [Solved] The files excerpt is not visible in Scientia Theme

        Watching Ignoring Scheduled Pinned Locked Moved Recipes and Known Solutions
        1
        0 Votes
        1 Posts
        487 Views
        No one has replied
      • EpsilonAdminE

        How to search posts by shortcode content in Wordpress?

        Watching Ignoring Scheduled Pinned Locked Moved Recipes and Known Solutions feature indexing search shortcode
        1
        0 Votes
        1 Posts
        1k Views
        No one has replied
      • EpsilonAdminE

        [Solved] Indexing and Search files by content in BuddyDrive

        Watching Ignoring Scheduled Pinned Locked Moved Recipes and Known Solutions buddydrive file search
        1
        0 Votes
        1 Posts
        778 Views
        No one has replied
      • EpsilonAdminE

        [Solved] Files not shown in TemplateToaster theme search results

        Watching Ignoring Scheduled Pinned Locked Moved Recipes and Known Solutions templatetoaster theme search
        1
        0 Votes
        1 Posts
        708 Views
        No one has replied
      • EpsilonAdminE

        [Solved] Incompatibility with Flatbase theme

        Watching Ignoring Scheduled Pinned Locked Moved Recipes and Known Solutions flatbase excerpt theme
        1
        0 Votes
        1 Posts
        736 Views
        No one has replied

      Additional Resources

      • My Account
      • Buy WPFTS Pro
      • Community Forum
      • Affiliate Program
      • Privacy Policy
      • Terms & Conditions
      • Contact Us
      • Coupon Partner

      Be the first to read the news!

      We are always improving our products, adding new functions and fixes. Subscribe now to be the first to get the updates and stay informed about our sales! We are not spammy. Seriously.

      Join Us Now!

      We are a professional IT-team. Many of us have been working in a Web IT field for more than 10 years. Our advanced experience of software development has been employed in the creation of the WordPress FullText Search plugin. All solutions implemented into the plugin have been used for 5 or more years in over 60 different web-projects.

      We are looking forward to your comments, requests and suggestions in relation to the current plugin and future updates.

      ewm-logo-450

      The forum powered by NodeBB | Contributors