is_human_page( $sitepress ) ) { if ( $sitepress->get_wp_api()->is_admin() ) { return $this->create_backend_ui( $sitepress ); } return $this->create_frontend_ui( $sitepress ); } return null; } private function create_backend_ui( SitePress $sitepress ) { $template_paths = array( WPML_PLUGIN_PATH . '/templates/widgets/', ); $template_loader = new WPML_Twig_Template_Loader( $template_paths ); return new WPML_Widgets_Support_Backend( $sitepress->get_active_languages(), $template_loader->get_template() ); } public function create_frontend_ui( SitePress $sitepress ) { return new WPML_Widgets_Support_Frontend( $sitepress->get_current_language() ); } /** * @param SitePress $sitepress * * @return bool */ private function is_human_page( SitePress $sitepress ) { $wpml_wp_api = $sitepress->get_wp_api(); return ! $wpml_wp_api->is_cron_job() && ! $wpml_wp_api->is_heartbeat(); } }