• Resolved giulianoromano

    (@giulianoromano)


    Hi, thanks for Your great plugin! I use it on my projects ??

    A little request: it is possible insert custom excerpt on single page insert?

    Eg: [insert page=’my-page-post’ display=’custom.php’ custom_except=”My custom excerpt different customized by page contest etc ect…”]

    It will be awesome ??

    MANY MANY THANKS!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter giulianoromano

    (@giulianoromano)

    Ok, i’m solved!

    https://www.portalituristici.it/costiera-amalfitana-offerte-coupon/

    But, i modified ../plugin/insert-pages/insert-pages.php file.

    How can i prevent overwriting this file with future updates???

    CODE Explanation:

    on line 321 (add customexcerpt shortcode)

    // Shortcode attributes.
    $attributes = shortcode_atts(
    array(
    'page' => '0',
    'display' => 'all',
    'class' => '',
    'id' => '',
    'querystring' => '',
    'size' => '',
    'inline' => false,
    'public' => false,

    CHANGED with

    // Shortcode attributes.
    $attributes = shortcode_atts(
    array(
    'page' => '0',
    'display' => 'all',
    'class' => '',
    'id' => '',
    'querystring' => '',
    'size' => '',
    'customexcerpt' => '',
    'inline' => false,
    'public' => false,

    on line 1109

    public function insert_pages_wrap_content( $content, $posts, $attributes ) {
    return sprintf(
    '<%1$s data-post-id="%2$s" class="insert-page insert-page-%2$s %3$s"%4$s>%5$s',
    esc_attr( $attributes['wrapper_tag'] ),
    esc_attr( $attributes['page'] ),
    esc_attr( $attributes['class'] ),
    empty( $attributes['id'] ) ? '' : ' id="' . esc_attr( $attributes['id'] ) . '"',
    $content
    );
    }

    changed with following code (add customexcerpt in esc_attr and a div to syling outpout)

    public function insert_pages_wrap_content( $content, $posts, $attributes ) {
    return sprintf(
    '<%1$s data-post-id="%2$s" class="insert-page insert-page-%2$s %3$s"%4$s><div class="customexcerpt">%5$s</div>%6$s</%1$s>',
    esc_attr( $attributes['wrapper_tag'] ),
    esc_attr( $attributes['page'] ),
    esc_attr( $attributes['class'] ),
    empty( $attributes['id'] ) ? '' : ' id="' . esc_attr( $attributes['id'] ) . '"',
    esc_attr( $attributes['customexcerpt'] ),
    $content);
    }

    Plugin Author Paul Ryan

    (@figureone)

    I would just hook into insert_pages_wrap_content and output your custom excerpt if it exists. To do this without adding another shortcode attribute, you can re-use the existing querystring attribute and add your custom_excerpt=Your excerpt text content in there; it will populate the $_REQUEST['custom_excerpt'] PHP global with your content that you can then use.

    For example for this shortcode:

    [insert page='123' display='custom.php' querystring='custom_excerpt=Your excerpt text']

    You can use this hook to do the same thing:

    add_filter( 'insert_pages_wrap_content', function ( $content, $inserted_page, $attributes ) {
    	if ( ! empty( $_REQUEST['custom_excerpt'] ) ) {
    		$content = sprintf(
    			'<%1$s data-post-id="%2$s" class="insert-page insert-page-%2$s %3$s"%4$s><div class="customexcerpt">%5$s</div>%6$s</%1$s>',
    			esc_attr( $attributes['wrapper_tag'] ),
    			esc_attr( $attributes['page'] ),
    			esc_attr( $attributes['class'] ),
    			empty( $attributes['id'] ) ? '' : ' id="' . esc_attr( $attributes['id'] ) . '"',
    			wp_kses_post( $_REQUEST['custom_excerpt'] ),
    			$content
    		);
    	}
    
    	return $content;
    }, PHP_INT_MAX, 3 );
    Thread Starter giulianoromano

    (@giulianoromano)

    Paul,

    many many thanks!!!

    I restored plugin files and use Your suggestion!

    GRAZIE ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom excerpt’ is closed to new replies.