block_slug` property * * @return mixed */ protected function set_block_slug() { $this->block_slug = 'plugin-cards'; } /** * Set the attributes required on the server side. * * @return mixed */ protected function set_attributes() { $this->attributes = array( 'slug' => array( 'type' => 'string', ), 'className' => array( 'type' => 'string', ), ); } /** * Block render function for server-side. * * This method will pe passed to the render_callback parameter and it will output * the server side output of the block. * * @param array $attributes Blocks attrs. * * @return mixed|string */ protected function render( $attributes ) { if ( empty( $attributes['slug'] ) ) { return; } $results = $this->search( $attributes['slug'] ); if ( ! is_wp_error( $results['data'] ) ) { $results = $results['data']; $icon = ''; if ( isset( $results->icons['svg'] ) ) { $icon = $results->icons['svg']; } if ( isset( $results->icons['2x'] ) ) { $icon = $results->icons['2x']; } if ( isset( $results->icons['1x'] ) ) { $icon = $results->icons['1x']; } if ( isset( $results->icons['default'] ) ) { $icon = $results->icons['default']; } $class = 'wp-block-themeisle-blocks-plugin-cards'; if ( isset( $attributes['className'] ) ) { $class .= ' ' . esc_attr( $attributes['className'] ); } $markup = '