| @@ -1,5 +1,10 @@ | ||
| 1 | 1 | <?php |
| 2 | + | |
| 3 | + if ( ! defined( 'ABSPATH' ) ) { | |
| 4 | + exit; | |
| 5 | + } | |
| 6 | + | |
| 2 | 7 | /** |
| 3 | 8 | * @var array $VARS |
| 4 | 9 | * @var Freemius $fs |
| 5 | 10 | */ |
| @@ -7,14 +12,18 @@ | ||
| 7 | 12 | $addon_id = $VARS['addon_id']; |
| 8 | 13 | $odd = $VARS['odd']; |
| 9 | 14 | $slug = $fs->get_slug(); |
| 10 | 15 | |
| 16 | + $fs_blog_id = $VARS['fs_blog_id']; | |
| 11 | 17 | |
| 12 | - $addon = $fs->get_addon( $addon_id ); | |
| 18 | + $active_plugins_directories_map = $VARS['active_plugins_directories_map']; | |
| 19 | + | |
| 20 | + $addon_info = $VARS['addon_info']; | |
| 13 | 21 | $is_addon_activated = $fs->is_addon_activated( $addon_id ); |
| 14 | - $is_addon_connected = $fs->is_addon_connected( $addon_id ); | |
| 22 | + $is_addon_connected = $addon_info['is_connected']; | |
| 23 | + $is_addon_installed = $VARS['is_addon_installed']; | |
| 15 | 24 | |
| 16 | - $fs_addon = $is_addon_connected ? | |
| 25 | + $fs_addon = ( $is_addon_connected && $is_addon_installed ) ? | |
| 17 | 26 | freemius( $addon_id ) : |
| 18 | 27 | false; |
| 19 | 28 | |
| 20 | 29 | // Aliases. |
| @@ -20,10 +29,10 @@ | ||
| 20 | 29 | // Aliases. |
| 21 | 30 | $download_latest_text = fs_text_x_inline( 'Download Latest', 'as download latest version', 'download-latest', $slug ); |
| 22 | 31 | $downgrading_plan_text = fs_text_inline( 'Downgrading your plan', 'downgrading-plan', $slug ); |
| 23 | 32 | $cancelling_subscription_text = fs_text_inline( 'Cancelling the subscription', 'cancelling-subscription', $slug ); |
| 24 | - /* translators: %1s: Either 'Downgrading your plan' or 'Cancelling the subscription' */ | |
| 25 | - $downgrade_x_confirm_text = fs_text_inline( '%1s will immediately stop all future recurring payments and your %s plan license will expire in %s.', 'downgrade-x-confirm', $slug ); | |
| 33 | + /* translators: %1$s: Either 'Downgrading your plan' or 'Cancelling the subscription' */ | |
| 34 | + $downgrade_x_confirm_text = fs_text_inline( '%1$s will immediately stop all future recurring payments and your %2$s plan license will expire in %3$s.', 'downgrade-x-confirm', $slug ); | |
| 26 | 35 | $prices_increase_text = fs_text_inline( 'Please note that we will not be able to grandfather outdated pricing for renewals/new subscriptions after a cancellation. If you choose to renew the subscription manually in the future, after a price increase, which typically occurs once a year, you will be charged the updated price.', 'pricing-increase-warning', $slug ); |
| 27 | 36 | $cancel_trial_confirm_text = fs_text_inline( 'Cancelling the trial will immediately block access to all premium features. Are you sure?', 'cancel-trial-confirm', $slug ); |
| 28 | 37 | $after_downgrade_non_blocking_text = fs_text_inline( 'You can still enjoy all %s features but you will not have access to %s security & feature updates, nor support.', 'after-downgrade-non-blocking', $slug ); |
| 29 | 38 | $after_downgrade_blocking_text = fs_text_inline( 'Once your license expires you can still use the Free version but you will NOT have access to the %s features.', 'after-downgrade-blocking', $slug ); |
| @@ -33,9 +42,8 @@ | ||
| 33 | 42 | /* translators: %s: Time period (e.g. Auto renews in "2 months") */ |
| 34 | 43 | $renews_in_text = fs_text_inline( 'Auto renews in %s', 'renews-in', $slug ); |
| 35 | 44 | /* translators: %s: Time period (e.g. Expires in "2 months") */ |
| 36 | 45 | $expires_in_text = fs_text_inline( 'Expires in %s', 'expires-in', $slug ); |
| 37 | - $sync_license_text = fs_text_x_inline( 'Sync License', 'as synchronize license', 'sync-license', $slug ); | |
| 38 | 46 | $cancel_trial_text = fs_text_inline( 'Cancel Trial', 'cancel-trial', $slug ); |
| 39 | 47 | $change_plan_text = fs_text_inline( 'Change Plan', 'change-plan', $slug ); |
| 40 | 48 | $upgrade_text = fs_text_x_inline( 'Upgrade', 'verb', 'upgrade', $slug ); |
| 41 | 49 | $addons_text = fs_text_inline( 'Add-Ons', 'add-ons', $slug ); |
| @@ -47,13 +55,18 @@ | ||
| 47 | 55 | |
| 48 | 56 | // Defaults. |
| 49 | 57 | $plan = null; |
| 50 | 58 | $is_paid_trial = false; |
| 59 | + /** | |
| 60 | + * @var FS_Plugin_License $license | |
| 61 | + */ | |
| 51 | 62 | $license = null; |
| 52 | 63 | $site = null; |
| 53 | 64 | $is_active_subscription = false; |
| 54 | 65 | $subscription = null; |
| 55 | 66 | $is_paying = false; |
| 67 | + $show_upgrade = false; | |
| 68 | + $is_whitelabeled = $VARS['is_whitelabeled']; | |
| 56 | 69 | |
| 57 | 70 | if ( is_object( $fs_addon ) ) { |
| 58 | 71 | $is_paying = $fs_addon->is_paying(); |
| 59 | 72 | $user = $fs_addon->get_user(); |
| @@ -62,13 +75,76 @@ | ||
| 62 | 75 | $subscription = ( is_object( $license ) ? |
| 63 | 76 | $fs_addon->_get_subscription( $license->id ) : |
| 64 | 77 | null ); |
| 65 | 78 | $plan = $fs_addon->get_plan(); |
| 66 | - $is_active_subscription = ( is_object( $subscription ) && $subscription->is_active() ); | |
| 79 | + $plan_name = $plan->name; | |
| 80 | + $plan_title = $plan->title; | |
| 67 | 81 | $is_paid_trial = $fs_addon->is_paid_trial(); |
| 68 | - $show_upgrade = ( $fs_addon->has_paid_plan() && ! $is_paying && ! $is_paid_trial && ! $fs_addon->_has_premium_license() ); | |
| 69 | - $is_current_license_expired = is_object( $license ) && $license->is_expired(); | |
| 82 | + $version = $fs_addon->get_plugin_version(); | |
| 83 | + $is_whitelabeled = ( | |
| 84 | + $fs_addon->is_whitelabeled( true ) && | |
| 85 | + ! $fs_addon->get_parent_instance()->is_data_debug_mode() | |
| 86 | + ); | |
| 87 | + $show_upgrade = ( | |
| 88 | + ! $is_whitelabeled && | |
| 89 | + $fs_addon->has_paid_plan() && | |
| 90 | + ! $is_paying && | |
| 91 | + ! $is_paid_trial && | |
| 92 | + ! $fs_addon->_has_premium_license() | |
| 93 | + ); | |
| 94 | + } else if ( $is_addon_connected ) { | |
| 95 | + if ( | |
| 96 | + empty( $addon_info ) || | |
| 97 | + ! isset( $addon_info['site'] ) | |
| 98 | + ) { | |
| 99 | + $is_addon_connected = false; | |
| 100 | + } else { | |
| 101 | + /** | |
| 102 | + * @var FS_Site $site | |
| 103 | + */ | |
| 104 | + $site = $addon_info['site']; | |
| 105 | + $version = $addon_info['version']; | |
| 106 | + | |
| 107 | + $plan_name = isset( $addon_info['plan_name'] ) ? | |
| 108 | + $addon_info['plan_name'] : | |
| 109 | + ''; | |
| 110 | + | |
| 111 | + $plan_title = isset( $addon_info['plan_title'] ) ? | |
| 112 | + $addon_info['plan_title'] : | |
| 113 | + ''; | |
| 114 | + | |
| 115 | + if ( isset( $addon_info['license'] ) ) { | |
| 116 | + $license = $addon_info['license']; | |
| 117 | + } | |
| 118 | + | |
| 119 | + if ( isset( $addon_info['subscription'] ) ) { | |
| 120 | + $subscription = $addon_info['subscription']; | |
| 121 | + } | |
| 122 | + | |
| 123 | + $has_valid_and_active_license = ( | |
| 124 | + is_object( $license ) && | |
| 125 | + $license->is_active() && | |
| 126 | + $license->is_valid() | |
| 127 | + ); | |
| 128 | + | |
| 129 | + $is_paid_trial = ( | |
| 130 | + $site->is_trial() && | |
| 131 | + $has_valid_and_active_license && | |
| 132 | + ( $site->trial_plan_id == $license->plan_id ) | |
| 133 | + ); | |
| 134 | + | |
| 135 | + $is_whitelabeled = $addon_info['is_whitelabeled']; | |
| 136 | + } | |
| 70 | 137 | } |
| 138 | + | |
| 139 | + $has_feature_enabled_license = ( | |
| 140 | + is_object( $license ) && | |
| 141 | + $license->is_features_enabled() | |
| 142 | + ); | |
| 143 | + | |
| 144 | + $is_active_subscription = ( is_object( $subscription ) && $subscription->is_active() ); | |
| 145 | + | |
| 146 | + $show_delete_install_button = ( ! $is_paying && WP_FS__DEV_MODE && ! $is_whitelabeled ); | |
| 71 | 147 | ?> |
| 72 | 148 | <tr<?php if ( $odd ) { |
| 73 | 149 | echo ' class="alternate"'; |
| 74 | 150 | } ?>> |
| @@ -73,9 +149,9 @@ | ||
| 73 | 149 | echo ' class="alternate"'; |
| 74 | 150 | } ?>> |
| 75 | 151 | <td> |
| 76 | 152 | <!-- Title --> |
| 77 | - <?php echo $addon->title ?> | |
| 153 | + <?php echo $addon_info['title'] ?> | |
| 78 | 154 | </td> |
| 79 | 155 | <?php if ( $is_addon_connected ) : ?> |
| 80 | 156 | <!-- ID --> |
| 81 | 157 | <td><?php echo $site->id ?></td> |
| @@ -81,23 +157,22 @@ | ||
| 81 | 157 | <td><?php echo $site->id ?></td> |
| 82 | 158 | <!--/ ID --> |
| 83 | 159 | |
| 84 | 160 | <!-- Version --> |
| 85 | - <td><?php echo $fs_addon->get_plugin_version() ?></td> | |
| 161 | + <td><?php echo $version ?></td> | |
| 86 | 162 | <!--/ Version --> |
| 87 | 163 | |
| 88 | 164 | <!-- Plan Title --> |
| 89 | - <td><?php echo strtoupper( is_string( $plan->name ) ? $plan->title : $free_text ) ?></td> | |
| 165 | + <td><?php echo strtoupper( is_string( $plan_name ) ? $plan_title : $free_text ) ?></td> | |
| 90 | 166 | <!--/ Plan Title --> |
| 91 | 167 | |
| 92 | - <?php if ( $fs_addon->is_trial() || is_object( $license ) ) : ?> | |
| 93 | - | |
| 94 | 168 | <!-- Expiration --> |
| 95 | 169 | <td> |
| 170 | + <?php if ( $site->is_trial() || is_object( $license ) ) : ?> | |
| 96 | 171 | <?php |
| 97 | 172 | $tags = array(); |
| 98 | 173 | |
| 99 | - if ( $fs_addon->is_trial() ) { | |
| 174 | + if ( $site->is_trial() ) { | |
| 100 | 175 | $tags[] = array( 'label' => $trial_text, 'type' => 'success' ); |
| 101 | 176 | |
| 102 | 177 | $tags[] = array( |
| 103 | 178 | 'label' => sprintf( |
| @@ -142,91 +217,106 @@ | ||
| 142 | 217 | foreach ( $tags as $t ) { |
| 143 | 218 | printf( '<label class="fs-tag fs-%s">%s</label>' . "\n", $t['type'], $t['label'] ); |
| 144 | 219 | } |
| 145 | 220 | ?> |
| 221 | + <?php endif ?> | |
| 146 | 222 | </td> |
| 147 | 223 | <!--/ Expiration --> |
| 148 | 224 | |
| 149 | - <?php endif ?> | |
| 150 | - | |
| 151 | 225 | <?php |
| 152 | 226 | $buttons = array(); |
| 227 | + $is_license_activation_added = false; | |
| 228 | + | |
| 153 | 229 | if ( $is_addon_activated ) { |
| 154 | - if ( $is_paying ) { | |
| 155 | - $buttons[] = fs_ui_get_action_button( | |
| 156 | - $fs->get_id(), | |
| 157 | - 'account', | |
| 158 | - 'deactivate_license', | |
| 159 | - fs_text_inline( 'Deactivate License', 'deactivate-license', $slug ), | |
| 160 | - '', | |
| 161 | - array( 'plugin_id' => $addon_id ), | |
| 162 | - false | |
| 163 | - ); | |
| 230 | + if ( ! $is_whitelabeled ) { | |
| 231 | + if ( $is_paying ) { | |
| 232 | + $buttons[] = fs_ui_get_action_button( | |
| 233 | + $fs->get_id(), | |
| 234 | + 'account', | |
| 235 | + 'deactivate_license', | |
| 236 | + fs_text_inline( 'Deactivate License', 'deactivate-license', $slug ), | |
| 237 | + '', | |
| 238 | + array( 'plugin_id' => $addon_id ), | |
| 239 | + false, | |
| 240 | + true | |
| 241 | + ); | |
| 164 | 242 | |
| 165 | - $human_readable_license_expiration = human_time_diff( time(), strtotime( $license->expiration ) ); | |
| 166 | - $downgrade_confirmation_message = sprintf( | |
| 167 | - $downgrade_x_confirm_text, | |
| 168 | - ( $fs_addon->is_only_premium() ? $cancelling_subscription_text : $downgrading_plan_text ), | |
| 169 | - $plan->title, | |
| 170 | - $human_readable_license_expiration | |
| 171 | - ); | |
| 243 | + $after_downgrade_message = ! $license->is_block_features ? | |
| 244 | + sprintf( $after_downgrade_non_blocking_text, $plan->title, $fs_addon->get_module_label( true ) ) : | |
| 245 | + sprintf( $after_downgrade_blocking_text, $plan->title ); | |
| 172 | 246 | |
| 173 | - $after_downgrade_message = ! $license->is_block_features ? | |
| 174 | - sprintf( $after_downgrade_non_blocking_text, $plan->title, $fs_addon->get_module_label( true ) ) : | |
| 175 | - sprintf( $after_downgrade_blocking_text, $plan->title ); | |
| 247 | + if ( ! $license->is_lifetime() && $is_active_subscription ) { | |
| 248 | + $human_readable_license_expiration = human_time_diff( time(), strtotime( $license->expiration ) ); | |
| 249 | + $downgrade_confirmation_message = sprintf( | |
| 250 | + $downgrade_x_confirm_text, | |
| 251 | + ( $fs_addon->is_only_premium() ? $cancelling_subscription_text : $downgrading_plan_text ), | |
| 252 | + $plan->title, | |
| 253 | + $human_readable_license_expiration | |
| 254 | + ); | |
| 176 | 255 | |
| 177 | - if ( ! $license->is_lifetime() && $is_active_subscription ) { | |
| 256 | + $buttons[] = fs_ui_get_action_button( | |
| 257 | + $fs->get_id(), | |
| 258 | + 'account', | |
| 259 | + 'downgrade_account', | |
| 260 | + esc_html( $fs_addon->is_only_premium() ? fs_text_inline( 'Cancel Subscription', 'cancel-subscription', $slug ) : $downgrade_text ), | |
| 261 | + '', | |
| 262 | + array( 'plugin_id' => $addon_id ), | |
| 263 | + false, | |
| 264 | + false, | |
| 265 | + false, | |
| 266 | + ( $downgrade_confirmation_message . ' ' . $after_downgrade_message . ' ' . $prices_increase_text ), | |
| 267 | + 'POST' | |
| 268 | + ); | |
| 269 | + } | |
| 270 | + } else if ( $is_paid_trial ) { | |
| 178 | 271 | $buttons[] = fs_ui_get_action_button( |
| 179 | 272 | $fs->get_id(), |
| 180 | 273 | 'account', |
| 181 | - 'downgrade_account', | |
| 182 | - esc_html( $fs_addon->is_only_premium() ? fs_text_inline( 'Cancel Subscription', 'cancel-subscription', $slug ) : $downgrade_text ), | |
| 274 | + 'cancel_trial', | |
| 275 | + esc_html( $cancel_trial_text ), | |
| 183 | 276 | '', |
| 184 | 277 | array( 'plugin_id' => $addon_id ), |
| 185 | 278 | false, |
| 186 | 279 | false, |
| 187 | - false, | |
| 188 | - ( $downgrade_confirmation_message . ' ' . $after_downgrade_message . ' ' . $prices_increase_text ), | |
| 280 | + 'dashicons dashicons-download', | |
| 281 | + $cancel_trial_confirm_text, | |
| 189 | 282 | 'POST' |
| 190 | 283 | ); |
| 191 | - } | |
| 192 | - } else if ( $is_paid_trial ) { | |
| 193 | - $buttons[] = fs_ui_get_action_button( | |
| 194 | - $fs->get_id(), | |
| 195 | - 'account', | |
| 196 | - 'cancel_trial', | |
| 197 | - esc_html( $cancel_trial_text ), | |
| 198 | - '', | |
| 199 | - array( 'plugin_id' => $addon_id ), | |
| 200 | - false, | |
| 201 | - false, | |
| 202 | - 'dashicons dashicons-download', | |
| 203 | - $cancel_trial_confirm_text, | |
| 204 | - 'POST' | |
| 205 | - ); | |
| 206 | - } else { | |
| 207 | - $premium_license = $fs_addon->_get_available_premium_license(); | |
| 284 | + } else if ( ! $has_feature_enabled_license ) { | |
| 285 | + $premium_licenses = $fs_addon->get_available_premium_licenses(); | |
| 208 | 286 | |
| 209 | - if ( is_object( $premium_license ) ) { | |
| 210 | - $premium_plan = $fs_addon->_get_plan_by_id( $premium_license->plan_id ); | |
| 211 | - $site = $fs_addon->get_site(); | |
| 287 | + if ( ! empty( $premium_licenses ) ) { | |
| 288 | + $premium_license = $premium_licenses[0]; | |
| 289 | + $has_multiple_premium_licenses = ( 1 < count( $premium_licenses ) ); | |
| 212 | 290 | |
| 213 | - $buttons[] = fs_ui_get_action_button( | |
| 214 | - $fs->get_id(), | |
| 215 | - 'account', | |
| 216 | - 'activate_license', | |
| 217 | - esc_html( sprintf( $activate_plan_text, $premium_plan->title, ( $site->is_localhost() && $premium_license->is_free_localhost ) ? '[localhost]' : ( 1 < $premium_license->left() ? $premium_license->left() . ' left' : '' ) ) ), | |
| 218 | - '', | |
| 219 | - array( | |
| 220 | - 'plugin_id' => $addon_id, | |
| 221 | - 'license_id' => $premium_license->id, | |
| 222 | - ) | |
| 223 | - ); | |
| 291 | + if ( ! $has_multiple_premium_licenses ) { | |
| 292 | + $premium_plan = $fs_addon->_get_plan_by_id( $premium_license->plan_id ); | |
| 293 | + $site = $fs_addon->get_site(); | |
| 294 | + | |
| 295 | + $buttons[] = fs_ui_get_action_button( | |
| 296 | + $fs->get_id(), | |
| 297 | + 'account', | |
| 298 | + 'activate_license', | |
| 299 | + esc_html( sprintf( $activate_plan_text, $premium_plan->title, ( $site->is_localhost() && $premium_license->is_free_localhost ) ? '[localhost]' : ( 1 < $premium_license->left() ? $premium_license->left() . ' left' : '' ) ) ), | |
| 300 | + ($has_multiple_premium_licenses ? | |
| 301 | + 'activate-license-trigger ' . $fs_addon->get_unique_affix() : | |
| 302 | + ''), | |
| 303 | + array( | |
| 304 | + 'plugin_id' => $addon_id, | |
| 305 | + 'license_id' => $premium_license->id, | |
| 306 | + ), | |
| 307 | + true, | |
| 308 | + true | |
| 309 | + ); | |
| 310 | + | |
| 311 | + $is_license_activation_added = true; | |
| 312 | + } | |
| 313 | + } | |
| 224 | 314 | } |
| 225 | 315 | } |
| 226 | 316 | |
| 227 | - if ( 0 == count( $buttons ) ) { | |
| 228 | - if ( $show_upgrade && $fs_addon->is_premium() ) { | |
| 317 | +// if ( 0 == count( $buttons ) ) { | |
| 318 | + if ( $fs_addon->is_premium() && ! $is_license_activation_added ) { | |
| 229 | 319 | $fs_addon->_add_license_activation_dialog_box(); |
| 230 | 320 | |
| 231 | 321 | $buttons[] = fs_ui_get_action_button( |
| 232 | 322 | $fs->get_id(), |
| @@ -231,50 +321,58 @@ | ||
| 231 | 321 | $buttons[] = fs_ui_get_action_button( |
| 232 | 322 | $fs->get_id(), |
| 233 | 323 | 'account', |
| 234 | 324 | 'activate_license', |
| 235 | - fs_esc_html_inline( 'Activate License', 'activate-license', $slug ), | |
| 325 | + ( ! $has_feature_enabled_license ) ? | |
| 326 | + fs_esc_html_inline( 'Activate License', 'activate-license', $slug ) : | |
| 327 | + fs_esc_html_inline( 'Change License', 'change-license', $slug ), | |
| 236 | 328 | 'activate-license-trigger ' . $fs_addon->get_unique_affix(), |
| 237 | 329 | array( |
| 238 | 330 | 'plugin_id' => $addon_id, |
| 239 | 331 | ), |
| 332 | + (! $has_feature_enabled_license), | |
| 333 | + true | |
| 334 | + ); | |
| 335 | + | |
| 336 | + $is_license_activation_added = true; | |
| 337 | + } | |
| 338 | + | |
| 339 | + if ( $fs_addon->has_paid_plan() ) { | |
| 340 | + // Add sync license only if non of the other CTAs are visible. | |
| 341 | + $buttons[] = fs_ui_get_action_button( | |
| 342 | + $fs->get_id(), | |
| 343 | + 'account', | |
| 344 | + $fs->get_unique_affix() . '_sync_license', | |
| 345 | + fs_esc_html_x_inline( 'Sync', 'as synchronize', 'sync', $slug ), | |
| 346 | + '', | |
| 347 | + array( 'plugin_id' => $addon_id ), | |
| 240 | 348 | false, |
| 241 | 349 | true |
| 242 | 350 | ); |
| 243 | 351 | } |
| 244 | - | |
| 245 | - // Add sync license only if non of the other CTAs are visible. | |
| 246 | - $buttons[] = fs_ui_get_action_button( | |
| 247 | - $fs->get_id(), | |
| 248 | - 'account', | |
| 249 | - $fs->get_unique_affix() . '_sync_license', | |
| 250 | - esc_html( $sync_license_text ), | |
| 251 | - '', | |
| 252 | - array( 'plugin_id' => $addon_id ), | |
| 253 | - false, | |
| 254 | - true | |
| 255 | - ); | |
| 256 | - | |
| 257 | - } | |
| 352 | +// } | |
| 258 | 353 | } else if ( ! $show_upgrade ) { |
| 259 | 354 | if ( $fs->is_addon_installed( $addon_id ) ) { |
| 260 | 355 | $addon_file = $fs->get_addon_basename( $addon_id ); |
| 261 | - $buttons[] = sprintf( | |
| 262 | - '<a class="button button-primary edit" href="%s" title="%s">%s</a>', | |
| 263 | - wp_nonce_url( 'plugins.php?action=activate&plugin=' . $addon_file, 'activate-plugin_' . $addon_file ), | |
| 264 | - fs_esc_attr_inline( 'Activate this add-on', 'activate-this-addon', $slug ), | |
| 265 | - $activate_text | |
| 266 | - ); | |
| 356 | + | |
| 357 | + if ( ! isset( $active_plugins_directories_map[ dirname( $addon_file ) ] ) ) { | |
| 358 | + $buttons[] = sprintf( | |
| 359 | + '<a class="button button-primary edit" href="%s" title="%s">%s</a>', | |
| 360 | + wp_nonce_url( 'plugins.php?action=activate&plugin=' . $addon_file, 'activate-plugin_' . $addon_file ), | |
| 361 | + fs_esc_attr_inline( 'Activate this add-on', 'activate-this-addon', $slug ), | |
| 362 | + $activate_text | |
| 363 | + ); | |
| 364 | + } | |
| 267 | 365 | } else { |
| 268 | 366 | if ( $fs->is_allowed_to_install() ) { |
| 269 | 367 | $buttons[] = sprintf( |
| 270 | 368 | '<a class="button button-primary edit" href="%s">%s</a>', |
| 271 | - wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $addon->slug ), 'install-plugin_' . $addon->slug ), | |
| 369 | + wp_nonce_url( self_admin_url( 'update.php?' . ( ( isset( $addon_info['has_paid_plan'] ) && $addon_info['has_paid_plan'] ) ? 'fs_allow_updater_and_dialog=true&' : '' ) . 'action=install-plugin&plugin=' . $addon_info['slug'] ), 'install-plugin_' . $addon_info['slug'] ), | |
| 272 | 370 | fs_text_inline( 'Install Now', 'install-now', $slug ) |
| 273 | 371 | ); |
| 274 | 372 | } else { |
| 275 | 373 | $buttons[] = sprintf( |
| 276 | - '<a target="_blank" class="button button-primary edit" href="%s">%s</a>', | |
| 374 | + '<a target="_blank" rel="noopener" class="button button-primary edit" href="%s">%s</a>', | |
| 277 | 375 | $fs->_get_latest_download_local_url( $addon_id ), |
| 278 | 376 | esc_html( $download_latest_text ) |
| 279 | 377 | ); |
| 280 | 378 | } |
| @@ -282,12 +380,12 @@ | ||
| 282 | 380 | } |
| 283 | 381 | |
| 284 | 382 | if ( $show_upgrade ) { |
| 285 | 383 | $buttons[] = sprintf( '<a href="%s" class="thickbox button button-small button-primary" aria-label="%s" data-title="%s"><i class="dashicons dashicons-cart"></i> %s</a>', |
| 286 | - esc_url( network_admin_url( 'plugin-install.php?fs_allow_updater_and_dialog=true&tab=plugin-information&parent_plugin_id=' . $fs->get_id() . '&plugin=' . $addon->slug . | |
| 384 | + esc_url( network_admin_url( 'plugin-install.php?fs_allow_updater_and_dialog=true' . ( ! empty( $fs_blog_id ) ? '&fs_blog_id=' . $fs_blog_id : '' ) . '&tab=plugin-information&parent_plugin_id=' . $fs->get_id() . '&plugin=' . $addon_info['slug'] . | |
| 287 | 385 | '&TB_iframe=true&width=600&height=550' ) ), |
| 288 | - esc_attr( sprintf( fs_text_inline( 'More information about %s', 'more-information-about-x', $slug ), $addon->title ) ), | |
| 289 | - esc_attr( $addon->title ), | |
| 386 | + esc_attr( sprintf( fs_text_inline( 'More information about %s', 'more-information-about-x', $slug ), $addon_info['title'] ) ), | |
| 387 | + esc_attr( $addon_info['title'] ), | |
| 290 | 388 | ( $fs_addon->has_free_plan() ? |
| 291 | 389 | $upgrade_text : |
| 292 | 390 | fs_text_x_inline( 'Purchase', 'verb', 'purchase', $slug ) ) |
| 293 | 391 | ); |
| @@ -306,23 +404,26 @@ | ||
| 306 | 404 | <!--/ Actions --> |
| 307 | 405 | |
| 308 | 406 | <?php else : ?> |
| 309 | 407 | <?php // Add-on NOT Installed or was never connected. |
| 408 | + $is_addon_installed_by_filesystem = $fs->is_addon_installed( $addon_id ); | |
| 310 | 409 | ?> |
| 311 | 410 | <!-- Action --> |
| 312 | - <td colspan="4"> | |
| 313 | - <?php if ( $fs->is_addon_installed( $addon_id ) ) : ?> | |
| 411 | + <td colspan="<?php echo ( $is_addon_installed_by_filesystem || $show_delete_install_button ) ? '5' : '4' ?>"> | |
| 412 | + <?php if ( $is_addon_installed_by_filesystem ) : ?> | |
| 314 | 413 | <?php $addon_file = $fs->get_addon_basename( $addon_id ) ?> |
| 414 | + <?php if ( ! isset( $active_plugins_directories_map[ dirname( $addon_file ) ] ) ) : ?> | |
| 315 | 415 | <a class="button button-primary" |
| 316 | 416 | href="<?php echo wp_nonce_url( 'plugins.php?action=activate&plugin=' . $addon_file, 'activate-plugin_' . $addon_file ) ?>" |
| 317 | 417 | title="<?php fs_esc_attr_echo_inline( 'Activate this add-on', 'activate-this-addon', $slug ) ?>" |
| 318 | 418 | class="edit"><?php echo esc_html( $activate_text ) ?></a> |
| 419 | + <?php endif ?> | |
| 319 | 420 | <?php else : ?> |
| 320 | 421 | <?php if ( $fs->is_allowed_to_install() ) : ?> |
| 321 | 422 | <a class="button button-primary" |
| 322 | - href="<?php echo wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $addon->slug ), 'install-plugin_' . $addon->slug ) ?>"><?php fs_esc_html_echo_inline( 'Install Now', 'install-now', $slug ) ?></a> | |
| 423 | + href="<?php echo wp_nonce_url( self_admin_url( 'update.php?' . ( ( isset( $addon_info['has_paid_plan'] ) && $addon_info['has_paid_plan'] ) ? 'fs_allow_updater_and_dialog=true&' : '' ) . 'action=install-plugin&plugin=' . $addon_info['slug'] ), 'install-plugin_' . $addon_info['slug'] ) ?>"><?php fs_esc_html_echo_inline( 'Install Now', 'install-now', $slug ) ?></a> | |
| 323 | 424 | <?php else : ?> |
| 324 | - <a target="_blank" class="button button-primary" | |
| 425 | + <a target="_blank" rel="noopener" class="button button-primary" | |
| 325 | 426 | href="<?php echo $fs->_get_latest_download_local_url( $addon_id ) ?>"><?php echo esc_html( $download_latest_text ) ?></a> |
| 326 | 427 | <?php endif ?> |
| 327 | 428 | <?php endif ?> |
| 328 | 429 | </td> |
| @@ -327,10 +428,10 @@ | ||
| 327 | 428 | <?php endif ?> |
| 328 | 429 | </td> |
| 329 | 430 | <!--/ Action --> |
| 330 | 431 | <?php endif ?> |
| 331 | - <?php if ( ! $is_paying && WP_FS__DEV_MODE ) : ?> | |
| 332 | - <!-- Optional Delete Action --> | |
| 432 | + <?php if ( $show_delete_install_button ) : ?> | |
| 433 | + <!-- Optional Delete Action --> | |
| 333 | 434 | <td> |
| 334 | 435 | <?php |
| 335 | 436 | if ( $is_addon_activated ) { |
| 336 | 437 | fs_ui_action_button( |
| @@ -346,5 +447,5 @@ | ||
| 346 | 447 | ?> |
| 347 | 448 | </td> |
| 348 | 449 | <!--/ Optional Delete Action --> |
| 349 | 450 | <?php endif ?> |
| 350 | -</tr> | |
| 451 | +</tr> | |