Survey.php
| 1 | <?php |
| 2 | /** |
| 3 | * Survey helper methods. |
| 4 | */ |
| 5 | |
| 6 | namespace Automattic\WooCommerce\Internal\Admin; |
| 7 | |
| 8 | defined( 'ABSPATH' ) || exit; |
| 9 | |
| 10 | /** |
| 11 | * Survey Class. |
| 12 | */ |
| 13 | class Survey { |
| 14 | /** |
| 15 | * Survey URL. |
| 16 | */ |
| 17 | const SURVEY_URL = 'https://automattic.survey.fm'; |
| 18 | |
| 19 | /** |
| 20 | * Get a survey's URL from a path. |
| 21 | * |
| 22 | * @param string $path Path of the survey. |
| 23 | * @param array $query Query arguments as key value pairs. |
| 24 | * @return string Full URL to survey. |
| 25 | */ |
| 26 | public static function get_url( $path, $query = array() ) { |
| 27 | $url = self::SURVEY_URL . $path; |
| 28 | |
| 29 | $query_args = apply_filters( 'woocommerce_admin_survey_query', $query ); |
| 30 | |
| 31 | if ( ! empty( $query_args ) ) { |
| 32 | $query_string = http_build_query( $query_args ); |
| 33 | $url = $url . '?' . $query_string; |
| 34 | } |
| 35 | |
| 36 | return $url; |
| 37 | } |
| 38 | } |
| 39 |