se. * * @return bool|string */ private function get_base_path() { $reflector = new ReflectionClass( get_called_class() ); $base_path = dirname( $reflector->getFileName(), 2 ); if ( is_dir( $base_path . DIRECTORY_SEPARATOR . 'controller' ) && is_dir( $base_path . DIRECTORY_SEPARATOR . 'view' ) ) { return $base_path . DIRECTORY_SEPARATOR; } return false; } /** * Render a partial view file. * * @param mixed $view_file The view file to render. * @param array $params Optional. The parameters to pass to the view file. Default is an empty array. * @param bool $output Optional. Whether to output the rendered content or return it. Default is true. * * @return string The rendered content. */ public function render_partial( $view_file, $params = array(), $output = true ) { $base_path = $this->get_base_path(); if ( ! isset( $params['controller'] ) ) { $params['controller'] = $this; } $view = new View( $base_path . 'view' ); if ( is_array( $view_file ) ) { $content = ''; foreach ( $view_file as $vf ) { $content .= $view->render( $vf, $params ); } } else { $content = $view->render( $view_file, $params ); } if ( true === $output ) { /** * Ignore WordPress.Security.EscapeOutput.OutputNotEscaped * Why? * Because $content has scripts that will be broken if we escape it. */ echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } return $content; } /** * Check for has server not found error. * * @return bool */ private function check_has_server_error(): bool { global $defender_server_not_supported; if ( is_wp_error( $defender_server_not_supported ) ) { $html = '
'; $html .= '
'; $html .= '
'; $html .= '

' . $defender_server_not_supported->get_error_message() . '

'; $html .= '
'; echo wp_kses_post( $html ); return true; } return false; } }