for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
if ( ! defined( 'ABSPATH' ) ) {
// Exit if accessed directly
exit;
}
/**
* This class introduces routines to get an affiliate code, that might be obtained from:
* - an `jetpack_affiliate_code` option in the WP database
* - an affiliate code returned by a filter bound to the `jetpack_affiliate_code` filter hook
*
* @since 6.9.0
*/
class Jetpack_Affiliate {
* @var Jetpack_Affiliate This class instance.
**/
private static $instance = null;
private function __construct() {
if ( Jetpack::is_development_mode() ) {
return;
* Initializes the class or returns the singleton
* @return Jetpack_Affiliate | false
public static function init() {
if ( is_null( self::$instance ) ) {
self::$instance = new Jetpack_Affiliate;
return self::$instance;
* Returns the affiliate code from database after filtering it.
* @return string The affiliate code.
public function get_affiliate_code() {
* Allow to filter the affiliate code.
* @param string $aff_code The affiliate code, blank by default.
return apply_filters( 'jetpack_affiliate_code', get_option( 'jetpack_affiliate_code', '' ) );
add_action( 'init', array( 'Jetpack_Affiliate', 'init' ) );