*/ function link_args( string $from = '' ): array { $args = array( 'v' => defined( 'FORGE12_OPTIN_VERSION' ) ? FORGE12_OPTIN_VERSION : '' ); if ( $from !== '' ) { $args['from'] = $from; } return $args; } /** * Campaign tags for links into the shop. * * forge12.com runs WooCommerce, whose Order Attribution stores the utm_* * parameters a buyer arrived with on the order. `from` alone only shows up in * server logs; these make a sale traceable to the place in the plugin that led * to it. Product links only — a feedback or support visit is not a sale. * * @param string $from Which entry point the click came from. * * @return array */ function campaign_args( string $from ): array { return array( 'utm_source' => 'double-opt-in', 'utm_medium' => 'plugin', 'utm_campaign' => $from !== '' ? $from : 'unspecified', ); } /** * Build a link to the product page. * * @param string $from Which entry point the click came from. * * @return string */ function get_product_url( string $from = '' ): string { $url = add_query_arg( link_args( $from ) + campaign_args( $from ), PRODUCT_BASE . PRODUCT_PATH ); /** * Filter a link to the product site. * * @param string $url The full URL including its query arguments. * @param string $from Which entry point this is. * * @since 5.2.0 */ return (string) apply_filters( 'f12_doi_product_url', $url, $from ); } /** * Build a feedback link. * * @param string $from Which entry point the click came from. * * @return string */ function get_feedback_url( string $from = '' ): string { $url = add_query_arg( link_args( $from ), FEEDBACK_URL ); /** * Filter the feedback destination. * * @param string $url The full URL including its query arguments. * @param string $from Which entry point this is. * * @since 5.2.0 */ return (string) apply_filters( 'f12_doi_feedback_url', $url, $from ); } /** * Build a support link. Same rules as get_feedback_url(). * * @param string $from Which entry point the click came from. * * @return string */ function get_support_url( string $from = '' ): string { $url = add_query_arg( link_args( $from ), sprintf( SUPPORT_URL, product_lang() ) ); /** * Filter the support destination. * * @param string $url The full URL including its query arguments. * @param string $from Which entry point this is. * * @since 5.2.0 */ return (string) apply_filters( 'f12_doi_support_url', $url, $from ); }