| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Beyondwords\Wordpress\Compatibility\Elementor\ControlsSections; |
| 6 |
|
| 7 |
use Elementor\Controls_Manager; |
| 8 |
use Elementor\Core\DocumentTypes\PageBase as PageBase; |
| 9 |
|
| 10 |
use WP_Post; |
| 11 |
|
| 12 |
/** |
| 13 |
* Help Controls Section |
| 14 |
* |
| 15 |
* @codeCoverageIgnore |
| 16 |
* |
| 17 |
* @since 3.10.0 |
| 18 |
*/ |
| 19 |
class Help |
| 20 |
{ |
| 21 |
/** |
| 22 |
* Register additional document controls. |
| 23 |
* |
| 24 |
* @todo replace with `$post = get_post();` with `$document->get_post();`? |
| 25 |
* |
| 26 |
* @param PageBase $document The PageBase document. |
| 27 |
* @param string $tab The Elementor tab. |
| 28 |
*/ |
| 29 |
public static function registerControls(&$document, $tab) |
| 30 |
{ |
| 31 |
// PageBase is the base class for documents like `post` `page` and etc. |
| 32 |
if (! $document instanceof PageBase || ! $document::get_property('has_elements')) { |
| 33 |
return; |
| 34 |
} |
| 35 |
|
| 36 |
$post = get_post(); |
| 37 |
|
| 38 |
if (!($post instanceof \WP_Post)) { |
| 39 |
return; |
| 40 |
} |
| 41 |
|
| 42 |
$document->start_controls_section( |
| 43 |
'beyondwords_help_section', |
| 44 |
[ |
| 45 |
'label' => __('Help', 'speechkit'), |
| 46 |
'tab' => $tab, |
| 47 |
] |
| 48 |
); |
| 49 |
|
| 50 |
$document->add_control( |
| 51 |
'beyondwords_help_guide', |
| 52 |
[ |
| 53 |
'text' => __('Setup guide', 'speechkit'), |
| 54 |
'type' => Controls_Manager::BUTTON, |
| 55 |
'label_block' => true, |
| 56 |
'label' => __('For setup instructions, troubleshooting, and FAQs, see our BeyondWords for WordPress guide.', 'speechkit'), // phpcs:ignore Generic.Files.LineLength.TooLong |
| 57 |
'event' => 'beyondwords:open-guide' |
| 58 |
] |
| 59 |
); |
| 60 |
|
| 61 |
$document->add_control( |
| 62 |
'beyondwords_help_email', |
| 63 |
[ |
| 64 |
'text' => __('Email BeyondWords', 'speechkit'), |
| 65 |
'type' => Controls_Manager::BUTTON, |
| 66 |
'separator' => 'before', |
| 67 |
'label_block' => true, |
| 68 |
'label' => __('Need help? Email our support team.', 'speechkit'), |
| 69 |
'event' => 'beyondwords:email-support' |
| 70 |
] |
| 71 |
); |
| 72 |
|
| 73 |
$document->end_controls_section(); |
| 74 |
} |
| 75 |
} |
| 76 |
|