| 1 |
<?php |
| 2 |
|
| 3 |
// Hook the post rendering to the block |
| 4 |
if ( function_exists( 'register_block_type' ) ) : |
| 5 |
register_block_type( |
| 6 |
'ew-block/ew-author', |
| 7 |
array( |
| 8 |
'attributes' => array( |
| 9 |
'title' => array( |
| 10 |
'type' => 'string', |
| 11 |
'default' => esc_html__( 'Authors', 'essential-widgets' ), |
| 12 |
), |
| 13 |
'order' => array( |
| 14 |
'type' => 'string', |
| 15 |
'default' => 'ASC', |
| 16 |
), |
| 17 |
'orderby' => array( |
| 18 |
'type' => 'string', |
| 19 |
'default' => 'display_name', |
| 20 |
), |
| 21 |
'number' => array( |
| 22 |
'type' => 'number', |
| 23 |
'default' => 5, |
| 24 |
), |
| 25 |
'include' => array( |
| 26 |
'type' => 'string', |
| 27 |
'default' => '', |
| 28 |
), |
| 29 |
'exclude' => array( |
| 30 |
'type' => 'string', |
| 31 |
'default' => '', |
| 32 |
), |
| 33 |
'optioncount' => array( |
| 34 |
'type' => 'boolean', |
| 35 |
'default' => false, |
| 36 |
), |
| 37 |
'exclude_admin' => array( |
| 38 |
'type' => 'boolean', |
| 39 |
'default' => false, |
| 40 |
), |
| 41 |
'show_fullname' => array( |
| 42 |
'type' => 'boolean', |
| 43 |
'default' => false, |
| 44 |
), |
| 45 |
'hide_empty' => array( |
| 46 |
'type' => 'boolean', |
| 47 |
'default' => true, |
| 48 |
), |
| 49 |
'style' => array( |
| 50 |
'type' => 'string', |
| 51 |
'default' => 'list', |
| 52 |
), |
| 53 |
'html' => array( |
| 54 |
'type' => 'boolean', |
| 55 |
'default' => true, |
| 56 |
), |
| 57 |
'feed' => array( |
| 58 |
'type' => 'string', |
| 59 |
'default' => '', |
| 60 |
), |
| 61 |
'feed_type' => array( |
| 62 |
'type' => 'string', |
| 63 |
'default' => '', |
| 64 |
), |
| 65 |
'feed_image' => array( |
| 66 |
'type' => 'string', |
| 67 |
'default' => '', |
| 68 |
), |
| 69 |
'is_block' => array( |
| 70 |
'type' => 'boolean', |
| 71 |
'default' => true, |
| 72 |
), |
| 73 |
), |
| 74 |
'render_callback' => 'ew_author_render_shortcode', |
| 75 |
) |
| 76 |
); |
| 77 |
endif; |
| 78 |
|
| 79 |
if ( ! function_exists( 'ew_author_render_shortcode' ) ) : |
| 80 |
add_shortcode( 'ew-author', 'ew_author_render_shortcode' ); |
| 81 |
function ew_author_render_shortcode( $atts ) { |
| 82 |
$instance['title'] = $atts['title']; |
| 83 |
$instance['order'] = $atts['order']; |
| 84 |
$instance['orderby'] = $atts['orderby']; |
| 85 |
$instance['number'] = $atts['number']; |
| 86 |
$instance['include'] = $atts['include']; |
| 87 |
$instance['exclude'] = $atts['exclude']; |
| 88 |
$instance['optioncount'] = $atts['optioncount']; |
| 89 |
$instance['exclude_admin'] = $atts['exclude_admin']; |
| 90 |
$instance['show_fullname'] = $atts['show_fullname']; |
| 91 |
$instance['hide_empty'] = $atts['hide_empty']; |
| 92 |
$instance['style'] = $atts['style']; |
| 93 |
$instance['html'] = $atts['html']; |
| 94 |
$instance['feed'] = $atts['feed']; |
| 95 |
$instance['feed_type'] = $atts['feed_type']; |
| 96 |
$instance['feed_image'] = $atts['feed_image']; |
| 97 |
$instance['is_block'] = $atts['is_block']; |
| 98 |
|
| 99 |
$ew_author = new EW_Authors(); |
| 100 |
|
| 101 |
return $ew_author->shortcode( $instance ); |
| 102 |
} |
| 103 |
endif; |
| 104 |
|