get_meta_field() ]; } public function add_hooks() { add_filter( 'pre_wpml_is_translated_taxonomy', [ $this, 'filterMenus' ], 10, 2 ); add_filter( 'siteorigin_panels_widgets', [ $this, 'removeWidgets' ] ); add_filter( 'siteorigin_panels_widget_form', [ $this, 'removeLanguageSelector' ] ); } /** * By letting WPML think `nav_menu` is translatable, it will filter out items in other languages. * To avoid interfeering with anything else, we do this only for the SiteOrigin menu widget. * * @param bool|null $result * @param string $tax * * @return bool|null */ public function filterMenus( $result, $tax ) { /* phpcs:ignore WordPress.Security.NonceVerification.Recommended */ if ( is_admin() && 'nav_menu' === $tax && Obj::prop( 'action', $_REQUEST ) === 'so_panels_widget_form' ) { $result = true; } return $result; } /** * @param array $widgets * * @return array */ public function removeWidgets( $widgets ) { unset( $widgets['WPML_LS_Widget'], $widgets['WP_Widget_Text_Icl'] ); return $widgets; } /** * @param int $postId * * @return bool */ public function is_handling_post( $postId ) { return (bool) get_post_meta( $postId, $this->get_meta_field(), true ); } /** * @param string $form * * @return string */ public function removeLanguageSelector( $form ) { $form = preg_replace( '/

[\n\r\t]*