Server IP : 85.214.239.14 / Your IP : 18.191.195.180 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /var/www/wordpress/wp-content/plugins/really-simple-ssl/settings/src/Menu/ |
Upload File : |
import { __ } from '@wordpress/i18n'; import useMenu from "./MenuData"; const MenuItem = (props) => { const {selectedSubMenuItem, selectedMainMenuItem, subMenu, menu} = useMenu(); const menuIsSelected = isSelectedMenuItem(selectedSubMenuItem, props.menuItem); const ensureArray = (data) => { return Array.isArray(data) ? data : [data]; } let menuClass = menuIsSelected ? ' rsssl-active' : ''; menuClass += props.menuItem.featured ? ' rsssl-featured' : ''; menuClass += props.menuItem.new ? ' rsssl-new' : ''; menuClass += props.menuItem.premium && !rsssl_settings.pro_plugin_active ? ' rsssl-premium' : ''; let menuLink = props.menuItem.directLink || '#'+selectedMainMenuItem+'/'+props.menuItem.id; return ( <> {props.menuItem.visible && ( <> {props.isMainMenu ? ( <div className="rsssl-main-menu"> <div className={"rsssl-menu-item" + menuClass}> <a href={menuLink}> <span>{props.menuItem.title}</span> {props.menuItem.featured && <span className='rsssl-menu-item-beta-pill'>{__('Beta', 'really-simple-ssl')}</span>} {props.menuItem.new && <span className='rsssl-menu-item-new-pill'>{__('New', 'really-simple-ssl')}</span>} </a> </div> </div> ) : ( <div className={"rsssl-menu-item" + menuClass}> <a href={menuLink}> <span>{props.menuItem.title}</span> {props.menuItem.featured && <span className='rsssl-menu-item-beta-pill'>{__('Beta', 'really-simple-ssl')}</span>} {props.menuItem.new && <span className='rsssl-menu-item-new-pill'>{__('New', 'really-simple-ssl')}</span>} </a> </div> )} {props.menuItem.menu_items && menuIsSelected && ( <div className="rsssl-submenu-item"> {ensureArray(props.menuItem.menu_items).map((subMenuItem, i) => ( subMenuItem.visible && <MenuItem key={"submenuItem" + i} menuItem={subMenuItem} isMainMenu={false} /> ))} </div> )} </> )} </> ); } export default MenuItem /** * Utility function to check if selected menu item is the current menu item or a child of the current menu item * @param selectedSubMenuItem * @param menuItem * @returns {boolean} */ const isSelectedMenuItem = (selectedSubMenuItem, menuItem) => { if (selectedSubMenuItem === menuItem.id) { return true; } if (menuItem.menu_items) { for (const item of menuItem.menu_items) { if (item.id === selectedSubMenuItem) { return true; } } } return false; };