Skip to content

Commit

Permalink
Issue #36 - output Select a Display type when shortcode not chosen. I…
Browse files Browse the repository at this point in the history
…ssue #34 - improve advanced parameter override capability - for bw_pages
  • Loading branch information
bobbingwide committed Jun 26, 2020
1 parent e64989b commit 0ae2de0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Empty file added blocks/oik-content/formats.js
Empty file.
18 changes: 14 additions & 4 deletions shortcodes/oik-content.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ function oik_content_block( $attributes ) {


switch ( $shortcode ) {

case 'bw_attachments':
case 'bw_attachments':
case 'bw_images':
case 'bw_pdf':
if ( $attributes['post_parent'] === '.' ) {
Expand All @@ -47,10 +46,19 @@ function oik_content_block( $attributes ) {

}

/**
* Apply advanced parameters to the set of attributes passed
* allowing them to override the selected values
* This enables the block to be used like the shortcode.
* adding such things as posts_per_page=
* Note: This appears to override numberposts=
*/

$parameters = trim( $parameters );
if ( $parameters ) {
$extra_atts=shortcode_parse_atts( $parameters );
$attributes+=$extra_atts;
//$attributes+=$extra_atts;
$attributes = array_merge( $attributes, $extra_atts );
}
bw_trace2( $attributes, "atts", false );

Expand All @@ -61,8 +69,10 @@ function oik_content_block( $attributes ) {
do_action( "oik_add_shortcodes" );

$result=bw_shortcode_event( $attributes, $content, $shortcode );
if ( null === $result ) {
bw_trace2( $result, 'result', true );
if ( '<span>&#91;</span>]' === $result ) {
$result="<!-- No result for shortcode $shortcode -->";
$result.= '<p>Select a Display type</p>';
}

return $result;
Expand Down

0 comments on commit 0ae2de0

Please sign in to comment.