settings->bar_enabled() ? array( $this->free_shipping ) : array(); /** * Filters the goals shown in progress bars. * * @since 1.0.0 * * @param GoalInterface[] $goals Goals. * @param Context $context Context. */ $goals = apply_filters( 'extrova_goals', $goals, $context ); return array_values( array_filter( (array) $goals, static fn( mixed $goal ): bool => $goal instanceof GoalInterface ) ); } /** * Evaluated goals: list of { id, threshold, current, remaining, reached, message }. * * @param Context $context Context. */ public function evaluate_all( Context $context ): array { $results = array(); foreach ( $this->goals( $context ) as $goal ) { $result = $goal->evaluate( $context ); if ( is_array( $result ) ) { $results[] = array_merge( array( 'id' => $goal->id() ), $result ); } } return $results; } /** * Whether goal assets may be needed (bar enabled or goals added by add-ons). */ public function may_have_goals(): bool { return $this->settings->bar_enabled() || has_filter( 'extrova_goals' ); } }