api
3 weeks ago
assets
3 weeks ago
controls
3 weeks ago
fonts
5 years ago
views
4 years ago
cpt.php
4 years ago
init.php
2 years ago
live-action.php
4 months ago
widget-file.php
4 years ago
live-action.php
46 lines
| 1 | <?php |
| 2 | namespace ElementsKit_Lite\Modules\Widget_Builder; |
| 3 | |
| 4 | defined( 'ABSPATH' ) || exit; |
| 5 | |
| 6 | |
| 7 | class Live_Action { |
| 8 | private $id; |
| 9 | |
| 10 | public function __construct() { |
| 11 | |
| 12 | // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- We are taking the post id from the URL. The page only can access admin. So nonce verification is not required. |
| 13 | $this->id = ( ! isset( $_GET['post'] ) ? 0 : intval( wp_unslash( $_GET['post'] ) ) ); |
| 14 | |
| 15 | // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- We are checking the page action. The page only can access admin. So nonce verification is not required. |
| 16 | if ( $this->id == 0 || ! isset( $_GET['action'] ) || $_GET['action'] != 'elementor' ) { |
| 17 | return; |
| 18 | } |
| 19 | |
| 20 | if ( get_post_type( $this->id ) != 'elementskit_widget' ) { |
| 21 | return; |
| 22 | } |
| 23 | |
| 24 | add_action( 'init', array( $this, 'reset' ) ); |
| 25 | } |
| 26 | |
| 27 | public function reset() { |
| 28 | // Capability check: Only allow users who can manage options |
| 29 | if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) { |
| 30 | wp_die( esc_html__( 'You are not allowed to perform this action.', 'elementskit-lite' ) ); |
| 31 | } |
| 32 | |
| 33 | if ( wp_verify_nonce( \Elementor\Utils::get_super_global_value( $_POST, '_nonce' ),'elementor_ajax' ) ) { |
| 34 | return; |
| 35 | } |
| 36 | |
| 37 | update_post_meta( $this->id, '_wp_page_template', 'elementor_canvas' ); |
| 38 | |
| 39 | update_post_meta( |
| 40 | $this->id, |
| 41 | '_elementor_data', |
| 42 | '[{"id":"e3a6ad6","elType":"section","settings":[],"elements":[{"id":"77605d8","elType":"column","settings":{"_column_size":100,"_inline_size":null},"elements":[{"id":"0d8eeb3","elType":"widget","settings":{},"elements":[],"widgetType":"ekit_wb_' . $this->id . '"}],"isInner":false}],"isInner":false}]' |
| 43 | ); |
| 44 | } |
| 45 | } |
| 46 |