| @@ -59,87 +59,11 @@ | ||
| 59 | 59 | $this->_addFilter( 'media_view_strings', 'setupMediaViewStrings' ); |
| 60 | 60 | $this->_addFilter( 'plugin_action_links', 'getPluginActionLinks', 10, 2 ); |
| 61 | 61 | $this->_addFilter( 'visualizer_logger_data', 'getLoggerData' ); |
| 62 | 62 | $this->_addFilter( 'visualizer_get_chart_counts', 'getChartCountsByTypeAndMeta' ); |
| 63 | - $this->_addFilter( 'visualizer_feedback_review_trigger', 'feedbackReviewTrigger' ); | |
| 64 | - | |
| 65 | - $this->_addAction( 'admin_init', 'init' ); | |
| 66 | 63 | } |
| 67 | 64 | |
| 68 | 65 | /** |
| 69 | - * Admin init. | |
| 70 | - * | |
| 71 | - * @access public | |
| 72 | - */ | |
| 73 | - public function init() { | |
| 74 | - if ( current_user_can( 'edit_posts' ) && current_user_can( 'edit_pages' ) && 'true' == get_user_option( 'rich_editing' ) ) { | |
| 75 | - $this->_addFilter( 'mce_external_languages', 'add_tinymce_lang', 10, 1 ); | |
| 76 | - $this->_addFilter( 'mce_external_plugins', 'tinymce_plugin', 10, 1 ); | |
| 77 | - $this->_addFilter( 'mce_buttons', 'register_mce_button', 10, 1 ); | |
| 78 | - } | |
| 79 | - } | |
| 80 | - | |
| 81 | - /** | |
| 82 | - * Load plugin translation for - TinyMCE API | |
| 83 | - * | |
| 84 | - * @access public | |
| 85 | - * @param array $arr The tinymce_lang array. | |
| 86 | - * @return array | |
| 87 | - */ | |
| 88 | - public function add_tinymce_lang( $arr ) { | |
| 89 | - $ui_lang = VISUALIZER_ABSPATH . '/classes/Visualizer/Module/Language.php'; | |
| 90 | - $ui_lang = apply_filters( 'visualizer_ui_lang_filter', $ui_lang ); | |
| 91 | - $arr[] = $ui_lang; | |
| 92 | - return $arr; | |
| 93 | - } | |
| 94 | - | |
| 95 | - /** | |
| 96 | - * Load custom js options - TinyMCE API | |
| 97 | - * | |
| 98 | - * @access public | |
| 99 | - * @param array $plugin_array The tinymce plugin array. | |
| 100 | - * @return array | |
| 101 | - */ | |
| 102 | - public function tinymce_plugin( $plugin_array ) { | |
| 103 | - $plugin_array['visualizer_mce_button'] = VISUALIZER_ABSURL . 'js/mce.js'; | |
| 104 | - return $plugin_array; | |
| 105 | - } | |
| 106 | - | |
| 107 | - /** | |
| 108 | - * Register new button in the editor | |
| 109 | - * | |
| 110 | - * @access public | |
| 111 | - * @param array $buttons The tinymce buttons array. | |
| 112 | - * @return array | |
| 113 | - */ | |
| 114 | - public function register_mce_button( $buttons ) { | |
| 115 | - array_push( $buttons, 'visualizer_mce_button' ); | |
| 116 | - return $buttons; | |
| 117 | - } | |
| 118 | - | |
| 119 | - /** | |
| 120 | - * Whether to show the feedback review or not. | |
| 121 | - * | |
| 122 | - * @access public | |
| 123 | - */ | |
| 124 | - public function feedbackReviewTrigger( $dumb ) { | |
| 125 | - $query = new WP_Query( | |
| 126 | - array( | |
| 127 | - 'posts_per_page' => 50, | |
| 128 | - 'post_type' => Visualizer_Plugin::CPT_VISUALIZER, | |
| 129 | - 'fields' => 'ids', | |
| 130 | - 'update_post_meta_cache' => false, | |
| 131 | - 'update_post_term_cache' => false, | |
| 132 | - ) | |
| 133 | - ); | |
| 134 | - | |
| 135 | - if ( $query->have_posts() && $query->post_count > 0 ) { | |
| 136 | - return true; | |
| 137 | - } | |
| 138 | - return false; | |
| 139 | - } | |
| 140 | - | |
| 141 | - /** | |
| 142 | 66 | * Enqueues media scripts and styles. |
| 143 | 67 | * |
| 144 | 68 | * @since 1.0.0 |
| 145 | 69 | * @uses wp_enqueue_style To enqueue style file. |
| @@ -173,9 +97,8 @@ | ||
| 173 | 97 | * |
| 174 | 98 | * @return array The extended array of media view strings. |
| 175 | 99 | */ |
| 176 | 100 | public function setupMediaViewStrings( $strings ) { |
| 177 | - $chart_types = self::_getChartTypesLocalized( true, true, true ); | |
| 178 | 101 | $strings['visualizer'] = array( |
| 179 | 102 | 'actions' => array( |
| 180 | 103 | 'get_charts' => Visualizer_Plugin::ACTION_GET_CHARTS, |
| 181 | 104 | 'delete_chart' => Visualizer_Plugin::ACTION_DELETE_CHART, |
| @@ -187,10 +110,10 @@ | ||
| 187 | 110 | 'library' => esc_html__( 'From Library', 'visualizer' ), |
| 188 | 111 | 'create' => esc_html__( 'Create New', 'visualizer' ), |
| 189 | 112 | ), |
| 190 | 113 | 'library' => array( |
| 191 | - 'filters' => $chart_types, | |
| 192 | - 'types' => array_keys( $chart_types ), | |
| 114 | + 'filters' => self::_getChartTypesLocalized( true, true ), | |
| 115 | + 'types' => array_keys( self::_getChartTypesLocalized( true, true ) ), | |
| 193 | 116 | ), |
| 194 | 117 | 'nonce' => wp_create_nonce(), |
| 195 | 118 | 'buildurl' => add_query_arg( 'action', Visualizer_Plugin::ACTION_CREATE_CHART, admin_url( 'admin-ajax.php' ) ), |
| 196 | 119 | ); |
| @@ -206,69 +129,59 @@ | ||
| 206 | 129 | * @static |
| 207 | 130 | * @access private |
| 208 | 131 | * @return array The associated array of chart types with localized names. |
| 209 | 132 | */ |
| 210 | - public static function _getChartTypesLocalized( $enabledOnly = false, $get2Darray = false, $add_select = false ) { | |
| 211 | - $additional = array(); | |
| 212 | - if ( $add_select ) { | |
| 213 | - $additional['select'] = array( | |
| 214 | - 'name' => esc_html__( 'All', 'visualizer' ), | |
| 133 | + public static function _getChartTypesLocalized( $enabledOnly = false, $get2Darray = false ) { | |
| 134 | + $types = array( | |
| 135 | + 'pie' => array( | |
| 136 | + 'name' => esc_html__( 'Pie', 'visualizer' ), | |
| 215 | 137 | 'enabled' => true, |
| 216 | - ); | |
| 217 | - } | |
| 218 | - | |
| 219 | - $types = array_merge( | |
| 220 | - $additional, array( | |
| 221 | - 'pie' => array( | |
| 222 | - 'name' => esc_html__( 'Pie', 'visualizer' ), | |
| 223 | - 'enabled' => true, | |
| 224 | - ), | |
| 225 | - 'line' => array( | |
| 226 | - 'name' => esc_html__( 'Line', 'visualizer' ), | |
| 227 | - 'enabled' => true, | |
| 228 | - ), | |
| 229 | - 'area' => array( | |
| 230 | - 'name' => esc_html__( 'Area', 'visualizer' ), | |
| 231 | - 'enabled' => true, | |
| 232 | - ), | |
| 233 | - 'geo' => array( | |
| 234 | - 'name' => esc_html__( 'Geo', 'visualizer' ), | |
| 235 | - 'enabled' => true, | |
| 236 | - ), | |
| 237 | - 'bar' => array( | |
| 238 | - 'name' => esc_html__( 'Bar', 'visualizer' ), | |
| 239 | - 'enabled' => true, | |
| 240 | - ), | |
| 241 | - 'column' => array( | |
| 242 | - 'name' => esc_html__( 'Column', 'visualizer' ), | |
| 243 | - 'enabled' => true, | |
| 244 | - ), | |
| 245 | - 'gauge' => array( | |
| 246 | - 'name' => esc_html__( 'Gauge', 'visualizer' ), | |
| 247 | - 'enabled' => true, | |
| 248 | - ), | |
| 249 | - 'scatter' => array( | |
| 250 | - 'name' => esc_html__( 'Scatter', 'visualizer' ), | |
| 251 | - 'enabled' => true, | |
| 252 | - ), | |
| 253 | - 'candlestick' => array( | |
| 254 | - 'name' => esc_html__( 'Candlestick', 'visualizer' ), | |
| 255 | - 'enabled' => true, | |
| 256 | - ), | |
| 257 | - // pro types | |
| 258 | - 'table' => array( | |
| 259 | - 'name' => esc_html__( 'Table', 'visualizer' ), | |
| 260 | - 'enabled' => false, | |
| 261 | - ), | |
| 262 | - 'timeline' => array( | |
| 263 | - 'name' => esc_html__( 'Timeline', 'visualizer' ), | |
| 264 | - 'enabled' => false, | |
| 265 | - ), | |
| 266 | - 'combo' => array( | |
| 267 | - 'name' => esc_html__( 'Combo', 'visualizer' ), | |
| 268 | - 'enabled' => false, | |
| 269 | - ), | |
| 270 | - ) | |
| 138 | + ), | |
| 139 | + 'line' => array( | |
| 140 | + 'name' => esc_html__( 'Line', 'visualizer' ), | |
| 141 | + 'enabled' => true, | |
| 142 | + ), | |
| 143 | + 'area' => array( | |
| 144 | + 'name' => esc_html__( 'Area', 'visualizer' ), | |
| 145 | + 'enabled' => true, | |
| 146 | + ), | |
| 147 | + 'geo' => array( | |
| 148 | + 'name' => esc_html__( 'Geo', 'visualizer' ), | |
| 149 | + 'enabled' => true, | |
| 150 | + ), | |
| 151 | + 'bar' => array( | |
| 152 | + 'name' => esc_html__( 'Bar', 'visualizer' ), | |
| 153 | + 'enabled' => true, | |
| 154 | + ), | |
| 155 | + 'column' => array( | |
| 156 | + 'name' => esc_html__( 'Column', 'visualizer' ), | |
| 157 | + 'enabled' => true, | |
| 158 | + ), | |
| 159 | + 'gauge' => array( | |
| 160 | + 'name' => esc_html__( 'Gauge', 'visualizer' ), | |
| 161 | + 'enabled' => true, | |
| 162 | + ), | |
| 163 | + 'scatter' => array( | |
| 164 | + 'name' => esc_html__( 'Scatter', 'visualizer' ), | |
| 165 | + 'enabled' => true, | |
| 166 | + ), | |
| 167 | + 'candlestick' => array( | |
| 168 | + 'name' => esc_html__( 'Candlestick', 'visualizer' ), | |
| 169 | + 'enabled' => true, | |
| 170 | + ), | |
| 171 | + // pro types | |
| 172 | + 'table' => array( | |
| 173 | + 'name' => esc_html__( 'Table', 'visualizer' ), | |
| 174 | + 'enabled' => false, | |
| 175 | + ), | |
| 176 | + 'timeline' => array( | |
| 177 | + 'name' => esc_html__( 'Timeline', 'visualizer' ), | |
| 178 | + 'enabled' => false, | |
| 179 | + ), | |
| 180 | + 'combo' => array( | |
| 181 | + 'name' => esc_html__( 'Combo', 'visualizer' ), | |
| 182 | + 'enabled' => false, | |
| 183 | + ), | |
| 271 | 184 | ); |
| 272 | 185 | $types = apply_filters( 'visualizer_pro_chart_types', $types ); |
| 273 | 186 | if ( $enabledOnly ) { |
| 274 | 187 | $filtered = array(); |