Advertisement
Guest User

Untitled

a guest
Aug 20th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. <?php
  2. /**
  3. * Elementor oEmbed Widget.
  4. *
  5. * Elementor widget that inserts an embbedable content into the page, from any given URL.
  6. *
  7. * @since 1.0.0
  8. */
  9. class Elementor_oEmbedd_Widget extends \Elementor\Widget_Base {
  10.  
  11. /**
  12. * Get widget name.
  13. *
  14. * Retrieve oEmbed widget name.
  15. *
  16. * @since 1.0.0
  17. * @access public
  18. *
  19. * @return string Widget name.
  20. */
  21. public function get_name() {
  22. return 'oembedd';
  23. }
  24.  
  25. /**
  26. * Get widget title.
  27. *
  28. * Retrieve oEmbed widget title.
  29. *
  30. * @since 1.0.0
  31. * @access public
  32. *
  33. * @return string Widget title.
  34. */
  35. public function get_title() {
  36. return __( 'oEmbedd', 'plugin-name' );
  37. }
  38.  
  39. /**
  40. * Get widget icon.
  41. *
  42. * Retrieve oEmbed widget icon.
  43. *
  44. * @since 1.0.0
  45. * @access public
  46. *
  47. * @return string Widget icon.
  48. */
  49. public function get_icon() {
  50. return 'fa fa-code';
  51. }
  52.  
  53. /**
  54. * Get widget categories.
  55. *
  56. * Retrieve the list of categories the oEmbed widget belongs to.
  57. *
  58. * @since 1.0.0
  59. * @access public
  60. *
  61. * @return array Widget categories.
  62. */
  63. public function get_categories() {
  64. return [ 'basic' ];
  65. }
  66.  
  67. /**
  68. * Register oEmbed widget controls.
  69. *
  70. * Adds different input fields to allow the user to change and customize the widget settings.
  71. *
  72. * @since 1.0.0
  73. * @access protected
  74. */
  75. protected function _register_controls() {
  76.  
  77. $this->start_controls_section(
  78. 'content_section',
  79. [
  80. 'label' => __( 'Content', 'plugin-name' ),
  81. 'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
  82. ]
  83. );
  84.  
  85. $this->add_control(
  86. 'url',
  87. [
  88. 'label' => __( 'URL to embed', 'plugin-name' ),
  89. 'type' => \Elementor\Controls_Manager::TEXT,
  90. 'input_type' => 'url',
  91. 'placeholder' => __( 'https://your-link.com', 'plugin-name' ),
  92. ]
  93. );
  94.  
  95. $this->end_controls_section();
  96.  
  97. }
  98.  
  99. /**
  100. * Render oEmbed widget output on the frontend.
  101. *
  102. * Written in PHP and used to generate the final HTML.
  103. *
  104. * @since 1.0.0
  105. * @access protected
  106. */
  107. protected function render() {
  108.  
  109. $settings = $this->get_settings_for_display();
  110.  
  111. echo $settings['url'];
  112.  
  113. }
  114.  
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement