diff --git a/inc/add_plugin_link_to_adminbar.php b/inc/add_plugin_link_to_adminbar.php index 549c8cd0..06cf38aa 100644 --- a/inc/add_plugin_link_to_adminbar.php +++ b/inc/add_plugin_link_to_adminbar.php @@ -3,6 +3,10 @@ add_action( 'admin_bar_menu', 'veu_plugin_link_to_adminbar',100 ); function veu_plugin_link_to_adminbar( $wp_admin_bar ) { + if ( ! veu_is_add_plugin_link_to_adminbar( get_bloginfo( 'version' ), is_admin() ) ){ + return; + } + // 「有効化設定」は edit_theme_options 権限にはアクセスさせない if ( current_user_can( 'activate_plugins' ) ) { @@ -18,3 +22,30 @@ function veu_plugin_link_to_adminbar( $wp_admin_bar ) { } } + +/** + * プラグインページへのリンクを追加するかどうか + * Whether or not to add a link to the plugin page. + * + * これくらい veu_plugin_link_to_adminbar に書きたいところだが、PHPUnit でテストするために関数化 + * + * @param string $wp_version + * @param bool $is_admin + * + * @return bool + */ +function veu_is_add_plugin_link_to_adminbar( $wp_version, $is_admin = false ){ + + if ( $is_admin ){ + // 管理画面ではバージョンに関係なく追加 + return true; + } else { + // 公開画面 + if ( version_compare( $wp_version, '6.5', '>=' ) ) { + // WordPress 6.5 以上の場合はコアが追加してくるので何もしない + return false; + } else { + return true; + } + } +} diff --git a/readme.txt b/readme.txt index 32872eb3..b9f0cfc6 100644 --- a/readme.txt +++ b/readme.txt @@ -81,6 +81,9 @@ e.g. == Changelog == += 9.97.2 = +[ Bug fix ] In WordPress 6.5, a link to the plugin page has been added to the admin bar on the front end by default. Consequently, ExUnit has been modified to no longer add this link on the front end. + = 9.97.1 = [ Bug fix ][ Child page index ] In the case of automatically inserting the child page list without using a block, the issue where all pages were displayed in WordPress 6.5 has been fixed. [ Design Bug Fix ][ Faq ] Fix stitching styles in Group blocks. diff --git a/tests/test-add-plugin-link-to-adminbar.php b/tests/test-add-plugin-link-to-adminbar.php new file mode 100644 index 00000000..4b5747df --- /dev/null +++ b/tests/test-add-plugin-link-to-adminbar.php @@ -0,0 +1,55 @@ + '6.5 / 公開画面', + 'wp_version' => '6.5', + 'is_admin' => false, + 'expected' => false, + ), + array( + 'title' => '6.5 / 管理画面', + 'wp_version' => '6.5', + 'is_admin' => true, + 'expected' => true, + ), + array( + 'title' => '6.4 / 公開画面', + 'wp_version' => '6.4', + 'is_admin' => false, + 'expected' => true, + ), + + ); + + print PHP_EOL; + print '------------------------------------' . PHP_EOL; + print 'test_veu_is_add_plugin_link_to_adminbar' . PHP_EOL; + print '------------------------------------' . PHP_EOL; + foreach ( $tests as $key => $test_value ) { + + // 現在表示中のURLを取得 + $acutual = veu_is_add_plugin_link_to_adminbar( $test_value['wp_version'], $test_value['is_admin'] ); + + print PHP_EOL; + print 'title :' . $test_value['title'] . PHP_EOL; + print 'actual :' . $acutual . PHP_EOL; + print 'expected :' . $test_value['expected'] . PHP_EOL; + + // PHPunit + $this->assertEquals( $test_value['expected'], $acutual ); + } + } +} diff --git a/vkExUnit.php b/vkExUnit.php index 11170242..c006b1c6 100644 --- a/vkExUnit.php +++ b/vkExUnit.php @@ -3,7 +3,7 @@ * Plugin Name: VK All in One Expansion Unit * Plugin URI: https://ex-unit.nagoya * Description: This plug-in is an integrated plug-in with a variety of features that make it powerful your web site. Many features can be stopped individually. Example Facebook Page Plugin,Social Bookmarks,Print OG Tags,Print Twitter Card Tags,Print Google Analytics tag,New post widget,Insert Related Posts and more! - * Version: 9.97.1.1 + * Version: 9.97.2.0 * Requires PHP: 7.4 * Requires at least: 5.9 * Author: Vektor,Inc.