PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 1.7.6
Visualizer – Tables & Charts Manager with Built-in AI Generator v1.7.6
4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 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.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 3.10.4 All 148 releases
← All changes | classes/Visualizer/Module/Sources.php +20 -59 3.1.21.7.6 View file →
@@ -1,5 +1,6 @@
1 1 <?php
2 +
2 3 // +----------------------------------------------------------------------+
3 4 // | Copyright 2013 Madpixels (email : visualizer@madpixels.net) |
4 5 // +----------------------------------------------------------------------+
5 6 // | This program is free software; you can redistribute it and/or modify |
@@ -45,48 +46,24 @@
45 46 *
46 47 * @since 1.1.0
47 48 *
48 49 * @access public
49 - *
50 50 * @param Visualizer_Plugin $plugin The instance of the plugin.
51 51 */
52 52 public function __construct( Visualizer_Plugin $plugin ) {
53 53 parent::__construct( $plugin );
54 +
54 55 $this->_addFilter( Visualizer_Plugin::FILTER_GET_CHART_SERIES, 'filterChartSeries', 1, 2 );
55 56 $this->_addFilter( Visualizer_Plugin::FILTER_GET_CHART_DATA, 'filterChartData', 1, 2 );
56 - $this->_addFilter( 'visualizer_pro_upsell', 'addProUpsell', 10, 2 );
57 57 }
58 58
59 59 /**
60 - * Filters chart sereis.
61 - *
62 - * @since 1.1.0
63 - *
64 - * @access public
65 - *
66 - * @param array $series The array of chart series.
67 - * @param int $chart_id The chart id.
68 - *
69 - * @return array The array of filtered series.
70 - */
71 - public function filterChartSeries( $series, $chart_id ) {
72 - $source = $this->_getSource( $chart_id );
73 - if ( ! $source ) {
74 - return $series;
75 - }
76 -
77 - return $source->repopulateSeries( $series, $chart_id );
78 - }
79 -
80 - /**
81 60 * Returns appropriate source object for a chart.
82 61 *
83 62 * @since 1.1.0
84 63 *
85 64 * @access private
86 - *
87 65 * @param int $chart_id The chart id.
88 - *
89 66 * @return Visualizer_Source The source object if source exists, otherwise FALSE.
90 67 */
91 68 private function _getSource( $chart_id ) {
92 69 if ( ! isset( $this->_sources[ $chart_id ] ) ) {
@@ -93,8 +70,9 @@
93 70 $class = get_post_meta( $chart_id, Visualizer_Plugin::CF_SOURCE, true );
94 71 if ( ! class_exists( $class, true ) ) {
95 72 return false;
96 73 }
74 +
97 75 $this->_sources[ $chart_id ] = new $class();
98 76 }
99 77
100 78 return $this->_sources[ $chart_id ];
@@ -100,59 +78,42 @@
100 78 return $this->_sources[ $chart_id ];
101 79 }
102 80
103 81 /**
104 - * Filters chart data.
82 + * Filters chart sereis.
105 83 *
106 84 * @since 1.1.0
107 85 *
108 86 * @access public
109 - *
110 - * @param array $data The array of chart data.
87 + * @param array $series The array of chart series.
111 88 * @param int $chart_id The chart id.
112 - *
113 - * @return array The array of filtered data.
89 + * @return array The array of filtered series.
114 90 */
115 - public function filterChartData( $data, $chart_id ) {
91 + public function filterChartSeries( $series, $chart_id ) {
116 92 $source = $this->_getSource( $chart_id );
117 93 if ( ! $source ) {
118 - return $data;
94 + return $series;
119 95 }
120 96
121 - return $source->repopulateData( $data, $chart_id );
97 + return $source->repopulateSeries( $series, $chart_id );
122 98 }
123 99
124 100 /**
125 - * Add the pro upsell html.
101 + * Filters chart data.
126 102 *
127 - * @param string $old The previous html string.
128 - * @param string $feature What feature is this filter running for.
103 + * @since 1.1.0
129 104 *
130 - * @return string The new html code.
105 + * @access public
106 + * @param array $data The array of chart data.
107 + * @param int $chart_id The chart id.
108 + * @return array The array of filtered data.
131 109 */
132 - public function addProUpsell( $old, $feature = null ) {
133 - $biz_features = array( 'schedule-chart', 'chart-permissions', 'db-query' );
134 - $return = '';
135 - $feature = strval( $feature );
136 - if ( empty( $feature ) || ( in_array( $feature, $biz_features ) && ! apply_filters( 'visualizer_is_business', false ) ) ) {
137 - $plan = 'PRO';
138 - if ( in_array( $feature, $biz_features ) ) {
139 - $plan = 'BUSINESS';
140 - }
141 - $return = '<div class="only-pro-content">';
142 - $return .= ' <div class="only-pro-container">';
143 - $return .= ' <div class="only-pro-inner">';
144 - $return .= ' <p>' . sprintf( __( 'Enable this feature in %s version!', 'visualizer' ), $plan ) . '</p>';
145 - $return .= ' <a target="_blank" href="' . Visualizer_Plugin::PRO_TEASER_URL . '" title="' . __( 'Buy now', 'visualizer' ) . '">' . __( 'Buy now', 'visualizer' ) . '</a>';
146 - $return .= ' </div>';
147 - $return .= ' </div>';
148 - $return .= '</div>';
110 + public function filterChartData( $data, $chart_id ) {
111 + $source = $this->_getSource( $chart_id );
112 + if ( ! $source ) {
113 + return $data;
149 114 }
150 - if ( empty( $feature ) && defined( 'VISUALIZER_PRO_VERSION' ) ) {
151 - remove_filter( 'visualizer_pro_upsell', 'addProUpsell', 10, 1 );
152 - $return = '';
153 - }
154 115
155 - return $return;
116 + return $source->repopulateData( $data, $chart_id );
156 117 }
157 118
158 119 }