'10', 'progressbarLayout' => 'line', 'progressbarStyle' => 'style1', 'progressbarTitle' => 'Progressbar', 'progressCircleSize' => "20", "progressColor" => "#000", "progressTextColor" => "#fff" ]; $attrs = array_merge($defaults, $block['attrs']); if( $attrs['progressbarLayout'] != 'line'){ $html = '
'; return $html; } $p->setAttribute( 'class', implode( ' ', [ ' ', ...explode( ' ', $p->getAttribute( 'class' ) ), ] ) ); $p->setAttribute( "data-value", (string) $attrs['progressValue'] ); $p->setAttribute( "data-layout", (string) $attrs['progressbarLayout'] ); $p->setAttribute( "data-style", (string) $attrs['progressbarStyle'] ); $p->setAttribute( "data-title", (string) $attrs['progressbarTitle'] ); $p->textContent = trim( $p->textContent ); $html = $dom->saveHTML(); return ""; } add_filter( 'ikreate_themes_block_inline_css', 'ikreate_themes_add_progressbar_support_css', 10, 2 ); /** * Conditionally add counter JS. * * @since 1.5.2 * * @param string $js Inline js. * @param string $html Block html content. * * @return string */ function ikreate_themes_add_progressbar_support_css( string $css, string $html ): string { /** clasic theme compatible */ if( !$html){ global $post; if( $post && $post->post_content) $html = apply_filters( 'the_content', $post->post_content ); } if ( str_contains( $html, 'is-sp-progressbar' ) ) { $dir = dirname( __DIR__, 1 ); $css .= file_get_contents( $dir . '/assets/css/progress.css' ); } return $css; } add_filter( 'ikreate_themes_block_inline_js', 'ikreate_themes_add_progressbar_support_js', 10, 2 ); function ikreate_themes_add_progressbar_support_js( string $js, string $html ): string { /** clasic theme compatible */ if( !$html){ global $post; if( $post && $post->post_content) $html = apply_filters( 'the_content', $post->post_content ); } if ( str_contains( $html, 'is-sp-progressbar' ) ) { $dir = dirname( __DIR__, 1 ); $js .= file_get_contents( $dir . '/assets/js/progressbar.js' ); } return $js; }