PluginProbe
Elementor Website Builder – more than just a page builder / 4.2.4
Elementor Website Builder – more than just a page builder v4.2.4
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / core / common / modules / connect / apps / feedback.php

feedback.php in Elementor Website Builder – more than just a page builder 4.2.4, at core/common/modules/connect/apps/feedback.php

95 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\Core\Common\Modules\Connect\Apps;
4
5 use Elementor\Plugin;
6
7 if ( ! defined( 'ABSPATH' ) ) {
8 exit; // Exit if accessed directly.
9 }
10
11 class Feedback extends Common_App {
12
13 const EXPERIMENT_NAME = 'in_editor_feedback';
14
15 const FEEDBACK_ENDPOINT = 'https://my.elementor.com/feedback/api/v1';
16
17 public function __construct() {
18 parent::__construct();
19 Plugin::$instance->experiments->add_feature([
20 'name' => self::EXPERIMENT_NAME,
21 'title' => esc_html__( 'In-Editor Feedback', 'elementor' ),
22 'description' => esc_html__( 'Enable in-editor feedback submission.', 'elementor' ),
23 'hidden' => true,
24 'release_status' => Plugin::$instance->experiments::RELEASE_STATUS_BETA,
25 'default' => Plugin::$instance->experiments::STATE_INACTIVE,
26 'new_site' => [
27 'default_active' => false,
28 'minimum_installation_version' => '3.35.0',
29 ],
30 ]);
31 }
32
33 public function get_title() {
34 return esc_html__( 'Product Feedback', 'elementor' );
35 }
36
37 /**
38 * @since 2.3.0
39 * @access protected
40 */
41 protected function get_slug() {
42 return 'product-feedback';
43 }
44
45 protected function get_base_connect_info() {
46 return [
47 'app' => 'editor',
48 'access_token' => $this->get( 'access_token' ),
49 'client_id' => $this->get( 'client_id' ),
50 'endpoint' => 'taxonomies',
51 'local_id' => get_current_user_id(),
52 'site_key' => $this->get_site_key(),
53 'home_url' => trailingslashit( home_url() ),
54 ];
55 }
56
57 protected function get_api_url() {
58 return static::FEEDBACK_ENDPOINT . '/' . $this->get_slug();
59 }
60
61 protected function get_generated_urls( $endpoint ) {
62 return [ $this->get_api_url() ];
63 }
64
65 public function submit( $body ) {
66 $is_active = Plugin::instance()->experiments->is_feature_active( self::EXPERIMENT_NAME );
67 if ( ! $is_active ) {
68 return [
69 'success' => false,
70 'data' => [
71 'message' => 'In-Editor Feedback is not active.',
72 ],
73 ];
74 }
75 $connect_info = $this->get_base_connect_info();
76 $merged_body = array_merge( $connect_info, $body );
77 $signature = $this->generate_signature( $merged_body );
78 $headers = [
79 'access-token' => $connect_info['access_token'],
80 'app' => 'library',
81 'client-id' => $connect_info['client_id'],
82 'endpoint' => 'taxonomies',
83 'home-url' => $connect_info['home_url'],
84 'local-id' => $connect_info['local_id'],
85 'site-key' => $this->get_site_key(),
86 'X-Elementor-Signature' => $signature,
87 ];
88 $response = wp_remote_post( $this->get_api_url(), [
89 'headers' => $headers,
90 'body' => $body,
91 ]);
92 return $response;
93 }
94 }
95