| 1 |
<?php |
| 2 |
namespace Elementor\Modules\History; |
| 3 |
|
| 4 |
use Elementor\Core\Base\Module as BaseModule; |
| 5 |
use Elementor\Plugin; |
| 6 |
|
| 7 |
if ( ! defined( 'ABSPATH' ) ) { |
| 8 |
exit; // Exit if accessed directly. |
| 9 |
} |
| 10 |
|
| 11 |
/** |
| 12 |
* Elementor history module. |
| 13 |
* |
| 14 |
* Elementor history module handler class is responsible for registering and |
| 15 |
* managing Elementor history modules. |
| 16 |
* |
| 17 |
* @since 1.7.0 |
| 18 |
*/ |
| 19 |
class Module extends BaseModule { |
| 20 |
|
| 21 |
/** |
| 22 |
* Get module name. |
| 23 |
* |
| 24 |
* Retrieve the history module name. |
| 25 |
* |
| 26 |
* @since 1.7.0 |
| 27 |
* @access public |
| 28 |
* |
| 29 |
* @return string Module name. |
| 30 |
*/ |
| 31 |
public function get_name() { |
| 32 |
return 'history'; |
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* Localize settings. |
| 37 |
* |
| 38 |
* Add new localized settings for the history module. |
| 39 |
* |
| 40 |
* Fired by `elementor/editor/localize_settings` filter. |
| 41 |
* |
| 42 |
* @since 1.7.0 |
| 43 |
* @access public |
| 44 |
* |
| 45 |
* @param array $settings Localized settings. |
| 46 |
* |
| 47 |
* @return array Localized settings. |
| 48 |
*/ |
| 49 |
public function localize_settings( $settings ) { |
| 50 |
$settings = array_replace_recursive( $settings, [ |
| 51 |
'i18n' => [ |
| 52 |
'history' => __( 'History', 'elementor' ), |
| 53 |
'template' => __( 'Template', 'elementor' ), |
| 54 |
'added' => __( 'Added', 'elementor' ), |
| 55 |
'removed' => __( 'Removed', 'elementor' ), |
| 56 |
'edited' => __( 'Edited', 'elementor' ), |
| 57 |
'moved' => __( 'Moved', 'elementor' ), |
| 58 |
'pasted' => __( 'Pasted', 'elementor' ), |
| 59 |
'editing_started' => __( 'Editing Started', 'elementor' ), |
| 60 |
'style_pasted' => __( 'Style Pasted', 'elementor' ), |
| 61 |
'style_reset' => __( 'Style Reset', 'elementor' ), |
| 62 |
'settings_reset' => __( 'Settings Reset', 'elementor' ), |
| 63 |
'enabled' => __( 'Enabled', 'elementor' ), |
| 64 |
'disabled' => __( 'Disabled', 'elementor' ), |
| 65 |
'all_content' => __( 'All Content', 'elementor' ), |
| 66 |
'elements' => __( 'Elements', 'elementor' ), |
| 67 |
], |
| 68 |
] ); |
| 69 |
|
| 70 |
return $settings; |
| 71 |
} |
| 72 |
|
| 73 |
/** |
| 74 |
* @since 2.3.0 |
| 75 |
* @access public |
| 76 |
*/ |
| 77 |
public function add_templates() { |
| 78 |
Plugin::$instance->common->add_template( __DIR__ . '/views/history-panel-template.php' ); |
| 79 |
Plugin::$instance->common->add_template( __DIR__ . '/views/revisions-panel-template.php' ); |
| 80 |
} |
| 81 |
|
| 82 |
/** |
| 83 |
* History module constructor. |
| 84 |
* |
| 85 |
* Initializing Elementor history module. |
| 86 |
* |
| 87 |
* @since 1.7.0 |
| 88 |
* @access public |
| 89 |
*/ |
| 90 |
public function __construct() { |
| 91 |
add_filter( 'elementor/editor/localize_settings', [ $this, 'localize_settings' ] ); |
| 92 |
|
| 93 |
add_action( 'elementor/editor/init', [ $this, 'add_templates' ] ); |
| 94 |
} |
| 95 |
} |
| 96 |
|