Skip to content

Commit

Permalink
added default code
Browse files Browse the repository at this point in the history
  • Loading branch information
manikantakailasa committed Mar 12, 2024
1 parent e77649f commit ab4a24c
Showing 1 changed file with 85 additions and 76 deletions.
161 changes: 85 additions & 76 deletions includes/Listeners/Jetpack.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,87 +6,96 @@
/**
* Monitors Jetpack events
*/
class Jetpack extends Listener {
class Jetpack extends Listener
{
private $brandCode = array(
'bluehost' => '86241',
'hostgator' => '57686',
'hostgator-india' => '57686',
'bluehost-india' => '86241',
'hostgator-latam' => '57686',
'default' => '86240'
);

private $brandCode = array('bluehost' => '86241', 'hostgator' => '57686', 'hostgator-india' => '57686', 'bluehost-india' => '86241', 'hostgator-latam' => '57686');
/**
* Register the hooks for the listener
*
* @return void
*/
public function register_hooks() {
// Connected
add_action( 'jetpack_site_registered', array( $this, 'connected' ), 10, 3 );

/**
* Register the hooks for the listener
*
* @return void
*/
public function register_hooks() {
// Connected
add_action( 'jetpack_site_registered', array( $this, 'connected' ), 10, 3 );

// Module enabled/disabled
add_action( 'jetpack_pre_activate_module', array( $this, 'module_enabled' ) );
add_action( 'jetpack_pre_deactivate_module', array( $this, 'module_disabled' ) );
add_action( 'activated_plugin', array( $this, 'detect_plugin_activation' ), 10, 1 );
// Publicize
add_action( 'publicize_save_meta', array( $this, 'publicize' ), 10, 4 );
}
// Module enabled/disabled
add_action( 'jetpack_pre_activate_module', array( $this, 'module_enabled' ) );
add_action( 'jetpack_pre_deactivate_module', array( $this, 'module_disabled' ) );
add_action( 'activated_plugin', array( $this, 'detect_plugin_activation' ), 10, 1 );
// Publicize
add_action( 'publicize_save_meta', array( $this, 'publicize' ), 10, 4 );
}

/**
* Jetpack connected
*
* @param integer $id Jetpack Site ID
* @param string $secret Jetpack blog token
* @param integer|boolan $public Whether the site is public
* @return void
*/
public function connected( $id, $secret, $public ) {
$this->push(
'jetpack_connected',
array(
'id' => $id,
'public' => $public,
)
);
}
/**
* Jetpack connected
*
* @param integer $id Jetpack Site ID
* @param string $secret Jetpack blog token
* @param integer|boolan $public Whether the site is public
* @return void
*/
public function connected( $id, $secret, $public ) {
$this->push(
'jetpack_connected',
array(
'id' => $id,
'public' => $public,
)
);
}

/**
* Jetpack module enabled
*
* @param string $module Name of the module
* @return void
*/
public function module_enabled( $module ) {
$this->push( 'jetpack_module_enabled', array( 'label_key' => 'module', 'module' => $module ) );
}
/**
* Jetpack module enabled
*
* @param string $module Name of the module
* @return void
*/
public function module_enabled( $module ) {
$this->push( 'jetpack_module_enabled', array( 'label_key' => 'module', 'module' => $module ) );
}

/**
* Jetpack module disabled
*
* @param string $module Name of the module
* @return void
*/
public function module_disabled( $module ) {
$this->push( 'jetpack_module_disabled', array( 'label_key' => 'module', 'module' => $module ) );
}
/**
* Jetpack module disabled
*
* @param string $module Name of the module
* @return void
*/
public function module_disabled( $module ) {
$this->push( 'jetpack_module_disabled', array( 'label_key' => 'module', 'module' => $module ) );
}

/**
* Post publicized
*
* @param bool $submit_post Whether to submit the post
* @param integer $post_id ID of the post being publicized
* @param string $service_name Service name
* @param array $connection Array of connection details
* @return void
*/
public function publicize( $submit_post, $post_id, $service_name, $connection ) {
// Bail if it's not being publicized
if ( ! $submit_post ) {
return;
}
$this->push( 'jetpack_publicized', array( 'label_key' => 'service', 'service' => $service_name ) );
}
/**
* Post publicized
*
* @param bool $submit_post Whether to submit the post
* @param integer $post_id ID of the post being publicized
* @param string $service_name Service name
* @param array $connection Array of connection details
* @return void
*/
public function publicize( $submit_post, $post_id, $service_name, $connection ) {
// Bail if it's not being publicized
if ( ! $submit_post ) {
return;
}
$this->push( 'jetpack_publicized', array( 'label_key' => 'service', 'service' => $service_name ) );
}

public function detect_plugin_activation( $plugin ) {
$container = container();
if( $plugin == "jetpack/jetpack.php" ){
$jetpack_affiliate_code = get_option("jetpack_affiliate_code");
!$jetpack_affiliate_code && update_option("jetpack_affiliate_code",$this->brandCode[$container->plugin()->brand]);
public function detect_plugin_activation( $plugin ) {
$container = container();
if( $plugin == "jetpack/jetpack.php" ){
$jetpack_affiliate_code = get_option("jetpack_affiliate_code");
!$jetpack_affiliate_code && $this->brandCode[$container->plugin()->brand]
? update_option("jetpack_affiliate_code",$this->brandCode[$container->plugin()->brand])
: update_option("jetpack_affiliate_code",$this->brandCode['default']) ;
}
}
}
}
}

0 comments on commit ab4a24c

Please sign in to comment.