PluginProbe
Chartify – WordPress Chart Plugin / 3.0.3
Chartify – WordPress Chart Plugin v3.0.3
3.8.0 3.7.9 3.7.8 3.7.7 3.7.6 3.7.5 trunk 1.0.0 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 All 83 releases
chart-builder / pb_templates / chart-builder-elementor.php

chart-builder-elementor.php in Chartify – WordPress Chart Plugin 3.0.3, at pb_templates/chart-builder-elementor.php

115 lines 4.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor;
3 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
4 class Widget_Chart_Builder_Elementor extends Widget_Base {
5 public function get_name() {
6 return 'chart-builder';
7 }
8 public function get_title() {
9 return __( 'Chart Builder', 'chart-builder' );
10 }
11 public function get_icon() {
12 // Icon name from the Elementor font file, as per http://dtbaker.net/web-development/creating-your-own-custom-elementor-widgets/
13 return 'chart-elementor-widget-logo';
14 }
15 public function get_categories() {
16 return array( 'general', 'wordpress' );
17 }
18 protected function register_controls() {
19 $this->start_controls_section(
20 'section_chart_builder',
21 array(
22 'label' => esc_html__( 'Chart Builder', 'chart-builder' ),
23 )
24 );
25 $this->add_control(
26 'important_note',
27 array(
28 'label' => '',
29 'type' => \Elementor\Controls_Manager::RAW_HTML,
30 'raw' => '<i class="chart-elementor-widget-logo"></i> '.esc_html__( 'Chart Builder', 'chart-builder' ),
31 'content_classes' => 'chart-elementor-widget-logo-wrap',
32 )
33 );
34 $this->add_control(
35 'chart_selector',
36 array(
37 'label' => __( 'Select chart', 'chart-builder' ),
38 'type' => Controls_Manager::SELECT,
39 'default' => $this->get_default_chart(),
40 'options' => $this->get_active_charts()
41 )
42 );
43
44 $this->end_controls_section();
45 }
46 protected function render( $instance = array() ) {
47
48 if ( ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) {
49 echo '<style>
50 .ays-chart-container .ays-chart-section:first-of-type {
51 display: block!important;
52 }
53
54 .ays-chart-container * {
55 pointer-events: none!important;
56 overflow: hidden!important;
57 }
58
59 div.elementor-widget-chart-builder>div.elementor-widget-container .chart-elementor-container {
60 width: 100%;
61 padding: 6px 8px;
62 font-size: 13px;
63 border: 1px solid #757575;
64 border-radius: 2px;
65 background-color: #f0f0f1;
66 color: #2c3338;
67 }
68 </style>';
69 }
70
71 $settings = $this->get_settings_for_display();
72 echo ("<div class='chart-elementor-container'>
73 [ays_chart id={$settings['chart_selector']}]
74 </div>");
75 if ( ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) {
76 echo ("<p style='margin:4px 0 0 3px;font-size:12px;font-style:italic;'>
77 " . __( 'Note: The chart will be visible on the front end of your website.', "chart-builder" ) . "
78 </p>");
79 }
80 }
81
82 public function get_active_charts(){
83 global $wpdb;
84 $current_user = get_current_user_id();
85 $charts_table = $wpdb->prefix . CHART_BUILDER_DB_PREFIX . 'charts';
86 $sql = "SELECT id,title FROM {$charts_table} WHERE `status`='published'";
87 if( ! current_user_can( 'manage_options' ) ){
88 $sql .= " AND author_id = ". absint( $current_user ) ." ";
89 }
90 $results = $wpdb->get_results( $sql, ARRAY_A );
91 $options = array();
92 foreach ( $results as $result ){
93 $options[$result['id']] = $result['title'];
94 }
95 return $options;
96 }
97
98 public function get_default_chart(){
99 global $wpdb;
100 $current_user = get_current_user_id();
101 $charts_table = $wpdb->prefix . CHART_BUILDER_DB_PREFIX . 'charts';
102 $sql = "SELECT id FROM {$charts_table} WHERE `status`='published'";
103 if( ! current_user_can( 'manage_options' ) ){
104 $sql .= " AND author_id = ". absint( $current_user ) ." ";
105 }
106 $sql .= " LIMIT 1;";
107 $id = $wpdb->get_var( $sql );
108
109 return intval($id);
110 }
111
112 protected function content_template() {}
113 public function render_plain_content( $instance = array() ) {}
114 }
115