PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 1.1.4
Visualizer – Tables & Charts Manager with Built-in AI Generator v1.1.4
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 +28 -70 3.10.11.1.4 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 |
@@ -17,8 +18,9 @@
17 18 // | MA 02110-1301 USA |
18 19 // +----------------------------------------------------------------------+
19 20 // | Author: Eugene Manuilov <eugene@manuilov.org> |
20 21 // +----------------------------------------------------------------------+
22 +
21 23 /**
22 24 * Sources module class.
23 25 *
24 26 * @category Visualizer
@@ -45,60 +47,56 @@
45 47 *
46 48 * @since 1.1.0
47 49 *
48 50 * @access public
49 - *
50 51 * @param Visualizer_Plugin $plugin The instance of the plugin.
51 52 */
52 53 public function __construct( Visualizer_Plugin $plugin ) {
53 54 parent::__construct( $plugin );
55 +
54 56 $this->_addFilter( Visualizer_Plugin::FILTER_GET_CHART_SERIES, 'filterChartSeries', 1, 2 );
55 57 $this->_addFilter( Visualizer_Plugin::FILTER_GET_CHART_DATA, 'filterChartData', 1, 2 );
56 - $this->_addFilter( 'visualizer_pro_upsell', 'addProUpsell', 10, 2 );
57 58 }
58 59
59 60 /**
60 - * Filters chart sereis.
61 + * Returns appropriate source object for a chart.
61 62 *
62 63 * @since 1.1.0
63 64 *
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.
65 + * @access private
66 + * @param int $chart_id The chart id.
67 + * @return Visualizer_Source The source object if source exists, otherwise FALSE.
70 68 */
71 - public function filterChartSeries( $series, $chart_id ) {
72 - $source = $this->_getSource( $chart_id );
73 - if ( ! $source ) {
74 - return $series;
69 + private function _getSource( $chart_id ) {
70 + if ( !isset( $this->_sources[$chart_id] ) ) {
71 + $class = get_post_meta( $chart_id, Visualizer_Plugin::CF_SOURCE, true );
72 + if ( !class_exists( $class, true ) ) {
73 + return false;
74 + }
75 +
76 + $this->_sources[$chart_id] = new $class();
75 77 }
76 78
77 - return $source->repopulateSeries( $series, $chart_id );
79 + return $this->_sources[$chart_id];
78 80 }
79 81
80 82 /**
81 - * Returns appropriate source object for a chart.
83 + * Filters chart sereis.
82 84 *
83 85 * @since 1.1.0
84 86 *
85 - * @access private
86 - *
87 + * @access public
88 + * @param array $series The array of chart series.
87 89 * @param int $chart_id The chart id.
88 - *
89 - * @return Visualizer_Source The source object if source exists, otherwise FALSE.
90 + * @return array The array of filtered series.
90 91 */
91 - private function _getSource( $chart_id ) {
92 - if ( ! isset( $this->_sources[ $chart_id ] ) ) {
93 - $class = get_post_meta( $chart_id, Visualizer_Plugin::CF_SOURCE, true );
94 - if ( ! class_exists( $class, true ) ) {
95 - return false;
96 - }
97 - $this->_sources[ $chart_id ] = new $class();
92 + public function filterChartSeries( $series, $chart_id ) {
93 + $source = $this->_getSource( $chart_id );
94 + if ( !$source ) {
95 + return $series;
98 96 }
99 97
100 - return $this->_sources[ $chart_id ];
98 + return $source->repopulateSeries( $series, $chart_id );
101 99 }
102 100
103 101 /**
104 102 * Filters chart data.
@@ -105,17 +103,15 @@
105 103 *
106 104 * @since 1.1.0
107 105 *
108 106 * @access public
109 - *
110 107 * @param array $data The array of chart data.
111 - * @param int $chart_id The chart id.
112 - *
108 + * @param int $chart_id The chart id.
113 109 * @return array The array of filtered data.
114 110 */
115 111 public function filterChartData( $data, $chart_id ) {
116 112 $source = $this->_getSource( $chart_id );
117 - if ( ! $source ) {
113 + if ( !$source ) {
118 114 return $data;
119 115 }
120 116
121 117 return $source->repopulateData( $data, $chart_id );
@@ -120,43 +116,5 @@
120 116
121 117 return $source->repopulateData( $data, $chart_id );
122 118 }
123 119
124 - /**
125 - * Add the pro upsell html.
126 - *
127 - * @param string $old The previous html string.
128 - * @param string $feature What feature is this filter running for.
129 - *
130 - * @return string The new html code.
131 - */
132 - public function addProUpsell( $old, $feature = null ) {
133 - $pro_features = Visualizer_Module::get_features_for_license( 1 );
134 - $biz_features = Visualizer_Module::get_features_for_license( 2 );
135 - $return = '';
136 - $feature = strval( $feature );
137 - if ( empty( $feature ) ||
138 - ( in_array( $feature, $biz_features, true ) && ! apply_filters( 'visualizer_is_business', false ) ) ||
139 - ( in_array( $feature, $pro_features, true ) && ! Visualizer_Module::is_pro() )
140 - ) {
141 - $msg = sprintf( __( 'Upgrade to %s to activate this feature!', 'visualizer' ), 'PRO' );
142 - if ( Visualizer_Module::is_pro() && in_array( $feature, $biz_features, true ) ) {
143 - $msg = sprintf( __( 'Upgrade your license to at least the %s version to activate this feature!', 'visualizer' ), 'DEVELOPER' );
144 - }
145 - $return = '<div class="only-pro-content">';
146 - $return .= ' <div class="only-pro-container">';
147 - $return .= ' <div class="only-pro-inner">';
148 - $return .= ' <p>' . $msg . '</p>';
149 - $return .= ' <a target="_blank" href="' . tsdk_utmify( Visualizer_Plugin::PRO_TEASER_URL, esc_attr( $feature ) ) . '" title="' . __( 'Buy now', 'visualizer' ) . '">' . __( 'Buy now', 'visualizer' ) . '</a>';
150 - $return .= ' </div>';
151 - $return .= ' </div>';
152 - $return .= '</div>';
153 - }
154 - if ( empty( $feature ) && Visualizer_Module::is_pro() ) {
155 - remove_filter( 'visualizer_pro_upsell', 'addProUpsell', 10, 1 );
156 - $return = '';
157 - }
158 -
159 - return $return;
160 - }
161 -
162 -}
120 +}