restriction home page excerpts
authorAnthony Talarico <talarico@gaslightmedia.com>
Thu, 28 Jan 2016 21:04:14 +0000 (16:04 -0500)
committerAnthony Talarico <talarico@gaslightmedia.com>
Thu, 28 Jan 2016 21:04:14 +0000 (16:04 -0500)
functions.php
js/app.js
js/custom/pageSetup.js

index 98d1924..7b48a1b 100644 (file)
@@ -167,4 +167,15 @@ function glm_has_shortcode($shortcode)
     $page = get_post( $post->ID );
     return has_shortcode( $page->post_content, $shortcode );
 }
+function ca_only_add_more_when_required( $default, $text, $options ) {                                    
+    $text = strip_tags( $text );                                    
+    if ( 'words' === $options['length_type'] ) {                                        
+        $excerpt_length = str_word_count( $text );                                    
+    } else {                                        
+        $excerpt_length = strlen( $text );                                    
+    }                                                                    
+    if ( $excerpt_length > $options['length'] ) return $default;                                                                    
+    return true;                                
+}                                
+add_filter( 'advanced_excerpt_disable_add_more', 'ca_only_add_more_when_required', 10, 3 );
 ?>
index f3bd5ed..b7df57b 100644 (file)
--- a/js/app.js
+++ b/js/app.js
@@ -110,22 +110,7 @@ $(document).ready(function () {
             $(this).parent("li").addClass("current");
         }
     });
-
-    // remove link from posts with less than 225 characters
-    for (var i = 0; i < $('div[class*="excerpt"]').length; i++){
-        var chars= $(".excerpt" + i).text();
-
-        if(chars.length < 225){
-           chars = chars.substr(0,chars.length - 2);
-            
-            // disable link if excerpt is < 225 characters
-            $(".excerpt" + i).parent().find("a").replaceWith(function(){
-               return $("<span />", {html: $(this).html()});
-            });
-            $('.excerpt' + i).text(chars);
-        }
-    }
-    $(".title-posts").find("span").addClass("excerptTitle");
+   
    
    /* get number of elements in DOM console.log($("*").length);
     var pageBytes = $('html').html().length;
index 3ce0ccb..8989f93 100644 (file)
@@ -101,22 +101,7 @@ $(document).ready(function () {
             $(this).parent("li").addClass("current");
         }
     });
-
-    // remove link from posts with less than 225 characters
-    for (var i = 0; i < $('div[class*="excerpt"]').length; i++){
-        var chars= $(".excerpt" + i).text();
-
-        if(chars.length < 225){
-           chars = chars.substr(0,chars.length - 2);
-            
-            // disable link if excerpt is < 225 characters
-            $(".excerpt" + i).parent().find("a").replaceWith(function(){
-               return $("<span />", {html: $(this).html()});
-            });
-            $('.excerpt' + i).text(chars);
-        }
-    }
-    $(".title-posts").find("span").addClass("excerptTitle");
+   
    
    /* get number of elements in DOM console.log($("*").length);
     var pageBytes = $('html').html().length;