christravelblog on "[Plugin: Custom Post Widget] Add support for spans"

ساخت وبلاگ

While it's possible to get content blocks to appear inline by adding a p tag with a style where display is set to inline, there's another, easier way.

Here's a modification we made to the plugin. Hopefully you can include it in future releases.

In post-widget.php, change this:

extract( shortcode_atts( array( 'id' => '', 'slug' => '', 'class' => 'content_block', 'suppress_content_filters' => 'no', 'title' => 'no', 'title_tag' => 'h3' ), $atts ) );

To this:

extract( shortcode_atts( array( 'id' => '', 'slug' => '', 'class' => 'content_block', 'suppress_content_filters' => 'no', 'title' => 'no', 'title_tag' => 'h3', 'markup' => 'div', ), $atts ) );

That just adds a new parameter of markup, which defaults to your default of div so as not to change existing behavior.

Just below that, add a bit of error checking (entirely new):

if (! in_array( $markup, array( 'div', 'span' ))) { $markup = 'div';
}

A little further down, change this:

$content .= '<div class="'. esc_attr($class) .'" id="custom_post_widget-' . $id . '">';

To this:

$content .= '<' . esc_attr( $markup ) . ' class="'. esc_attr( $class ) .'" id="custom_post_widget-' . $id . '">';

And this:

$content .= '</div>';

To this:

$content .= '</' . esc_attr( $markup ) . '>';

That allows adding a parameter such as markup=span to the shortcode, which will allow content blocks to be used inline.

Hope that helps.

https://wordpress.org/plugins/custom-post-widget/

WordPress ...
ما را در سایت WordPress دنبال می کنید

برچسب : نویسنده : استخدام کار wpss بازدید : 255 تاريخ : يکشنبه 30 خرداد 1395 ساعت: 22:32