| 1 |
<?php |
| 2 |
namespace Elementor\Core\Editor; |
| 3 |
|
| 4 |
use Elementor\Core\Utils\Promotions\Filtered_Promotions_Manager; |
| 5 |
use Elementor\Utils; |
| 6 |
|
| 7 |
if ( ! defined( 'ABSPATH' ) ) { |
| 8 |
exit; // Exit if accessed directly. |
| 9 |
} |
| 10 |
|
| 11 |
class Promotion { |
| 12 |
|
| 13 |
/** |
| 14 |
* @return array |
| 15 |
*/ |
| 16 |
public function get_elements_promotion() { |
| 17 |
return Filtered_Promotions_Manager::get_filtered_promotion_data( |
| 18 |
$this->get_promotion_data(), |
| 19 |
'elementor/editor/promotion/get_elements_promotion', |
| 20 |
'action_button', |
| 21 |
'url' |
| 22 |
); |
| 23 |
} |
| 24 |
|
| 25 |
/** |
| 26 |
* @return array |
| 27 |
*/ |
| 28 |
private function get_action_button_content(): array { |
| 29 |
$has_pro = Utils::has_pro(); |
| 30 |
return $has_pro ? [ |
| 31 |
'text' => __( 'Connect & Activate', 'elementor' ), |
| 32 |
'url' => admin_url( 'admin.php?page=elementor-license' ), |
| 33 |
] : [ |
| 34 |
'text' => __( 'Upgrade Now', 'elementor' ), |
| 35 |
'url' => 'https://go.elementor.com/go-pro-%s', |
| 36 |
]; |
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* @return string |
| 41 |
*/ |
| 42 |
private function get_promotion_url(): string { |
| 43 |
return Utils::has_pro() |
| 44 |
? admin_url( 'admin.php?page=elementor-license' ) |
| 45 |
: 'https://go.elementor.com/go-pro-%s'; |
| 46 |
} |
| 47 |
|
| 48 |
/** |
| 49 |
* @return array |
| 50 |
*/ |
| 51 |
private function get_promotion_data(): array { |
| 52 |
return [ |
| 53 |
/* translators: %s: Widget title. */ |
| 54 |
'title' => __( '%s Widget', 'elementor' ), |
| 55 |
/* translators: %s: Widget title. */ |
| 56 |
'content' => __( |
| 57 |
'Use %s widget and dozens more pro features to extend your toolbox and build sites faster and better.', |
| 58 |
'elementor' |
| 59 |
), |
| 60 |
'action_button' => $this->get_action_button_content(), |
| 61 |
]; |
| 62 |
} |
| 63 |
} |
| 64 |
|