Black Friday sale! Get 25% off WPSP Pro! Discount automatically applied at checkout.

[Support request] Cornerstone from Themeco

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support Cornerstone from Themeco

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #2476
    Ira
    Participant

    I am using the XTheme with the Cornerstone page builder. Because the blogs are created using Cornerstone they have lots of extra tags enclosed with square brackets. The content of one of my blogs looks like this.

    [cs_content][cs_section parallax="false" separator_top_type="none" separator_top_height="50px" separator_top_angle_point="50" separator_bottom_type="none" separator_bottom_height="50px" separator_bottom_angle_point="50" style="margin: 0px;padding: 45px 0px;"][cs_row inner_container="true" marginless_columns="false" style="margin: 0px auto;padding: 0px;"][cs_column fade="false" fade_animation="in" fade_animation_offset="45px" fade_duration="750" type="2/3" class="cs-ta-left" style="padding: 0px;"][cs_text]In the near future, I will be featuring answers to common questions people have about how to deal with a police encounter and the criminal justice system. In the meantime, please don't hesitate to contact my offices with any questions you may have about your particular case.[/cs_text][/cs_column][cs_column fade="false" fade_animation="in" fade_animation_offset="45px" fade_duration="750" type="1/3" class="right-column" style="padding: 0px;"][x_widget_area sidebar="ups-sidebar-ezralevy1" ][/cs_column][/cs_row][/cs_section][/cs_content]

    In /wp-content/plugins/wp-show-posts/inc/functions.php around line 10 is a function wpsp_excerpt( $excerpt_length ). This creates the excerpt and shortens it to the proper length.

    Here is the code:

    
    function wpsp_excerpt( $excerpt_length )
    {
    	global $post;
    	
    	// Run our content through wp_trim_words()
    	$content = wp_trim_words( get_the_content(), $excerpt_length, apply_filters( 'wpsp_ellipses', '...' ) );
    	
    	// Strip shortcodes from our content
    	$content = strip_shortcodes( $content );
    	
    	// Strip URLs from our excerpt (oembeds etc..)
    	$content = preg_replace( '~http(s)?://[^\s]*~i', '', $content );
    	
    	// If we have a manual excerpt, use it instead
    	if ( '' !== $post->post_excerpt ) {
    		$content = $post->post_excerpt;
    	}
    	
    	// Return our content
    	echo $content;
    }
    

    I have 2 issues.

    1) function wp_trim_words should be called at the end after we strip out the URLS and Shortcodes from the content. Otherwise if you have URLS or Shortcodes at the beginning of the content, the content gets shortened and then stripped of the URLS and Shortcodes.

    2) The Shortcodes of Cornerstone are not being stripped out.

    I created a new wpsp_excerpt:

    
    function wpsp_excerpt( $excerpt_length )
    {
    	global $post;
    	
    	$content = get_the_content();
    
    	//Strip Cornerstone 
    	$content = preg_replace('/\[([^\[\]]++|(?R))*+\]/', '', $content);
    	
    	// Strip shortcodes from our content
    	$content = strip_shortcodes( $content );
    	
    	// Strip URLs from our excerpt (oembeds etc..)
    	$content = preg_replace( '~http(s)?://[^\s]*~i', '', $content );
    
    	// Run our content through wp_trim_words()
    	$content = wp_trim_words( $content, $excerpt_length, apply_filters( 'wpsp_ellipses', '...' ) );
    	
    	// If we have a manual excerpt, use it instead
    	if ( '' !== $post->post_excerpt ) {
    		$content = $post->post_excerpt;
    	}
    	
    	// Return our content
    	echo $content;
    }
    

    I put this is a custom plugin in my mu-plugins directory so I don’t have to change the code of your plugin. Please consider adding this functionality to your plugin.

    • This topic was modified 3 years, 3 months ago by Ira.
    • This topic was modified 3 years, 3 months ago by Ira.
    • This topic was modified 3 years, 3 months ago by Ira.
    • This topic was modified 3 years, 3 months ago by Ira.
    #2535
    Ira
    Participant

    Someone please respond pleasse

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.