PluginProbe
Chartify – WordPress Chart Plugin / 3.1.4
Chartify – WordPress Chart Plugin v3.1.4
3.8.1 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 All 84 releases
chart-builder / pb_templates / chart-builder-elementor.php

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

116 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( '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 $sql .= " ORDER BY id DESC";
91 $results = $wpdb->get_results( $sql, ARRAY_A );
92 $options = array();
93 foreach ( $results as $result ){
94 $options[$result['id']] = $result['title'];
95 }
96 return $options;
97 }
98
99 public function get_default_chart(){
100 global $wpdb;
101 $current_user = get_current_user_id();
102 $charts_table = $wpdb->prefix . CHART_BUILDER_DB_PREFIX . 'charts';
103 $sql = "SELECT id FROM {$charts_table} WHERE `status`='published'";
104 if( ! current_user_can( 'manage_options' ) ){
105 $sql .= " AND author_id = ". absint( $current_user ) ." ";
106 }
107 $sql .= " ORDER BY id DESC LIMIT 1;";
108 $id = $wpdb->get_var( $sql );
109
110 return intval($id);
111 }
112
113 protected function content_template() {}
114 public function render_plain_content( $instance = array() ) {}
115 }
116