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 1.2k 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

      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

      With your input, this post could be even better 💗

      Register Login
      • First post
        Last post

      Suggested Topics

      • EpsilonAdminE

        [Solved] EduMall theme does not show Smart Excerpts and broken the search results page

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

        [Solved] Exclude some PDF from results when using Download Monitor

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

        [Solved] Polylang limits search by language taxonomy

        Watching Ignoring Scheduled Pinned Locked Moved Recipes and Known Solutions fix patch polylang search taxonomy
        1
        0 Votes
        1 Posts
        989 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
        1
        0 Votes
        1 Posts
        893 Views
        No one has replied
      • EpsilonAdminE

        [Solved] WP Knowledgebase publications (kbe_knowledgebase) do not show in search results

        Watching Ignoring Scheduled Pinned Locked Moved Recipes and Known Solutions knowledgebase kbe
        1
        0 Votes
        1 Posts
        881 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