array( $this, 'render_faq' ),
) );
register_block_type( AEOMATIC_DIR . 'blocks/faq-item', array(
'render_callback' => array( $this, 'render_faq_item' ),
) );
}
public function render_faq( array $attrs, string $content ): string {
if ( empty( $content ) ) {
return '';
}
return sprintf(
'
%s
',
$content
);
}
public function render_faq_item( array $attrs ): string {
$q = isset( $attrs['question'] ) ? wp_kses_post( $attrs['question'] ) : '';
$a = isset( $attrs['answer'] ) ? wp_kses_post( $attrs['answer'] ) : '';
if ( '' === trim( wp_strip_all_tags( $q ) ) || '' === trim( wp_strip_all_tags( $a ) ) ) {
return '';
}
return sprintf(
'' .
'%s
' .
'' .
' ',
$q,
$a
);
}
public function enqueue_editor_assets(): void {
// Audit sidebar panel.
$asset_file = AEOMATIC_DIR . 'assets/js/editor-sidebar.asset.php';
$deps = array( 'wp-plugins', 'wp-edit-post', 'wp-element', 'wp-components', 'wp-data', 'wp-i18n', 'wp-api-fetch' );
$ver = AEOMATIC_VERSION;
if ( file_exists( $asset_file ) ) {
$asset = include $asset_file;
$deps = $asset['dependencies'] ?? $deps;
$ver = $asset['version'] ?? $ver;
}
wp_enqueue_script(
'aeob-editor-sidebar',
AEOMATIC_URL . 'assets/js/editor-sidebar.js',
$deps,
$ver,
true
);
wp_set_script_translations( 'aeob-editor-sidebar', 'aeomatic' );
}
}