Skip to content

Commit e35e204

Browse files
add tracking data #77
1 parent b17e307 commit e35e204

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

classes/Visualizer/Module/Admin.php

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,45 @@ public function __construct( Visualizer_Plugin $plugin ) {
5858
$this->_addAction( 'admin_menu', 'registerAdminMenu' );
5959
$this->_addFilter( 'media_view_strings', 'setupMediaViewStrings' );
6060
$this->_addFilter( 'plugin_action_links', 'getPluginActionLinks', 10, 2 );
61-
$this->_addFilter( 'plugin_row_meta', 'getPluginMetaLinks', 10, 2 );
61+
$this->_addFilter( 'visualizer_logger_data', 'getLoggerData' );
6262
}
6363

64+
/**
65+
* Fetches the SDK logger data.
66+
*
67+
* @param array $data The default data that needs to be sent.
68+
*
69+
* @access public
70+
*/
71+
public function getLoggerData( $data ) {
72+
return array(
73+
'chart_types' => $this->getChartTypesAndCounts(),
74+
'wordpress_filters' => '',
75+
);
76+
}
77+
78+
/**
79+
* Fetches the types of charts created and their counts.
80+
*
81+
* @access private
82+
*/
83+
private function getChartTypesAndCounts() {
84+
$charts = array();
85+
// the initial query arguments to fetch charts
86+
$query_args = array(
87+
'post_type' => Visualizer_Plugin::CPT_VISUALIZER,
88+
'posts_per_page' => 300,
89+
'fields' => 'ids',
90+
);
91+
92+
$query = new WP_Query( $query_args );
93+
while ( $query->have_posts() ) {
94+
$chart_id = $query->next_post();
95+
$type = get_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_TYPE, true );
96+
$charts[ $type ] = isset( $charts[ $type ] ) ? $charts[ $type ] + 1 : 1;
97+
}
98+
return $charts;
99+
}
64100

65101
/**
66102
* Enqueues media scripts and styles.

0 commit comments

Comments
 (0)