From abba0e5ebf242ab18e9ca3f8f5134beb3e6b782b Mon Sep 17 00:00:00 2001 From: JiveDig Date: Thu, 6 Jul 2023 10:20:26 -0400 Subject: [PATCH 1/6] register block with json, better handling of inline css --- ...{mai-toc.css => mai-table-of-contents.css} | 0 ....min.css => mai-table-of-contents.min.css} | 0 blocks/table-of-contents/block.json | 18 ++ blocks/table-of-contents/block.php | 123 +++++++++++++ classes/class-block.php | 165 ------------------ classes/class-table-of-contents.php | 56 +++--- mai-table-of-contents.php | 3 +- 7 files changed, 167 insertions(+), 198 deletions(-) rename assets/css/{mai-toc.css => mai-table-of-contents.css} (100%) rename assets/css/{mai-toc.min.css => mai-table-of-contents.min.css} (100%) create mode 100644 blocks/table-of-contents/block.json create mode 100644 blocks/table-of-contents/block.php delete mode 100644 classes/class-block.php diff --git a/assets/css/mai-toc.css b/assets/css/mai-table-of-contents.css similarity index 100% rename from assets/css/mai-toc.css rename to assets/css/mai-table-of-contents.css diff --git a/assets/css/mai-toc.min.css b/assets/css/mai-table-of-contents.min.css similarity index 100% rename from assets/css/mai-toc.min.css rename to assets/css/mai-table-of-contents.min.css diff --git a/blocks/table-of-contents/block.json b/blocks/table-of-contents/block.json new file mode 100644 index 0000000..2e36afd --- /dev/null +++ b/blocks/table-of-contents/block.json @@ -0,0 +1,18 @@ +{ + "name": "acf/mai-table-of-contents", + "title": "Mai Table of Contents", + "description": "A table of contents block.", + "category": "formatting", + "keywords": [ "talbe", "contents", "toc" ], + "icon": "list-view", + "textdomain": "mai-table-of-contents", + "editorStyle": "file:../../assets/css/mai-toc.min.css", + "acf": { + "mode": "preview", + "renderCallback": "mai_do_toc_block" + }, + "supports": { + "align": [ "wide" ], + "anchor": true + } +} \ No newline at end of file diff --git a/blocks/table-of-contents/block.php b/blocks/table-of-contents/block.php new file mode 100644 index 0000000..c11e116 --- /dev/null +++ b/blocks/table-of-contents/block.php @@ -0,0 +1,123 @@ + $is_preview, + 'align' => $block['align'], + 'class' => isset( $block['className'] ) && $block['className'] ? $block['className'] : '', + ]; + + if ( $custom ) { + $args['open'] = get_field( 'maitoc_open' ); + $args['headings'] = get_field( 'maitoc_headings' ); + } + + $toc = new Mai_Table_Of_Contents( $args ); + + echo $toc->get(); +} + +add_action( 'acf/init', 'mai_register_toc_field_group' ); +/** + * Registers field groups. + * + * @since 0.1.0 + * + * @return void + */ +function mai_register_toc_field_group() { + if ( ! function_exists( 'acf_add_local_field_group' ) ) { + return; + } + + acf_add_local_field_group( + [ + 'key' => 'maitoc_table_of_contents_block', + 'title' => __( 'Table of Contents', 'mai-table-of-contents' ), + 'fields' => [ + [ + 'key' => 'field_5dd59fad35b30', + 'label' => __( 'Override default settings', 'mai-table-of-contents' ), + 'name' => 'maitoc_custom', + 'type' => 'true_false', + 'message' => __( 'Use custom settings', 'mai-table-of-contents' ), + ], + [ + 'key' => 'field_5dd5a09a56ef9', + 'label' => __( 'Load Open/Closed', 'mai-table-of-contents' ), + 'name' => 'maitoc_open', + 'type' => 'true_false', + 'default_value' => 1, + 'ui' => 1, + 'ui_off_text' => __( 'Closed', 'mai-table-of-contents' ), + 'ui_on_text' => __( 'Open', 'mai-table-of-contents' ), + 'conditional_logic' => [ + [ + [ + 'field' => 'field_5dd59fad35b30', + 'operator' => '==', + 'value' => '1', + ], + ], + ], + ], + [ + 'key' => 'field_5dd5a0d956efa', + 'label' => __( 'Minimum Headings', 'mai-table-of-contents' ), + 'name' => 'maitoc_headings', + 'type' => 'number', + 'default_value' => 2, + 'step' => 1, + 'conditional_logic' => [ + [ + [ + 'field' => 'field_5dd59fad35b30', + 'operator' => '==', + 'value' => '1', + ], + ], + ], + ], + ], + 'location' => [ + [ + [ + 'param' => 'block', + 'operator' => '==', + 'value' => 'acf/mai-table-of-contents', + ], + ], + ], + ] + ); +} diff --git a/classes/class-block.php b/classes/class-block.php deleted file mode 100644 index 0a2fdf5..0000000 --- a/classes/class-block.php +++ /dev/null @@ -1,165 +0,0 @@ -hooks(); - } - - /** - * Runs hooks. - * - * @since 0.1.0 - * - * @return void - */ - function hooks() { - add_action( 'acf/init', [ $this, 'register_block' ] ); - add_action( 'acf/init', [ $this, 'register_field_group' ] ); - } - - /** - * Register block. - * - * @since 0.1.0 - * - * @return void - */ - function register_block() { - if ( ! function_exists( 'acf_register_block_type' ) ) { - return; - } - - acf_register_block_type( - [ - 'name' => 'mai-table-of-contents', - 'title' => __( 'Mai Table of Contents', 'mai-table-of-contents' ), - 'description' => __( 'A table of contents block.', 'mai-table-of-contents' ), - 'icon' => 'list-view', - 'category' => 'formatting', - 'keywords' => [ 'table', 'contents', 'toc' ], - 'mode' => 'preview', - 'multiple' => false, - 'render_callback' => [ $this, 'do_toc' ], - 'enqueue_assets' => function() { - if ( is_admin() ) { - $suffix = maitoc_get_suffix(); - wp_enqueue_style( 'mai-table-of-contents', MAI_TABLE_OF_CONTENTS_PLUGIN_URL . "assets/css/mai-toc{$suffix}.css", [], MAI_TABLE_OF_CONTENTS_VERSION ); - } - }, - 'supports' => [ - 'align' => [ 'wide' ], - 'ancher' => true, - ], - ] - ); - } - - /** - * Renders table of contents. - * - * @since 0.1.0 - * - * @return void - */ - function do_toc( $block, $content = '', $is_preview = false ) { - $custom = get_field( 'maitoc_custom' ); - $args = [ - 'preview' => $is_preview, - 'align' => $block['align'], - 'class' => isset( $block['className'] ) && $block['className'] ? $block['className'] : '', - ]; - - if ( $custom ) { - $args['open'] = get_field( 'maitoc_open' ); - $args['headings'] = get_field( 'maitoc_headings' ); - } - - $toc = new Mai_Table_Of_Contents( $args ); - - echo $toc->get(); - } - - /** - * Registers field groups. - * - * @since 0.1.0 - * - * @return void - */ - function register_field_group() { - if ( ! function_exists( 'acf_add_local_field_group' ) ) { - return; - } - - acf_add_local_field_group( - [ - 'key' => 'maitoc_table_of_contents_block', - 'title' => __( 'Table of Contents', 'mai-table-of-contents' ), - 'fields' => [ - [ - 'key' => 'field_5dd59fad35b30', - 'label' => __( 'Override default settings', 'mai-table-of-contents' ), - 'name' => 'maitoc_custom', - 'type' => 'true_false', - 'message' => __( 'Use custom settings', 'mai-table-of-contents' ), - ], - [ - 'key' => 'field_5dd5a09a56ef9', - 'label' => __( 'Load Open/Closed', 'mai-table-of-contents' ), - 'name' => 'maitoc_open', - 'type' => 'true_false', - 'default_value' => 1, - 'ui' => 1, - 'ui_off_text' => __( 'Closed', 'mai-table-of-contents' ), - 'ui_on_text' => __( 'Open', 'mai-table-of-contents' ), - 'conditional_logic' => [ - [ - [ - 'field' => 'field_5dd59fad35b30', - 'operator' => '==', - 'value' => '1', - ], - ], - ], - ], - [ - 'key' => 'field_5dd5a0d956efa', - 'label' => __( 'Minimum Headings', 'mai-table-of-contents' ), - 'name' => 'maitoc_headings', - 'type' => 'number', - 'default_value' => 2, - 'step' => 1, - 'conditional_logic' => [ - [ - [ - 'field' => 'field_5dd59fad35b30', - 'operator' => '==', - 'value' => '1', - ], - ], - ], - ], - ], - 'location' => [ - [ - [ - 'param' => 'block', - 'operator' => '==', - 'value' => 'acf/mai-table-of-contents', - ], - ], - ], - ] - ); - } -} diff --git a/classes/class-table-of-contents.php b/classes/class-table-of-contents.php index 2891c76..3796dd1 100644 --- a/classes/class-table-of-contents.php +++ b/classes/class-table-of-contents.php @@ -82,8 +82,10 @@ function get_content() { * @return string */ function get_preview() { + // Adds inline CSS. + $this->add_styles(); + $html = '
'; - $html .= $this->get_css(); $html .= sprintf( '
', $this->args['open'] ? ' open': '' ); $html .= ''; $html .= ''; @@ -130,9 +132,8 @@ function get_preview() { * @return string */ function get_toc() { - $post_id = $this->post_id; - static $cache = []; + $post_id = $this->post_id; if ( isset( $cache[ $this->post_id ] ) ) { return $cache[ $this->post_id ]; @@ -153,6 +154,9 @@ function get_toc() { return $cache[ $this->post_id ]; } + // Adds inline CSS. + $this->add_styles(); + // Get classes. $classes = 'mai-toc'; @@ -176,8 +180,7 @@ function get_toc() { } // Build HTML. - $html = sprintf( '
', trim( $classes ) ); - $html .= $this->get_css(); + $html = sprintf( '
', trim( $classes ) ); $html .= sprintf( '
', $this->args['open'] ? ' open' : '' ); $html .= ''; $html .= ''; @@ -220,6 +223,22 @@ function get_toc() { return $cache[ $this->post_id ]; } + /** + * Adds inline CSS. + * + * @since TBD + * + * @return void + */ + function add_styles() { + $suffix = maitoc_get_suffix(); + $url = MAI_TABLE_OF_CONTENTS_PLUGIN_URL . "assets/css/mai-table-of-contents{$suffix}.css"; + $path = MAI_TABLE_OF_CONTENTS_PLUGIN_DIR . "assets/css/mai-table-of-contents{$suffix}.css"; + + wp_enqueue_style( 'mai-table-of-contents', $url ); + wp_style_add_data( 'mai-table-of-contents', 'path', $path ); + } + /** * Gets content as structured data. * This can't be statically cached because a block or shortcode @@ -417,31 +436,4 @@ function get_labels() { return $labels; } - - /** - * Gets toc css link if it hasn't been loaded yet. - * - * @since 1.3.0 - * - * @return string - */ - function get_css() { - static $loaded = false; - - if ( $loaded ) { - return; - } - - $css = ''; - - // if ( ! is_admin() && did_action( 'wp_print_styles' ) ) { - if ( ! is_admin() ) { - $suffix = maitoc_get_suffix(); - $href = MAI_TABLE_OF_CONTENTS_PLUGIN_URL . "assets/css/mai-toc{$suffix}.css"; - $css = sprintf( '', $href ); - $loaded = true; - } - - return $css; - } } diff --git a/mai-table-of-contents.php b/mai-table-of-contents.php index 7d83bd6..bb7b8d0 100644 --- a/mai-table-of-contents.php +++ b/mai-table-of-contents.php @@ -140,6 +140,8 @@ private function includes() { foreach ( glob( MAI_TABLE_OF_CONTENTS_INCLUDES_DIR . '*.php' ) as $file ) { include $file; } // Classes. foreach ( glob( MAI_TABLE_OF_CONTENTS_CLASSES_DIR . '*.php' ) as $file ) { include $file; } + // Blocks. + include MAI_TABLE_OF_CONTENTS_PLUGIN_DIR . 'blocks/table-of-contents/block.php'; } /** @@ -198,7 +200,6 @@ public function run() { } new Mai_Table_Of_Contents_Settings; - new Mai_Table_Of_Contents_Block; new Mai_Table_Of_Contents_Display; } } From d1abd8115091fc7c241001b729fdc384d00eca7b Mon Sep 17 00:00:00 2001 From: JiveDig Date: Thu, 6 Jul 2023 10:23:04 -0400 Subject: [PATCH 2/6] readable exit --- classes/class-table-of-contents.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/class-table-of-contents.php b/classes/class-table-of-contents.php index 3796dd1..24b37a9 100644 --- a/classes/class-table-of-contents.php +++ b/classes/class-table-of-contents.php @@ -1,7 +1,7 @@ Date: Tue, 17 Oct 2023 11:19:23 -0400 Subject: [PATCH 3/6] Adds new filter to declare custom display mai_table_of_contents_has_custom --- classes/class-display.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/classes/class-display.php b/classes/class-display.php index 19fe964..d4199ab 100644 --- a/classes/class-display.php +++ b/classes/class-display.php @@ -5,9 +5,11 @@ class Mai_Table_Of_Contents_Display { protected $post_id; - protected $has_toc; + protected $has_default; protected $has_block; protected $has_shortcode; + protected $has_native; + protected $has_custom; /** * Gets it started. @@ -78,13 +80,17 @@ function filter_content( $content ) { return $content; } - // Check if we have a block or shortcode. - $this->has_toc = $this->has_toc(); + // Check if we have a default, block, or shortcode. + $this->has_default = $this->has_default(); $this->has_block = $this->has_block(); $this->has_shortcode = $this->has_shortcode( $content ); + $this->has_native = $this->has_default || $this->has_block || $this->has_shortcode; + $this->has_custom = apply_filters( 'mai_table_of_contents_has_custom', false, $this->post_id ); + + ray( $this->has_custom ); // Bail if no TOC. - if ( ! ( $this->has_toc || $this->has_block || $this->has_shortcode ) ) { + if ( ! ( $this->has_native || $this->has_custom ) ) { return $content; } @@ -93,7 +99,7 @@ function filter_content( $content ) { $toc = new Mai_Table_Of_Contents( [], $this->post_id, $content ); // If no block or shortcode in the content, add TOC. - if ( ! ( $this->has_block || $this->has_shortcode ) ) { + if ( ! ( $this->has_block || $this->has_shortcode || $this->has_custom ) ) { $html .= $toc->get(); } @@ -110,7 +116,7 @@ function filter_content( $content ) { * * @return bool */ - function has_toc() { + function has_default() { // Get post_types (with ACF strange key). $post_types = (array) get_option( 'options_maitoc_post_types', [] ); From 68148f8b238138fadfd701e57fe12592126e0d4c Mon Sep 17 00:00:00 2001 From: JiveDig Date: Tue, 17 Oct 2023 11:20:42 -0400 Subject: [PATCH 4/6] update the updater --- composer.lock | 14 +++++------ vendor/composer/autoload_files.php | 2 +- vendor/composer/autoload_static.php | 2 +- vendor/composer/installed.json | 16 ++++++------- vendor/composer/installed.php | 10 ++++---- .../Puc/v5/PucFactory.php | 2 +- .../Puc/{v5p1 => v5p2}/Autoloader.php | 2 +- .../Puc/{v5p1 => v5p2}/DebugBar/Extension.php | 6 ++--- .../Puc/{v5p1 => v5p2}/DebugBar/Panel.php | 4 ++-- .../DebugBar/PluginExtension.php | 4 ++-- .../{v5p1 => v5p2}/DebugBar/PluginPanel.php | 4 ++-- .../{v5p1 => v5p2}/DebugBar/ThemePanel.php | 4 ++-- .../Puc/{v5p1 => v5p2}/InstalledPackage.php | 2 +- .../Puc/{v5p1 => v5p2}/Metadata.php | 24 ++++++++++++++++++- .../Puc/{v5p1 => v5p2}/OAuthSignature.php | 2 +- .../Puc/{v5p1 => v5p2}/Plugin/Package.php | 6 ++--- .../Puc/{v5p1 => v5p2}/Plugin/PluginInfo.php | 4 ++-- .../Puc/{v5p1 => v5p2}/Plugin/Ui.php | 2 +- .../Puc/{v5p1 => v5p2}/Plugin/Update.php | 4 ++-- .../{v5p1 => v5p2}/Plugin/UpdateChecker.php | 10 ++++---- .../Puc/{v5p1 => v5p2}/PucFactory.php | 10 ++++---- .../Puc/{v5p1 => v5p2}/Scheduler.php | 2 +- .../Puc/{v5p1 => v5p2}/StateStore.php | 2 +- .../Puc/{v5p1 => v5p2}/Theme/Package.php | 4 ++-- .../Puc/{v5p1 => v5p2}/Theme/Update.php | 4 ++-- .../{v5p1 => v5p2}/Theme/UpdateChecker.php | 10 ++++---- .../Puc/{v5p1 => v5p2}/Update.php | 2 +- .../Puc/{v5p1 => v5p2}/UpdateChecker.php | 2 +- .../Puc/{v5p1 => v5p2}/UpgraderStatus.php | 2 +- .../Puc/{v5p1 => v5p2}/Utils.php | 2 +- .../Puc/{v5p1 => v5p2}/Vcs/Api.php | 2 +- .../Puc/{v5p1 => v5p2}/Vcs/BaseChecker.php | 2 +- .../Puc/{v5p1 => v5p2}/Vcs/BitBucketApi.php | 6 ++--- .../Puc/{v5p1 => v5p2}/Vcs/GitHubApi.php | 2 +- .../Puc/{v5p1 => v5p2}/Vcs/GitLabApi.php | 2 +- .../Vcs/PluginUpdateChecker.php | 4 ++-- .../Puc/{v5p1 => v5p2}/Vcs/Reference.php | 2 +- .../Vcs/ReleaseAssetSupport.php | 2 +- .../Vcs/ReleaseFilteringFeature.php | 2 +- .../{v5p1 => v5p2}/Vcs/ThemeUpdateChecker.php | 6 ++--- .../{v5p1 => v5p2}/Vcs/VcsCheckerMethods.php | 2 +- .../plugin-update-checker/README.md | 24 +++++++++---------- .../plugin-update-checker/composer.json | 2 +- .../languages/plugin-update-checker.pot | 12 +++++----- .../plugin-update-checker/license.txt | 2 +- .../{load-v5p1.php => load-v5p2.php} | 12 +++++----- .../plugin-update-checker.php | 4 ++-- 47 files changed, 137 insertions(+), 115 deletions(-) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p1 => v5p2}/Autoloader.php (98%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p1 => v5p2}/DebugBar/Extension.php (97%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p1 => v5p2}/DebugBar/Panel.php (97%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p1 => v5p2}/DebugBar/PluginExtension.php (90%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p1 => v5p2}/DebugBar/PluginPanel.php (87%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p1 => v5p2}/DebugBar/ThemePanel.php (79%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p1 => v5p2}/InstalledPackage.php (98%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p1 => v5p2}/Metadata.php (86%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p1 => v5p2}/OAuthSignature.php (98%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p1 => v5p2}/Plugin/Package.php (96%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p1 => v5p2}/Plugin/PluginInfo.php (97%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p1 => v5p2}/Plugin/Ui.php (99%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p1 => v5p2}/Plugin/Update.php (96%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p1 => v5p2}/Plugin/UpdateChecker.php (97%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p1 => v5p2}/PucFactory.php (97%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p1 => v5p2}/Scheduler.php (99%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p1 => v5p2}/StateStore.php (98%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p1 => v5p2}/Theme/Package.php (93%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p1 => v5p2}/Theme/Update.php (94%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p1 => v5p2}/Theme/UpdateChecker.php (94%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p1 => v5p2}/Update.php (93%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p1 => v5p2}/UpdateChecker.php (99%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p1 => v5p2}/UpgraderStatus.php (99%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p1 => v5p2}/Utils.php (97%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p1 => v5p2}/Vcs/Api.php (99%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p1 => v5p2}/Vcs/BaseChecker.php (90%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p1 => v5p2}/Vcs/BitBucketApi.php (97%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p1 => v5p2}/Vcs/GitHubApi.php (99%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p1 => v5p2}/Vcs/GitLabApi.php (99%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p1 => v5p2}/Vcs/PluginUpdateChecker.php (98%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p1 => v5p2}/Vcs/Reference.php (95%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p1 => v5p2}/Vcs/ReleaseAssetSupport.php (97%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p1 => v5p2}/Vcs/ReleaseFilteringFeature.php (98%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p1 => v5p2}/Vcs/ThemeUpdateChecker.php (94%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p1 => v5p2}/Vcs/VcsCheckerMethods.php (95%) rename vendor/yahnis-elsts/plugin-update-checker/{load-v5p1.php => load-v5p2.php} (80%) diff --git a/composer.lock b/composer.lock index 08d5783..74e3314 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "yahnis-elsts/plugin-update-checker", - "version": "v5.1", + "version": "v5.2", "source": { "type": "git", "url": "https://github.com/YahnisElsts/plugin-update-checker.git", - "reference": "48b03e93c9c2587f9276dce00ce2b6d94c1190d2" + "reference": "5a270988c5f76bfdfbbb42cccc7c9627f7dd64d0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/YahnisElsts/plugin-update-checker/zipball/48b03e93c9c2587f9276dce00ce2b6d94c1190d2", - "reference": "48b03e93c9c2587f9276dce00ce2b6d94c1190d2", + "url": "https://api.github.com/repos/YahnisElsts/plugin-update-checker/zipball/5a270988c5f76bfdfbbb42cccc7c9627f7dd64d0", + "reference": "5a270988c5f76bfdfbbb42cccc7c9627f7dd64d0", "shasum": "" }, "require": { @@ -27,7 +27,7 @@ "type": "library", "autoload": { "files": [ - "load-v5p1.php" + "load-v5p2.php" ] }, "notification-url": "https://packagist.org/downloads/", @@ -52,9 +52,9 @@ ], "support": { "issues": "https://github.com/YahnisElsts/plugin-update-checker/issues", - "source": "https://github.com/YahnisElsts/plugin-update-checker/tree/v5.1" + "source": "https://github.com/YahnisElsts/plugin-update-checker/tree/v5.2" }, - "time": "2023-05-20T11:55:43+00:00" + "time": "2023-08-17T12:44:32+00:00" } ], "packages-dev": [], diff --git a/vendor/composer/autoload_files.php b/vendor/composer/autoload_files.php index a9b255d..2874378 100644 --- a/vendor/composer/autoload_files.php +++ b/vendor/composer/autoload_files.php @@ -6,5 +6,5 @@ $baseDir = dirname($vendorDir); return array( - '9b77ddcfb14408a32f5aaf74e0a11694' => $vendorDir . '/yahnis-elsts/plugin-update-checker/load-v5p1.php', + 'efd9d646f43178e7ba3f07758c02ce1d' => $vendorDir . '/yahnis-elsts/plugin-update-checker/load-v5p2.php', ); diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 7e44255..54a788e 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -7,7 +7,7 @@ class ComposerStaticInit1782162e12bcf11213202aa27e2616cd { public static $files = array ( - '9b77ddcfb14408a32f5aaf74e0a11694' => __DIR__ . '/..' . '/yahnis-elsts/plugin-update-checker/load-v5p1.php', + 'efd9d646f43178e7ba3f07758c02ce1d' => __DIR__ . '/..' . '/yahnis-elsts/plugin-update-checker/load-v5p2.php', ); public static $classMap = array ( diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 48d679d..68dc7f2 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -2,29 +2,29 @@ "packages": [ { "name": "yahnis-elsts/plugin-update-checker", - "version": "v5.1", - "version_normalized": "5.1.0.0", + "version": "v5.2", + "version_normalized": "5.2.0.0", "source": { "type": "git", "url": "https://github.com/YahnisElsts/plugin-update-checker.git", - "reference": "48b03e93c9c2587f9276dce00ce2b6d94c1190d2" + "reference": "5a270988c5f76bfdfbbb42cccc7c9627f7dd64d0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/YahnisElsts/plugin-update-checker/zipball/48b03e93c9c2587f9276dce00ce2b6d94c1190d2", - "reference": "48b03e93c9c2587f9276dce00ce2b6d94c1190d2", + "url": "https://api.github.com/repos/YahnisElsts/plugin-update-checker/zipball/5a270988c5f76bfdfbbb42cccc7c9627f7dd64d0", + "reference": "5a270988c5f76bfdfbbb42cccc7c9627f7dd64d0", "shasum": "" }, "require": { "ext-json": "*", "php": ">=5.6.20" }, - "time": "2023-05-20T11:55:43+00:00", + "time": "2023-08-17T12:44:32+00:00", "type": "library", "installation-source": "dist", "autoload": { "files": [ - "load-v5p1.php" + "load-v5p2.php" ] }, "notification-url": "https://packagist.org/downloads/", @@ -49,7 +49,7 @@ ], "support": { "issues": "https://github.com/YahnisElsts/plugin-update-checker/issues", - "source": "https://github.com/YahnisElsts/plugin-update-checker/tree/v5.1" + "source": "https://github.com/YahnisElsts/plugin-update-checker/tree/v5.2" }, "install-path": "../yahnis-elsts/plugin-update-checker" } diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index d43598d..6971c33 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => '__root__', 'pretty_version' => 'dev-develop', 'version' => 'dev-develop', - 'reference' => 'd85d6f58ef5e011135e6e304f79b2527c17c2935', + 'reference' => '8630a81cb04dd13343bc8135de13c434933a6006', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -13,16 +13,16 @@ '__root__' => array( 'pretty_version' => 'dev-develop', 'version' => 'dev-develop', - 'reference' => 'd85d6f58ef5e011135e6e304f79b2527c17c2935', + 'reference' => '8630a81cb04dd13343bc8135de13c434933a6006', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev_requirement' => false, ), 'yahnis-elsts/plugin-update-checker' => array( - 'pretty_version' => 'v5.1', - 'version' => '5.1.0.0', - 'reference' => '48b03e93c9c2587f9276dce00ce2b6d94c1190d2', + 'pretty_version' => 'v5.2', + 'version' => '5.2.0.0', + 'reference' => '5a270988c5f76bfdfbbb42cccc7c9627f7dd64d0', 'type' => 'library', 'install_path' => __DIR__ . '/../yahnis-elsts/plugin-update-checker', 'aliases' => array(), diff --git a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5/PucFactory.php b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5/PucFactory.php index 3cda059..c2e1243 100644 --- a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5/PucFactory.php +++ b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5/PucFactory.php @@ -4,7 +4,7 @@ if ( !class_exists(PucFactory::class, false) ): - class PucFactory extends \YahnisElsts\PluginUpdateChecker\v5p1\PucFactory { + class PucFactory extends \YahnisElsts\PluginUpdateChecker\v5p2\PucFactory { } endif; diff --git a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/Autoloader.php b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p2/Autoloader.php similarity index 98% rename from vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/Autoloader.php rename to vendor/yahnis-elsts/plugin-update-checker/Puc/v5p2/Autoloader.php index ecdede9..87e734d 100644 --- a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/Autoloader.php +++ b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p2/Autoloader.php @@ -1,6 +1,6 @@ + */ + protected $extraProperties = array(); /** * Create an instance of this class from a JSON document. @@ -135,6 +141,22 @@ protected function getFieldNames() { protected function getPrefixedFilter($tag) { return 'puc_' . $tag; } + + public function __set($name, $value) { + $this->extraProperties[$name] = $value; + } + + public function __get($name) { + return isset($this->extraProperties[$name]) ? $this->extraProperties[$name] : null; + } + + public function __isset($name) { + return isset($this->extraProperties[$name]); + } + + public function __unset($name) { + unset($this->extraProperties[$name]); + } } endif; diff --git a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/OAuthSignature.php b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p2/OAuthSignature.php similarity index 98% rename from vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/OAuthSignature.php rename to vendor/yahnis-elsts/plugin-update-checker/Puc/v5p2/OAuthSignature.php index 578bc72..b92eb15 100644 --- a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/OAuthSignature.php +++ b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p2/OAuthSignature.php @@ -1,5 +1,5 @@ $pucVersionedClass ) { - MajorFactory::addVersion($pucGeneralClass, $pucVersionedClass, '5.1'); + MajorFactory::addVersion($pucGeneralClass, $pucVersionedClass, '5.2'); //Also add it to the minor-version factory in case the major-version factory //was already defined by another, older version of the update checker. - MinorFactory::addVersion($pucGeneralClass, $pucVersionedClass, '5.1'); + MinorFactory::addVersion($pucGeneralClass, $pucVersionedClass, '5.2'); } diff --git a/vendor/yahnis-elsts/plugin-update-checker/plugin-update-checker.php b/vendor/yahnis-elsts/plugin-update-checker/plugin-update-checker.php index ebf10bc..98f3af8 100644 --- a/vendor/yahnis-elsts/plugin-update-checker/plugin-update-checker.php +++ b/vendor/yahnis-elsts/plugin-update-checker/plugin-update-checker.php @@ -1,10 +1,10 @@ Date: Tue, 17 Oct 2023 11:21:05 -0400 Subject: [PATCH 5/6] remove debugging function --- classes/class-display.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/classes/class-display.php b/classes/class-display.php index d4199ab..29a1800 100644 --- a/classes/class-display.php +++ b/classes/class-display.php @@ -87,8 +87,6 @@ function filter_content( $content ) { $this->has_native = $this->has_default || $this->has_block || $this->has_shortcode; $this->has_custom = apply_filters( 'mai_table_of_contents_has_custom', false, $this->post_id ); - ray( $this->has_custom ); - // Bail if no TOC. if ( ! ( $this->has_native || $this->has_custom ) ) { return $content; From 8c1da3e7bbe85f3fb2f31ca041efebc1b5a2d5f3 Mon Sep 17 00:00:00 2001 From: JiveDig Date: Tue, 17 Oct 2023 11:24:45 -0400 Subject: [PATCH 6/6] since --- CHANGES.md | 5 +++++ blocks/table-of-contents/block.php | 2 -- classes/class-table-of-contents.php | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index d227a84..baaab32 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,10 @@ # Changelog +## 1.5.3 (10/17/23) +* Added: [Developers] New `mai_table_of_contents_has_custom` filter to declare when you're rendering a TOC via custom display methods. +* Changed: Register TOC block with block.json. +* Changed: Update the updater. + ## 1.5.2 (6/28/23) * Changed: Update the updater. * Fixed: TOC block and shortcode not respecting the minimum headings count. diff --git a/blocks/table-of-contents/block.php b/blocks/table-of-contents/block.php index c11e116..808dd7d 100644 --- a/blocks/table-of-contents/block.php +++ b/blocks/table-of-contents/block.php @@ -12,8 +12,6 @@ * @return void */ function mai_register_toc_block() { - // "style": [ "file:../../assets/css/mai-toc.css", "mai-table-of-contents" ], - register_block_type( __DIR__ . '/block.json' ); } diff --git a/classes/class-table-of-contents.php b/classes/class-table-of-contents.php index 24b37a9..c598108 100644 --- a/classes/class-table-of-contents.php +++ b/classes/class-table-of-contents.php @@ -226,7 +226,7 @@ function get_toc() { /** * Adds inline CSS. * - * @since TBD + * @since 1.5.3 * * @return void */