• Hi
    i’m trying to add a new parameter to the ‘post-content-shortcodes-title’ filter.

    At the end of the function function post_content( $atts=array()), i had the PHP code :

    /* MODIF MANU */
    
    $icon_class = get_post_meta($id,'icon_class'); //My new parameter
    if ( $show_title )
    $content = apply_filters( 'post-content-shortcodes-title', '<h2>' . $p->post_title . '</h2>', $p->post_title, $icon_class ) . $content;
    
    /* FIN MODIF MANU */

    Then i can with a custom filter in my functions.php

    add_filter( 'post-content-shortcodes-title', 'alter_pcs_title', 10, 3 );
    function alter_pcs_title( $html, $title, $icon_class_array) {
    $icon_class = $icon_class_array[0];
    return '<h2 class="widget-title"><span></span><span data-icon="'.$icon_class.'"></span>' . $title . '</h2>';
    }

    But it’s not a good solution for upgrade, and i prefer to override this method.

    Thanks in advance

    https://wordpress.org/plugins/post-content-shortcodes/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Curtiss Grymala

    (@cgrymala)

    I’ll be releasing a new version of the plugin today. While it doesn’t apply things exactly the way you’ve done, it should satisfy your request.

    Instead of getting the post meta information within my plugin, the post-content-shortcodes-title filter will now send the post object (and the shortcode attributes) as additional parameters when applying the filters.

    Therefore, in order to accomplish what you’re trying to do, you’ll use the following code in your functions.php file:

    add_filter( 'post-content-shortcodes-title', 'alter_pcs_title', 10, 3 );
    function alter_pcs_title( $html, $title, $post=null ) {
        $icon_class = get_post_meta( $post->ID, 'icon_class' );
        if ( is_array( $icon_class ) ) {
            $icon_class = array_shift( $icon_class );
        }
        return '<h2 class="widget-title"><span></span><span data-icon="' . $icon_class . '"></span>' . $itlte . '</h2>';
    }

    Hope that helps. Thanks for the feedback.

    Thread Starter manuonet

    (@manuonet)

    Excellent, all it’s ok now !!
    Thanks a lot to have added my request and modified your plugin.
    have a nice day

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Post Content Shortcode Class Override’ is closed to new replies.