-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add/jetpack affiliation - PRESS4-516 #64
Changes from 3 commits
3294233
52c540f
419dc60
0496f4d
8616dd5
b0b716b
7edea61
fcfe363
857f9fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
use NewfoldLabs\WP\Module\Data\Data; | ||
use NewfoldLabs\WP\Module\Data\Helpers\Encryption; | ||
use NewfoldLabs\WP\Module\Data\Helpers\Transient; | ||
use NewfoldLabs\WP\Module\Data\Listeners\Jetpack; | ||
use NewfoldLabs\WP\Module\Data\SiteCapabilities; | ||
use NewfoldLabs\WP\ModuleLoader\Container; | ||
use WP_Forge\UpgradeHandler\UpgradeHandler; | ||
|
@@ -19,7 +20,7 @@ | |
return; | ||
} | ||
|
||
define( 'NFD_DATA_MODULE_VERSION', '2.4.20' ); | ||
define( 'NFD_DATA_MODULE_VERSION', '2.4.21' ); | ||
|
||
if ( function_exists( 'is_admin' ) && is_admin() ) { | ||
$upgrade_handler = new UpgradeHandler( | ||
|
@@ -79,6 +80,8 @@ function ( $value ) { | |
'newfold_container_set', | ||
function ( Container $container ) { | ||
|
||
NFD_DATA_MODULE_VERSION === '2.4.21' && nfd_update_options_table( $container ); | ||
|
||
register_activation_hook( | ||
$container->plugin()->file, | ||
function () use ( $container ) { | ||
|
@@ -137,6 +140,33 @@ function nfd_create_event_queue_table() { | |
dbDelta( $sql ); | ||
} | ||
|
||
/** | ||
* Update affiliation code in option table | ||
* | ||
* @param object $container Container information | ||
*/ | ||
function nfd_update_options_table( $container ) { | ||
$brand_code = array( | ||
'bluehost' => '86241', | ||
'hostgator' => '57686', | ||
'web' => '86239', | ||
'crazy-domains' => '57687', | ||
'hostgator-india' => '57686', | ||
'bluehost-india' => '86241', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't have a good way to determine if a site is Bluehost India or HostGator India right now. We can keep this code, but it won't do anything. |
||
'hostgator-latam' => '57686', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. HostGator LATAM requires an additional region check to differentiate from normal HostGator There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it necessary to verify additional regions because we have the same Jetpack affiliation code for all hosts, including Hostgator, Hostgator-India, and Hostgator-Latam? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @manikantakailasa Ah, no. Let's remove the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removing hostgator-india, bluehost-india, and hostgator-latam will result in the brands mapping to default and not having their respective Jetpack affiliation codes. $container->plugin()->id; container will return brand as hostgator-india, bluehost-india, and hostgator-latam There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @manikantakailasa The
It is not configured to include any suffixes. |
||
'default' => '86240', | ||
wpscholar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
); | ||
$brand = $container->plugin()->id; | ||
if ( is_plugin_active( 'jetpack/jetpack.php' ) ) { | ||
if ( empty( $brand ) || ! array_key_exists( $brand, $brand_code ) ) { | ||
$brand = 'default'; | ||
} | ||
$jetpack_affiliate_code = get_option( 'jetpack_affiliate_code' ); | ||
! $jetpack_affiliate_code && | ||
update_option( 'jetpack_affiliate_code', $brand_code[ $brand ] ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to fix code formatting here |
||
} | ||
} | ||
|
||
/** | ||
* Drop the event queue table | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did the upgrade routine approach not work? That is the preferred method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we are getting this error - Uncaught NewfoldLabs\Container\NotFoundException : No entry was found for "plugin" identifier.
As we talked about earlier, we're employing a hook call and specifying a version condition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@manikantakailasa, I was thinking we would add the hook to the upgrade routine file. So in the
2.4.22.php
file, add thenewfold_container_set
callback and move the code out of the called function into the hook.