| 1 |
<?php |
| 2 |
|
| 3 |
namespace Getwid\Blocks; |
| 4 |
|
| 5 |
class TableOfContents extends AbstractBlock { |
| 6 |
|
| 7 |
public function __construct() { |
| 8 |
|
| 9 |
parent::__construct( 'getwid/table-of-contents' ); |
| 10 |
|
| 11 |
register_block_type( |
| 12 |
getwid_get_plugin_path( 'assets/blocks/table-of-contents' ), |
| 13 |
array( |
| 14 |
'render_callback' => array( $this, 'render_callback' ), |
| 15 |
) |
| 16 |
); |
| 17 |
|
| 18 |
/** |
| 19 |
* Rank Math ToC Plugins List. |
| 20 |
*/ |
| 21 |
add_filter( |
| 22 |
'rank_math/researches/toc_plugins', |
| 23 |
function ( $toc_plugins ) { |
| 24 |
$toc_plugins['getwid/getwid.php'] = 'Getwid'; |
| 25 |
|
| 26 |
return $toc_plugins; |
| 27 |
} |
| 28 |
); |
| 29 |
} |
| 30 |
|
| 31 |
public function get_label() { |
| 32 |
return __( 'Table of Contents', 'getwid' ); |
| 33 |
} |
| 34 |
|
| 35 |
public function render_callback( $attributes, $content ) { |
| 36 |
return $content; |
| 37 |
} |
| 38 |
} |
| 39 |
|
| 40 |
getwid()->blocksManager()->addBlock( |
| 41 |
new TableOfContents() |
| 42 |
); |
| 43 |
|