篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 更好地将Flamingo管理菜单与Contact Form 7集成相关的知识,希望对你有一定的参考价值。
<?php
add_action( 'admin_menu', '_wp_flamingo_humility', 999 );
function _wp_flamingo_humility() {
// Only do if Contact Form 7 is active
if ( !is_plugin_active( 'contact-form-7/wp-contact-form-7.php' ) ) return;
// More descriptive CF7 menu label
$wpcf7_menu = _get_menu_index_by_slug( 'wpcf7' );
$GLOBALS['menu'][$wpcf7_menu][0] = __('Forms', 'textdomain');
// Optional: Hide CF7 "Integration" submenu
remove_submenu_page( 'wpcf7', 'wpcf7-integration' );
// Only do if Flamingo is active
if ( !is_plugin_active( 'flamingo/flamingo.php' ) ) return;
// Drop default Flamingo admin menu
remove_menu_page('flamingo');
// Add "Inbound Messages" link to CF7 Menu with better menu label
add_submenu_page(
'wpcf7',
__( 'Flamingo Inbound Messages', 'flamingo' ),
__( 'Submissions', 'flamingo' ),
'flamingo_edit_inbound_messages',
'admin.php?page=flamingo_inbound'
);
}
// Fix menu highlighting for Flamingo when moved to CF7 submenu
add_filter( 'parent_file', '_wp_flamingo_menu_highlight' );
function _wp_flamingo_menu_highlight( $parent_file ) {
if (isset($_GET['page']) && $_GET['page'] == 'flamingo_inbound'){
$GLOBALS['plugin_page'] = 'wpcf7';
$GLOBALS['submenu_file'] = 'admin.php?page=flamingo_inbound';
}
return $parent_file;
}
// Helper function to find admin menu index by slug
function _get_menu_index_by_slug( $location = '' ) {
foreach ( $GLOBALS['menu'] as $index => $menu_item ) {
if ( $location === $menu_item[2] ) {
return $index;
}
}
return false;
}
以上是关于php 更好地将Flamingo管理菜单与Contact Form 7集成的主要内容,如果未能解决你的问题,请参考以下文章