Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Custom Table Blocks #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,9 @@ function teamwpugph_scripts() {
/**
* Custom Walker Comment
*/
require get_template_directory() . '/inc/class-teamwpugph-comments.php';
require get_template_directory() . '/inc/class-teamwpugph-comments.php';

/**
* Custom Blocks
*/
require get_template_directory() . '/inc/custom-blocks.php';
26 changes: 26 additions & 0 deletions inc/custom-blocks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
/**
* Custom blocks
*
* @package TeamWPUGPHTheme
*/

/**
* Table block filter
*/
function teamwpugph_table_block_fitler( $block_content, $block ) {

if ( 'core/table' !== $block['blockName'] ) {
return $block_content;
}

$doc = new DOMDocument();
$doc->loadHTML( $block_content );
$table = $doc->getElementsByTagName( 'table' );
$table[0]->setAttribute( 'class', 'uk-table' );

$output = $doc->saveHTML();

return $output;
}
add_filter( 'render_block', 'teamwpugph_table_block_fitler', 10, 3 );