module.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace Elementor\Modules\Library;
  3. use Elementor\Core\Base\Module as BaseModule;
  4. use Elementor\Modules\Library\Documents;
  5. use Elementor\Plugin;
  6. if ( ! defined( 'ABSPATH' ) ) {
  7. exit; // Exit if accessed directly.
  8. }
  9. /**
  10. * Elementor library module.
  11. *
  12. * Elementor library module handler class is responsible for registering and
  13. * managing Elementor library modules.
  14. *
  15. * @since 2.0.0
  16. */
  17. class Module extends BaseModule {
  18. /**
  19. * Get module name.
  20. *
  21. * Retrieve the library module name.
  22. *
  23. * @since 2.0.0
  24. * @access public
  25. *
  26. * @return string Module name.
  27. */
  28. public function get_name() {
  29. return 'library';
  30. }
  31. /**
  32. * Localize settings.
  33. *
  34. * Add new localized settings for the library module.
  35. *
  36. * Fired by `elementor/editor/localize_settings` filter.
  37. *
  38. * @since 2.0.0
  39. * @access public
  40. *
  41. * @param array $settings Localized settings.
  42. *
  43. * @return array Localized settings.
  44. */
  45. public function localize_settings( $settings ) {
  46. $settings = array_replace_recursive( $settings, [
  47. 'i18n' => [],
  48. ] );
  49. return $settings;
  50. }
  51. /**
  52. * Library module constructor.
  53. *
  54. * Initializing Elementor library module.
  55. *
  56. * @since 2.0.0
  57. * @access public
  58. */
  59. public function __construct() {
  60. Plugin::$instance->documents
  61. ->register_document_type( 'page', Documents\Page::get_class_full_name() )
  62. ->register_document_type( 'section', Documents\Section::get_class_full_name() )
  63. ->register_group( 'blocks', [
  64. 'label' => __( 'Blocks', 'elementor' ),
  65. ] )->register_group( 'pages', [
  66. 'label' => __( 'Pages', 'elementor' ),
  67. ] );
  68. add_filter( 'elementor/editor/localize_settings', [ $this, 'localize_settings' ] );
  69. }
  70. }