Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

公開画面側にプラグイン画面へのリンクを追加しないように変更 #1084

Merged
merged 4 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions inc/add_plugin_link_to_adminbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) ) {

Expand All @@ -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;
}
}
}
3 changes: 3 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
55 changes: 55 additions & 0 deletions tests/test-add-plugin-link-to-adminbar.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php
/**
* Class InsertPluginLinkToAdminbarTest
*
* @package vektor-inc\vk-all-in-one-expansion-unit
*/

/**
*
*/
class addPluginLinkToAdminbarTest extends WP_UnitTestCase {

function test_veu_is_add_plugin_link_to_adminbar() {

$tests = array(
array(
'title' => '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 );
}
}
}
2 changes: 1 addition & 1 deletion vkExUnit.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading