Skip to content

Commit

Permalink
Issue #34 - Improve Dynamic content block for Attachments, Images and…
Browse files Browse the repository at this point in the history
… PDF
  • Loading branch information
bobbingwide committed Jun 24, 2020
1 parent 00e8f06 commit e64989b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion blocks/oik-blockinfo/blockinfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function BlockinfoStyled( blockname, showBlockTypeName, showTitle, showDescripti

return(
<div className={ props.className }>
{ blockicon } <div>{blockSupportsInserter}</div>
{ blockicon }<div>{blockSupportsInserter}</div>
{ blockTypeName }
{ blockTitle }
{ blockDescription }
Expand Down
4 changes: 4 additions & 0 deletions blocks/oik-content/editor.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.wp-core-ui .bw_attachment .attachment,
.wp-core-ui .bw_images .attachment {
float: none;
}
4 changes: 3 additions & 1 deletion blocks/oik-content/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @author Herb Miller @bobbingwide
*/
//import './style.scss';
//import './editor.scss';
import './editor.scss';

// Get just the __() localization function from wp.i18n
const { __ } = wp.i18n;
Expand Down Expand Up @@ -89,7 +89,9 @@ export default registerBlockType(
customClassName: false,
className: true,
html: false,
align: true,
alignWide: true,
alignFull: true,
},

edit,
Expand Down
15 changes: 11 additions & 4 deletions shortcodes/oik-content.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,24 @@ function oik_content_block( $attributes ) {
* We need to set defaults to the same values as in the browser.
*/
$attributes = oik_content_block_attributes( $attributes );
$attributes['post_parent'] = bw_array_get( $attributes, 'post_parent', '0');
$attributes['post_parent'] = bw_array_get( $attributes, 'post_parent', null);
$attributes['orderby'] = bw_array_get( $attributes, 'orderby', 'date');
$attributes['order'] = bw_array_get( $attributes, 'order', 'desc');


switch ( $shortcode ) {

case 'bw_attachments':
if ( $attributes['post_parent'] !== '0') {
$attributes['post_parent'] = bw_current_post_id();
}
case 'bw_images':
case 'bw_pdf':
if ( $attributes['post_parent'] === '.' ) {
$attributes['post_parent'] = bw_current_post_id();
}
//} elseif ( $attributes['post_parent'] !== '0' ) {
// $attributes['post_parent'] = bw_current_post_id();
//}
unset( $attributes['post_type']);

//unset( $attributes['post_parent']);
break;

Expand Down

0 comments on commit e64989b

Please sign in to comment.