PluginProbe
Commerce7 for WordPress / trunk
Commerce7 for WordPress vtrunk
1.8.1 1.8.0 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 1.1.3 1.2.0 1.2.1 1.2.2 1.2.3 1.2.5 1.2.6 1.3.0 1.3.1 1.3.2 1.3.4 1.3.5 1.4.0 1.4.1 All 37 releases
wp-commerce7 / includes / elementor / elementor-buy.php

elementor-buy.php in Commerce7 for WordPress trunk, at includes/elementor/elementor-buy.php

150 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Elementor widget: Buy Button (single Variant)
4 *
5 * Created Date: Wednesday September 2nd 2020
6 * Author: Michael Bourne
7 * -----
8 * Last Modified: Thursday, January 9th 2025, 1:51:17 pm
9 * Modified By: Michael Bourne
10 * -----
11 * Copyright (c) 2020 URSA6
12 *
13 * @package wp-commerce7
14 * @author Michael Bourne
15 * @license GPL3
16 * @link https://ursa6.com
17 * @since 1.0.8
18 */
19
20 if ( ! defined( 'ABSPATH' ) ) {
21 return;
22 }
23
24 /**
25 * Widget class
26 */
27 class C7WP_Elementor_Buy extends \Elementor\Widget_Base {
28
29
30 /**
31 * Get widget name.
32 *
33 * Retrieve Commerce7 widget name.
34 *
35 * @since 1.0.0
36 * @access public
37 *
38 * @return string Widget name.
39 */
40 public function get_name() {
41 return 'commerce7-buy';
42 }
43
44 /**
45 * Get widget title.
46 *
47 * Retrieve Commerce7 widget title.
48 *
49 * @since 1.0.0
50 * @access public
51 *
52 * @return string Widget title.
53 */
54 public function get_title() {
55 return __( 'Buy Button (SKU)', 'wp-commerce7' );
56 }
57
58 /**
59 * Get widget icon.
60 *
61 * Retrieve Commerce7 widget icon.
62 *
63 * @since 1.0.0
64 * @access public
65 *
66 * @return string Widget icon.
67 */
68 public function get_icon() {
69 return 'c7icon-c7sm';
70 }
71
72 /**
73 * Get widget categories.
74 *
75 * Retrieve the list of categories the widget belongs to.
76 *
77 * @since 1.0.0
78 * @access public
79 *
80 * @return array Widget categories.
81 */
82 public function get_categories() {
83 return [ 'commerce7' ];
84 }
85
86 /**
87 * Retrieve widget keywords.
88 *
89 * @since 1.0.0
90 * @access public
91 *
92 * @return array Widget keywords.
93 */
94 public function get_keywords() {
95 return [ 'commerce7', 'buy', 'button' ];
96 }
97
98 /**
99 * Register widget controls.
100 *
101 * Adds different input fields to allow the user to change and customize the widget settings.
102 *
103 * @since 1.0.0
104 * @access protected
105 */
106 protected function register_controls() { // phpcs:ignore
107
108 $this->start_controls_section(
109 'content_section',
110 [
111 'label' => __( 'Settings', 'wp-commerce7' ),
112 'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
113 ]
114 );
115
116 $this->add_control(
117 'data',
118 [
119 'label' => __( 'Variant SKU', 'wp-commerce7' ),
120 'type' => \Elementor\Controls_Manager::TEXT,
121 'placeholder' => __( 'ABC123', 'wp-commerce7' ),
122 ]
123 );
124
125 $this->end_controls_section();
126
127 }
128
129 /**
130 * Render Commerce widget output on the frontend.
131 *
132 * Written in PHP and used to generate the final HTML.
133 *
134 * @since 1.0.0
135 * @access protected
136 */
137 protected function render() {
138
139 $settings = $this->get_settings_for_display();
140
141 $data = esc_attr( $settings['data'] );
142
143 echo do_shortcode( '[c7wp type="buy" data="' . $data . '"]' );
144
145 }
146
147 protected function content_template() {} //phpcs:ignore
148 public function render_plain_content( $instance = [] ) {}
149
150 }