PluginProbe ʕ •ᴥ•ʔ
WP Popular Posts / 7.3.1
WP Popular Posts v7.3.1
4.0.8 4.0.9 4.1.0 4.1.1 4.1.2 4.2.0 4.2.1 4.2.2 5.0.0 5.0.1 5.0.2 5.1.0 5.2.0 5.2.1 5.2.2 5.2.3 5.2.4 5.3.0 5.3.1 5.3.2 5.3.3 5.3.4 5.3.5 5.3.6 5.4.0 5.4.1 5.4.2 5.5.0 5.5.1 6.0.0 6.0.1 6.0.2 6.0.3 6.0.4 6.0.5 6.1.0 6.1.1 6.1.2 6.1.3 6.1.4 6.2.0 6.2.1 6.3.0 6.3.1 6.3.2 6.3.3 6.3.4 6.4.0 6.4.1 6.4.2 7.0.0 7.0.1 7.1.0 7.2.0 7.3.0 7.3.1 7.3.2 7.3.3 7.3.4 7.3.5 7.3.6 7.3.7 7.3.8 7.4.0 trunk 2.3.7 3.0.0 3.0.1 3.0.2 3.0.3 3.1.0 3.1.1 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 4.0.0 4.0.1 4.0.10 4.0.11 4.0.12 4.0.13 4.0.2 4.0.3 4.0.5 4.0.6
wordpress-popular-posts / src / Compatibility / Elementor / Elementor.php
wordpress-popular-posts / src / Compatibility / Elementor Last commit date
widgets 1 year ago Elementor.php 1 year ago
Elementor.php
99 lines
1 <?php
2 /**
3 * Integrates WPP with Elementor.
4 *
5 * @package WordPressPopularPosts
6 * @subpackage WordPressPopularPosts/Compatibility
7 * @author Hector Cabrera <me@cabrerahector.com>
8 */
9
10 namespace WordPressPopularPosts\Compatibility\Elementor;
11
12 use WordPressPopularPosts\Compatibility\Compat;
13 use WordPressPopularPosts\{Image, Themer};
14
15 class Elementor extends Compat
16 {
17 /**
18 * Image object.
19 *
20 * @var \WordPressPopularPosts\Image
21 * @access private
22 */
23 private $thumbnail;
24
25 /**
26 * Themer object.
27 *
28 * @var \WordPressPopularPosts\Themer $themer
29 * @access private
30 */
31 private $themer;
32
33 /**
34 * Construct.
35 *
36 * @param array $settings
37 */
38 public function __construct($settings, Image $image, Themer $themer)
39 {
40 $this->thumbnail = $image;
41 $this->themer = $themer;
42 }
43
44 /**
45 * Registers various WPPxElementor things.
46 *
47 * @since 7.3.0
48 */
49 public function init()
50 {
51 if ( defined('ELEMENTOR_VERSION') && version_compare(ELEMENTOR_VERSION, '3.5.0', '>=') ) {
52 // Registers flame icon
53 add_action('elementor/editor/after_enqueue_scripts', [$this, 'elementor_icon_css']);
54 // Registers WPP widget
55 add_action('elementor/widgets/register', [$this, 'register_widget']);
56 }
57 }
58
59 /**
60 * Registers WPP's icon for Elementor.
61 *
62 * @since 7.3.0
63 */
64 public function elementor_icon_css() {
65 $icon_file = esc_url(plugin_dir_url(dirname(__FILE__, 3))) . 'assets/images/flame.svg';
66
67 echo '<style>
68 .wpp-eicon {
69 display: inline-block;
70 width: 24px;
71 height: 24px;
72 background: url("' . $icon_file . '") center center /contain no-repeat;
73 }
74 </style>';
75 }
76
77 /**
78 * Registers WPP widget.
79 *
80 * @since 7.3.0
81 * @param \Elementor\Widgets_Manager $widgets_manager Elementor widgets manager.
82 */
83 public function register_widget($widgets_manager) {
84 $registered_themes = $this->themer->get_themes();
85 ksort($registered_themes);
86
87 require_once(__DIR__ . '/widgets/widget.php');
88 $widgets_manager->register(
89 new \Elementor_WPP_Widget(
90 [],
91 [
92 'image' => $this->thumbnail,
93 'themer' => $this->themer
94 ]
95 )
96 );
97 }
98 }
99