PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 1.5.3
Visualizer – Tables & Charts Manager with Built-in AI Generator v1.5.3
4.0.8 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 All 149 releases
← All changes | classes/Visualizer/Module/Setup.php +77 -130 3.0.81.5.3 View file →
@@ -1,130 +1,77 @@
1 -<?php
2 -
3 -// +----------------------------------------------------------------------+
4 -// | Copyright 2013 Madpixels (email : visualizer@madpixels.net) |
5 -// +----------------------------------------------------------------------+
6 -// | This program is free software; you can redistribute it and/or modify |
7 -// | it under the terms of the GNU General Public License, version 2, as |
8 -// | published by the Free Software Foundation. |
9 -// | |
10 -// | This program is distributed in the hope that it will be useful, |
11 -// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 -// | GNU General Public License for more details. |
14 -// | |
15 -// | You should have received a copy of the GNU General Public License |
16 -// | along with this program; if not, write to the Free Software |
17 -// | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, |
18 -// | MA 02110-1301 USA |
19 -// +----------------------------------------------------------------------+
20 -// | Author: Eugene Manuilov <eugene@manuilov.org> |
21 -// +----------------------------------------------------------------------+
22 -/**
23 - * General module what setups all required environment.
24 - *
25 - * @category Visualizer
26 - * @package Module
27 - *
28 - * @since 1.0.0
29 - */
30 -class Visualizer_Module_Setup extends Visualizer_Module {
31 -
32 - const NAME = __CLASS__;
33 -
34 - /**
35 - * Constructor.
36 - *
37 - * @since 1.0.0
38 - *
39 - * @access public
40 - * @param Visualizer_Plugin $plugin The instance of the plugin.
41 - */
42 - public function __construct( Visualizer_Plugin $plugin ) {
43 - parent::__construct( $plugin );
44 -
45 - $this->_addAction( 'init', 'setupCustomPostTypes' );
46 - $this->_addAction( 'plugins_loaded', 'loadTextDomain' );
47 - $this->_addFilter( 'visualizer_logger_data', 'getLoggerData' );
48 - $this->_addFilter( 'visualizer_get_chart_counts', 'getChartCountsByTypeAndMeta' );
49 - }
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 -
61 - /**
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 - * Registers custom post type for charts.
102 - *
103 - * @since 1.0.0
104 - * @uses register_post_type() To register custom post type for charts.
105 - *
106 - * @access public
107 - */
108 - public function setupCustomPostTypes() {
109 - register_post_type(
110 - Visualizer_Plugin::CPT_VISUALIZER, array(
111 - 'label' => 'Visualizer Charts',
112 - 'public' => false,
113 - 'supports' => array( 'revisions' ),
114 - )
115 - );
116 - }
117 -
118 - /**
119 - * Loads plugin text domain translations.
120 - *
121 - * @since 1.0.0
122 - * @uses load_plugin_textdomain() To load translations for the plugin.
123 - *
124 - * @access public
125 - */
126 - public function loadTextDomain() {
127 - load_plugin_textdomain( Visualizer_Plugin::NAME, false, dirname( plugin_basename( VISUALIZER_BASEFILE ) ) . '/languages/' );
128 - }
129 -
130 -}
1 +<?php
2 +
3 +// +----------------------------------------------------------------------+
4 +// | Copyright 2013 Madpixels (email : visualizer@madpixels.net) |
5 +// +----------------------------------------------------------------------+
6 +// | This program is free software; you can redistribute it and/or modify |
7 +// | it under the terms of the GNU General Public License, version 2, as |
8 +// | published by the Free Software Foundation. |
9 +// | |
10 +// | This program is distributed in the hope that it will be useful, |
11 +// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 +// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 +// | GNU General Public License for more details. |
14 +// | |
15 +// | You should have received a copy of the GNU General Public License |
16 +// | along with this program; if not, write to the Free Software |
17 +// | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, |
18 +// | MA 02110-1301 USA |
19 +// +----------------------------------------------------------------------+
20 +// | Author: Eugene Manuilov <eugene@manuilov.org> |
21 +// +----------------------------------------------------------------------+
22 +
23 +/**
24 + * General module what setups all required environment.
25 + *
26 + * @category Visualizer
27 + * @package Module
28 + *
29 + * @since 1.0.0
30 + */
31 +class Visualizer_Module_Setup extends Visualizer_Module {
32 +
33 + const NAME = __CLASS__;
34 +
35 + /**
36 + * Constructor.
37 + *
38 + * @since 1.0.0
39 + *
40 + * @access public
41 + * @param Visualizer_Plugin $plugin The instance of the plugin.
42 + */
43 + public function __construct( Visualizer_Plugin $plugin ) {
44 + parent::__construct( $plugin );
45 +
46 + $this->_addAction( 'init', 'setupCustomPostTypes' );
47 + $this->_addAction( 'plugins_loaded', 'loadTextDomain' );
48 + }
49 +
50 + /**
51 + * Registers custom post type for charts.
52 + *
53 + * @since 1.0.0
54 + * @uses register_post_type() To register custom post type for charts.
55 + *
56 + * @access public
57 + */
58 + public function setupCustomPostTypes() {
59 + register_post_type( Visualizer_Plugin::CPT_VISUALIZER, array(
60 + 'label' => 'Visualizer Charts',
61 + 'public' => false,
62 + ) );
63 + }
64 +
65 + /**
66 + * Loads plugin text domain translations.
67 + *
68 + * @since 1.0.0
69 + * @uses load_plugin_textdomain() To load translations for the plugin.
70 + *
71 + * @access public
72 + */
73 + public function loadTextDomain() {
74 + load_plugin_textdomain( Visualizer_Plugin::NAME, false, dirname( plugin_basename( VISUALIZER_BASEFILE ) ) . '/languages/' );
75 + }
76 +
77 +}