From ae4e7130ef90ea5686602ed8273c087ecb75beb0 Mon Sep 17 00:00:00 2001 From: Erwin Pagulong Date: Fri, 24 May 2019 16:26:31 +0800 Subject: [PATCH] Added Custom Quote blocks --- inc/custom-blocks.php | 56 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 inc/custom-blocks.php diff --git a/inc/custom-blocks.php b/inc/custom-blocks.php new file mode 100644 index 0000000..8ea0583 --- /dev/null +++ b/inc/custom-blocks.php @@ -0,0 +1,56 @@ +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 ); + +/** + * Quote block filter + */ +function teamwpugph_quote_block_fitler( $block_content, $block ) { + + if ( 'core/quote' !== $block['blockName'] ) { + return $block_content; + } + + $html = new DOMDocument(); + $html->loadHTML( $block_content ); + $p = $html->getElementsByTagName( 'p' ); + $cite = $html->getElementsByTagName( 'cite' ); + + $output = '
'; + $output .= '

'; + $output .= $p[0]->nodeValue; + $output .= '

'; + $output .= ''; + $output .= '
'; + + return $output; + +} +add_filter( 'render_block', 'teamwpugph_quote_block_fitler', 10, 3 );