' . esc_html( $filter_template ) . '' ), '1.0.0' ); return; } $template = $filter_template; } $action_args = array( 'template_name' => $template_name, 'template_path' => $template_path, 'located' => $template, 'args' => $args, ); if ( ! empty( $args ) && is_array( $args ) ) { if ( isset( $args['action_args'] ) ) { _doing_it_wrong( __FUNCTION__, sprintf( // translators: %s. Class-Method name. esc_html__( 'The “action_args” can not be overwritten when calling %s.', 'storeengine' ), esc_html( __METHOD__ ) ), '1.0.0' ); unset( $args['action_args'] ); } /** * This use of extract() cannot be removed. There are many possible ways that * templates could depend on variables that it creates existing, and no way to * detect and deprecate it. * * Passing the EXTR_SKIP flag is the safest option, ensuring globals and * function variables cannot be overwritten. * @see load_template() */ extract( $args, EXTR_SKIP ); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract } do_action( 'storeengine/before_template_part', $action_args['template_name'], $action_args['template_path'], $action_args['located'], $action_args['args'] ); include $action_args['located']; do_action( 'storeengine/after_template_part', $action_args['template_name'], $action_args['template_path'], $action_args['located'], $action_args['args'] ); } /** * Returns rendered content for the template. * * @param string $template_name Template file name/path. * @param array $args Args to decode (will be available as variable inside the template). * @param string $template_path Template path (relative from default/root path). * @param string $default_path Template root path (default to plugins template directory). * * @return string */ public static function get_template_content( string $template_name, array $args = [], string $template_path = '', string $default_path = '' ): string { ob_start(); self::get_template( $template_name, $args, $template_path, $default_path ); $rendered = (string) ob_get_clean(); return apply_filters( 'storeengine/template/get_content', $rendered, $template_name, $args, $template_path, $default_path ); } }