| @@ -18,8 +18,9 @@ | ||
| 18 | 18 | // | MA 02110-1301 USA | |
| 19 | 19 | // +----------------------------------------------------------------------+ |
| 20 | 20 | // | Author: Eugene Manuilov <eugene@manuilov.org> | |
| 21 | 21 | // +----------------------------------------------------------------------+ |
| 22 | + | |
| 22 | 23 | /** |
| 23 | 24 | * General module what setups all required environment. |
| 24 | 25 | * |
| 25 | 26 | * @category Visualizer |
| @@ -43,62 +44,11 @@ | ||
| 43 | 44 | parent::__construct( $plugin ); |
| 44 | 45 | |
| 45 | 46 | $this->_addAction( 'init', 'setupCustomPostTypes' ); |
| 46 | 47 | $this->_addAction( 'plugins_loaded', 'loadTextDomain' ); |
| 47 | - $this->_addFilter( 'visualizer_logger_data', 'getLoggerData' ); | |
| 48 | - $this->_addFilter( 'visualizer_get_chart_counts', 'getChartCountsByTypeAndMeta' ); | |
| 49 | 48 | } |
| 50 | - /** | |
| 51 | - * Fetches the SDK logger data. | |
| 52 | - * | |
| 53 | - * @param array $data The default data that needs to be sent. | |
| 54 | - * | |
| 55 | - * @access public | |
| 56 | - */ | |
| 57 | - public function getLoggerData( $data ) { | |
| 58 | - return $this->getChartCountsByTypeAndMeta(); | |
| 59 | - } | |
| 60 | 49 | |
| 61 | 50 | /** |
| 62 | - * Fetches the types of charts created and their counts. | |
| 63 | - * | |
| 64 | - * @param array $meta_keys An array of name vs. meta keys - to return how many charts have these keys. | |
| 65 | - * @access private | |
| 66 | - */ | |
| 67 | - public function getChartCountsByTypeAndMeta( $meta_keys = array() ) { | |
| 68 | - $charts = array(); | |
| 69 | - $charts['chart_types'] = array(); | |
| 70 | - // the initial query arguments to fetch charts | |
| 71 | - $query_args = array( | |
| 72 | - 'post_type' => Visualizer_Plugin::CPT_VISUALIZER, | |
| 73 | - 'posts_per_page' => 300, | |
| 74 | - 'fields' => 'ids', | |
| 75 | - 'no_rows_found' => false, | |
| 76 | - 'update_post_meta_cache' => false, | |
| 77 | - 'update_post_term_cache' => false, | |
| 78 | - | |
| 79 | - ); | |
| 80 | - | |
| 81 | - $query = new WP_Query( $query_args ); | |
| 82 | - while ( $query->have_posts() ) { | |
| 83 | - $chart_id = $query->next_post(); | |
| 84 | - $type = get_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_TYPE, true ); | |
| 85 | - $charts['chart_types'][ $type ] = isset( $charts['chart_types'][ $type ] ) ? $charts['chart_types'][ $type ] + 1 : 1; | |
| 86 | - if ( ! empty( $meta_keys ) ) { | |
| 87 | - foreach ( $meta_keys as $name => $key ) { | |
| 88 | - $data = get_post_meta( $chart_id, $key, true ); | |
| 89 | - if ( ! empty( $data ) ) { | |
| 90 | - $charts[ $name ] = isset( $charts[ $name ] ) ? $charts[ $name ] + 1 : 1; | |
| 91 | - } else { | |
| 92 | - $charts[ $name ] = 0; | |
| 93 | - } | |
| 94 | - } | |
| 95 | - } | |
| 96 | - } | |
| 97 | - return $charts; | |
| 98 | - } | |
| 99 | - | |
| 100 | - /** | |
| 101 | 51 | * Registers custom post type for charts. |
| 102 | 52 | * |
| 103 | 53 | * @since 1.0.0 |
| 104 | 54 | * @uses register_post_type() To register custom post type for charts. |
| @@ -105,14 +55,12 @@ | ||
| 105 | 55 | * |
| 106 | 56 | * @access public |
| 107 | 57 | */ |
| 108 | 58 | public function setupCustomPostTypes() { |
| 109 | - register_post_type( | |
| 110 | - Visualizer_Plugin::CPT_VISUALIZER, array( | |
| 111 | - 'label' => 'Visualizer Charts', | |
| 112 | - 'public' => false, | |
| 113 | - ) | |
| 114 | - ); | |
| 59 | + register_post_type( Visualizer_Plugin::CPT_VISUALIZER, array( | |
| 60 | + 'label' => 'Visualizer Chart', | |
| 61 | + 'public' => false, | |
| 62 | + ) ); | |
| 115 | 63 | } |
| 116 | 64 | |
| 117 | 65 | /** |
| 118 | 66 | * Loads plugin text domain translations. |
| @@ -125,5 +73,5 @@ | ||
| 125 | 73 | public function loadTextDomain() { |
| 126 | 74 | load_plugin_textdomain( Visualizer_Plugin::NAME, false, dirname( plugin_basename( VISUALIZER_BASEFILE ) ) . '/languages/' ); |
| 127 | 75 | } |
| 128 | 76 | |
| 129 | -} | |
| 77 | +} | |