| @@ -138,12 +138,38 @@ | ||
| 138 | 138 | } |
| 139 | 139 | $install = get_option( $this->get_key() . '_install', 0 ); |
| 140 | 140 | if ( 0 === $install ) { |
| 141 | 141 | $install = time(); |
| 142 | + /** | |
| 143 | + * Action to be triggered when the product is first activated. | |
| 144 | + * | |
| 145 | + * @param string $basefile The basefile of the product. | |
| 146 | + */ | |
| 147 | + do_action( 'themeisle_sdk_first_activation', $basefile ); | |
| 148 | + | |
| 142 | 149 | update_option( $this->get_key() . '_install', time() ); |
| 143 | 150 | } |
| 144 | 151 | $this->install = $install; |
| 145 | 152 | self::$cached_products[ crc32( $basefile ) ] = $this; |
| 153 | + $current_version = get_option( $this->slug . '_version', '' ); | |
| 154 | + | |
| 155 | + if ( $current_version !== $this->version && wp_cache_get( "{$this->slug}_version_upgrade" ) === false ) { | |
| 156 | + // Set the cache lock to avoid multiple calls. | |
| 157 | + wp_cache_set( "{$this->slug}_version_upgrade", true, HOUR_IN_SECONDS ); | |
| 158 | + /** | |
| 159 | + * Action to be triggered when the product is updated. | |
| 160 | + * | |
| 161 | + * @param string $current_version The current version of the product. | |
| 162 | + * @param string $new_version The new version of the product. | |
| 163 | + * @param string $basefile The basefile of the product. | |
| 164 | + */ | |
| 165 | + do_action( "themeisle_sdk_update_{$this->slug}", $current_version, $this->version, $basefile ); | |
| 166 | + | |
| 167 | + // Update the version of the product. | |
| 168 | + update_option( "{$this->slug}_version", $this->version ); | |
| 169 | + // Delete the cache lock. | |
| 170 | + wp_cache_delete( "{$this->slug}_version_upgrade" ); | |
| 171 | + } | |
| 146 | 172 | } |
| 147 | 173 | |
| 148 | 174 | /** |
| 149 | 175 | * Return a product. |
| @@ -345,9 +371,19 @@ | ||
| 345 | 371 | * |
| 346 | 372 | * @return string Friendly name. |
| 347 | 373 | */ |
| 348 | 374 | public function get_friendly_name() { |
| 349 | - $name = apply_filters( $this->get_key() . '_friendly_name', trim( str_replace( 'Lite', '', $this->get_name() ) ) ); | |
| 375 | + $name = trim( str_replace( 'Lite', '', $this->get_name() ) ); | |
| 376 | + if ( defined( 'OTTER_BLOCKS_BASEFILE' ) && OTTER_BLOCKS_BASEFILE === $this->basefile ) { | |
| 377 | + $name = 'Otter Blocks'; | |
| 378 | + } | |
| 379 | + if ( defined( 'OPTML_BASEFILE' ) && OPTML_BASEFILE === $this->basefile ) { | |
| 380 | + $name = 'Optimole'; | |
| 381 | + } | |
| 382 | + if ( defined( 'WPMM_FILE' ) && WPMM_FILE === $this->basefile ) { | |
| 383 | + $name = 'LightStart'; | |
| 384 | + } | |
| 385 | + $name = apply_filters( $this->get_key() . '_friendly_name', $name ); | |
| 350 | 386 | $name = rtrim( $name, '- ()' ); |
| 351 | 387 | |
| 352 | 388 | return $name; |
| 353 | 389 | } |
| @@ -411,8 +447,9 @@ | ||
| 411 | 447 | return add_query_arg( |
| 412 | 448 | [ |
| 413 | 449 | 'name' => rawurlencode( $this->get_name() ), |
| 414 | 450 | 'edd_action' => 'view_changelog', |
| 451 | + 'locale' => get_user_locale(), | |
| 415 | 452 | ], |
| 416 | 453 | $this->get_store_url() |
| 417 | 454 | ); |
| 418 | 455 | } |