_load( $view, $args ); if ( ! empty( $view ) ) { echo $view; // phpcs:ignore -- The template being rendered could contain anything } return ! empty( $view ); } /** * Loads the view file and returns the output as string * * @param string $view View file to load * @param array $args Optional array of arguments to pass to view * * @return mixed (string)View output on success, (bool)false on failure */ protected function _load( $view, $args = array() ) { $view = preg_replace( '/[^\-_a-z0-9\/]/i', '', $view ); if ( empty( $view ) ) { return false; } $_path = wp_normalize_path( SMARTCRAWL_PLUGIN_DIR . 'admin/templates/' . $view . '.php' ); if ( ! file_exists( $_path ) || ! is_readable( $_path ) ) { return false; } if ( empty( $args ) || ! is_array( $args ) ) { $args = array(); } if ( is_null( $this->view_defaults ) ) { $this->view_defaults = $this->_get_view_defaults(); } $args = wp_parse_args( $args, $this->view_defaults ); if ( ! empty( $args ) ) { extract( $args ); // phpcs:ignore -- extract method is necessary here for making variables available to template } ob_start(); include $_path; return ob_get_clean(); } abstract protected function _get_view_defaults(); }