| 1 |
<?php |
| 2 |
|
| 3 |
namespace MasterAddons\Inc\Classes\Notifications; |
| 4 |
|
| 5 |
defined('ABSPATH') || exit; |
| 6 |
|
| 7 |
use MasterAddons\Inc\Classes\Notifications\Model\Notice; |
| 8 |
|
| 9 |
if (!class_exists('Latest_Updates')) { |
| 10 |
/** |
| 11 |
* Latest Plugin Updates Notice Class |
| 12 |
* |
| 13 |
* Jewel Theme <[email protected]> |
| 14 |
*/ |
| 15 |
class Latest_Updates extends Notice |
| 16 |
{ |
| 17 |
|
| 18 |
public $color = 'info'; |
| 19 |
private $version_option_key = 'jltma_latest_updates_notice_version'; |
| 20 |
|
| 21 |
/** |
| 22 |
* Latest Updates Notice |
| 23 |
* |
| 24 |
* @return void |
| 25 |
*/ |
| 26 |
public function __construct() |
| 27 |
{ |
| 28 |
$this->maybe_reset_for_new_version(); |
| 29 |
parent::__construct(); |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* Reset notice data when plugin version changes so the notice |
| 34 |
* re-appears after every update. |
| 35 |
* |
| 36 |
* @return void |
| 37 |
*/ |
| 38 |
private function maybe_reset_for_new_version() |
| 39 |
{ |
| 40 |
if (!defined('JLTMA_VER')) { |
| 41 |
return; |
| 42 |
} |
| 43 |
|
| 44 |
$stored_version = get_option($this->version_option_key); |
| 45 |
|
| 46 |
if ($stored_version === JLTMA_VER) { |
| 47 |
return; |
| 48 |
} |
| 49 |
|
| 50 |
// Version changed — delete old notice data so init() rebuilds it fresh. |
| 51 |
delete_option('jltma_notice_' . strtolower((new \ReflectionClass($this))->getShortName())); |
| 52 |
update_option($this->version_option_key, JLTMA_VER); |
| 53 |
} |
| 54 |
|
| 55 |
|
| 56 |
/** |
| 57 |
* Notice Content |
| 58 |
* |
| 59 |
* @author Jewel Theme <[email protected]> |
| 60 |
*/ |
| 61 |
public function notice_content() |
| 62 |
{ |
| 63 |
$jltma_changelog_message = sprintf( |
| 64 |
/* translators: 1: URL to changelogs page, 2: Link text for changelogs, 3: Plugin name and version heading HTML, 4: First changelog item HTML, 5: Second changelog item HTML */ |
| 65 |
__('%3$s %4$s <br> <strong>Check Changelogs for </strong> <a href="%1$s" target="__blank">%2$s</a>', 'master-addons'), |
| 66 |
esc_url_raw('https://master-addons.com/changelogs'), |
| 67 |
__('More Details', 'master-addons'), |
| 68 |
/** Changelog Items |
| 69 |
* Starts from: %3$s |
| 70 |
*/ |
| 71 |
|
| 72 |
'<h3 class="jltma-update-head">' . JLTMA . ' <span><small><em>v' . esc_html(JLTMA_VER) . '</em></small>' . __(' has some updates..', 'master-addons') . '</span></h3><br>', // %3$s |
| 73 |
// Changelogs |
| 74 |
__('<span class="dashicons dashicons-yes"></span> <span class="jltma-changes-list"> Security: Security update. </span><br>', 'master-addons') |
| 75 |
. __('<span class="dashicons dashicons-yes"></span> <span class="jltma-changes-list">Changed: Custom CSS Pro to Free. </span><br>', 'master-addons') |
| 76 |
); |
| 77 |
printf(wp_kses_post($jltma_changelog_message)); |
| 78 |
} |
| 79 |
|
| 80 |
/** |
| 81 |
* Intervals |
| 82 |
* |
| 83 |
* @author Jewel Theme <[email protected]> |
| 84 |
*/ |
| 85 |
public function intervals() |
| 86 |
{ |
| 87 |
return array(0); |
| 88 |
} |
| 89 |
} |
| 90 |
} |
| 91 |
|