'gutenberg-extend', 'title' => __( 'Advance Block Extend', 'advance-block-extend' ), 'icon' => 'shield', ), ) ); } public function advance_block_extend_register_block(){ $block_file = array( 'posts', 'profile', 'transform', 'heading', 'button', 'cover-image'); $wpArray = array( 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-editor', 'wp-data' ); if( is_array( $block_file ) && !empty( $block_file ) ){ foreach ($block_file as $file) { // Register Scripts wp_register_script( $file.'-block-script', GE_ROOT_BLOCK_URI . $file .'/'. $file . '.js', $wpArray , filemtime( GE_ROOT_BLOCK . $file .'/'. $file . '.js' ), true ); // Register Styles wp_register_style( $file. '-block-editor-style', GE_ROOT_BLOCK_URI . $file .'/'. $file . '-editor.css' , array( 'wp-edit-blocks' ), filemtime( GE_ROOT_BLOCK . $file .'/'. $file . '-editor.css' ) ); wp_register_style( $file. '-block-frontend-style', GE_ROOT_BLOCK_URI . $file .'/'. $file . '-style.css' , array(), filemtime( GE_ROOT_BLOCK . $file .'/'. $file . '-style.css' ) ); register_block_type( 'gutenberg-extend/'.$file.'-block', array( 'editor_script' => $file. '-block-script', 'editor_style' => $file. '-block-editor-style', 'style' => $file. '-block-frontend-style', 'render_callback' => 'advance_block_extend_'. $file.'_render_block', ) ); } } wp_register_style( 'fontawesome', GE_ROOT_URI . '/font-awesome.css' , array(), '4.7.0' ); wp_enqueue_style('fontawesome'); } } // END of Class $Advance_Block_Extend = new Advance_Block_Extend(); } // END of Class Exists if( !function_exists('advance_block_extend_posts_render_block') ){ function advance_block_extend_posts_render_block( $attributes, $content ) { $output = $title_style = $box_style = ''; $TitleColor = ( !empty($attributes['TitleColor'] ) ) ? 'color:'.$attributes['TitleColor'].';' : ''; $boxColor = ( !empty($attributes['boxColor'] ) ) ? 'background-color:'.$attributes['boxColor'].';': ''; $title_style = ($attributes ) ? ' style="'.$TitleColor.'"' : ''; $box_style = ($attributes ) ? ' style="'.$boxColor.'"' : ''; $recent_posts = wp_get_recent_posts( array( 'numberposts' => 5, 'post_status' => 'publish', ) ); if ( count( $recent_posts ) === 0 ) { return __( 'No posts', 'advance-block-extend' ); } $posts = $recent_posts; if( is_array( $posts) && !empty( $posts) ){ $output .= '
'; $output .= ""; $output .= "
"; } return $output; } }