| @@ -1,342 +1,1933 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -if( !class_exists( 'Chart_Builder_Functions' ) ){ | |
| 4 | - | |
| 5 | - /** | |
| 6 | - * Class Chart_Builder_Functions | |
| 7 | - * Class contains useful functions that uses in common | |
| 8 | - * | |
| 9 | - * | |
| 10 | - * Hooks used in the class | |
| 11 | - * There are not hooks yet | |
| 12 | - * @hooks @actions | |
| 13 | - * @filters | |
| 14 | - * | |
| 15 | - * | |
| 16 | - * @param $plugin_name | |
| 17 | - * | |
| 18 | - * @since 1.0.0 | |
| 19 | - * @package Chart_Builder | |
| 20 | - * @subpackage Chart_Builder/includes | |
| 21 | - * @author Chart Builder Team <[email protected]> | |
| 22 | - */ | |
| 23 | - class Chart_Builder_Functions { | |
| 24 | - | |
| 25 | - /** | |
| 26 | - * The ID of this plugin. | |
| 27 | - * | |
| 28 | - * @since 1.0.0 | |
| 29 | - * @access private | |
| 30 | - * @var string $plugin_name The ID of this plugin. | |
| 31 | - */ | |
| 32 | - private $plugin_name; | |
| 33 | - | |
| 34 | - /** | |
| 35 | - * The constructor of the class | |
| 36 | - * | |
| 37 | - * @since 1.0.0 | |
| 38 | - * @param $plugin_name | |
| 39 | - */ | |
| 40 | - public function __construct( $plugin_name ) { | |
| 41 | - global $wpdb; | |
| 42 | - /** | |
| 43 | - * Assigning $plugin_name to the @plugin_name property | |
| 44 | - */ | |
| 45 | - $this->plugin_name = $plugin_name; | |
| 46 | - $this->db_table = $wpdb->prefix . CHART_BUILDER_DB_PREFIX . "charts"; | |
| 47 | - } | |
| 48 | - | |
| 49 | - | |
| 50 | - /** | |
| 51 | - * Get instance of this class | |
| 52 | - * | |
| 53 | - * @access public | |
| 54 | - * @since 1.0.0 | |
| 55 | - * @param $plugin_name | |
| 56 | - * @return Chart_Builder_Functions | |
| 57 | - */ | |
| 58 | - public static function get_instance( $plugin_name ){ | |
| 59 | - return new self( $plugin_name ); | |
| 60 | - } | |
| 61 | - | |
| 62 | - /** | |
| 63 | - * Date validation function | |
| 64 | - * | |
| 65 | - * @accept two parameters | |
| 66 | - * @param $date | |
| 67 | - * @param string $format | |
| 68 | - * | |
| 69 | - * @return bool | |
| 70 | - */ | |
| 71 | - public function validateDate( $date, $format = 'Y-m-d H:i:s' ){ | |
| 72 | - $d = DateTime::createFromFormat($format, $date); | |
| 73 | - return $d && $d->format($format) == $date; | |
| 74 | - } | |
| 75 | - | |
| 76 | - | |
| 77 | - /** | |
| 78 | - * Version compare function | |
| 79 | - * | |
| 80 | - * @accept two parameters | |
| 81 | - * @param $version1 | |
| 82 | - * @param $operator | |
| 83 | - * @param $version2 | |
| 84 | - * | |
| 85 | - * @return bool|int | |
| 86 | - */ | |
| 87 | - public function versionCompare( $version1, $operator, $version2 ) { | |
| 88 | - | |
| 89 | - $_fv = intval ( trim ( str_replace ( '.', '', $version1 ) ) ); | |
| 90 | - $_sv = intval ( trim ( str_replace ( '.', '', $version2 ) ) ); | |
| 91 | - | |
| 92 | - if (strlen ( $_fv ) > strlen ( $_sv )) { | |
| 93 | - $_sv = str_pad ( $_sv, strlen ( $_fv ), 0 ); | |
| 94 | - } | |
| 95 | - | |
| 96 | - if (strlen ( $_fv ) < strlen ( $_sv )) { | |
| 97 | - $_fv = str_pad ( $_fv, strlen ( $_sv ), 0 ); | |
| 98 | - } | |
| 99 | - | |
| 100 | - return version_compare ( ( string ) $_fv, ( string ) $_sv, $operator ); | |
| 101 | - } | |
| 102 | - | |
| 103 | - public function get_all_charts_count() { | |
| 104 | - global $wpdb; | |
| 105 | - $sql = "SELECT COUNT(id) FROM " . $this->db_table . " WHERE `status`='published'"; | |
| 106 | - return intval( $wpdb->get_var( $sql ) ); | |
| 107 | - } | |
| 108 | - | |
| 109 | - | |
| 110 | - /** | |
| 111 | - * Gets the properties of the post type | |
| 112 | - * | |
| 113 | - * @access friendly | |
| 114 | - */ | |
| 115 | - // public function fetch_post_type_properties() { | |
| 116 | - // $array = $this->get_post_type_properties( $_POST['post_type'] ); | |
| 117 | - // $this->_sendResponse( | |
| 118 | - // array( | |
| 119 | - // 'success' => true, | |
| 120 | - // 'fields' => $array, | |
| 121 | - // ) | |
| 122 | - // ); | |
| 123 | - // wp_die(); | |
| 124 | - // } | |
| 125 | - | |
| 126 | - /** | |
| 127 | - * Gets the allowed types | |
| 128 | - * | |
| 129 | - * @access private | |
| 130 | - */ | |
| 131 | - public function getAllowedTypes() { | |
| 132 | - return array( | |
| 133 | - 'string', | |
| 134 | - 'number', | |
| 135 | - 'boolean', | |
| 136 | - 'date', | |
| 137 | - 'datetime', | |
| 138 | - 'timeofday', | |
| 139 | - ); | |
| 140 | - } | |
| 141 | - | |
| 142 | - /** | |
| 143 | - * Gets the properties of the post type | |
| 144 | - * | |
| 145 | - * @access private | |
| 146 | - */ | |
| 147 | - public function get_post_type_properties( $post_type ) { | |
| 148 | - $array = null; | |
| 149 | - | |
| 150 | - $query = new WP_Query( | |
| 151 | - array( | |
| 152 | - 'post_type' => $post_type, | |
| 153 | - 'no_rows_found' => false, | |
| 154 | - 'post_per_page' => 1, | |
| 155 | - 'orderby' => 'post_date', | |
| 156 | - 'order' => 'DESC', | |
| 157 | - 'fields' => 'ids', | |
| 158 | - 'update_post_meta_cache' => false, | |
| 159 | - 'update_post_term_cache' => false, | |
| 160 | - ) | |
| 161 | - ); | |
| 162 | - | |
| 163 | - $array = array( | |
| 164 | - 'post_title', | |
| 165 | - 'post_status', | |
| 166 | - 'comment_count', | |
| 167 | - 'post_date', | |
| 168 | - 'post_modified', | |
| 169 | - ); | |
| 170 | - | |
| 171 | - if ( $query->have_posts() ) { | |
| 172 | - $id = $query->posts[0]; | |
| 173 | - $meta = get_post_meta( $id, '', true ); | |
| 174 | - foreach ( $meta as $key => $values ) { | |
| 175 | - $array[] = $key; | |
| 176 | - } | |
| 177 | - } | |
| 178 | - | |
| 179 | - return $array; | |
| 180 | - } | |
| 181 | - | |
| 182 | - /** | |
| 183 | - * Gets all tables and their columns. | |
| 184 | - * | |
| 185 | - * @access public | |
| 186 | - * @return array | |
| 187 | - */ | |
| 188 | - public function get_all_db_tables_column_mapping( $chart_id, $use_filter = true ) { | |
| 189 | - $mapping = array(); | |
| 190 | - $tables = $this->get_db_tables(); | |
| 191 | - foreach ( $tables as $table ) { | |
| 192 | - $cols = $this->get_db_table_columns( $table, true ); | |
| 193 | - $names = wp_list_pluck( $cols, 'name' ); | |
| 194 | - $mapping[ $table ] = $names; | |
| 195 | - } | |
| 196 | - | |
| 197 | - return $mapping; | |
| 198 | - } | |
| 199 | - | |
| 200 | - /** | |
| 201 | - * Gets the tables in the database; | |
| 202 | - * | |
| 203 | - * @access public | |
| 204 | - * @return array | |
| 205 | - */ | |
| 206 | - public function get_db_tables() { | |
| 207 | - global $wpdb; | |
| 208 | - $tables = get_transient( CHART_BUILDER_DB_PREFIX . 'db_tables' ); | |
| 209 | - if ( $tables ) { | |
| 210 | - return $tables; | |
| 211 | - } | |
| 212 | - | |
| 213 | - $sql = $wpdb->get_col( 'SHOW TABLES', 0 ); | |
| 214 | - foreach ( $sql as $table ) { | |
| 215 | - if ( empty( $prefix ) || 0 === strpos( $table, $wpdb->prefix ) ) { | |
| 216 | - $tables[] = $table; | |
| 217 | - } | |
| 218 | - } | |
| 219 | - | |
| 220 | - set_transient( CHART_BUILDER_DB_PREFIX . 'db_tables', $tables, HOUR_IN_SECONDS ); | |
| 221 | - return $tables; | |
| 222 | - } | |
| 223 | - | |
| 224 | - /** | |
| 225 | - * Gets the column information for the table. | |
| 226 | - * | |
| 227 | - * @param string $table The table. | |
| 228 | - * @param bool $prefix_with_table Whether to prefix column name with the name of the table. | |
| 229 | - * @access private | |
| 230 | - * @return array | |
| 231 | - */ | |
| 232 | - private function get_db_table_columns( $table, $prefix_with_table = false ) { | |
| 233 | - global $wpdb; | |
| 234 | - $columns = get_transient( CHART_BUILDER_DB_PREFIX . "db_{$table}_columns" ); | |
| 235 | - if ( $columns ) { | |
| 236 | - return $columns; | |
| 237 | - } | |
| 238 | - $columns = array(); | |
| 239 | - // @codingStandardsIgnoreStart | |
| 240 | - $rows = $wpdb->get_results( "SHOW COLUMNS IN `$table`", ARRAY_N ); | |
| 241 | - // @codingStandardsIgnoreEnd | |
| 242 | - if ( $rows ) { | |
| 243 | - // n => numeric, d => date-ish, s => string-ish. | |
| 244 | - foreach ( $rows as $row ) { | |
| 245 | - $col = ( $prefix_with_table ? "$table." : '' ) . $row[0]; | |
| 246 | - $type = $row[1]; | |
| 247 | - if ( strpos( $type, 'int' ) !== false || strpos( $type, 'float' ) !== false ) { | |
| 248 | - $type = 'n'; | |
| 249 | - } elseif ( strpos( $type, 'date' ) !== false || strpos( $type, 'time' ) !== false ) { | |
| 250 | - $type = 'd'; | |
| 251 | - } else { | |
| 252 | - $type = 's'; | |
| 253 | - } | |
| 254 | - $columns[] = array( 'name' => $col, 'type' => $type ); | |
| 255 | - } | |
| 256 | - } | |
| 257 | - | |
| 258 | - set_transient( CHART_BUILDER_DB_PREFIX . "db_{$table}_columns", $columns, DAY_IN_SECONDS ); | |
| 259 | - return $columns; | |
| 260 | - } | |
| 261 | - | |
| 262 | - /** | |
| 263 | - * Gets the dependent tables and then gets column information for all the tables. | |
| 264 | - * | |
| 265 | - * @param string $table The table. | |
| 266 | - * @access public | |
| 267 | - * @return array | |
| 268 | - */ | |
| 269 | - public function get_table_columns( $table ) { | |
| 270 | - $columns = array(); | |
| 271 | - if ( ! $table ) { | |
| 272 | - return $columns; | |
| 273 | - } | |
| 274 | - | |
| 275 | - $tables = array( $table ); | |
| 276 | - $mapping = $this->get_db_table_mapping(); | |
| 277 | - if ( array_key_exists( $table, $mapping ) ) { | |
| 278 | - $tables[] = $mapping[ $table ]; | |
| 279 | - } | |
| 280 | - foreach ( $tables as $table ) { | |
| 281 | - $cols = $this->get_db_table_columns( $table, count( $tables ) > 1 ); | |
| 282 | - $columns = array_merge( $columns, $cols ); | |
| 283 | - } | |
| 284 | - return $columns; | |
| 285 | - } | |
| 286 | - | |
| 287 | - /** | |
| 288 | - * Gets the relationship between tables in the database. | |
| 289 | - * | |
| 290 | - * @access public | |
| 291 | - * @return array | |
| 292 | - */ | |
| 293 | - public function get_db_table_mapping() { | |
| 294 | - global $wpdb; | |
| 295 | - $mapping = get_transient( CHART_BUILDER_DB_PREFIX . 'db_table_mapping' ); | |
| 296 | - if ( $mapping ) { | |
| 297 | - return $mapping; | |
| 298 | - } | |
| 299 | - // no need to provide x=>y and then y=>x as we will flip the array shortly. | |
| 300 | - $mapping = array( | |
| 301 | - $wpdb->prefix . 'posts' => $wpdb->prefix . 'postmeta', | |
| 302 | - $wpdb->prefix . 'users' => $wpdb->prefix . 'usermeta', | |
| 303 | - $wpdb->prefix . 'terms' => $wpdb->prefix . 'termmeta', | |
| 304 | - $wpdb->prefix . 'comments' => $wpdb->prefix . 'commentmeta', | |
| 305 | - ); | |
| 306 | - | |
| 307 | - $mapping += array_flip( $mapping ); | |
| 308 | - set_transient( CHART_BUILDER_DB_PREFIX . 'db_table_mapping', $mapping, HOUR_IN_SECONDS ); | |
| 309 | - return $mapping; | |
| 310 | - } | |
| 311 | - | |
| 312 | - /** | |
| 313 | - * Creates HTML table from passed data | |
| 314 | - * | |
| 315 | - * @access public | |
| 316 | - * @return string | |
| 317 | - */ | |
| 318 | - } | |
| 319 | -} | |
| 320 | - | |
| 321 | -if( ! function_exists( 'CBFunctions' ) ){ | |
| 322 | - /** | |
| 323 | - * Function for quick access to Chart_Builder_Functions class | |
| 324 | - * | |
| 325 | - * @since 1.0.0 | |
| 326 | - * @return Chart_Builder_Functions | |
| 327 | - */ | |
| 328 | - function CBFunctions(){ | |
| 329 | - | |
| 330 | - static $instance = null; | |
| 331 | - | |
| 332 | - if( $instance === null ){ | |
| 333 | - $instance = Chart_Builder_Functions::get_instance( CHART_BUILDER_NAME ); | |
| 334 | - } | |
| 335 | - | |
| 336 | - if( $instance instanceof Chart_Builder_Functions ){ | |
| 337 | - return $instance; | |
| 338 | - } | |
| 339 | - | |
| 340 | - return Chart_Builder_Functions::get_instance( CHART_BUILDER_NAME ); | |
| 341 | - } | |
| 1 | +<?php | |
| 2 | + | |
| 3 | +if( !class_exists( 'Chart_Builder_Functions' ) ){ | |
| 4 | + | |
| 5 | + /** | |
| 6 | + * Class Chart_Builder_Functions | |
| 7 | + * Class contains useful functions that uses in common | |
| 8 | + * | |
| 9 | + * | |
| 10 | + * Hooks used in the class | |
| 11 | + * There are not hooks yet | |
| 12 | + * @hooks @actions | |
| 13 | + * @filters | |
| 14 | + * | |
| 15 | + * | |
| 16 | + * @param $plugin_name | |
| 17 | + * | |
| 18 | + * @since 1.0.0 | |
| 19 | + * @package Chart_Builder | |
| 20 | + * @subpackage Chart_Builder/includes | |
| 21 | + * @author Chart Builder Team <[email protected]> | |
| 22 | + */ | |
| 23 | + class Chart_Builder_Functions { | |
| 24 | + | |
| 25 | + /** | |
| 26 | + * The ID of this plugin. | |
| 27 | + * | |
| 28 | + * @since 1.0.0 | |
| 29 | + * @access private | |
| 30 | + * @var string $plugin_name The ID of this plugin. | |
| 31 | + */ | |
| 32 | + private $plugin_name; | |
| 33 | + | |
| 34 | + /** | |
| 35 | + * The database table name | |
| 36 | + * | |
| 37 | + * @since 1.0.0 | |
| 38 | + * @access private | |
| 39 | + * @var string $db_table The database table name | |
| 40 | + */ | |
| 41 | + private $db_table; | |
| 42 | + | |
| 43 | + /** | |
| 44 | + * The constructor of the class | |
| 45 | + * | |
| 46 | + * @since 1.0.0 | |
| 47 | + * @param $plugin_name | |
| 48 | + */ | |
| 49 | + public function __construct( $plugin_name ) { | |
| 50 | + global $wpdb; | |
| 51 | + /** | |
| 52 | + * Assigning $plugin_name to the @plugin_name property | |
| 53 | + */ | |
| 54 | + $this->plugin_name = $plugin_name; | |
| 55 | + $this->db_table = $wpdb->prefix . CHART_BUILDER_DB_PREFIX . "charts"; | |
| 56 | + } | |
| 57 | + | |
| 58 | + /** | |
| 59 | + * Get instance of this class | |
| 60 | + * | |
| 61 | + * @access public | |
| 62 | + * @since 1.0.0 | |
| 63 | + * @param $plugin_name | |
| 64 | + * @return Chart_Builder_Functions | |
| 65 | + */ | |
| 66 | + public static function get_instance( $plugin_name ){ | |
| 67 | + return new self( $plugin_name ); | |
| 68 | + } | |
| 69 | + | |
| 70 | + /** | |
| 71 | + * Date validation function | |
| 72 | + * | |
| 73 | + * @accept two parameters | |
| 74 | + * @param $date | |
| 75 | + * @param string $format | |
| 76 | + * | |
| 77 | + * @return bool | |
| 78 | + */ | |
| 79 | + public function validateDate( $date, $format = 'Y-m-d H:i:s' ){ | |
| 80 | + $d = DateTime::createFromFormat($format, $date); | |
| 81 | + return $d && $d->format($format) == $date; | |
| 82 | + } | |
| 83 | + | |
| 84 | + /** | |
| 85 | + * Version compare function | |
| 86 | + * | |
| 87 | + * @accept two parameters | |
| 88 | + * @param $version1 | |
| 89 | + * @param $operator | |
| 90 | + * @param $version2 | |
| 91 | + * | |
| 92 | + * @return bool|int | |
| 93 | + */ | |
| 94 | + public function versionCompare( $version1, $operator, $version2 ) { | |
| 95 | + | |
| 96 | + $_fv = intval ( trim ( str_replace ( '.', '', $version1 ) ) ); | |
| 97 | + $_sv = intval ( trim ( str_replace ( '.', '', $version2 ) ) ); | |
| 98 | + | |
| 99 | + if (strlen ( $_fv ) > strlen ( $_sv )) { | |
| 100 | + $_sv = str_pad ( $_sv, strlen ( $_fv ), 0 ); | |
| 101 | + } | |
| 102 | + | |
| 103 | + if (strlen ( $_fv ) < strlen ( $_sv )) { | |
| 104 | + $_fv = str_pad ( $_fv, strlen ( $_sv ), 0 ); | |
| 105 | + } | |
| 106 | + | |
| 107 | + return version_compare ( ( string ) $_fv, ( string ) $_sv, $operator ); | |
| 108 | + } | |
| 109 | + | |
| 110 | + public function get_all_charts_count() { | |
| 111 | + global $wpdb; | |
| 112 | + $where = str_replace("WHERE", "AND", Chart_Builder_DB_Actions::get_where_condition()); | |
| 113 | + | |
| 114 | + $sql = "SELECT COUNT(id) FROM {$this->db_table} WHERE `status` = %s {$where}"; | |
| 115 | + return intval( $wpdb->get_var( $wpdb->prepare($sql, 'published') ));// phpcs:ignore | |
| 116 | + } | |
| 117 | + | |
| 118 | + /** | |
| 119 | + * Gets the allowed types | |
| 120 | + * | |
| 121 | + * @access private | |
| 122 | + */ | |
| 123 | + public function getAllowedTypes() { | |
| 124 | + return array( | |
| 125 | + 'string', | |
| 126 | + 'number', | |
| 127 | + 'boolean', | |
| 128 | + 'date', | |
| 129 | + 'datetime', | |
| 130 | + 'timeofday', | |
| 131 | + ); | |
| 132 | + } | |
| 133 | + | |
| 134 | + /** | |
| 135 | + * Gets the properties of the post type | |
| 136 | + * | |
| 137 | + * @access private | |
| 138 | + */ | |
| 139 | + public function get_post_type_properties( $post_type ) { | |
| 140 | + $array = null; | |
| 141 | + | |
| 142 | + $query = new WP_Query( | |
| 143 | + array( | |
| 144 | + 'post_type' => $post_type, | |
| 145 | + 'no_rows_found' => false, | |
| 146 | + 'post_per_page' => 1, | |
| 147 | + 'orderby' => 'post_date', | |
| 148 | + 'order' => 'DESC', | |
| 149 | + 'fields' => 'ids', | |
| 150 | + 'update_post_meta_cache' => false, | |
| 151 | + 'update_post_term_cache' => false, | |
| 152 | + ) | |
| 153 | + ); | |
| 154 | + | |
| 155 | + $array = array( | |
| 156 | + 'post_title', | |
| 157 | + 'post_status', | |
| 158 | + 'comment_count', | |
| 159 | + 'post_date', | |
| 160 | + 'post_modified', | |
| 161 | + ); | |
| 162 | + | |
| 163 | + if ( $query->have_posts() ) { | |
| 164 | + $id = $query->posts[0]; | |
| 165 | + $meta = get_post_meta( $id, '', true ); | |
| 166 | + foreach ( $meta as $key => $values ) { | |
| 167 | + $array[] = $key; | |
| 168 | + } | |
| 169 | + } | |
| 170 | + | |
| 171 | + return $array; | |
| 172 | + } | |
| 173 | + | |
| 174 | + /** | |
| 175 | + * Gets all tables and their columns. | |
| 176 | + * | |
| 177 | + * @access public | |
| 178 | + * @return array | |
| 179 | + */ | |
| 180 | + public function get_all_db_tables_column_mapping( $chart_id, $use_filter = true ) { | |
| 181 | + $mapping = array(); | |
| 182 | + $tables = $this->get_db_tables(); | |
| 183 | + foreach ( $tables as $table ) { | |
| 184 | + $cols = $this->get_db_table_columns( $table, true ); | |
| 185 | + $names = wp_list_pluck( $cols, 'name' ); | |
| 186 | + $mapping[ $table ] = $names; | |
| 187 | + } | |
| 188 | + | |
| 189 | + return $mapping; | |
| 190 | + } | |
| 191 | + | |
| 192 | + /** | |
| 193 | + * Gets the tables in the database; | |
| 194 | + * | |
| 195 | + * @access public | |
| 196 | + * @return array | |
| 197 | + */ | |
| 198 | + public function get_db_tables() { | |
| 199 | + global $wpdb; | |
| 200 | + $tables = get_transient( CHART_BUILDER_DB_PREFIX . 'db_tables' ); | |
| 201 | + if ( $tables ) { | |
| 202 | + return $tables; | |
| 203 | + } | |
| 204 | + $tables = array(); | |
| 205 | + | |
| 206 | + $sql = $wpdb->get_col( 'SHOW TABLES', 0 );// phpcs:ignore | |
| 207 | + foreach ( $sql as $table ) { | |
| 208 | + if ( empty( $prefix ) || 0 === strpos( $table, $wpdb->prefix ) ) { | |
| 209 | + $tables[] = $table; | |
| 210 | + } | |
| 211 | + } | |
| 212 | + | |
| 213 | + set_transient( CHART_BUILDER_DB_PREFIX . 'db_tables', $tables, HOUR_IN_SECONDS ); | |
| 214 | + return $tables; | |
| 215 | + } | |
| 216 | + | |
| 217 | + /** | |
| 218 | + * Gets the column information for the table. | |
| 219 | + * | |
| 220 | + * @param string $table The table. | |
| 221 | + * @param bool $prefix_with_table Whether to prefix column name with the name of the table. | |
| 222 | + * @access private | |
| 223 | + * @return array | |
| 224 | + */ | |
| 225 | + private function get_db_table_columns( $table, $prefix_with_table = false ) { | |
| 226 | + global $wpdb; | |
| 227 | + $columns = get_transient( CHART_BUILDER_DB_PREFIX . "db_{$table}_columns" ); | |
| 228 | + if ( $columns ) { | |
| 229 | + return $columns; | |
| 230 | + } | |
| 231 | + $columns = array(); | |
| 232 | + // @codingStandardsIgnoreStart | |
| 233 | + $rows = $wpdb->get_results( "SHOW COLUMNS IN `$table`", ARRAY_N ); | |
| 234 | + // @codingStandardsIgnoreEnd | |
| 235 | + if ( $rows ) { | |
| 236 | + // n => numeric, d => date-ish, s => string-ish. | |
| 237 | + foreach ( $rows as $row ) { | |
| 238 | + $col = ( $prefix_with_table ? "$table." : '' ) . $row[0]; | |
| 239 | + $type = $row[1]; | |
| 240 | + if ( strpos( $type, 'int' ) !== false || strpos( $type, 'float' ) !== false ) { | |
| 241 | + $type = 'n'; | |
| 242 | + } elseif ( strpos( $type, 'date' ) !== false || strpos( $type, 'time' ) !== false ) { | |
| 243 | + $type = 'd'; | |
| 244 | + } else { | |
| 245 | + $type = 's'; | |
| 246 | + } | |
| 247 | + $columns[] = array( 'name' => $col, 'type' => $type ); | |
| 248 | + } | |
| 249 | + } | |
| 250 | + | |
| 251 | + set_transient( CHART_BUILDER_DB_PREFIX . "db_{$table}_columns", $columns, DAY_IN_SECONDS ); | |
| 252 | + return $columns; | |
| 253 | + } | |
| 254 | + | |
| 255 | + /** | |
| 256 | + * Gets the dependent tables and then gets column information for all the tables. | |
| 257 | + * | |
| 258 | + * @param string $table The table. | |
| 259 | + * @access public | |
| 260 | + * @return array | |
| 261 | + */ | |
| 262 | + public function get_table_columns( $table ) { | |
| 263 | + $columns = array(); | |
| 264 | + if ( ! $table ) { | |
| 265 | + return $columns; | |
| 266 | + } | |
| 267 | + | |
| 268 | + $tables = array( $table ); | |
| 269 | + $mapping = $this->get_db_table_mapping(); | |
| 270 | + if ( array_key_exists( $table, $mapping ) ) { | |
| 271 | + $tables[] = $mapping[ $table ]; | |
| 272 | + } | |
| 273 | + foreach ( $tables as $table ) { | |
| 274 | + $cols = $this->get_db_table_columns( $table, count( $tables ) > 1 ); | |
| 275 | + $columns = array_merge( $columns, $cols ); | |
| 276 | + } | |
| 277 | + return $columns; | |
| 278 | + } | |
| 279 | + | |
| 280 | + /** | |
| 281 | + * Gets the relationship between tables in the database. | |
| 282 | + * | |
| 283 | + * @access public | |
| 284 | + * @return array | |
| 285 | + */ | |
| 286 | + public function get_db_table_mapping() { | |
| 287 | + global $wpdb; | |
| 288 | + $mapping = get_transient( CHART_BUILDER_DB_PREFIX . 'db_table_mapping' ); | |
| 289 | + if ( $mapping ) { | |
| 290 | + return $mapping; | |
| 291 | + } | |
| 292 | + // no need to provide x=>y and then y=>x as we will flip the array shortly. | |
| 293 | + $mapping = array( | |
| 294 | + $wpdb->prefix . 'posts' => $wpdb->prefix . 'postmeta', | |
| 295 | + $wpdb->prefix . 'users' => $wpdb->prefix . 'usermeta', | |
| 296 | + $wpdb->prefix . 'terms' => $wpdb->prefix . 'termmeta', | |
| 297 | + $wpdb->prefix . 'comments' => $wpdb->prefix . 'commentmeta', | |
| 298 | + ); | |
| 299 | + | |
| 300 | + $mapping += array_flip( $mapping ); | |
| 301 | + set_transient( CHART_BUILDER_DB_PREFIX . 'db_table_mapping', $mapping, HOUR_IN_SECONDS ); | |
| 302 | + return $mapping; | |
| 303 | + } | |
| 304 | + | |
| 305 | + /** | |
| 306 | + * Creates HTML table from passed data | |
| 307 | + * | |
| 308 | + * @access public | |
| 309 | + * @return string | |
| 310 | + */ | |
| 311 | + public function get_table_html( $headers, $rows, $table_id = 'results' ) { | |
| 312 | + ob_start(); | |
| 313 | + ?> | |
| 314 | + <table cellspacing="0" width="100%" id="<?php echo esc_attr($table_id) ?>"> | |
| 315 | + <thead> | |
| 316 | + <tr> | |
| 317 | + <?php | |
| 318 | + foreach ( $headers as $header ) { | |
| 319 | + if( empty( $header ) ){ | |
| 320 | + continue; | |
| 321 | + } | |
| 322 | + echo '<th>' . esc_html($header) . '</th>'; | |
| 323 | + } | |
| 324 | + ?> | |
| 325 | + </tr> | |
| 326 | + </thead> | |
| 327 | + <tfoot> | |
| 328 | + </tfoot> | |
| 329 | + <tbody> | |
| 330 | + <?php | |
| 331 | + foreach ( $rows as $row ) { | |
| 332 | + if( empty( $row ) ){ | |
| 333 | + continue; | |
| 334 | + } | |
| 335 | + echo '<tr>'; | |
| 336 | + foreach ( $row as $r ) { | |
| 337 | + echo '<td>' . esc_html($r) . '</td>'; | |
| 338 | + } | |
| 339 | + echo '</tr>'; | |
| 340 | + } | |
| 341 | + ?> | |
| 342 | + </tbody> | |
| 343 | + </table> | |
| 344 | + <?php | |
| 345 | + return ob_get_clean(); | |
| 346 | + } | |
| 347 | + | |
| 348 | + /** | |
| 349 | + * Gets the the queries from quiz maker database tables. | |
| 350 | + * | |
| 351 | + * @access public | |
| 352 | + * @return array | |
| 353 | + */ | |
| 354 | + public function get_quiz_query ($query, $quiz_id = null, $user_id = null) { | |
| 355 | + global $wpdb; | |
| 356 | + $reports_table = $wpdb->prefix . 'aysquiz_reports'; | |
| 357 | + $quizes_table = $wpdb->prefix . 'aysquiz_quizes'; | |
| 358 | + | |
| 359 | + switch ($query) { | |
| 360 | + case 'q1': | |
| 361 | + $sql = "SELECT CAST(end_date AS date) AS `Date`, COUNT(id) AS `Count` FROM {$reports_table} WHERE quiz_id = %d GROUP BY CAST(end_date AS date)"; | |
| 362 | + $result = $wpdb->get_results($wpdb->prepare($sql, $quiz_id), "ARRAY_A");// phpcs:ignore | |
| 363 | + break; | |
| 364 | + case 'q2': | |
| 365 | + $sql = "SELECT CAST(end_date AS date) AS `Date`, COUNT(id) AS `Count` FROM {$reports_table} WHERE user_id = %d GROUP BY CAST(end_date AS date)"; | |
| 366 | + $result = $wpdb->get_results($wpdb->prepare($sql, $user_id), "ARRAY_A");// phpcs:ignore | |
| 367 | + break; | |
| 368 | + case 'q3': | |
| 369 | + $sql = "SELECT CAST(end_date AS date) AS `Date`, COUNT(id) AS `Count` FROM {$reports_table} WHERE user_id = %d AND quiz_id = %d GROUP BY CAST(end_date AS date)"; | |
| 370 | + $result = $wpdb->get_results($wpdb->prepare($sql, $user_id, $quiz_id), "ARRAY_A");// phpcs:ignore | |
| 371 | + break; | |
| 372 | + case 'q4': | |
| 373 | + $sql = "SELECT {$quizes_table}.title AS `Quiz`, AVG({$reports_table}.score) AS `Average` FROM {$reports_table} LEFT JOIN {$quizes_table} ON {$reports_table}.quiz_id = {$quizes_table}.id WHERE {$reports_table}.user_id = %d GROUP BY {$quizes_table}.title"; | |
| 374 | + $result = $wpdb->get_results($wpdb->prepare($sql, $user_id), "ARRAY_A");// phpcs:ignore | |
| 375 | + break; | |
| 376 | + case 'q5': | |
| 377 | + $sql = "SELECT {$quizes_table}.title AS `Quiz`, COUNT({$reports_table}.score) AS `Count` FROM {$reports_table} LEFT JOIN {$quizes_table} ON {$reports_table}.quiz_id = {$quizes_table}.id WHERE {$reports_table}.user_id = %d GROUP BY {$quizes_table}.title"; | |
| 378 | + $result = $wpdb->get_results($wpdb->prepare($sql, $user_id), "ARRAY_A");// phpcs:ignore | |
| 379 | + break; | |
| 380 | + case 'q6': | |
| 381 | + $sql = "SELECT score AS `Score` FROM {$reports_table} WHERE user_id = %d AND quiz_id = %d"; | |
| 382 | + $result = $wpdb->get_results($wpdb->prepare($sql, $user_id, $quiz_id), "ARRAY_A");// phpcs:ignore | |
| 383 | + break; | |
| 384 | + default: | |
| 385 | + break; | |
| 386 | + } | |
| 387 | + | |
| 388 | + | |
| 389 | + $message = empty($result) ? __( "There is no data for your query.", "chart-builder" ) : ""; | |
| 390 | + return array( | |
| 391 | + 'message' => $message, | |
| 392 | + 'result' => $result, | |
| 393 | + 'query' => $sql | |
| 394 | + ); | |
| 395 | + } | |
| 396 | + | |
| 397 | + /** | |
| 398 | + * Gets all settings of google charts for admin area. | |
| 399 | + * | |
| 400 | + * @access public | |
| 401 | + * @return array | |
| 402 | + */ | |
| 403 | + public function get_chart_settings_google_admin($settings, $action, $source) { | |
| 404 | + $chart_default_colors = array('#3366cc','#dc3912','#ff9900','#109618', '#990099','#0099c6','#dd4477','#66aa00', '#b82e2e','#316395','#994499','#22aa99', '#aaaa11','#6633cc','#e67300','#8b0707', '#651067','#329262','#5574a6','#3b3eac', '#b77322','#16d620','#b91383','#f4359e', '#9c5935','#a9c413','#2a778d','#668d1c', '#bea413','#0c5922','#743411'); | |
| 405 | + | |
| 406 | + $tooltip_trigger_options = array( | |
| 407 | + "hover" => __("While hovering", "chart-builder"), | |
| 408 | + "selection" => __("When selected", "chart-builder"), | |
| 409 | + "none" => __("Disable", "chart-builder") | |
| 410 | + ); | |
| 411 | + | |
| 412 | + $tooltip_bold_options = array( | |
| 413 | + "default" => __("Default", "chart-builder"), | |
| 414 | + "true" => __("Enable", "chart-builder"), | |
| 415 | + "false" => __("Disable", "chart-builder") | |
| 416 | + ); | |
| 417 | + | |
| 418 | + $tooltip_text_options = array( | |
| 419 | + "value" => __("Value", "chart-builder"), | |
| 420 | + "percentage" => __("Percent", "chart-builder"), | |
| 421 | + "both" => __("Value & Percent", "chart-builder") | |
| 422 | + ); | |
| 423 | + | |
| 424 | + $focus_target_options = array( | |
| 425 | + "datum" => __("Single data", "chart-builder"), | |
| 426 | + "category" => __("Group data", "chart-builder"), | |
| 427 | + ); | |
| 428 | + | |
| 429 | + $legend_positions = array( | |
| 430 | + "left" => __("Left of the chart", "chart-builder"), | |
| 431 | + "right" => __("Right of the chart", "chart-builder"), | |
| 432 | + "top" => __("Above the chart", "chart-builder"), | |
| 433 | + "bottom" => __("Below the chart", "chart-builder"), | |
| 434 | + "in" => __("Inside the chart", "chart-builder"), | |
| 435 | + "labeled" => __("Labeled", "chart-builder"), | |
| 436 | + "none" => __("Hide", "chart-builder") | |
| 437 | + ); | |
| 438 | + | |
| 439 | + $legend_alignments = array( | |
| 440 | + "start" => __("Start", "chart-builder"), | |
| 441 | + "center" => __("Center", "chart-builder"), | |
| 442 | + "end" => __("End", "chart-builder"), | |
| 443 | + ); | |
| 444 | + | |
| 445 | + $slice_texts = array( | |
| 446 | + "percentage" => __("Percentage", "chart-builder"), | |
| 447 | + "value" => __("Quantitative value", "chart-builder"), | |
| 448 | + "label" => __("Name", "chart-builder"), | |
| 449 | + "none" => __("Disable", "chart-builder") | |
| 450 | + ); | |
| 451 | + | |
| 452 | + $axes_text_positions = array( | |
| 453 | + "in" => __("Inside the chart", "chart-builder"), | |
| 454 | + "out" => __("Outside the chart", "chart-builder"), | |
| 455 | + "none" => __("Hide", "chart-builder") | |
| 456 | + ); | |
| 457 | + | |
| 458 | + $haxis_slanted_options = array( | |
| 459 | + "automatic" => __("Automatic", "chart-builder"), | |
| 460 | + "true" => __("True", "chart-builder"), | |
| 461 | + "false" => __("False", "chart-builder") | |
| 462 | + ); | |
| 463 | + | |
| 464 | + $title_positions = array( | |
| 465 | + "left" => __("Left", "chart-builder"), | |
| 466 | + "right" => __("Right", "chart-builder"), | |
| 467 | + "center" => __("Center", "chart-builder") | |
| 468 | + ); | |
| 469 | + | |
| 470 | + $border_styles = array( | |
| 471 | + "solid" => __("Solid", "chart-builder"), | |
| 472 | + "dashed" => __("Dashed", "chart-builder"), | |
| 473 | + "dotted" => __("Dotted", "chart-builder"), | |
| 474 | + "double" => __("Double", "chart-builder"), | |
| 475 | + "groove" => __("Groove", "chart-builder"), | |
| 476 | + "inset" => __("Inset", "chart-builder"), | |
| 477 | + "outset" => __("Outset", "chart-builder"), | |
| 478 | + "ridge" => __("Ridge", "chart-builder") | |
| 479 | + ); | |
| 480 | + | |
| 481 | + $animation_easing_options = array( | |
| 482 | + "linear" => __("Linear", "chart-builder"), | |
| 483 | + "in" => __("Ease in", "chart-builder"), | |
| 484 | + "out" => __("Ease out", "chart-builder"), | |
| 485 | + "inAndOut" => __("Ease in and out", "chart-builder") | |
| 486 | + ); | |
| 487 | + | |
| 488 | + $multiple_data_format_options = array( | |
| 489 | + "category" => __("Category", "chart-builder"), | |
| 490 | + "series" => __("Series", "chart-builder"), | |
| 491 | + "auto" => __("Auto", "chart-builder"), | |
| 492 | + "none" => __("None", "chart-builder"), | |
| 493 | + ); | |
| 494 | + | |
| 495 | + $point_shape_options = array( | |
| 496 | + "circle" => __("Circle", "chart-builder"), | |
| 497 | + "triangle" => __("Triangle", "chart-builder"), | |
| 498 | + "square" => __("Square", "chart-builder"), | |
| 499 | + "diamond" => __("Diamond", "chart-builder"), | |
| 500 | + "star" => __("Star", "chart-builder"), | |
| 501 | + "polygon" => __("Polygon", "chart-builder"), | |
| 502 | + ); | |
| 503 | + | |
| 504 | + $crosshair_trigger_options = array( | |
| 505 | + "focus" => __("Focus", "chart-builder"), | |
| 506 | + "selection" => __("Selection", "chart-builder"), | |
| 507 | + "both" => __("Focus and Selection", "chart-builder"), | |
| 508 | + "none" => __("Disable", "chart-builder"), | |
| 509 | + ); | |
| 510 | + | |
| 511 | + $crosshair_orientation_options = array( | |
| 512 | + "vertical" => __("Vertical", "chart-builder"), | |
| 513 | + "horizontal" => __("Horizontal", "chart-builder"), | |
| 514 | + "both" => __("Both", "chart-builder"), | |
| 515 | + ); | |
| 516 | + | |
| 517 | + $axes_format_options = array( | |
| 518 | + "" => __("None", "chart-builder"), | |
| 519 | + "decimal" => __("Decimal", "chart-builder"), | |
| 520 | + "scientific" => __("Scientific", "chart-builder"), | |
| 521 | + "currency" => __("Currency", "chart-builder"), | |
| 522 | + "percent" => __("Percent", "chart-builder"), | |
| 523 | + "short" => __("Short", "chart-builder"), | |
| 524 | + "long" => __("Long", "chart-builder"), | |
| 525 | + ); | |
| 526 | + | |
| 527 | + $group_width_format_options = array( | |
| 528 | + "%" => __("%", "chart-builder"), | |
| 529 | + "px" => __("px", "chart-builder"), | |
| 530 | + ); | |
| 531 | + | |
| 532 | + $position_styles = array( | |
| 533 | + "left" => 'margin-left:0', | |
| 534 | + "right" => 'margin-right:0', | |
| 535 | + "center" => 'margin:auto', | |
| 536 | + ); | |
| 537 | + | |
| 538 | + $org_chart_font_size_options = array( | |
| 539 | + "small" => __("Small", "chart-builder"), | |
| 540 | + "medium" => __("Medium", "chart-builder"), | |
| 541 | + "large" => __("Large", "chart-builder"), | |
| 542 | + ); | |
| 543 | + | |
| 544 | + $text_transforms = array( | |
| 545 | + "uppercase" => __("Uppercase", "chart-builder"), | |
| 546 | + "lowercase" => __("Lowercase", "chart-builder"), | |
| 547 | + "capitalize" => __("Capitalize", "chart-builder"), | |
| 548 | + "none" => __("None", "chart-builder"), | |
| 549 | + ); | |
| 550 | + | |
| 551 | + $text_decorations = array( | |
| 552 | + "overline" => __("Overline", "chart-builder"), | |
| 553 | + "underline" => __("Underline", "chart-builder"), | |
| 554 | + "line-through" => __("Line through", "chart-builder"), | |
| 555 | + "none" => __("None", "chart-builder"), | |
| 556 | + ); | |
| 557 | + | |
| 558 | + // Width | |
| 559 | + $settings['width'] = isset( $settings['width'] ) && $settings['width'] != '' ? esc_attr( $settings['width'] ) : '100'; | |
| 560 | + $settings['width_format'] = isset( $settings['width_format'] ) && $settings['width_format'] != '' ? esc_attr( $settings['width_format'] ) : '%'; | |
| 561 | + $settings['width_format_options'] = $group_width_format_options; | |
| 562 | + | |
| 563 | + // responsive width | |
| 564 | + $settings['responsive_width'] = ( isset( $settings['responsive_width'] ) && $settings['responsive_width'] != '' ) ? $settings['responsive_width'] : 'off'; | |
| 565 | + $settings['responsive_width'] = isset( $settings['responsive_width'] ) && $settings['responsive_width'] == 'on' ? 'checked' : ''; | |
| 566 | + | |
| 567 | + // position | |
| 568 | + $settings['position'] = isset( $settings['position'] ) && $settings['position'] != '' ? esc_attr( $settings['position'] ) : 'center'; | |
| 569 | + $settings['position_styles'] = $position_styles; | |
| 570 | + | |
| 571 | + // Height | |
| 572 | + $settings['height'] = isset( $settings['height'] ) && $settings['height'] != '' ? esc_attr( $settings['height'] ) : '400'; | |
| 573 | + $settings['height_format'] = isset( $settings['height_format'] ) && $settings['height_format'] != '' ? esc_attr( $settings['height_format'] ) : 'px'; | |
| 574 | + | |
| 575 | + // Font size | |
| 576 | + $settings['font_size'] = isset( $settings['font_size'] ) && $settings['font_size'] != '' ? esc_attr( $settings['font_size'] ) : '15'; | |
| 577 | + | |
| 578 | + // Background color | |
| 579 | + $settings['background_color'] = isset( $settings['background_color'] ) && $settings['background_color'] != '' ? esc_attr( $settings['background_color'] ) : '#ffffff'; | |
| 580 | + | |
| 581 | + // Transparent background | |
| 582 | + $settings['transparent_background'] = isset( $settings['transparent_background'] ) && $settings['transparent_background'] != '' ? esc_attr( $settings['transparent_background'] ) : 'off'; | |
| 583 | + $settings['transparent_background'] = isset( $settings['transparent_background'] ) && $settings['transparent_background'] == 'on' ? 'checked' : ''; | |
| 584 | + | |
| 585 | + // Box shadow | |
| 586 | + $settings['box_shadow'] = isset( $settings['box_shadow'] ) && $settings['box_shadow'] != '' ? esc_attr( $settings['box_shadow'] ) : 'off'; | |
| 587 | + $settings['box_shadow'] = isset( $settings['box_shadow'] ) && $settings['box_shadow'] == 'on' ? 'checked' : ''; | |
| 588 | + | |
| 589 | + // Border width | |
| 590 | + $settings['border_width'] = isset( $settings['border_width'] ) && $settings['border_width'] != '' ? esc_attr( $settings['border_width'] ) : '0'; | |
| 591 | + | |
| 592 | + // Border radius | |
| 593 | + $settings['border_radius'] = isset( $settings['border_radius'] ) && $settings['border_radius'] != '' ? esc_attr( $settings['border_radius'] ) : '0'; | |
| 594 | + | |
| 595 | + // Border color | |
| 596 | + $settings['border_color'] = isset( $settings['border_color'] ) && $settings['border_color'] != '' ? esc_attr( $settings['border_color'] ) : '#666666'; | |
| 597 | + | |
| 598 | + // Border style | |
| 599 | + $settings['border_style'] = isset( $settings['border_style'] ) && $settings['border_style'] != '' ? esc_attr( $settings['border_style'] ) : 'solid'; | |
| 600 | + | |
| 601 | + // Border width with title | |
| 602 | + $settings['border_width_with_title'] = isset( $settings['border_width_with_title'] ) && $settings['border_width_with_title'] != '' ? esc_attr( $settings['border_width_with_title'] ) : '0'; | |
| 603 | + | |
| 604 | + // Border radius with title | |
| 605 | + $settings['border_radius_with_title'] = isset( $settings['border_radius_with_title'] ) && $settings['border_radius_with_title'] != '' ? esc_attr( $settings['border_radius_with_title'] ) : '0'; | |
| 606 | + | |
| 607 | + // Border color with title | |
| 608 | + $settings['border_color_with_title'] = isset( $settings['border_color_with_title'] ) && $settings['border_color_with_title'] != '' ? esc_attr( $settings['border_color_with_title'] ) : '#000000'; | |
| 609 | + | |
| 610 | + // Border style with title | |
| 611 | + $settings['border_style_with_title'] = isset( $settings['border_style_with_title'] ) && $settings['border_style_with_title'] != '' ? esc_attr( $settings['border_style_with_title'] ) : 'solid'; | |
| 612 | + $settings['border_styles'] = $border_styles; | |
| 613 | + | |
| 614 | + // Padding outer | |
| 615 | + $settings['padding_outer'] = isset( $settings['padding_outer'] ) && $settings['padding_outer'] != '' ? esc_attr( $settings['padding_outer'] ) : '0'; | |
| 616 | + | |
| 617 | + // Box shadow color | |
| 618 | + $settings['box_shadow_color'] = isset( $settings['box_shadow_color'] ) && $settings['box_shadow_color'] != '' ? esc_attr( $settings['box_shadow_color'] ) : $settings['border_color']; | |
| 619 | + | |
| 620 | + // Chart Area background color | |
| 621 | + $settings['chart_background_color'] = isset( $settings['chart_background_color'] ) && $settings['chart_background_color'] != '' ? esc_attr( $settings['chart_background_color'] ) : '#ffffff'; | |
| 622 | + | |
| 623 | + // Chart Area border width | |
| 624 | + $settings['chart_border_width'] = isset( $settings['chart_border_width'] ) && $settings['chart_border_width'] != '' ? esc_attr( $settings['chart_border_width'] ) : '0'; | |
| 625 | + | |
| 626 | + // Chart Area border color | |
| 627 | + $settings['chart_border_color'] = isset( $settings['chart_border_color'] ) && $settings['chart_border_color'] != '' ? esc_attr( $settings['chart_border_color'] ) : '#666666'; | |
| 628 | + | |
| 629 | + // Chart Area left margin | |
| 630 | + $settings['chart_left_margin'] = isset( $settings['chart_left_margin'] ) && $settings['chart_left_margin'] != '' ? esc_attr( $settings['chart_left_margin'] ) : ''; | |
| 631 | + $settings['chart_left_margin_for_js'] = isset( $settings['chart_left_margin'] ) && $settings['chart_left_margin'] != '' ? esc_attr( $settings['chart_left_margin'] ) : 'auto'; | |
| 632 | + | |
| 633 | + // Chart Area right margin | |
| 634 | + $settings['chart_right_margin'] = isset( $settings['chart_right_margin'] ) && $settings['chart_right_margin'] != '' ? esc_attr( $settings['chart_right_margin'] ) : ''; | |
| 635 | + $settings['chart_right_margin_for_js'] = isset( $settings['chart_right_margin'] ) && $settings['chart_right_margin'] != '' ? esc_attr( $settings['chart_right_margin'] ) : 'auto'; | |
| 636 | + | |
| 637 | + // Chart Area top margin | |
| 638 | + $settings['chart_top_margin'] = isset( $settings['chart_top_margin'] ) && $settings['chart_top_margin'] != '' ? esc_attr( $settings['chart_top_margin'] ) : ''; | |
| 639 | + $settings['chart_top_margin_for_js'] = isset( $settings['chart_top_margin'] ) && $settings['chart_top_margin'] != '' ? esc_attr( $settings['chart_top_margin'] ) : 'auto'; | |
| 640 | + | |
| 641 | + // Chart Area bottom margin | |
| 642 | + $settings['chart_bottom_margin'] = isset( $settings['chart_bottom_margin'] ) && $settings['chart_bottom_margin'] != '' ? esc_attr( $settings['chart_bottom_margin'] ) : ''; | |
| 643 | + $settings['chart_bottom_margin_for_js'] = isset( $settings['chart_bottom_margin'] ) && $settings['chart_bottom_margin'] != '' ? esc_attr( $settings['chart_bottom_margin'] ) : 'auto'; | |
| 644 | + | |
| 645 | + // Title color | |
| 646 | + $settings['title_color'] = isset( $settings['title_color'] ) && $settings['title_color'] != '' ? esc_attr( $settings['title_color'] ) : '#000000'; | |
| 647 | + | |
| 648 | + // Title color | |
| 649 | + $settings['title_shadow_color'] = isset( $settings['title_shadow_color'] ) && $settings['title_shadow_color'] != '' ? esc_attr( $settings['title_shadow_color'] ) : $settings['title_color']; | |
| 650 | + | |
| 651 | + // Title font size | |
| 652 | + $settings['title_font_size'] = isset( $settings['title_font_size'] ) && $settings['title_font_size'] != '' ? esc_attr( $settings['title_font_size'] ) : '30'; | |
| 653 | + | |
| 654 | + // Title Bold text | |
| 655 | + $settings['title_bold'] = ( isset( $settings['title_bold'] ) && $settings['title_bold'] != '' ) ? esc_attr($settings['title_bold']) : 'on'; | |
| 656 | + $settings['title_bold'] = isset( $settings['title_bold'] ) && $settings['title_bold'] == 'on' ? 'checked' : ''; | |
| 657 | + | |
| 658 | + // Title text shadow | |
| 659 | + $settings['title_text_shadow'] = ( isset( $settings['title_text_shadow'] ) && $settings['title_text_shadow'] != '' ) ? esc_attr($settings['title_text_shadow']) : 'off'; | |
| 660 | + $settings['title_text_shadow'] = isset( $settings['title_text_shadow'] ) && $settings['title_text_shadow'] == 'on' ? 'checked' : ''; | |
| 661 | + | |
| 662 | + // Title italic text | |
| 663 | + $settings['title_italic'] = ( isset( $settings['title_italic'] ) && $settings['title_italic'] != '' ) ? esc_attr($settings['title_italic']) : 'off'; | |
| 664 | + $settings['title_italic'] = isset( $settings['title_italic'] ) && $settings['title_italic'] == 'on' ? 'checked' : ''; | |
| 665 | + | |
| 666 | + // Title gap | |
| 667 | + $settings['title_gap'] = isset( $settings['title_gap'] ) && $settings['title_gap'] != '' ? esc_attr( $settings['title_gap'] ) : '5'; | |
| 668 | + | |
| 669 | + // Title gap | |
| 670 | + $settings['title_gap_description'] = isset( $settings['title_gap_description'] ) && $settings['title_gap_description'] != '' ? esc_attr( $settings['title_gap_description'] ) : '5'; | |
| 671 | + | |
| 672 | + // Title letter spacing | |
| 673 | + $settings['title_letter_spacing'] = isset( $settings['title_letter_spacing'] ) && $settings['title_letter_spacing'] != '' ? esc_attr( $settings['title_letter_spacing'] ) : 0; | |
| 674 | + | |
| 675 | + // Title position | |
| 676 | + $settings['title_position'] = isset( $settings['title_position'] ) && $settings['title_position'] != '' ? esc_attr( $settings['title_position'] ) : 'left'; | |
| 677 | + $settings['title_positions'] = $title_positions; | |
| 678 | + | |
| 679 | + // Title text transform | |
| 680 | + $settings['title_text_transform'] = isset( $settings['title_text_transform'] ) && $settings['title_text_transform'] != '' ? esc_attr( $settings['title_text_transform'] ) : 'none'; | |
| 681 | + $settings['text_transforms'] = $text_transforms; | |
| 682 | + | |
| 683 | + // Title text decoration | |
| 684 | + $settings['title_text_decoration'] = isset( $settings['title_text_decoration'] ) && $settings['title_text_decoration'] != '' ? esc_attr( $settings['title_text_decoration'] ) : 'none'; | |
| 685 | + $settings['text_decorations'] = $text_decorations; | |
| 686 | + | |
| 687 | + // description color | |
| 688 | + $settings['description_color'] = isset( $settings['description_color'] ) && $settings['description_color'] != '' ? esc_attr( $settings['description_color'] ) : '#4c4c4c'; | |
| 689 | + | |
| 690 | + // description font size | |
| 691 | + $settings['description_font_size'] = isset( $settings['description_font_size'] ) && $settings['description_font_size'] != '' ? esc_attr( $settings['description_font_size'] ) : '16'; | |
| 692 | + | |
| 693 | + // description Bold text | |
| 694 | + $settings['description_bold'] = ( isset( $settings['description_bold'] ) && $settings['description_bold'] != '' ) ? esc_attr($settings['description_bold']) : 'off'; | |
| 695 | + $settings['description_bold'] = isset( $settings['description_bold'] ) && $settings['description_bold'] == 'on' ? 'checked' : ''; | |
| 696 | + | |
| 697 | + // description text shadow | |
| 698 | + $settings['description_text_shadow'] = ( isset( $settings['description_text_shadow'] ) && $settings['description_text_shadow'] != '' ) ? esc_attr($settings['description_text_shadow']) : 'off'; | |
| 699 | + $settings['description_text_shadow'] = isset( $settings['description_text_shadow'] ) && $settings['description_text_shadow'] == 'on' ? 'checked' : ''; | |
| 700 | + | |
| 701 | + // description color | |
| 702 | + $settings['description_shadow_color'] = isset( $settings['description_shadow_color'] ) && $settings['description_shadow_color'] != '' ? esc_attr( $settings['description_shadow_color'] ) : $settings['description_color']; | |
| 703 | + | |
| 704 | + // description italic text | |
| 705 | + $settings['description_italic'] = ( isset( $settings['description_italic'] ) && $settings['description_italic'] != '' ) ? esc_attr($settings['description_italic']) : 'off'; | |
| 706 | + $settings['description_italic'] = isset( $settings['description_italic'] ) && $settings['description_italic'] == 'on' ? 'checked' : ''; | |
| 707 | + | |
| 708 | + // description position | |
| 709 | + $settings['description_position'] = isset( $settings['description_position'] ) && $settings['description_position'] != '' ? esc_attr( $settings['description_position'] ) : 'left'; | |
| 710 | + | |
| 711 | + // description text transform | |
| 712 | + $settings['description_text_transform'] = isset( $settings['description_text_transform'] ) && $settings['description_text_transform'] != '' ? esc_attr( $settings['description_text_transform'] ) : 'none'; | |
| 713 | + | |
| 714 | + // description letter spacing | |
| 715 | + $settings['description_letter_spacing'] = isset( $settings['description_letter_spacing'] ) && $settings['description_letter_spacing'] != '' ? esc_attr( $settings['description_letter_spacing'] ) : 0; | |
| 716 | + | |
| 717 | + // description text decoration | |
| 718 | + $settings['description_text_decoration'] = isset( $settings['description_text_decoration'] ) && $settings['description_text_decoration'] != '' ? esc_attr( $settings['description_text_decoration'] ) : 'none'; | |
| 719 | + | |
| 720 | + // Rotation degree | |
| 721 | + $settings['rotation_degree'] = isset( $settings['rotation_degree'] ) && $settings['rotation_degree'] != '' ? esc_attr( $settings['rotation_degree'] ) : '0'; | |
| 722 | + | |
| 723 | + // Is stacked | |
| 724 | + $settings['is_stacked'] = ( isset( $settings['is_stacked'] ) && $settings['is_stacked'] != '' ) ? $settings['is_stacked'] : 'off'; | |
| 725 | + $settings['is_stacked'] = isset( $settings['is_stacked'] ) && $settings['is_stacked'] == 'on' ? 'checked' : ''; | |
| 726 | + | |
| 727 | + // Line width | |
| 728 | + $settings['line_width'] = isset( $settings['line_width'] ) && $settings['line_width'] != '' ? esc_attr( $settings['line_width'] ) : '2'; | |
| 729 | + | |
| 730 | + // Slice border color | |
| 731 | + $settings['slice_border_color'] = isset( $settings['slice_border_color'] ) && $settings['slice_border_color'] != '' ? esc_attr( $settings['slice_border_color'] ) : '#ffffff'; | |
| 732 | + | |
| 733 | + // Reverse categories | |
| 734 | + $settings['reverse_categories'] = ( isset( $settings['reverse_categories'] ) && $settings['reverse_categories'] != '' ) ? $settings['reverse_categories'] : 'off'; | |
| 735 | + $settings['reverse_categories'] = isset( $settings['reverse_categories'] ) && $settings['reverse_categories'] == 'on' ? 'checked' : ''; | |
| 736 | + | |
| 737 | + // Slice text | |
| 738 | + $settings['slice_text'] = isset( $settings['slice_text'] ) && $settings['slice_text'] != '' ? esc_attr( $settings['slice_text'] ) : 'percentage'; | |
| 739 | + $settings['slice_texts'] = $slice_texts; | |
| 740 | + | |
| 741 | + // Tooltip trigger | |
| 742 | + $settings['tooltip_trigger'] = isset( $settings['tooltip_trigger'] ) && $settings['tooltip_trigger'] != '' ? esc_attr( $settings['tooltip_trigger'] ) : 'hover'; | |
| 743 | + $settings['tooltip_trigger_options'] = $tooltip_trigger_options; | |
| 744 | + | |
| 745 | + // Tooltip text | |
| 746 | + $settings['tooltip_text'] = isset( $settings['tooltip_text'] ) && $settings['tooltip_text'] != '' ? esc_attr( $settings['tooltip_text'] ) : 'both'; | |
| 747 | + $settings['tooltip_text_options'] = $tooltip_text_options; | |
| 748 | + | |
| 749 | + // Multiple data format | |
| 750 | + $settings['multiple_data_format'] = isset( $settings['multiple_data_format'] ) && $settings['multiple_data_format'] != '' ? esc_attr( $settings['multiple_data_format'] ) : 'auto'; | |
| 751 | + $settings['multiple_data_format_options'] = $multiple_data_format_options; | |
| 752 | + | |
| 753 | + // Data grouping settings | |
| 754 | + $settings['data_grouping_limit'] = isset( $settings['data_grouping_limit'] ) && $settings['data_grouping_limit'] != '' ? esc_attr( $settings['data_grouping_limit'] ) : '0.5'; | |
| 755 | + $settings['data_grouping_label'] = isset( $settings['data_grouping_label'] ) && $settings['data_grouping_label'] != '' ? esc_attr( $settings['data_grouping_label'] ) : 'Other'; | |
| 756 | + $settings['data_grouping_color'] = isset( $settings['data_grouping_color'] ) && $settings['data_grouping_color'] != '' ? esc_attr( $settings['data_grouping_color'] ) : '#ccc'; | |
| 757 | + | |
| 758 | + // Focus target | |
| 759 | + $settings['focus_target'] = isset( $settings['focus_target'] ) && $settings['focus_target'] != '' ? esc_attr( $settings['focus_target'] ) : 'datum'; | |
| 760 | + $settings['focus_target_options'] = $focus_target_options; | |
| 761 | + | |
| 762 | + // Show color code | |
| 763 | + $settings['show_color_code'] = ( isset( $settings['show_color_code'] ) && $settings['show_color_code'] != '' ) ? $settings['show_color_code'] : 'off'; | |
| 764 | + $settings['show_color_code'] = isset( $settings['show_color_code'] ) && $settings['show_color_code'] == 'on' ? 'checked' : ''; | |
| 765 | + | |
| 766 | + // Italic text | |
| 767 | + $settings['tooltip_italic'] = ( isset( $settings['tooltip_italic'] ) && $settings['tooltip_italic'] != '' ) ? $settings['tooltip_italic'] : 'off'; | |
| 768 | + $settings['tooltip_italic'] = isset( $settings['tooltip_italic'] ) && $settings['tooltip_italic'] == 'on' ? 'checked' : ''; | |
| 769 | + | |
| 770 | + // Bold text | |
| 771 | + $settings['tooltip_bold'] = isset( $settings['tooltip_bold'] ) && $settings['tooltip_bold'] != '' ? esc_attr( $settings['tooltip_bold'] ) : 'default'; | |
| 772 | + $settings['tooltip_bold_options'] = $tooltip_bold_options; | |
| 773 | + | |
| 774 | + // Tooltip text color | |
| 775 | + $settings['tooltip_text_color'] = isset( $settings['tooltip_text_color'] ) && $settings['tooltip_text_color'] != '' ? esc_attr( $settings['tooltip_text_color'] ) : '#000000'; | |
| 776 | + | |
| 777 | + // Tooltip font size | |
| 778 | + $settings['tooltip_font_size'] = isset( $settings['tooltip_font_size'] ) && intval($settings['tooltip_font_size']) > 0 ? esc_attr( $settings['tooltip_font_size'] ) : $settings['font_size']; | |
| 779 | + | |
| 780 | + // Legend position | |
| 781 | + $settings['legend_position'] = isset( $settings['legend_position'] ) && $settings['legend_position'] != '' ? esc_attr( $settings['legend_position'] ) : 'right'; | |
| 782 | + $settings['legend_positions'] = $legend_positions; | |
| 783 | + | |
| 784 | + // Legend alignment | |
| 785 | + $settings['legend_alignment'] = isset( $settings['legend_alignment'] ) && $settings['legend_alignment'] != '' ? esc_attr( $settings['legend_alignment'] ) : 'start'; | |
| 786 | + $settings['legend_alignments'] = $legend_alignments; | |
| 787 | + | |
| 788 | + // Legend font color | |
| 789 | + $settings['legend_color'] = isset( $settings['legend_color'] ) && $settings['legend_color'] != '' ? esc_attr( $settings['legend_color'] ) : '#000000'; | |
| 790 | + | |
| 791 | + // Legend font size | |
| 792 | + $settings['legend_font_size'] = isset( $settings['legend_font_size'] ) && intval($settings['legend_font_size']) > 0 ? esc_attr( $settings['legend_font_size'] ) : $settings['font_size']; | |
| 793 | + | |
| 794 | + // Legend Italic text | |
| 795 | + $settings['legend_italic'] = ( isset( $settings['legend_italic'] ) && $settings['legend_italic'] != '' ) ? $settings['legend_italic'] : 'off'; | |
| 796 | + $settings['legend_italic'] = isset( $settings['legend_italic'] ) && $settings['legend_italic'] == 'on' ? 'checked' : ''; | |
| 797 | + | |
| 798 | + // Legend Bold text | |
| 799 | + $settings['legend_bold'] = ( isset( $settings['legend_bold'] ) && $settings['legend_bold'] != '' ) ? $settings['legend_bold'] : 'off'; | |
| 800 | + $settings['legend_bold'] = isset( $settings['legend_bold'] ) && $settings['legend_bold'] == 'on' ? 'checked' : ''; | |
| 801 | + | |
| 802 | + // Opacity | |
| 803 | + $settings['opacity'] = isset( $settings['opacity'] ) && $settings['opacity'] != '' ? esc_attr( $settings['opacity'] ) : '1.0'; | |
| 804 | + | |
| 805 | + // Group width | |
| 806 | + $settings['group_width'] = isset( $settings['group_width'] ) && $settings['group_width'] != '' ? esc_attr( $settings['group_width'] ) : '61.8'; | |
| 807 | + $settings['group_width_format'] = isset( $settings['group_width_format'] ) && $settings['group_width_format'] != '' ? esc_attr( $settings['group_width_format'] ) : '%'; | |
| 808 | + $settings['group_width_format_options'] = $group_width_format_options; | |
| 809 | + | |
| 810 | + // Show chart description | |
| 811 | + if (!isset($settings['show_description'])) { | |
| 812 | + $settings['show_description'] = 'checked'; | |
| 813 | + } else { | |
| 814 | + $settings['show_description'] = ( $settings['show_description'] != '' ) ? $settings['show_description'] : 'off'; | |
| 815 | + $settings['show_description'] = isset( $settings['show_description'] ) && $settings['show_description'] == 'on' ? 'checked' : ''; | |
| 816 | + } | |
| 817 | + | |
| 818 | + // Show chart title | |
| 819 | + if (!isset($settings['show_title'])) { | |
| 820 | + $settings['show_title'] = 'checked'; | |
| 821 | + } else { | |
| 822 | + $settings['show_title'] = ( $settings['show_title'] != '' ) ? $settings['show_title'] : 'off'; | |
| 823 | + $settings['show_title'] = isset( $settings['show_title'] ) && $settings['show_title'] == 'on' ? 'checked' : ''; | |
| 824 | + } | |
| 825 | + | |
| 826 | + // Enable interactivity | |
| 827 | + if (!isset($settings['enable_interactivity'])) { | |
| 828 | + $settings['enable_interactivity'] = 'checked'; | |
| 829 | + } else { | |
| 830 | + $settings['enable_interactivity'] = ( $settings['enable_interactivity'] != '' ) ? $settings['enable_interactivity'] : 'off'; | |
| 831 | + $settings['enable_interactivity'] = isset( $settings['enable_interactivity'] ) && $settings['enable_interactivity'] == 'on' ? 'checked' : ''; | |
| 832 | + } | |
| 833 | + | |
| 834 | + // Maximized view | |
| 835 | + $settings['maximized_view'] = ( isset( $settings['maximized_view'] ) && $settings['maximized_view'] != '' ) ? $settings['maximized_view'] : 'off'; | |
| 836 | + $settings['maximized_view'] = isset( $settings['maximized_view'] ) && $settings['maximized_view'] == 'on' ? 'checked' : ''; | |
| 837 | + | |
| 838 | + // Multiple data selection | |
| 839 | + $settings['multiple_selection'] = ( isset( $settings['multiple_selection'] ) && $settings['multiple_selection'] != '' ) ? $settings['multiple_selection'] : 'off'; | |
| 840 | + $settings['multiple_selection'] = isset( $settings['multiple_selection'] ) && $settings['multiple_selection'] == 'on' ? 'checked' : ''; | |
| 841 | + | |
| 842 | + // Point shape | |
| 843 | + $settings['point_shape'] = isset( $settings['point_shape'] ) && $settings['point_shape'] != '' ? esc_attr( $settings['point_shape'] ) : 'circle'; | |
| 844 | + $settings['point_shape_options'] = $point_shape_options; | |
| 845 | + | |
| 846 | + // Point size | |
| 847 | + $settings['point_size'] = isset( $settings['point_size'] ) && $settings['point_size'] != '' ? absint(esc_attr( $settings['point_size'] )) : '0'; | |
| 848 | + | |
| 849 | + // Crosshair trigger | |
| 850 | + $settings['crosshair_trigger'] = isset( $settings['crosshair_trigger'] ) && $settings['crosshair_trigger'] != '' ? esc_attr( $settings['crosshair_trigger'] ) : 'none'; | |
| 851 | + $settings['crosshair_trigger_options'] = $crosshair_trigger_options; | |
| 852 | + | |
| 853 | + // Crosshair orientation | |
| 854 | + $settings['crosshair_orientation'] = isset( $settings['crosshair_orientation'] ) && $settings['crosshair_orientation'] != '' ? esc_attr( $settings['crosshair_orientation'] ) : 'both'; | |
| 855 | + $settings['crosshair_orientation_options'] = $crosshair_orientation_options; | |
| 856 | + | |
| 857 | + // Crosshair opacity | |
| 858 | + $settings['crosshair_opacity'] = isset( $settings['crosshair_opacity'] ) && $settings['crosshair_opacity'] != '' ? esc_attr( $settings['crosshair_opacity'] ) : '1.0'; | |
| 859 | + | |
| 860 | + // Dash style | |
| 861 | + $settings['dash_style'] = isset( $settings['dash_style'] ) && $settings['dash_style'] != '' ? esc_attr( str_replace(' ', '', $settings['dash_style']) ) : ''; | |
| 862 | + | |
| 863 | + // Orientation | |
| 864 | + $settings['orientation'] = ( isset( $settings['orientation'] ) && $settings['orientation'] != '' ) ? $settings['orientation'] : 'off'; | |
| 865 | + $settings['orientation'] = isset( $settings['orientation'] ) && $settings['orientation'] == 'on' ? 'checked' : ''; | |
| 866 | + | |
| 867 | + // Fill nulls | |
| 868 | + $settings['fill_nulls'] = ( isset( $settings['fill_nulls'] ) && $settings['fill_nulls'] != '' ) ? $settings['fill_nulls'] : 'off'; | |
| 869 | + $settings['fill_nulls'] = isset( $settings['fill_nulls'] ) && $settings['fill_nulls'] == 'on' ? 'checked' : ''; | |
| 870 | + | |
| 871 | + // Font size for org chart | |
| 872 | + $settings['org_chart_font_size'] = isset( $settings['org_chart_font_size'] ) && $settings['org_chart_font_size'] != '' ? esc_attr( $settings['org_chart_font_size'] ) : 'medium'; | |
| 873 | + $settings['org_chart_font_size_options'] = $org_chart_font_size_options; | |
| 874 | + | |
| 875 | + // Donut hole size | |
| 876 | + $settings['donut_hole_size'] = isset( $settings['donut_hole_size'] ) && $settings['donut_hole_size'] != '' ? esc_attr( $settings['donut_hole_size'] ) : '0.4'; | |
| 877 | + | |
| 878 | + // Allow collapse | |
| 879 | + $settings['allow_collapse'] = ( isset( $settings['allow_collapse'] ) && $settings['allow_collapse'] != '' ) ? $settings['allow_collapse'] : 'off'; | |
| 880 | + $settings['allow_collapse'] = isset( $settings['allow_collapse'] ) && $settings['allow_collapse'] == 'on' ? 'checked' : ''; | |
| 881 | + | |
| 882 | + // Org custom css class | |
| 883 | + $settings['org_classname'] = isset( $settings['org_classname'] ) && $settings['org_classname'] != '' ? esc_attr( $settings['org_classname'] ) : ''; | |
| 884 | + | |
| 885 | + $settings['org_node_background_color'] = isset( $settings['org_node_background_color'] ) && $settings['org_node_background_color'] != '' ? esc_attr( $settings['org_node_background_color'] ) : '#edf7ff'; | |
| 886 | + $settings['org_node_padding'] = isset( $settings['org_node_padding'] ) && $settings['org_node_padding'] != '' ? esc_attr( $settings['org_node_padding'] ) : '2'; | |
| 887 | + $settings['org_node_border_radius'] = isset( $settings['org_node_border_radius'] ) && $settings['org_node_border_radius'] != '' ? esc_attr( $settings['org_node_border_radius'] ) : '5'; | |
| 888 | + $settings['org_node_border_width'] = isset( $settings['org_node_border_width'] ) && $settings['org_node_border_width'] != '' ? esc_attr( $settings['org_node_border_width'] ) : '0'; | |
| 889 | + $settings['org_node_border_color'] = isset( $settings['org_node_border_color'] ) && $settings['org_node_border_color'] != '' ? esc_attr( $settings['org_node_border_color'] ) : '#b5d9ea'; | |
| 890 | + $settings['org_node_text_color'] = isset( $settings['org_node_text_color'] ) && $settings['org_node_text_color'] != '' ? esc_attr( $settings['org_node_text_color'] ) : '#000000'; | |
| 891 | + $settings['org_node_text_font_size'] = isset( $settings['org_node_text_font_size'] ) && $settings['org_node_text_font_size'] != '' ? esc_attr( $settings['org_node_text_font_size'] ) : '13'; | |
| 892 | + $settings['org_node_description_font_color'] = isset( $settings['org_node_description_font_color'] ) && $settings['org_node_description_font_color'] != '' ? esc_attr( $settings['org_node_description_font_color'] ) : '#ff0000'; | |
| 893 | + $settings['org_node_description_font_size'] = isset( $settings['org_node_description_font_size'] ) && $settings['org_node_description_font_size'] != '' ? esc_attr( $settings['org_node_description_font_size'] ) : '13'; | |
| 894 | + | |
| 895 | + // Org custom selected css class | |
| 896 | + $settings['org_selected_classname'] = isset( $settings['org_selected_classname'] ) && $settings['org_selected_classname'] != '' ? esc_attr( $settings['org_selected_classname'] ) : ''; | |
| 897 | + | |
| 898 | + $settings['org_selected_node_background_color'] = isset( $settings['org_selected_node_background_color'] ) && $settings['org_selected_node_background_color'] != '' ? esc_attr( $settings['org_selected_node_background_color'] ) : '#fff7ae'; | |
| 899 | + $settings['org_selected_node_text_color'] = isset( $settings['org_selected_node_text_color'] ) && $settings['org_selected_node_text_color'] != '' ? esc_attr( $settings['org_selected_node_text_color'] ) : $settings['org_node_text_color']; | |
| 900 | + | |
| 901 | + | |
| 902 | + $settings['axes_text_positions'] = $axes_text_positions; | |
| 903 | + $settings['axes_format_options'] = $axes_format_options; | |
| 904 | + // Horizontal axis settings | |
| 905 | + $settings['haxis_title'] = isset( $settings['haxis_title'] ) && $settings['haxis_title'] != '' ? esc_attr( $settings['haxis_title'] ) : ''; | |
| 906 | + $settings['haxis_label_font_size'] = isset( $settings['haxis_label_font_size'] ) && $settings['haxis_label_font_size'] != '' ? esc_attr( $settings['haxis_label_font_size'] ) : $settings['font_size']; | |
| 907 | + $settings['haxis_label_color'] = isset( $settings['haxis_label_color'] ) && $settings['haxis_label_color'] != '' ? esc_attr( $settings['haxis_label_color'] ) : '#000000'; | |
| 908 | + $settings['haxis_text_position'] = isset( $settings['haxis_text_position'] ) && $settings['haxis_text_position'] != '' ? esc_attr( $settings['haxis_text_position'] ) : 'out'; | |
| 909 | + $settings['haxis_direction'] = ( isset( $settings['haxis_direction'] ) && $settings['haxis_direction'] != '' ) ? $settings['haxis_direction'] : '1'; | |
| 910 | + $settings['haxis_direction'] = isset( $settings['haxis_direction'] ) && $settings['haxis_direction'] == '-1' ? 'checked' : ''; | |
| 911 | + $settings['haxis_text_color'] = isset( $settings['haxis_text_color'] ) && $settings['haxis_text_color'] != '' ? esc_attr( $settings['haxis_text_color'] ) : '#000000'; | |
| 912 | + $settings['haxis_baseline_color'] = isset( $settings['haxis_baseline_color'] ) && $settings['haxis_baseline_color'] != '' ? esc_attr( $settings['haxis_baseline_color'] ) : '#000000'; | |
| 913 | + $settings['haxis_text_font_size'] = isset( $settings['haxis_text_font_size'] ) && $settings['haxis_text_font_size'] != '' ? absint(esc_attr( $settings['haxis_text_font_size'] )) : $settings['font_size']; | |
| 914 | + $settings['haxis_slanted_options'] = $haxis_slanted_options; | |
| 915 | + $settings['haxis_slanted'] = isset( $settings['haxis_slanted'] ) && $settings['haxis_slanted'] != '' ? esc_attr( $settings['haxis_slanted'] ) : 'automatic'; | |
| 916 | + $settings['haxis_slanted_text_angle'] = isset( $settings['haxis_slanted_text_angle'] ) && $settings['haxis_slanted_text_angle'] != '' && $settings['haxis_slanted_text_angle'] != '0' ? esc_attr( $settings['haxis_slanted_text_angle'] ) : '30'; | |
| 917 | + $settings['haxis_show_text_every'] = isset( $settings['haxis_show_text_every'] ) && $settings['haxis_show_text_every'] != '' ? esc_attr( $settings['haxis_show_text_every'] ) : '0'; | |
| 918 | + $settings['haxis_format'] = isset( $settings['haxis_format'] ) && $settings['haxis_format'] != '' ? esc_attr( $settings['haxis_format'] ) : ''; | |
| 919 | + $settings['haxis_enable_divide_percent'] = ( isset( $settings['haxis_enable_divide_percent'] ) && $settings['haxis_enable_divide_percent'] != '' ) ? $settings['haxis_enable_divide_percent'] : 'off'; | |
| 920 | + $settings['haxis_enable_divide_percent'] = isset( $settings['haxis_enable_divide_percent'] ) && $settings['haxis_enable_divide_percent'] == 'on' ? 'checked' : ''; | |
| 921 | + $settings['haxis_max_value'] = isset( $settings['haxis_max_value'] ) && $settings['haxis_max_value'] != '' ? esc_attr( $settings['haxis_max_value'] ) : null; | |
| 922 | + $settings['haxis_min_value'] = isset( $settings['haxis_min_value'] ) && $settings['haxis_min_value'] != '' ? esc_attr( $settings['haxis_min_value'] ) : null; | |
| 923 | + $settings['haxis_gridlines_count'] = isset( $settings['haxis_gridlines_count'] ) && $settings['haxis_gridlines_count'] != '' ? esc_attr( $settings['haxis_gridlines_count'] ) : -1;$settings['haxis_italic'] = ( isset( $settings['haxis_italic'] ) && $settings['haxis_italic'] != '' ) ? $settings['haxis_italic'] : 'off'; | |
| 924 | + $settings['haxis_italic'] = isset( $settings['haxis_italic'] ) && $settings['haxis_italic'] == 'on' ? 'checked' : ''; | |
| 925 | + $settings['haxis_bold'] = ( isset( $settings['haxis_bold'] ) && $settings['haxis_bold'] != '' ) ? $settings['haxis_bold'] : 'off'; | |
| 926 | + $settings['haxis_bold'] = isset( $settings['haxis_bold'] ) && $settings['haxis_bold'] == 'on' ? 'checked' : ''; | |
| 927 | + $settings['haxis_title_italic'] = ( isset( $settings['haxis_title_italic'] ) && $settings['haxis_title_italic'] != '' ) ? $settings['haxis_title_italic'] : 'off'; | |
| 928 | + $settings['haxis_title_italic'] = isset( $settings['haxis_title_italic'] ) && $settings['haxis_title_italic'] == 'on' ? 'checked' : ''; | |
| 929 | + $settings['haxis_title_bold'] = ( isset( $settings['haxis_title_bold'] ) && $settings['haxis_title_bold'] != '' ) ? $settings['haxis_title_bold'] : 'off'; | |
| 930 | + $settings['haxis_title_bold'] = isset( $settings['haxis_title_bold'] ) && $settings['haxis_title_bold'] == 'on' ? 'checked' : ''; | |
| 931 | + $settings['haxis_gridlines_color'] = isset( $settings['haxis_gridlines_color'] ) && $settings['haxis_gridlines_color'] != '' ? esc_attr( $settings['haxis_gridlines_color'] ) : '#cccccc'; | |
| 932 | + $settings['haxis_minor_gridlines_color'] = isset( $settings['haxis_minor_gridlines_color'] ) && $settings['haxis_minor_gridlines_color'] != '' ? esc_attr( $settings['haxis_minor_gridlines_color'] ) : $settings['haxis_gridlines_color']; | |
| 933 | + | |
| 934 | + // Vertical axis settings | |
| 935 | + $settings['vaxis_title'] = isset( $settings['vaxis_title'] ) && $settings['vaxis_title'] != '' ? esc_attr( $settings['vaxis_title'] ) : ''; | |
| 936 | + $settings['vaxis_label_font_size'] = isset( $settings['vaxis_label_font_size'] ) && $settings['vaxis_label_font_size'] != '' ? esc_attr( $settings['vaxis_label_font_size'] ) : $settings['font_size']; | |
| 937 | + $settings['vaxis_label_color'] = isset( $settings['vaxis_label_color'] ) && $settings['vaxis_label_color'] != '' ? esc_attr( $settings['vaxis_label_color'] ) : '#000000'; | |
| 938 | + $settings['vaxis_text_position'] = isset( $settings['vaxis_text_position'] ) && $settings['vaxis_text_position'] != '' ? esc_attr( $settings['vaxis_text_position'] ) : 'out'; | |
| 939 | + $settings['vaxis_direction'] = ( isset( $settings['vaxis_direction'] ) && $settings['vaxis_direction'] != '' ) ? $settings['vaxis_direction'] : '1'; | |
| 940 | + $settings['vaxis_direction'] = isset( $settings['vaxis_direction'] ) && $settings['vaxis_direction'] == '-1' ? 'checked' : ''; | |
| 941 | + $settings['vaxis_text_color'] = isset( $settings['vaxis_text_color'] ) && $settings['vaxis_text_color'] != '' ? esc_attr( $settings['vaxis_text_color'] ) : '#000000'; | |
| 942 | + $settings['vaxis_baseline_color'] = isset( $settings['vaxis_baseline_color'] ) && $settings['vaxis_baseline_color'] != '' ? esc_attr( $settings['vaxis_baseline_color'] ) : '#000000'; | |
| 943 | + $settings['vaxis_text_font_size'] = isset( $settings['vaxis_text_font_size'] ) && $settings['vaxis_text_font_size'] != '' ? absint(esc_attr( $settings['vaxis_text_font_size'] )) : $settings['font_size']; | |
| 944 | + $settings['vaxis_format'] = isset( $settings['vaxis_format'] ) && $settings['vaxis_format'] != '' ? esc_attr( $settings['vaxis_format'] ) : ''; | |
| 945 | + $settings['vaxis_enable_divide_percent'] = ( isset( $settings['vaxis_enable_divide_percent'] ) && $settings['vaxis_enable_divide_percent'] != '' ) ? $settings['vaxis_enable_divide_percent'] : 'off'; | |
| 946 | + $settings['vaxis_enable_divide_percent'] = isset( $settings['vaxis_enable_divide_percent'] ) && $settings['vaxis_enable_divide_percent'] == 'on' ? 'checked' : ''; | |
| 947 | + $settings['vaxis_max_value'] = isset( $settings['vaxis_max_value'] ) && $settings['vaxis_max_value'] != '' ? esc_attr( $settings['vaxis_max_value'] ) : null; | |
| 948 | + $settings['vaxis_min_value'] = isset( $settings['vaxis_min_value'] ) && $settings['vaxis_min_value'] != '' ? esc_attr( $settings['vaxis_min_value'] ) : null; | |
| 949 | + $settings['vaxis_gridlines_count'] = isset( $settings['vaxis_gridlines_count'] ) && $settings['vaxis_gridlines_count'] != '' ? esc_attr( $settings['vaxis_gridlines_count'] ) : -1; | |
| 950 | + $settings['vaxis_italic'] = ( isset( $settings['vaxis_italic'] ) && $settings['vaxis_italic'] != '' ) ? $settings['vaxis_italic'] : 'off'; | |
| 951 | + $settings['vaxis_italic'] = isset( $settings['vaxis_italic'] ) && $settings['vaxis_italic'] == 'on' ? 'checked' : ''; | |
| 952 | + $settings['vaxis_bold'] = ( isset( $settings['vaxis_bold'] ) && $settings['vaxis_bold'] != '' ) ? $settings['vaxis_bold'] : 'off'; | |
| 953 | + $settings['vaxis_bold'] = isset( $settings['vaxis_bold'] ) && $settings['vaxis_bold'] == 'on' ? 'checked' : ''; | |
| 954 | + $settings['vaxis_title_italic'] = ( isset( $settings['vaxis_title_italic'] ) && $settings['vaxis_title_italic'] != '' ) ? $settings['vaxis_title_italic'] : 'off'; | |
| 955 | + $settings['vaxis_title_italic'] = isset( $settings['vaxis_title_italic'] ) && $settings['vaxis_title_italic'] == 'on' ? 'checked' : ''; | |
| 956 | + $settings['vaxis_title_bold'] = ( isset( $settings['vaxis_title_bold'] ) && $settings['vaxis_title_bold'] != '' ) ? $settings['vaxis_title_bold'] : 'off'; | |
| 957 | + $settings['vaxis_title_bold'] = isset( $settings['vaxis_title_bold'] ) && $settings['vaxis_title_bold'] == 'on' ? 'checked' : ''; | |
| 958 | + $settings['vaxis_gridlines_color'] = isset( $settings['vaxis_gridlines_color'] ) && $settings['vaxis_gridlines_color'] != '' ? esc_attr( $settings['vaxis_gridlines_color'] ) : '#cccccc'; | |
| 959 | + $settings['vaxis_minor_gridlines_color'] = isset( $settings['vaxis_minor_gridlines_color'] ) && $settings['vaxis_minor_gridlines_color'] != '' ? esc_attr( $settings['vaxis_minor_gridlines_color'] ) : $settings['vaxis_gridlines_color']; | |
| 960 | + | |
| 961 | + // Animation settings | |
| 962 | + $settings['enable_animation'] = ( isset( $settings['enable_animation'] ) && $settings['enable_animation'] != '' ) ? $settings['enable_animation'] : 'off'; | |
| 963 | + $settings['enable_animation'] = isset( $settings['enable_animation'] ) && $settings['enable_animation'] == 'on' ? 'checked' : ''; | |
| 964 | + $settings['animation_duration'] = isset( $settings['animation_duration'] ) && $settings['animation_duration'] != '' ? absint(esc_attr( $settings['animation_duration'] )) : '1000'; | |
| 965 | + $settings['animation_startup'] = ( isset( $settings['animation_startup'] ) && $settings['animation_startup'] != '' ) ? $settings['animation_startup'] : 'on'; | |
| 966 | + $settings['animation_startup'] = isset( $settings['animation_startup'] ) && $settings['animation_startup'] == 'on' ? 'checked' : ''; | |
| 967 | + $settings['animation_easing_options'] = $animation_easing_options; | |
| 968 | + $settings['animation_easing'] = isset( $settings['animation_easing'] ) && $settings['animation_easing'] != '' ? esc_attr( $settings['animation_easing'] ) : 'linear'; | |
| 969 | + | |
| 970 | + $settings['enable_img'] = ( isset( $settings['enable_img'] ) && $settings['enable_img'] != '' ) ? $settings['enable_img'] : 'off'; | |
| 971 | + $settings['enable_img'] = isset( $settings['enable_img'] ) && $settings['enable_img'] == 'on' ? 'checked' : ''; | |
| 972 | + | |
| 973 | + $counting_source = !empty($source) ? $source : array(); | |
| 974 | + | |
| 975 | + $count_slices = (isset($counting_source) && !is_null($counting_source) && count($counting_source) > 0) ? count($counting_source) - 1 : 0; | |
| 976 | + $count_series = (isset($counting_source[0]) && !is_null($counting_source[0]) && count($counting_source[0]) > 0) ? count($counting_source[0]) - 1 : 0; | |
| 977 | + $count_rows = (isset($counting_source) && !is_null($counting_source) && count($counting_source) > 0) ? count(array_column($counting_source, 0)) - 1 : 0; | |
| 978 | + | |
| 979 | + // Slices settings | |
| 980 | + $settings['slice_colors_default'] = $chart_default_colors; | |
| 981 | + $settings['slice_color'] = isset( $settings['slice_color'] ) && $settings['slice_color'] != '' ? json_decode($settings['slice_color'], true) : array_slice($chart_default_colors, 0, $count_slices);; | |
| 982 | + $settings['slice_offset'] = isset( $settings['slice_offset'] ) && $settings['slice_offset'] != '' ? json_decode($settings['slice_offset'], true) : array_fill(0, $count_slices, 0); | |
| 983 | + $settings['slice_text_color'] = isset( $settings['slice_text_color'] ) && $settings['slice_text_color'] != '' ? json_decode($settings['slice_text_color'], true) : array_fill(0, $count_slices, '#ffffff'); | |
| 984 | + | |
| 985 | + // Series settings | |
| 986 | + $settings['series_colors_default'] = $chart_default_colors; | |
| 987 | + $settings['series_color'] = isset( $settings['series_color'] ) && $settings['series_color'] != '' ? json_decode($settings['series_color'], true) : array_slice($chart_default_colors, 0, $count_series);; | |
| 988 | + $settings['series_visible_in_legend'] = isset( $settings['series_visible_in_legend'] ) && $settings['series_visible_in_legend'] != '' ? json_decode($settings['series_visible_in_legend'], true) : array_fill(0, $count_series, 'on'); | |
| 989 | + $settings['series_line_width'] = isset( $settings['series_line_width'] ) && $settings['series_line_width'] != '' ? json_decode($settings['series_line_width'], true) : array_fill(0, $count_series, $settings['line_width']); | |
| 990 | + $settings['series_point_size'] = isset( $settings['series_point_size'] ) && $settings['series_point_size'] != '' ? json_decode($settings['series_point_size'], true) : array_fill(0, $count_series, $settings['point_size']); | |
| 991 | + $settings['series_point_shape'] = isset( $settings['series_point_shape'] ) && $settings['series_point_shape'] != '' ? json_decode($settings['series_point_shape'], true) : array_fill(0, $count_series, $settings['point_shape']); | |
| 992 | + $settings['series_format'] = isset( $settings['series_format'] ) && $settings['series_format'] != '' ? json_decode($settings['series_format'], true) : array_fill(0, $count_series, ''); | |
| 993 | + | |
| 994 | + // Rows settings | |
| 995 | + $settings['enable_row_settings'] = ( isset( $settings['enable_row_settings'] ) && $settings['enable_row_settings'] != '' ) ? $settings['enable_row_settings'] : 'on'; | |
| 996 | + $settings['enable_row_settings'] = isset( $settings['enable_row_settings'] ) && $settings['enable_row_settings'] == 'on' ? 'checked' : ''; | |
| 997 | + | |
| 998 | + $settings['rows_color'] = isset( $settings['rows_color'] ) && $settings['rows_color'] != '' ? json_decode($settings['rows_color'], true) : array_fill(0, $count_rows, ''); | |
| 999 | + $settings['rows_opacity'] = isset( $settings['rows_opacity'] ) && $settings['rows_opacity'] != '' ? json_decode($settings['rows_opacity'], true) : array_fill(0, $count_rows, 1.0); | |
| 1000 | + | |
| 1001 | + return $settings; | |
| 1002 | + | |
| 1003 | + } | |
| 1004 | + | |
| 1005 | + /** | |
| 1006 | + * Gets all settings of google charts for public area. | |
| 1007 | + * | |
| 1008 | + * @access public | |
| 1009 | + * @return array | |
| 1010 | + */ | |
| 1011 | + public function get_chart_settings_google_public ($settings, $chartData) { | |
| 1012 | + $chart_default_colors = array('#3366cc','#dc3912','#ff9900','#109618', '#990099','#0099c6','#dd4477','#66aa00', '#b82e2e','#316395','#994499','#22aa99', '#aaaa11','#6633cc','#e67300','#8b0707', '#651067','#329262','#5574a6','#3b3eac', '#b77322','#16d620','#b91383','#f4359e', '#9c5935','#a9c413','#2a778d','#668d1c', '#bea413','#0c5922','#743411'); | |
| 1013 | + | |
| 1014 | + $position_styles = array( | |
| 1015 | + "left" => 'margin-left:0', | |
| 1016 | + "right" => 'margin-right:0', | |
| 1017 | + "center" => 'margin:auto', | |
| 1018 | + ); | |
| 1019 | + | |
| 1020 | + // Width | |
| 1021 | + $settings['width'] = isset( $settings['width'] ) && $settings['width'] != '' ? esc_attr( $settings['width'] ) : '100'; | |
| 1022 | + $settings['width_format'] = isset( $settings['width_format'] ) && $settings['width_format'] != '' ? esc_attr( $settings['width_format'] ) : '%'; | |
| 1023 | + $settings['responsive_width'] = ( isset( $settings['responsive_width'] ) && $settings['responsive_width'] != '' ) ? $settings['responsive_width'] : 'off'; | |
| 1024 | + $settings['chart_width'] = isset($settings['responsive_width']) && $settings['responsive_width'] == 'on' ? '100%' : $settings['width'].$settings['width_format']; | |
| 1025 | + | |
| 1026 | + // position | |
| 1027 | + $settings['position'] = isset( $settings['position'] ) && $settings['position'] != '' ? esc_attr( $settings['position'] ) : 'center'; | |
| 1028 | + $settings['position'] = isset($position_styles[$settings['position']]) && $position_styles[$settings['position']] != '' ? $position_styles[$settings['position']] : 'margin:auto'; | |
| 1029 | + | |
| 1030 | + // height | |
| 1031 | + $settings['height'] = isset( $settings['height'] ) && $settings['height'] != '' ? esc_attr( $settings['height'] ) : '400'; | |
| 1032 | + $settings['height_format'] = isset( $settings['height_format'] ) && $settings['height_format'] != '' ? esc_attr( $settings['height_format'] ) : 'px'; | |
| 1033 | + $settings['chart_height'] = $settings['height'].$settings['height_format']; | |
| 1034 | + | |
| 1035 | + // Font size | |
| 1036 | + $settings['font_size'] = isset( $settings['font_size'] ) && $settings['font_size'] != '' ? esc_attr( $settings['font_size'] ) : '15'; | |
| 1037 | + | |
| 1038 | + // Background color | |
| 1039 | + $settings['background_color'] = isset( $settings['background_color'] ) && $settings['background_color'] != '' ? esc_attr( $settings['background_color'] ) : '#ffffff'; | |
| 1040 | + | |
| 1041 | + // Transparent background | |
| 1042 | + $settings['transparent_background'] = isset( $settings['transparent_background'] ) && $settings['transparent_background'] != '' ? esc_attr( $settings['transparent_background'] ) : 'off'; | |
| 1043 | + | |
| 1044 | + // Box shadow | |
| 1045 | + $settings['box_shadow'] = isset( $settings['box_shadow'] ) && $settings['box_shadow'] != '' ? esc_attr( $settings['box_shadow'] ) : 'off'; | |
| 1046 | + $settings['box_shadow'] = isset( $settings['box_shadow'] ) && $settings['box_shadow'] == 'on' ? 'checked' : ''; | |
| 1047 | + | |
| 1048 | + // Border width | |
| 1049 | + $settings['border_width'] = isset( $settings['border_width'] ) && $settings['border_width'] != '' ? esc_attr( $settings['border_width'] ) : '0'; | |
| 1050 | + | |
| 1051 | + // Border radius | |
| 1052 | + $settings['border_radius'] = isset( $settings['border_radius'] ) && $settings['border_radius'] != '' ? esc_attr( $settings['border_radius'] ) : '0'; | |
| 1053 | + | |
| 1054 | + // Border color | |
| 1055 | + $settings['border_color'] = isset( $settings['border_color'] ) && $settings['border_color'] != '' ? esc_attr( $settings['border_color'] ) : '#666666'; | |
| 1056 | + | |
| 1057 | + // Border style | |
| 1058 | + $settings['border_style'] = isset( $settings['border_style'] ) && $settings['border_style'] != '' ? esc_attr( $settings['border_style'] ) : 'solid'; | |
| 1059 | + | |
| 1060 | + // Border width with title | |
| 1061 | + $settings['border_width_with_title'] = isset( $settings['border_width_with_title'] ) && $settings['border_width_with_title'] != '' ? esc_attr( $settings['border_width_with_title'] ) : '0'; | |
| 1062 | + | |
| 1063 | + // Border radius with title | |
| 1064 | + $settings['border_radius_with_title'] = isset( $settings['border_radius_with_title'] ) && $settings['border_radius_with_title'] != '' ? esc_attr( $settings['border_radius_with_title'] ) : '0'; | |
| 1065 | + | |
| 1066 | + // Border color with title | |
| 1067 | + $settings['border_color_with_title'] = isset( $settings['border_color_with_title'] ) && $settings['border_color_with_title'] != '' ? esc_attr( $settings['border_color_with_title'] ) : '#000000'; | |
| 1068 | + | |
| 1069 | + // Border style with title | |
| 1070 | + $settings['border_style_with_title'] = isset( $settings['border_style_with_title'] ) && $settings['border_style_with_title'] != '' ? esc_attr( $settings['border_style_with_title'] ) : 'solid'; | |
| 1071 | + | |
| 1072 | + // Padding outer | |
| 1073 | + $settings['padding_outer'] = isset( $settings['padding_outer'] ) && $settings['padding_outer'] != '' ? esc_attr( $settings['padding_outer'] ) : '0'; | |
| 1074 | + | |
| 1075 | + // Box shadow color | |
| 1076 | + $settings['box_shadow_color'] = isset( $settings['box_shadow_color'] ) && $settings['box_shadow_color'] != '' ? esc_attr( $settings['box_shadow_color'] ) : $settings['border_color']; | |
| 1077 | + | |
| 1078 | + // Chart Area background color | |
| 1079 | + $settings['chart_background_color'] = isset( $settings['chart_background_color'] ) && $settings['chart_background_color'] != '' ? esc_attr( $settings['chart_background_color'] ) : '#ffffff'; | |
| 1080 | + | |
| 1081 | + // Chart Area border width | |
| 1082 | + $settings['chart_border_width'] = isset( $settings['chart_border_width'] ) && $settings['chart_border_width'] != '' ? esc_attr( $settings['chart_border_width'] ) : '0'; | |
| 1083 | + | |
| 1084 | + // Chart Area border color | |
| 1085 | + $settings['chart_border_color'] = isset( $settings['chart_border_color'] ) && $settings['chart_border_color'] != '' ? esc_attr( $settings['chart_border_color'] ) : '#666666'; | |
| 1086 | + | |
| 1087 | + // Chart Area left margin | |
| 1088 | + $settings['chart_left_margin_for_js'] = isset( $settings['chart_left_margin'] ) && $settings['chart_left_margin'] != '' ? esc_attr( $settings['chart_left_margin'] ) : 'auto'; | |
| 1089 | + | |
| 1090 | + // Chart Area right margin | |
| 1091 | + $settings['chart_right_margin_for_js'] = isset( $settings['chart_right_margin'] ) && $settings['chart_right_margin'] != '' ? esc_attr( $settings['chart_right_margin'] ) : 'auto'; | |
| 1092 | + | |
| 1093 | + // Chart Area top margin | |
| 1094 | + $settings['chart_top_margin_for_js'] = isset( $settings['chart_top_margin'] ) && $settings['chart_top_margin'] != '' ? esc_attr( $settings['chart_top_margin'] ) : 'auto'; | |
| 1095 | + | |
| 1096 | + // Chart Area bottom margin | |
| 1097 | + $settings['chart_bottom_margin_for_js'] = isset( $settings['chart_bottom_margin'] ) && $settings['chart_bottom_margin'] != '' ? esc_attr( $settings['chart_bottom_margin'] ) : 'auto'; | |
| 1098 | + | |
| 1099 | + // Title color | |
| 1100 | + $settings['title_color'] = isset( $settings['title_color'] ) && $settings['title_color'] != '' ? esc_attr( $settings['title_color'] ) : '#000000'; | |
| 1101 | + | |
| 1102 | + // Title color | |
| 1103 | + $settings['title_shadow_color'] = isset( $settings['title_shadow_color'] ) && $settings['title_shadow_color'] != '' ? esc_attr( $settings['title_shadow_color'] ) : $settings['title_color']; | |
| 1104 | + | |
| 1105 | + // Title font size | |
| 1106 | + $settings['title_font_size'] = isset( $settings['title_font_size'] ) && $settings['title_font_size'] != '' ? esc_attr( $settings['title_font_size'] ) : '30'; | |
| 1107 | + | |
| 1108 | + // title bold | |
| 1109 | + $settings['title_bold'] = ( isset( $settings['title_bold'] ) && $settings['title_bold'] != '' ) ? esc_attr($settings['title_bold']) : 'on'; | |
| 1110 | + $settings['title_bold'] = isset( $settings['title_bold'] ) && $settings['title_bold'] != 'off'? 'bold' : 'normal'; | |
| 1111 | + | |
| 1112 | + // Title text shadow | |
| 1113 | + $settings['title_text_shadow'] = ( isset( $settings['title_text_shadow'] ) && $settings['title_text_shadow'] != '' ) ? esc_attr($settings['title_text_shadow']) : 'off'; | |
| 1114 | + $settings['title_text_shadow'] = isset( $settings['title_text_shadow'] ) && $settings['title_text_shadow'] == 'on' ? 'checked' : ''; | |
| 1115 | + | |
| 1116 | + // title italic | |
| 1117 | + $settings['title_italic'] = ( isset( $settings['title_italic'] ) && $settings['title_italic'] != '' ) ? esc_attr($settings['title_italic']) : 'off'; | |
| 1118 | + $settings['title_italic'] = isset( $settings['title_italic'] ) && $settings['title_italic'] != 'on'? 'normal' : 'italic'; | |
| 1119 | + | |
| 1120 | + // title gap | |
| 1121 | + $settings['title_gap'] = (isset( $settings['title_gap'] ) && $settings['title_gap'] != '') ? esc_attr( $settings['title_gap'] ) : '5'; | |
| 1122 | + | |
| 1123 | + // title gap | |
| 1124 | + $settings['title_gap_description'] = (isset( $settings['title_gap_description'] ) && $settings['title_gap_description'] != '') ? esc_attr( $settings['title_gap_description'] ) : '5'; | |
| 1125 | + | |
| 1126 | + // title letter spacing | |
| 1127 | + $settings['title_letter_spacing'] = (isset( $settings['title_letter_spacing'] ) && $settings['title_letter_spacing'] != '') ? esc_attr( $settings['title_letter_spacing'] ) : 0; | |
| 1128 | + | |
| 1129 | + // title position | |
| 1130 | + $settings['title_position'] = isset( $settings['title_position'] ) && $settings['title_position'] != '' ? esc_attr( $settings['title_position'] ) : 'left'; | |
| 1131 | + | |
| 1132 | + // title text transform | |
| 1133 | + $settings['title_text_transform'] = isset( $settings['title_text_transform'] ) && $settings['title_text_transform'] != '' ? esc_attr( $settings['title_text_transform'] ) : 'none'; | |
| 1134 | + | |
| 1135 | + // title text decoration | |
| 1136 | + $settings['title_text_decoration'] = isset( $settings['title_text_decoration'] ) && $settings['title_text_decoration'] != '' ? esc_attr( $settings['title_text_decoration'] ) : 'none'; | |
| 1137 | + | |
| 1138 | + // description color | |
| 1139 | + $settings['description_color'] = isset( $settings['description_color'] ) && $settings['description_color'] != '' ? esc_attr( $settings['description_color'] ) : '#4c4c4c'; | |
| 1140 | + | |
| 1141 | + // description font size | |
| 1142 | + $settings['description_font_size'] = (isset( $settings['description_font_size'] ) && $settings['description_font_size'] != '') ? esc_attr( $settings['description_font_size'] ) : '16'; | |
| 1143 | + | |
| 1144 | + // description Bold text | |
| 1145 | + $settings['description_bold'] = ( isset( $settings['description_bold'] ) && $settings['description_bold'] != '' ) ? esc_attr($settings['description_bold']) : 'off'; | |
| 1146 | + $settings['description_bold'] = isset( $settings['description_bold'] ) && $settings['description_bold'] != 'on'? 'normal' : 'bold'; | |
| 1147 | + | |
| 1148 | + // description text shadow | |
| 1149 | + $settings['description_text_shadow'] = ( isset( $settings['description_text_shadow'] ) && $settings['description_text_shadow'] != '' ) ? esc_attr($settings['description_text_shadow']) : 'off'; | |
| 1150 | + $settings['description_text_shadow'] = isset( $settings['description_text_shadow'] ) && $settings['description_text_shadow'] == 'on' ? 'checked' : ''; | |
| 1151 | + | |
| 1152 | + // description color | |
| 1153 | + $settings['description_shadow_color'] = isset( $settings['description_shadow_color'] ) && $settings['description_shadow_color'] != '' ? esc_attr( $settings['description_shadow_color'] ) : $settings['description_color']; | |
| 1154 | + | |
| 1155 | + // desctiption italic text | |
| 1156 | + $settings['description_italic'] = ( isset( $settings['description_italic'] ) && $settings['description_italic'] != '' ) ? esc_attr($settings['description_italic']) : 'off'; | |
| 1157 | + $settings['description_italic'] = isset( $settings['description_italic'] ) && $settings['description_italic'] != 'on'? 'normal' : 'italic'; | |
| 1158 | + | |
| 1159 | + // description position | |
| 1160 | + $settings['description_position'] = isset( $settings['description_position'] ) && $settings['description_position'] != '' ? esc_attr( $settings['description_position'] ) : 'left'; | |
| 1161 | + | |
| 1162 | + // description text transform | |
| 1163 | + $settings['description_text_transform'] = isset( $settings['description_text_transform'] ) && $settings['description_text_transform'] != '' ? esc_attr( $settings['description_text_transform'] ) : 'none'; | |
| 1164 | + | |
| 1165 | + // description letter spacing | |
| 1166 | + $settings['description_letter_spacing'] = isset( $settings['description_letter_spacing'] ) && $settings['description_letter_spacing'] != '' ? esc_attr( $settings['description_letter_spacing'] ) : 0; | |
| 1167 | + | |
| 1168 | + // description text decoration | |
| 1169 | + $settings['description_text_decoration'] = isset( $settings['description_text_decoration'] ) && $settings['description_text_decoration'] != '' ? esc_attr( $settings['description_text_decoration'] ) : 'none'; | |
| 1170 | + | |
| 1171 | + // Rotation degree | |
| 1172 | + $settings['rotation_degree'] = isset( $settings['rotation_degree'] ) && $settings['rotation_degree'] != '' ? esc_attr( $settings['rotation_degree'] ) : '0'; | |
| 1173 | + | |
| 1174 | + // Is stacked | |
| 1175 | + $settings['is_stacked'] = ( isset( $settings['is_stacked'] ) && $settings['is_stacked'] != '' ) ? $settings['is_stacked'] : 'off'; | |
| 1176 | + | |
| 1177 | + // Line width | |
| 1178 | + $settings['line_width'] = isset( $settings['line_width'] ) && $settings['line_width'] != '' ? esc_attr( $settings['line_width'] ) : '2'; | |
| 1179 | + | |
| 1180 | + // Slice border color | |
| 1181 | + $settings['slice_border_color'] = isset( $settings['slice_border_color'] ) && $settings['slice_border_color'] != '' ? esc_attr( $settings['slice_border_color'] ) : '#ffffff'; | |
| 1182 | + | |
| 1183 | + // Reverse categories | |
| 1184 | + $settings['reverse_categories'] = ( isset( $settings['reverse_categories'] ) && $settings['reverse_categories'] != '' ) ? $settings['reverse_categories'] : 'off'; | |
| 1185 | + | |
| 1186 | + // Slice text | |
| 1187 | + $settings['slice_text'] = isset( $settings['slice_text'] ) && $settings['slice_text'] != '' ? esc_attr( $settings['slice_text'] ) : 'percentage'; | |
| 1188 | + | |
| 1189 | + // Tooltip trigger | |
| 1190 | + $settings['tooltip_trigger'] = isset( $settings['tooltip_trigger'] ) && $settings['tooltip_trigger'] != '' ? esc_attr( $settings['tooltip_trigger'] ) : 'hover'; | |
| 1191 | + | |
| 1192 | + // Tooltip text | |
| 1193 | + $settings['tooltip_text'] = isset( $settings['tooltip_text'] ) && $settings['tooltip_text'] != '' ? esc_attr( $settings['tooltip_text'] ) : 'both'; | |
| 1194 | + | |
| 1195 | + // Multiple data format | |
| 1196 | + $settings['multiple_data_format'] = isset( $settings['multiple_data_format'] ) && $settings['multiple_data_format'] != '' ? esc_attr( $settings['multiple_data_format'] ) : 'auto'; | |
| 1197 | + | |
| 1198 | + // Data grouping settings | |
| 1199 | + $settings['data_grouping_limit'] = isset( $settings['data_grouping_limit'] ) && $settings['data_grouping_limit'] != '' ? esc_attr( $settings['data_grouping_limit'] ) : '0.5'; | |
| 1200 | + $settings['data_grouping_label'] = isset( $settings['data_grouping_label'] ) && $settings['data_grouping_label'] != '' ? esc_attr( $settings['data_grouping_label'] ) : 'Other'; | |
| 1201 | + $settings['data_grouping_color'] = isset( $settings['data_grouping_color'] ) && $settings['data_grouping_color'] != '' ? esc_attr( $settings['data_grouping_color'] ) : '#ccc'; | |
| 1202 | + | |
| 1203 | + // Focus target | |
| 1204 | + $settings['focus_target'] = isset( $settings['focus_target'] ) && $settings['focus_target'] != '' ? esc_attr( $settings['focus_target'] ) : 'datum'; | |
| 1205 | + | |
| 1206 | + // Show color code | |
| 1207 | + $settings['show_color_code'] = ( isset( $settings['show_color_code'] ) && $settings['show_color_code'] != '' ) ? $settings['show_color_code'] : 'off'; | |
| 1208 | + | |
| 1209 | + // Italic text | |
| 1210 | + $settings['tooltip_italic'] = ( isset( $settings['tooltip_italic'] ) && $settings['tooltip_italic'] != '' ) ? $settings['tooltip_italic'] : 'off'; | |
| 1211 | + | |
| 1212 | + // Bold text | |
| 1213 | + $settings['tooltip_bold'] = isset( $settings['tooltip_bold'] ) && $settings['tooltip_bold'] != '' ? esc_attr( $settings['tooltip_bold'] ) : 'default'; | |
| 1214 | + | |
| 1215 | + // Tooltip text color | |
| 1216 | + $settings['tooltip_text_color'] = isset( $settings['tooltip_text_color'] ) && $settings['tooltip_text_color'] != '' ? esc_attr( $settings['tooltip_text_color'] ) : '#000000'; | |
| 1217 | + | |
| 1218 | + // Tooltip font size | |
| 1219 | + $settings['tooltip_font_size'] = isset( $settings['tooltip_font_size'] ) && intval($settings['tooltip_font_size']) > 0 ? esc_attr( $settings['tooltip_font_size'] ) : $settings['font_size']; | |
| 1220 | + | |
| 1221 | + // Legend position | |
| 1222 | + $settings['legend_position'] = isset( $settings['legend_position'] ) && $settings['legend_position'] != '' ? esc_attr( $settings['legend_position'] ) : 'right'; | |
| 1223 | + | |
| 1224 | + // Legend alignment | |
| 1225 | + $settings['legend_alignment'] = isset( $settings['legend_alignment'] ) && $settings['legend_alignment'] != '' ? esc_attr( $settings['legend_alignment'] ) : 'start'; | |
| 1226 | + | |
| 1227 | + // Legend font color | |
| 1228 | + $settings['legend_color'] = isset( $settings['legend_color'] ) && $settings['legend_color'] != '' ? esc_attr( $settings['legend_color'] ) : '#000000'; | |
| 1229 | + | |
| 1230 | + // Legend font size | |
| 1231 | + $settings['legend_font_size'] = isset( $settings['legend_font_size'] ) && intval($settings['legend_font_size']) > 0 ? esc_attr( $settings['legend_font_size'] ) : $settings['font_size']; | |
| 1232 | + | |
| 1233 | + // Legend Italic text | |
| 1234 | + $settings['legend_italic'] = ( isset( $settings['legend_italic'] ) && $settings['legend_italic'] != '' ) ? $settings['legend_italic'] : 'off'; | |
| 1235 | + | |
| 1236 | + // Legend Bold text | |
| 1237 | + $settings['legend_bold'] = ( isset( $settings['legend_bold'] ) && $settings['legend_bold'] != '' ) ? $settings['legend_bold'] : 'off'; | |
| 1238 | + | |
| 1239 | + // Opacity | |
| 1240 | + $settings['opacity'] = isset( $settings['opacity'] ) && $settings['opacity'] != '' ? esc_attr( $settings['opacity'] ) : '1.0'; | |
| 1241 | + | |
| 1242 | + // Group width | |
| 1243 | + $settings['group_width'] = isset( $settings['group_width'] ) && $settings['group_width'] != '' ? esc_attr( $settings['group_width'] ) : '61.8'; | |
| 1244 | + $settings['group_width_format'] = isset( $settings['group_width_format'] ) && $settings['group_width_format'] != '' ? esc_attr( $settings['group_width_format'] ) : '%'; | |
| 1245 | + | |
| 1246 | + // Show chart description | |
| 1247 | + $settings['show_description'] = isset( $settings['show_description'] ) && $settings['show_description'] != '' ? esc_attr( $settings['show_description'] ) : 'on'; | |
| 1248 | + | |
| 1249 | + // Show chart title | |
| 1250 | + $settings['show_title'] = isset( $settings['show_title'] ) && $settings['show_title'] != '' ? esc_attr( $settings['show_title'] ) : 'on'; | |
| 1251 | + | |
| 1252 | + // Enable interactivity | |
| 1253 | + $settings['enable_interactivity'] = isset( $settings['enable_interactivity'] ) && $settings['enable_interactivity'] != '' ? esc_attr( $settings['enable_interactivity'] ) : 'on'; | |
| 1254 | + | |
| 1255 | + // Maximized view | |
| 1256 | + $settings['maximized_view'] = ( isset( $settings['maximized_view'] ) && $settings['maximized_view'] != '' ) ? $settings['maximized_view'] : 'off'; | |
| 1257 | + | |
| 1258 | + // Multiple data selection | |
| 1259 | + $settings['multiple_selection'] = ( isset( $settings['multiple_selection'] ) && $settings['multiple_selection'] != '' ) ? $settings['multiple_selection'] : 'off'; | |
| 1260 | + | |
| 1261 | + // Point shape | |
| 1262 | + $settings['point_shape'] = isset( $settings['point_shape'] ) && $settings['point_shape'] != '' ? esc_attr( $settings['point_shape'] ) : 'circle'; | |
| 1263 | + | |
| 1264 | + // Point size | |
| 1265 | + $settings['point_size'] = isset( $settings['point_size'] ) && $settings['point_size'] != '' ? absint(esc_attr( $settings['point_size'] )) : '0'; | |
| 1266 | + | |
| 1267 | + // Crosshair trigger | |
| 1268 | + $settings['crosshair_trigger'] = isset( $settings['crosshair_trigger'] ) && $settings['crosshair_trigger'] != '' ? esc_attr( $settings['crosshair_trigger'] ) : 'none'; | |
| 1269 | + | |
| 1270 | + // Crosshair orientation | |
| 1271 | + $settings['crosshair_orientation'] = isset( $settings['crosshair_orientation'] ) && $settings['crosshair_orientation'] != '' ? esc_attr( $settings['crosshair_orientation'] ) : 'both'; | |
| 1272 | + | |
| 1273 | + // Crosshair opacity | |
| 1274 | + $settings['crosshair_opacity'] = isset( $settings['crosshair_opacity'] ) && $settings['crosshair_opacity'] != '' ? esc_attr( $settings['crosshair_opacity'] ) : '1.0'; | |
| 1275 | + | |
| 1276 | + // Dash style | |
| 1277 | + $settings['dash_style'] = isset( $settings['dash_style'] ) && $settings['dash_style'] != '' ? esc_attr( str_replace(' ', '', $settings['dash_style']) ) : ''; | |
| 1278 | + | |
| 1279 | + // Orientation | |
| 1280 | + $settings['orientation'] = ( isset( $settings['orientation'] ) && $settings['orientation'] != '' ) ? $settings['orientation'] : 'off'; | |
| 1281 | + | |
| 1282 | + // Fill nulls | |
| 1283 | + $settings['fill_nulls'] = ( isset( $settings['fill_nulls'] ) && $settings['fill_nulls'] != '' ) ? $settings['fill_nulls'] : 'off'; | |
| 1284 | + | |
| 1285 | + // Font size for org chart | |
| 1286 | + $settings['org_chart_font_size'] = isset( $settings['org_chart_font_size'] ) && $settings['org_chart_font_size'] != '' ? esc_attr( $settings['org_chart_font_size'] ) : 'medium'; | |
| 1287 | + | |
| 1288 | + // Allow collapse | |
| 1289 | + $settings['allow_collapse'] = ( isset( $settings['allow_collapse'] ) && $settings['allow_collapse'] != '' ) ? $settings['allow_collapse'] : 'off'; | |
| 1290 | + | |
| 1291 | + // Donut hole size | |
| 1292 | + $settings['donut_hole_size'] = isset( $settings['donut_hole_size'] ) && $settings['donut_hole_size'] != '' ? esc_attr( $settings['donut_hole_size'] ) : '0.4'; | |
| 1293 | + | |
| 1294 | + // Org custom css class | |
| 1295 | + $settings['org_classname'] = isset( $settings['org_classname'] ) && $settings['org_classname'] != '' ? esc_attr( $settings['org_classname'] ) : ''; | |
| 1296 | + | |
| 1297 | + $settings['org_node_background_color'] = isset( $settings['org_node_background_color'] ) && $settings['org_node_background_color'] != '' ? esc_attr( $settings['org_node_background_color'] ) : '#edf7ff'; | |
| 1298 | + $settings['org_node_padding'] = isset( $settings['org_node_padding'] ) && $settings['org_node_padding'] != '' ? esc_attr( $settings['org_node_padding'] ) : '2'; | |
| 1299 | + $settings['org_node_border_radius'] = isset( $settings['org_node_border_radius'] ) && $settings['org_node_border_radius'] != '' ? esc_attr( $settings['org_node_border_radius'] ) : '5'; | |
| 1300 | + $settings['org_node_border_width'] = isset( $settings['org_node_border_width'] ) && $settings['org_node_border_width'] != '' ? esc_attr( $settings['org_node_border_width'] ) : '0'; | |
| 1301 | + $settings['org_node_border_color'] = isset( $settings['org_node_border_color'] ) && $settings['org_node_border_color'] != '' ? esc_attr( $settings['org_node_border_color'] ) : '#b5d9ea'; | |
| 1302 | + $settings['org_node_text_color'] = isset( $settings['org_node_text_color'] ) && $settings['org_node_text_color'] != '' ? esc_attr( $settings['org_node_text_color'] ) : '#000000'; | |
| 1303 | + $settings['org_node_text_font_size'] = isset( $settings['org_node_text_font_size'] ) && $settings['org_node_text_font_size'] != '' ? esc_attr( $settings['org_node_text_font_size'] ) : '13'; | |
| 1304 | + $settings['org_node_description_font_color'] = isset( $settings['org_node_description_font_color'] ) && $settings['org_node_description_font_color'] != '' ? esc_attr( $settings['org_node_description_font_color'] ) : '#ff0000'; | |
| 1305 | + $settings['org_node_description_font_size'] = isset( $settings['org_node_description_font_size'] ) && $settings['org_node_description_font_size'] != '' ? esc_attr( $settings['org_node_description_font_size'] ) : '13'; | |
| 1306 | + | |
| 1307 | + // Org custom selected css class | |
| 1308 | + $settings['org_selected_classname'] = isset( $settings['org_selected_classname'] ) && $settings['org_selected_classname'] != '' ? esc_attr( $settings['org_selected_classname'] ) : ''; | |
| 1309 | + | |
| 1310 | + $settings['org_selected_node_background_color'] = isset( $settings['org_selected_node_background_color'] ) && $settings['org_selected_node_background_color'] != '' ? esc_attr( $settings['org_selected_node_background_color'] ) : '#fff7ae'; | |
| 1311 | + $settings['org_selected_node_text_color'] = isset( $settings['org_selected_node_text_color'] ) && $settings['org_selected_node_text_color'] != '' ? esc_attr( $settings['org_selected_node_text_color'] ) : $settings['org_node_text_color']; | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + // Horizontal axis settings | |
| 1315 | + $settings['haxis_title'] = isset( $settings['haxis_title'] ) && $settings['haxis_title'] != '' ? esc_attr( $settings['haxis_title'] ) : ''; | |
| 1316 | + $settings['haxis_label_font_size'] = isset( $settings['haxis_label_font_size'] ) && $settings['haxis_label_font_size'] != '' ? esc_attr( $settings['haxis_label_font_size'] ) : $settings['font_size']; | |
| 1317 | + $settings['haxis_label_color'] = isset( $settings['haxis_label_color'] ) && $settings['haxis_label_color'] != '' ? esc_attr( $settings['haxis_label_color'] ) : '#000000'; | |
| 1318 | + $settings['haxis_text_position'] = isset( $settings['haxis_text_position'] ) && $settings['haxis_text_position'] != '' ? esc_attr( $settings['haxis_text_position'] ) : 'out'; | |
| 1319 | + $settings['haxis_direction'] = ( isset( $settings['haxis_direction'] ) && $settings['haxis_direction'] != '' ) ? $settings['haxis_direction'] : '1'; | |
| 1320 | + $settings['haxis_text_color'] = isset( $settings['haxis_text_color'] ) && $settings['haxis_text_color'] != '' ? esc_attr( $settings['haxis_text_color'] ) : '#000000'; | |
| 1321 | + $settings['haxis_baseline_color'] = isset( $settings['haxis_baseline_color'] ) && $settings['haxis_baseline_color'] != '' ? esc_attr( $settings['haxis_baseline_color'] ) : '#000000'; | |
| 1322 | + $settings['haxis_text_font_size'] = isset( $settings['haxis_text_font_size'] ) && $settings['haxis_text_font_size'] != '' ? absint(esc_attr( $settings['haxis_text_font_size'] )) : $settings['font_size']; | |
| 1323 | + $settings['haxis_slanted'] = isset( $settings['haxis_slanted'] ) && $settings['haxis_slanted'] != '' ? esc_attr( $settings['haxis_slanted'] ) : 'automatic'; | |
| 1324 | + $settings['haxis_slanted_text_angle'] = isset( $settings['haxis_slanted_text_angle'] ) && $settings['haxis_slanted_text_angle'] != '' && $settings['haxis_slanted_text_angle'] != '0' ? esc_attr( $settings['haxis_slanted_text_angle'] ) : '30'; | |
| 1325 | + $settings['haxis_show_text_every'] = isset( $settings['haxis_show_text_every'] ) && $settings['haxis_show_text_every'] != '' ? esc_attr( $settings['haxis_show_text_every'] ) : '0'; | |
| 1326 | + $settings['haxis_format'] = isset( $settings['haxis_format'] ) && $settings['haxis_format'] != '' ? esc_attr( $settings['haxis_format'] ) : ''; | |
| 1327 | + $settings['haxis_enable_divide_percent'] = ( isset( $settings['haxis_enable_divide_percent'] ) && $settings['haxis_enable_divide_percent'] != '' ) ? $settings['haxis_enable_divide_percent'] : 'off'; | |
| 1328 | + $settings['haxis_max_value'] = isset( $settings['haxis_max_value'] ) && $settings['haxis_max_value'] != '' ? esc_attr( $settings['haxis_max_value'] ) : null; | |
| 1329 | + $settings['haxis_min_value'] = isset( $settings['haxis_min_value'] ) && $settings['haxis_min_value'] != '' ? esc_attr( $settings['haxis_min_value'] ) : null; | |
| 1330 | + $settings['haxis_gridlines_count'] = isset( $settings['haxis_gridlines_count'] ) && $settings['haxis_gridlines_count'] != '' ? esc_attr( $settings['haxis_gridlines_count'] ) : -1; | |
| 1331 | + $settings['haxis_italic'] = ( isset( $settings['haxis_italic'] ) && $settings['haxis_italic'] != '' ) ? $settings['haxis_italic'] : 'off'; | |
| 1332 | + $settings['haxis_bold'] = ( isset( $settings['haxis_bold'] ) && $settings['haxis_bold'] != '' ) ? $settings['haxis_bold'] : 'off'; | |
| 1333 | + $settings['haxis_title_italic'] = ( isset( $settings['haxis_title_italic'] ) && $settings['haxis_title_italic'] != '' ) ? $settings['haxis_title_italic'] : 'off'; | |
| 1334 | + $settings['haxis_title_bold'] = ( isset( $settings['haxis_title_bold'] ) && $settings['haxis_title_bold'] != '' ) ? $settings['haxis_title_bold'] : 'off'; | |
| 1335 | + $settings['haxis_gridlines_color'] = isset( $settings['haxis_gridlines_color'] ) && $settings['haxis_gridlines_color'] != '' ? esc_attr( $settings['haxis_gridlines_color'] ) : '#cccccc'; | |
| 1336 | + $settings['haxis_minor_gridlines_color'] = isset( $settings['haxis_minor_gridlines_color'] ) && $settings['haxis_minor_gridlines_color'] != '' ? esc_attr( $settings['haxis_minor_gridlines_color'] ) : $settings['haxis_gridlines_color']; | |
| 1337 | + | |
| 1338 | + // Vertical axis settings | |
| 1339 | + $settings['vaxis_title'] = isset( $settings['vaxis_title'] ) && $settings['vaxis_title'] != '' ? esc_attr( $settings['vaxis_title'] ) : ''; | |
| 1340 | + $settings['vaxis_label_font_size'] = isset( $settings['vaxis_label_font_size'] ) && $settings['vaxis_label_font_size'] != '' ? esc_attr( $settings['vaxis_label_font_size'] ) : $settings['font_size']; | |
| 1341 | + $settings['vaxis_label_color'] = isset( $settings['vaxis_label_color'] ) && $settings['vaxis_label_color'] != '' ? esc_attr( $settings['vaxis_label_color'] ) : '#000000'; | |
| 1342 | + $settings['vaxis_text_position'] = isset( $settings['vaxis_text_position'] ) && $settings['vaxis_text_position'] != '' ? esc_attr( $settings['vaxis_text_position'] ) : 'out'; | |
| 1343 | + $settings['vaxis_direction'] = ( isset( $settings['vaxis_direction'] ) && $settings['vaxis_direction'] != '' ) ? $settings['vaxis_direction'] : '1'; | |
| 1344 | + $settings['vaxis_text_color'] = isset( $settings['vaxis_text_color'] ) && $settings['vaxis_text_color'] != '' ? esc_attr( $settings['vaxis_text_color'] ) : '#000000'; | |
| 1345 | + $settings['vaxis_baseline_color'] = isset( $settings['vaxis_baseline_color'] ) && $settings['vaxis_baseline_color'] != '' ? esc_attr( $settings['vaxis_baseline_color'] ) : '#000000'; | |
| 1346 | + $settings['vaxis_text_font_size'] = isset( $settings['vaxis_text_font_size'] ) && $settings['vaxis_text_font_size'] != '' ? absint(esc_attr( $settings['vaxis_text_font_size'] )) : $settings['font_size']; | |
| 1347 | + $settings['vaxis_format'] = isset( $settings['vaxis_format'] ) && $settings['vaxis_format'] != '' ? esc_attr( $settings['vaxis_format'] ) : ''; | |
| 1348 | + $settings['vaxis_enable_divide_percent'] = ( isset( $settings['vaxis_enable_divide_percent'] ) && $settings['vaxis_enable_divide_percent'] != '' ) ? $settings['vaxis_enable_divide_percent'] : 'off'; | |
| 1349 | + $settings['vaxis_max_value'] = isset( $settings['vaxis_max_value'] ) && $settings['vaxis_max_value'] != '' ? esc_attr( $settings['vaxis_max_value'] ) : null; | |
| 1350 | + $settings['vaxis_min_value'] = isset( $settings['vaxis_min_value'] ) && $settings['vaxis_min_value'] != '' ? esc_attr( $settings['vaxis_min_value'] ) : null; | |
| 1351 | + $settings['vaxis_gridlines_count'] = isset( $settings['vaxis_gridlines_count'] ) && $settings['vaxis_gridlines_count'] != '' ? esc_attr( $settings['vaxis_gridlines_count'] ) : -1; | |
| 1352 | + $settings['vaxis_italic'] = ( isset( $settings['vaxis_italic'] ) && $settings['vaxis_italic'] != '' ) ? $settings['vaxis_italic'] : 'off'; | |
| 1353 | + $settings['vaxis_bold'] = ( isset( $settings['vaxis_bold'] ) && $settings['vaxis_bold'] != '' ) ? $settings['vaxis_bold'] : 'off'; | |
| 1354 | + $settings['vaxis_title_italic'] = ( isset( $settings['vaxis_title_italic'] ) && $settings['vaxis_title_italic'] != '' ) ? $settings['vaxis_title_italic'] : 'off'; | |
| 1355 | + $settings['vaxis_title_bold'] = ( isset( $settings['vaxis_title_bold'] ) && $settings['vaxis_title_bold'] != '' ) ? $settings['vaxis_title_bold'] : 'off'; | |
| 1356 | + $settings['vaxis_gridlines_color'] = isset( $settings['vaxis_gridlines_color'] ) && $settings['vaxis_gridlines_color'] != '' ? esc_attr( $settings['vaxis_gridlines_color'] ) : '#cccccc'; | |
| 1357 | + $settings['vaxis_minor_gridlines_color'] = isset( $settings['vaxis_minor_gridlines_color'] ) && $settings['vaxis_minor_gridlines_color'] != '' ? esc_attr( $settings['vaxis_minor_gridlines_color'] ) : $settings['vaxis_gridlines_color']; | |
| 1358 | + | |
| 1359 | + // Animation settings | |
| 1360 | + $settings['enable_animation'] = ( isset( $settings['enable_animation'] ) && $settings['enable_animation'] != '' ) ? $settings['enable_animation'] : 'off'; | |
| 1361 | + $settings['animation_duration'] = isset( $settings['animation_duration'] ) && $settings['animation_duration'] != '' ? absint(esc_attr( $settings['animation_duration'] )) : '1000'; | |
| 1362 | + $settings['animation_startup'] = ( isset( $settings['animation_startup'] ) && $settings['animation_startup'] != '' ) ? $settings['animation_startup'] : 'on'; | |
| 1363 | + $settings['animation_easing'] = isset( $settings['animation_easing'] ) && $settings['animation_easing'] != '' ? esc_attr( $settings['animation_easing'] ) : 'linear'; | |
| 1364 | + | |
| 1365 | + $settings['enable_img'] = ( isset( $settings['enable_img'] ) && $settings['enable_img'] != '' ) ? $settings['enable_img'] : 'off'; | |
| 1366 | + | |
| 1367 | + $count_slices = (isset($chartData['source']) && !is_null($chartData['source']) && count($chartData['source']) > 0) ? count($chartData['source']) - 1 : 0; | |
| 1368 | + $count_series = (isset($chartData['source'][0]) && !is_null($chartData['source'][0]) && count($chartData['source'][0]) > 0) ? count($chartData['source'][0]) - 1 : 0; | |
| 1369 | + $count_rows = (isset($chartData['source']) && !is_null($chartData['source']) && count($chartData['source']) > 0) ? count(array_column($chartData['source'], 0)) - 1 : 0; | |
| 1370 | + | |
| 1371 | + // Slices settings | |
| 1372 | + $settings['slice_colors_default'] = $chart_default_colors; | |
| 1373 | + $settings['slice_color'] = isset( $settings['slice_color'] ) && $settings['slice_color'] != '' ? json_decode($settings['slice_color'], true) : $chart_default_colors; | |
| 1374 | + $settings['slice_offset'] = isset( $settings['slice_offset'] ) && $settings['slice_offset'] != '' ? json_decode($settings['slice_offset'], true) : array_fill(0, $count_slices, 0); | |
| 1375 | + $settings['slice_text_color'] = isset( $settings['slice_text_color'] ) && $settings['slice_text_color'] != '' ? json_decode($settings['slice_text_color'], true) : array_fill(0, $count_slices, '#ffffff'); | |
| 1376 | + | |
| 1377 | + // Series settings | |
| 1378 | + $settings['series_colors_default'] = $chart_default_colors; | |
| 1379 | + $settings['series_color'] = isset( $settings['series_color'] ) && $settings['series_color'] != '' ? json_decode($settings['series_color'], true) : $chart_default_colors; | |
| 1380 | + $settings['series_visible_in_legend'] = isset( $settings['series_visible_in_legend'] ) && $settings['series_visible_in_legend'] != '' ? json_decode($settings['series_visible_in_legend'], true) : array_fill(0, $count_series, 'on'); | |
| 1381 | + $settings['series_line_width'] = isset( $settings['series_line_width'] ) && $settings['series_line_width'] != '' ? json_decode($settings['series_line_width'], true) : array_fill(0, $count_series, $settings['line_width']); | |
| 1382 | + $settings['series_point_size'] = isset( $settings['series_point_size'] ) && $settings['series_point_size'] != '' ? json_decode($settings['series_point_size'], true) : array_fill(0, $count_series, $settings['point_size']); | |
| 1383 | + $settings['series_point_shape'] = isset( $settings['series_point_shape'] ) && $settings['series_point_shape'] != '' ? json_decode($settings['series_point_shape'], true) : array_fill(0, $count_series, $settings['point_shape']); | |
| 1384 | + $settings['series_format'] = isset( $settings['series_format'] ) && $settings['series_format'] != '' ? json_decode($settings['series_format'], true) : array_fill(0, $count_series, ''); | |
| 1385 | + // Rows settings | |
| 1386 | + $settings['enable_row_settings'] = ( isset( $settings['enable_row_settings'] ) && $settings['enable_row_settings'] != '' ) ? $settings['enable_row_settings'] : 'on'; | |
| 1387 | + | |
| 1388 | + $settings['rows_color'] = isset( $settings['rows_color'] ) && $settings['rows_color'] != '' ? json_decode($settings['rows_color'], true) : array_fill(0, $count_rows, ''); | |
| 1389 | + $settings['rows_opacity'] = isset( $settings['rows_opacity'] ) && $settings['rows_opacity'] != '' ? json_decode($settings['rows_opacity'], true) : array_fill(0, $count_rows, 1.0); | |
| 1390 | + | |
| 1391 | + return $settings; | |
| 1392 | + | |
| 1393 | + } | |
| 1394 | + | |
| 1395 | + /** | |
| 1396 | + * Gets all settings of chart.js charts for admin area. | |
| 1397 | + * | |
| 1398 | + * @access public | |
| 1399 | + * @return array | |
| 1400 | + */ | |
| 1401 | + public function get_chart_settings_chartjs_admin($settings, $source) { | |
| 1402 | + $chart_default_colors = array('#36A2EB','#FF6384','#FF9F40','#FFCD56', '#4BC0C0','#0099c6','#dd4477','#66aa00', '#b82e2e','#316395','#994499','#22aa99', '#aaaa11','#6633cc','#e67300','#8b0707', '#651067','#329262','#5574a6','#3b3eac', '#b77322','#16d620','#b91383','#f4359e', '#9c5935','#a9c413','#2a778d','#668d1c', '#bea413','#0c5922','#743411'); | |
| 1403 | + | |
| 1404 | + $title_positions = array( | |
| 1405 | + "left" => __("Left", "chart-builder"), | |
| 1406 | + "right" => __("Right", "chart-builder"), | |
| 1407 | + "center" => __("Center", "chart-builder") | |
| 1408 | + ); | |
| 1409 | + | |
| 1410 | + $text_transforms = array( | |
| 1411 | + "uppercase" => __("Uppercase", "chart-builder"), | |
| 1412 | + "lowercase" => __("Lowercase", "chart-builder"), | |
| 1413 | + "capitalize" => __("Capitalize", "chart-builder"), | |
| 1414 | + "none" => __("None", "chart-builder"), | |
| 1415 | + ); | |
| 1416 | + | |
| 1417 | + $text_decorations = array( | |
| 1418 | + "overline" => __("Overline", "chart-builder"), | |
| 1419 | + "underline" => __("Underline", "chart-builder"), | |
| 1420 | + "line-through" => __("Line through", "chart-builder"), | |
| 1421 | + "none" => __("None", "chart-builder"), | |
| 1422 | + ); | |
| 1423 | + | |
| 1424 | + $border_styles = array( | |
| 1425 | + "solid" => __("Solid", "chart-builder"), | |
| 1426 | + "dashed" => __("Dashed", "chart-builder"), | |
| 1427 | + "dotted" => __("Dotted", "chart-builder"), | |
| 1428 | + "double" => __("Double", "chart-builder"), | |
| 1429 | + "groove" => __("Groove", "chart-builder"), | |
| 1430 | + "inset" => __("Inset", "chart-builder"), | |
| 1431 | + "outset" => __("Outset", "chart-builder"), | |
| 1432 | + "ridge" => __("Ridge", "chart-builder") | |
| 1433 | + ); | |
| 1434 | + | |
| 1435 | + $legend_positions = array( | |
| 1436 | + "top" => __("Above the chart", "chart-builder"), | |
| 1437 | + "bottom" => __("Below the chart", "chart-builder"), | |
| 1438 | + "left" => __("Left of the chart", "chart-builder"), | |
| 1439 | + "right" => __("Right of the chart", "chart-builder"), | |
| 1440 | + ); | |
| 1441 | + | |
| 1442 | + $legend_alignments = array( | |
| 1443 | + "start" => __("Start", "chart-builder"), | |
| 1444 | + "center" => __("Center", "chart-builder"), | |
| 1445 | + "end" => __("End", "chart-builder"), | |
| 1446 | + ); | |
| 1447 | + | |
| 1448 | + $group_width_format_options = array( | |
| 1449 | + "%" => __("%", "chart-builder"), | |
| 1450 | + "px" => __("px", "chart-builder"), | |
| 1451 | + ); | |
| 1452 | + | |
| 1453 | + // Width | |
| 1454 | + $settings['width'] = isset( $settings['width'] ) && $settings['width'] != '' ? esc_attr( $settings['width'] ) : '100'; | |
| 1455 | + $settings['width_format'] = isset( $settings['width_format'] ) && $settings['width_format'] != '' ? esc_attr( $settings['width_format'] ) : '%'; | |
| 1456 | + $settings['width_format_options'] = $group_width_format_options; | |
| 1457 | + | |
| 1458 | + // Height | |
| 1459 | + $settings['height'] = isset( $settings['height'] ) && $settings['height'] != '' ? esc_attr( $settings['height'] ) : '100'; | |
| 1460 | + $settings['height_format'] = isset( $settings['height_format'] ) && $settings['height_format'] != '' ? esc_attr( $settings['height_format'] ) : '%'; | |
| 1461 | + | |
| 1462 | + // Title color | |
| 1463 | + $settings['title_color'] = isset( $settings['title_color'] ) && $settings['title_color'] != '' ? esc_attr( $settings['title_color'] ) : '#000000'; | |
| 1464 | + | |
| 1465 | + // Title color | |
| 1466 | + $settings['title_shadow_color'] = isset( $settings['title_shadow_color'] ) && $settings['title_shadow_color'] != '' ? esc_attr( $settings['title_shadow_color'] ) : $settings['title_color']; | |
| 1467 | + | |
| 1468 | + // Title font size | |
| 1469 | + $settings['title_font_size'] = isset( $settings['title_font_size'] ) && $settings['title_font_size'] != '' ? esc_attr( $settings['title_font_size'] ) : '30'; | |
| 1470 | + | |
| 1471 | + // Title Bold text | |
| 1472 | + $settings['title_bold'] = ( isset( $settings['title_bold'] ) && $settings['title_bold'] != '' ) ? esc_attr($settings['title_bold']) : 'on'; | |
| 1473 | + $settings['title_bold'] = isset( $settings['title_bold'] ) && $settings['title_bold'] == 'on' ? 'checked' : ''; | |
| 1474 | + | |
| 1475 | + // Title text shadow | |
| 1476 | + $settings['title_text_shadow'] = ( isset( $settings['title_text_shadow'] ) && $settings['title_text_shadow'] != '' ) ? esc_attr($settings['title_text_shadow']) : 'off'; | |
| 1477 | + $settings['title_text_shadow'] = isset( $settings['title_text_shadow'] ) && $settings['title_text_shadow'] == 'on' ? 'checked' : ''; | |
| 1478 | + | |
| 1479 | + // Title italic text | |
| 1480 | + $settings['title_italic'] = ( isset( $settings['title_italic'] ) && $settings['title_italic'] != '' ) ? esc_attr($settings['title_italic']) : 'off'; | |
| 1481 | + $settings['title_italic'] = isset( $settings['title_italic'] ) && $settings['title_italic'] == 'on' ? 'checked' : ''; | |
| 1482 | + | |
| 1483 | + // Title gap | |
| 1484 | + $settings['title_gap'] = isset( $settings['title_gap'] ) && $settings['title_gap'] != '' ? esc_attr( $settings['title_gap'] ) : '5'; | |
| 1485 | + | |
| 1486 | + // Title gap | |
| 1487 | + $settings['title_gap_description'] = isset( $settings['title_gap_description'] ) && $settings['title_gap_description'] != '' ? esc_attr( $settings['title_gap_description'] ) : '5'; | |
| 1488 | + | |
| 1489 | + // Title letter spacing | |
| 1490 | + $settings['title_letter_spacing'] = isset( $settings['title_letter_spacing'] ) && $settings['title_letter_spacing'] != '' ? esc_attr( $settings['title_letter_spacing'] ) : 0; | |
| 1491 | + | |
| 1492 | + // Title position | |
| 1493 | + $settings['title_position'] = isset( $settings['title_position'] ) && $settings['title_position'] != '' ? esc_attr( $settings['title_position'] ) : 'left'; | |
| 1494 | + $settings['title_positions'] = $title_positions; | |
| 1495 | + | |
| 1496 | + // Title text transform | |
| 1497 | + $settings['title_text_transform'] = isset( $settings['title_text_transform'] ) && $settings['title_text_transform'] != '' ? esc_attr( $settings['title_text_transform'] ) : 'none'; | |
| 1498 | + $settings['text_transforms'] = $text_transforms; | |
| 1499 | + | |
| 1500 | + // Title text decoration | |
| 1501 | + $settings['title_text_decoration'] = isset( $settings['title_text_decoration'] ) && $settings['title_text_decoration'] != '' ? esc_attr( $settings['title_text_decoration'] ) : 'none'; | |
| 1502 | + $settings['text_decorations'] = $text_decorations; | |
| 1503 | + | |
| 1504 | + // description color | |
| 1505 | + $settings['description_color'] = isset( $settings['description_color'] ) && $settings['description_color'] != '' ? esc_attr( $settings['description_color'] ) : '#4c4c4c'; | |
| 1506 | + | |
| 1507 | + // description font size | |
| 1508 | + $settings['description_font_size'] = isset( $settings['description_font_size'] ) && $settings['description_font_size'] != '' ? esc_attr( $settings['description_font_size'] ) : '16'; | |
| 1509 | + | |
| 1510 | + // description Bold text | |
| 1511 | + $settings['description_bold'] = ( isset( $settings['description_bold'] ) && $settings['description_bold'] != '' ) ? esc_attr($settings['description_bold']) : 'off'; | |
| 1512 | + $settings['description_bold'] = isset( $settings['description_bold'] ) && $settings['description_bold'] == 'on' ? 'checked' : ''; | |
| 1513 | + | |
| 1514 | + // description text shadow | |
| 1515 | + $settings['description_text_shadow'] = ( isset( $settings['description_text_shadow'] ) && $settings['description_text_shadow'] != '' ) ? esc_attr($settings['description_text_shadow']) : 'off'; | |
| 1516 | + $settings['description_text_shadow'] = isset( $settings['description_text_shadow'] ) && $settings['description_text_shadow'] == 'on' ? 'checked' : ''; | |
| 1517 | + | |
| 1518 | + // description color | |
| 1519 | + $settings['description_shadow_color'] = isset( $settings['description_shadow_color'] ) && $settings['description_shadow_color'] != '' ? esc_attr( $settings['description_shadow_color'] ) : $settings['description_color']; | |
| 1520 | + | |
| 1521 | + // description italic text | |
| 1522 | + $settings['description_italic'] = ( isset( $settings['description_italic'] ) && $settings['description_italic'] != '' ) ? esc_attr($settings['description_italic']) : 'off'; | |
| 1523 | + $settings['description_italic'] = isset( $settings['description_italic'] ) && $settings['description_italic'] == 'on' ? 'checked' : ''; | |
| 1524 | + | |
| 1525 | + // description position | |
| 1526 | + $settings['description_position'] = isset( $settings['description_position'] ) && $settings['description_position'] != '' ? esc_attr( $settings['description_position'] ) : 'left'; | |
| 1527 | + | |
| 1528 | + // description text transform | |
| 1529 | + $settings['description_text_transform'] = isset( $settings['description_text_transform'] ) && $settings['description_text_transform'] != '' ? esc_attr( $settings['description_text_transform'] ) : 'none'; | |
| 1530 | + | |
| 1531 | + // description letter spacing | |
| 1532 | + $settings['description_letter_spacing'] = isset( $settings['description_letter_spacing'] ) && $settings['description_letter_spacing'] != '' ? esc_attr( $settings['description_letter_spacing'] ) : 0; | |
| 1533 | + | |
| 1534 | + // description text decoration | |
| 1535 | + $settings['description_text_decoration'] = isset( $settings['description_text_decoration'] ) && $settings['description_text_decoration'] != '' ? esc_attr( $settings['description_text_decoration'] ) : 'none'; | |
| 1536 | + | |
| 1537 | + // Box shadow | |
| 1538 | + $settings['box_shadow'] = isset( $settings['box_shadow'] ) && $settings['box_shadow'] != '' ? esc_attr( $settings['box_shadow'] ) : 'off'; | |
| 1539 | + $settings['box_shadow'] = isset( $settings['box_shadow'] ) && $settings['box_shadow'] == 'on' ? 'checked' : ''; | |
| 1540 | + | |
| 1541 | + // Border width | |
| 1542 | + $settings['border_width'] = isset( $settings['border_width'] ) && $settings['border_width'] != '' ? esc_attr( $settings['border_width'] ) : '0'; | |
| 1543 | + | |
| 1544 | + // Border radius | |
| 1545 | + $settings['border_radius'] = isset( $settings['border_radius'] ) && $settings['border_radius'] != '' ? esc_attr( $settings['border_radius'] ) : '0'; | |
| 1546 | + | |
| 1547 | + // Border color | |
| 1548 | + $settings['border_color'] = isset( $settings['border_color'] ) && $settings['border_color'] != '' ? esc_attr( $settings['border_color'] ) : '#000000'; | |
| 1549 | + | |
| 1550 | + // Background color | |
| 1551 | + $settings['background_color_chart'] = isset( $settings['background_color_chart'] ) && $settings['background_color_chart'] != '' ? esc_attr( $settings['background_color_chart'] ) : '#ffffff'; | |
| 1552 | + | |
| 1553 | + // Border width with title | |
| 1554 | + $settings['border_width_with_title'] = isset( $settings['border_width_with_title'] ) && $settings['border_width_with_title'] != '' ? esc_attr( $settings['border_width_with_title'] ) : '0'; | |
| 1555 | + | |
| 1556 | + // Border radius with title | |
| 1557 | + $settings['border_radius_with_title'] = isset( $settings['border_radius_with_title'] ) && $settings['border_radius_with_title'] != '' ? esc_attr( $settings['border_radius_with_title'] ) : '0'; | |
| 1558 | + | |
| 1559 | + // Border color with title | |
| 1560 | + $settings['border_color_with_title'] = isset( $settings['border_color_with_title'] ) && $settings['border_color_with_title'] != '' ? esc_attr( $settings['border_color_with_title'] ) : '#000000'; | |
| 1561 | + | |
| 1562 | + // Border style with title | |
| 1563 | + $settings['border_style_with_title'] = isset( $settings['border_style_with_title'] ) && $settings['border_style_with_title'] != '' ? esc_attr( $settings['border_style_with_title'] ) : 'solid'; | |
| 1564 | + $settings['border_styles'] = $border_styles; | |
| 1565 | + | |
| 1566 | + //Box shadow color | |
| 1567 | + $settings['box_shadow_color'] = isset( $settings['box_shadow_color'] ) && $settings['box_shadow_color'] != '' ? esc_attr( $settings['box_shadow_color'] ) : $settings['border_color']; | |
| 1568 | + | |
| 1569 | + // Border style | |
| 1570 | + $settings['border_style'] = isset( $settings['border_style'] ) && $settings['border_style'] != '' ? esc_attr( $settings['border_style'] ) : 'solid'; | |
| 1571 | + $settings['border_styles'] = $border_styles; | |
| 1572 | + | |
| 1573 | + // slice_spacing | |
| 1574 | + $settings['slice_spacing'] = isset( $settings['slice_spacing'] ) && $settings['slice_spacing'] != '' ? esc_attr( absint($settings['slice_spacing']) ) : 1; | |
| 1575 | + | |
| 1576 | + // outer_radius | |
| 1577 | + $settings['outer_radius'] = isset( $settings['outer_radius'] ) && $settings['outer_radius'] != '' ? esc_attr( absint($settings['outer_radius']) ) : 100; | |
| 1578 | + | |
| 1579 | + // Padding outer | |
| 1580 | + $settings['padding_outer'] = isset( $settings['padding_outer'] ) && $settings['padding_outer'] != '' ? esc_attr( $settings['padding_outer'] ) : '0'; | |
| 1581 | + | |
| 1582 | + // circumference | |
| 1583 | + $settings['circumference'] = isset( $settings['circumference'] ) && $settings['circumference'] != '' ? esc_attr( absint($settings['circumference']) ) : 360; | |
| 1584 | + | |
| 1585 | + // start_angle | |
| 1586 | + $settings['start_angle'] = isset( $settings['start_angle'] ) && $settings['start_angle'] != '' ? esc_attr( absint($settings['start_angle']) ) : 0; | |
| 1587 | + | |
| 1588 | + // rotation_degree | |
| 1589 | + $settings['rotation_degree'] = isset( $settings['rotation_degree'] ) && $settings['rotation_degree'] != '' ? esc_attr( absint($settings['rotation_degree']) ) : 0; | |
| 1590 | + | |
| 1591 | + // Tooltip text options | |
| 1592 | + $tooltip_text_options = array( | |
| 1593 | + "value" => __("Value", "chart-builder"), | |
| 1594 | + "percentage" => __("Percent", "chart-builder"), | |
| 1595 | + "both" => __("Value & Percent", "chart-builder") | |
| 1596 | + ); | |
| 1597 | + $settings['tooltip_text_options'] = $tooltip_text_options; | |
| 1598 | + | |
| 1599 | + // Tooltip text | |
| 1600 | + $settings['tooltip_text'] = isset( $settings['tooltip_text'] ) && $settings['tooltip_text'] != '' ? esc_attr( $settings['tooltip_text'] ) : 'value'; | |
| 1601 | + | |
| 1602 | + // Data grouping settings | |
| 1603 | + $settings['data_grouping_limit'] = isset( $settings['data_grouping_limit'] ) && $settings['data_grouping_limit'] != '' ? esc_attr( $settings['data_grouping_limit'] ) : '0.5'; | |
| 1604 | + $settings['data_grouping_label'] = isset( $settings['data_grouping_label'] ) && $settings['data_grouping_label'] != '' ? esc_attr( $settings['data_grouping_label'] ) : 'Other'; | |
| 1605 | + $settings['data_grouping_color'] = isset( $settings['data_grouping_color'] ) && $settings['data_grouping_color'] != '' ? esc_attr( $settings['data_grouping_color'] ) : '#ccc'; | |
| 1606 | + | |
| 1607 | + // Show chart description | |
| 1608 | + if (!isset($settings['show_description'])) { | |
| 1609 | + $settings['show_description'] = 'checked'; | |
| 1610 | + } else { | |
| 1611 | + $settings['show_description'] = ( $settings['show_description'] != '' ) ? $settings['show_description'] : 'off'; | |
| 1612 | + $settings['show_description'] = isset( $settings['show_description'] ) && $settings['show_description'] == 'on' ? 'checked' : ''; | |
| 1613 | + } | |
| 1614 | + | |
| 1615 | + // Show chart title | |
| 1616 | + if (!isset($settings['show_title'])) { | |
| 1617 | + $settings['show_title'] = 'checked'; | |
| 1618 | + } else { | |
| 1619 | + $settings['show_title'] = ( $settings['show_title'] != '' ) ? $settings['show_title'] : 'off'; | |
| 1620 | + $settings['show_title'] = isset( $settings['show_title'] ) && $settings['show_title'] == 'on' ? 'checked' : ''; | |
| 1621 | + } | |
| 1622 | + | |
| 1623 | + // Enable interactivity | |
| 1624 | + if (!isset($settings['enable_interactivity'])) { | |
| 1625 | + $settings['enable_interactivity'] = 'checked'; | |
| 1626 | + } else { | |
| 1627 | + $settings['enable_interactivity'] = ( $settings['enable_interactivity'] != '' ) ? $settings['enable_interactivity'] : 'off'; | |
| 1628 | + $settings['enable_interactivity'] = isset( $settings['enable_interactivity'] ) && $settings['enable_interactivity'] == 'on' ? 'checked' : ''; | |
| 1629 | + } | |
| 1630 | + | |
| 1631 | + $counting_source = !empty($source) ? $source : array(); | |
| 1632 | + $count_slices = (isset($counting_source) && !is_null($counting_source) && count($counting_source) > 0) ? count($counting_source) - 1 : 0; | |
| 1633 | + | |
| 1634 | + // Slices settings | |
| 1635 | + $settings['slice_colors_default'] = $chart_default_colors; | |
| 1636 | + $settings['slice_color'] = isset( $settings['slice_color'] ) && $settings['slice_color'] != '' ? json_decode($settings['slice_color'], true) : array_slice($chart_default_colors, 0, $count_slices); | |
| 1637 | + | |
| 1638 | + // Slice border color | |
| 1639 | + $settings['slice_border_color'] = isset( $settings['slice_border_color'] ) && $settings['slice_border_color'] != '' ? esc_attr( $settings['slice_border_color'] ) : '#ffffff'; | |
| 1640 | + | |
| 1641 | + // Slice border color | |
| 1642 | + $settings['slices_border_color'] = isset( $settings['slices_border_color'] ) && $settings['slices_border_color'] != '' ? json_decode($settings['slices_border_color'], true) : array_fill(0, $count_slices, $settings['slice_border_color']); | |
| 1643 | + | |
| 1644 | + // Slices border width | |
| 1645 | + $settings['slice_border_width'] = isset( $settings['slice_border_width'] ) && $settings['slice_border_width'] != '' ? esc_attr( $settings['slice_border_width'] ) : '1'; | |
| 1646 | + | |
| 1647 | + // Tooltip text color | |
| 1648 | + $settings['tooltip_text_color'] = isset( $settings['tooltip_text_color'] ) && $settings['tooltip_text_color'] != '' ? esc_attr( $settings['tooltip_text_color'] ) : '#fff'; | |
| 1649 | + | |
| 1650 | + $settings['show_color_code'] = isset( $settings['show_color_code'] ) && $settings['show_color_code'] != '' ? esc_attr( $settings['show_color_code'] ) : 'off'; | |
| 1651 | + $settings['show_color_code'] = isset( $settings['show_color_code'] ) && $settings['show_color_code'] == 'on' ? 'checked' : ''; | |
| 1652 | + | |
| 1653 | + $settings['tooltip_italic'] = ( isset( $settings['tooltip_italic'] ) && $settings['tooltip_italic'] != '' ) ? $settings['tooltip_italic'] : 'off'; | |
| 1654 | + $settings['tooltip_italic'] = isset( $settings['tooltip_italic'] ) && $settings['tooltip_italic'] == 'on' ? 'checked' : ''; | |
| 1655 | + | |
| 1656 | + // Tooltip font size | |
| 1657 | + $settings['tooltip_font_size'] = isset( $settings['tooltip_font_size'] ) && intval($settings['tooltip_font_size']) > 0 ? esc_attr( $settings['tooltip_font_size'] ) : '12'; | |
| 1658 | + | |
| 1659 | + // Tooltip bold options | |
| 1660 | + $tooltip_bold_options = array( | |
| 1661 | + "default" => __("Default", "chart-builder"), | |
| 1662 | + "true" => __("Enable", "chart-builder"), | |
| 1663 | + "false" => __("Disable", "chart-builder") | |
| 1664 | + ); | |
| 1665 | + | |
| 1666 | + // Tooltip bold text | |
| 1667 | + $settings['tooltip_bold'] = isset( $settings['tooltip_bold'] ) && $settings['tooltip_bold'] != '' ? esc_attr( $settings['tooltip_bold'] ) : 'default'; | |
| 1668 | + $settings['tooltip_bold_options'] = $tooltip_bold_options; | |
| 1669 | + | |
| 1670 | + // Legend font color | |
| 1671 | + $settings['legend_color'] = isset( $settings['legend_color'] ) && $settings['legend_color'] != '' ? esc_attr( $settings['legend_color'] ) : '#000000'; | |
| 1672 | + | |
| 1673 | + // Legend font size | |
| 1674 | + $settings['legend_font_size'] = isset( $settings['legend_font_size'] ) && intval($settings['legend_font_size']) > 0 ? esc_attr( $settings['legend_font_size'] ) : 12; | |
| 1675 | + | |
| 1676 | + // Legend position | |
| 1677 | + $settings['legend_position'] = isset( $settings['legend_position'] ) && $settings['legend_position'] != '' ? esc_attr( $settings['legend_position'] ) : 'top'; | |
| 1678 | + $settings['legend_positions'] = $legend_positions; | |
| 1679 | + | |
| 1680 | + // Legend alignment | |
| 1681 | + $settings['legend_alignment'] = isset( $settings['legend_alignment'] ) && $settings['legend_alignment'] != '' ? esc_attr( $settings['legend_alignment'] ) : 'start'; | |
| 1682 | + $settings['legend_alignments'] = $legend_alignments; | |
| 1683 | + | |
| 1684 | + // Legend Italic text | |
| 1685 | + $settings['legend_italic'] = ( isset( $settings['legend_italic'] ) && $settings['legend_italic'] != '' ) ? $settings['legend_italic'] : 'off'; | |
| 1686 | + $settings['legend_italic'] = isset( $settings['legend_italic'] ) && $settings['legend_italic'] == 'on' ? 'checked' : ''; | |
| 1687 | + | |
| 1688 | + // Legend Bold text | |
| 1689 | + $settings['legend_bold'] = ( isset( $settings['legend_bold'] ) && $settings['legend_bold'] != '' ) ? $settings['legend_bold'] : 'off'; | |
| 1690 | + $settings['legend_bold'] = isset( $settings['legend_bold'] ) && $settings['legend_bold'] == 'on' ? 'checked' : ''; | |
| 1691 | + | |
| 1692 | + // Legend reverse | |
| 1693 | + $settings['legend_reverse'] = ( isset( $settings['legend_reverse'] ) && $settings['legend_reverse'] != '' ) ? $settings['legend_reverse'] : 'off'; | |
| 1694 | + $settings['legend_reverse'] = isset( $settings['legend_reverse'] ) && $settings['legend_reverse'] == 'on' ? 'checked' : ''; | |
| 1695 | + | |
| 1696 | + return $settings; | |
| 1697 | + | |
| 1698 | + } | |
| 1699 | + | |
| 1700 | + /** | |
| 1701 | + * Gets all settings of chart.js charts for public area. | |
| 1702 | + * | |
| 1703 | + * @access public | |
| 1704 | + * @return array | |
| 1705 | + */ | |
| 1706 | + public function get_chart_settings_chartjs_public($settings, $chartData) { | |
| 1707 | + $chart_default_colors = array('#36A2EB','#FF6384','#FF9F40','#FFCD56', '#4BC0C0','#0099c6','#dd4477','#66aa00', '#b82e2e','#316395','#994499','#22aa99', '#aaaa11','#6633cc','#e67300','#8b0707', '#651067','#329262','#5574a6','#3b3eac', '#b77322','#16d620','#b91383','#f4359e', '#9c5935','#a9c413','#2a778d','#668d1c', '#bea413','#0c5922','#743411'); | |
| 1708 | + // echo "<pre>"; var_dump($settings); echo "</pre>"; | |
| 1709 | + // Width | |
| 1710 | + $settings['width'] = isset( $settings['width'] ) && $settings['width'] != '' ? esc_attr( $settings['width'] ) : '100'; | |
| 1711 | + $settings['width_format'] = isset( $settings['width_format'] ) && $settings['width_format'] != '' ? esc_attr( $settings['width_format'] ) : '%'; | |
| 1712 | + $settings['chart_width'] = $settings['width'].$settings['width_format']; | |
| 1713 | + | |
| 1714 | + // height | |
| 1715 | + $settings['height'] = isset( $settings['height'] ) && $settings['height'] != '' ? esc_attr( $settings['height'] ) : '100'; | |
| 1716 | + $settings['height_format'] = isset( $settings['height_format'] ) && $settings['height_format'] != '' ? esc_attr( $settings['height_format'] ) : '%'; | |
| 1717 | + $settings['chart_height'] = $settings['height'].$settings['height_format']; | |
| 1718 | + | |
| 1719 | + // Show chart description | |
| 1720 | + $settings['show_description'] = isset( $settings['show_description'] ) && $settings['show_description'] != '' ? esc_attr( $settings['show_description'] ) : 'on'; | |
| 1721 | + | |
| 1722 | + // Show chart title | |
| 1723 | + $settings['show_title'] = isset( $settings['show_title'] ) && $settings['show_title'] != '' ? esc_attr( $settings['show_title'] ) : 'on'; | |
| 1724 | + | |
| 1725 | + // Enable interactivity | |
| 1726 | + $settings['enable_interactivity'] = isset( $settings['enable_interactivity'] ) && $settings['enable_interactivity'] != '' ? esc_attr( $settings['enable_interactivity'] ) : 'on'; | |
| 1727 | + | |
| 1728 | + // Title color | |
| 1729 | + $settings['title_color'] = isset( $settings['title_color'] ) && $settings['title_color'] != '' ? esc_attr( $settings['title_color'] ) : '#000000'; | |
| 1730 | + | |
| 1731 | + // Title color | |
| 1732 | + $settings['title_shadow_color'] = isset( $settings['title_shadow_color'] ) && $settings['title_shadow_color'] != '' ? esc_attr( $settings['title_shadow_color'] ) : $settings['title_color']; | |
| 1733 | + | |
| 1734 | + // Title font size | |
| 1735 | + $settings['title_font_size'] = isset( $settings['title_font_size'] ) && $settings['title_font_size'] != '' ? esc_attr( $settings['title_font_size'] ) : '30'; | |
| 1736 | + | |
| 1737 | + // title bold | |
| 1738 | + $settings['title_bold'] = ( isset( $settings['title_bold'] ) && $settings['title_bold'] != '' ) ? esc_attr($settings['title_bold']) : 'on'; | |
| 1739 | + $settings['title_bold'] = isset( $settings['title_bold'] ) && $settings['title_bold'] != 'off'? 'bold' : 'normal'; | |
| 1740 | + | |
| 1741 | + // Title text shadow | |
| 1742 | + $settings['title_text_shadow'] = ( isset( $settings['title_text_shadow'] ) && $settings['title_text_shadow'] != '' ) ? esc_attr($settings['title_text_shadow']) : 'off'; | |
| 1743 | + $settings['title_text_shadow'] = isset( $settings['title_text_shadow'] ) && $settings['title_text_shadow'] == 'on' ? 'checked' : ''; | |
| 1744 | + | |
| 1745 | + // title italic | |
| 1746 | + $settings['title_italic'] = ( isset( $settings['title_italic'] ) && $settings['title_italic'] != '' ) ? esc_attr($settings['title_italic']) : 'off'; | |
| 1747 | + $settings['title_italic'] = isset( $settings['title_italic'] ) && $settings['title_italic'] != 'on'? 'normal' : 'italic'; | |
| 1748 | + | |
| 1749 | + // title gap | |
| 1750 | + $settings['title_gap'] = (isset( $settings['title_gap'] ) && $settings['title_gap'] != '') ? esc_attr( $settings['title_gap'] ) : '5'; | |
| 1751 | + | |
| 1752 | + // title gap | |
| 1753 | + $settings['title_gap_description'] = (isset( $settings['title_gap_description'] ) && $settings['title_gap_description'] != '') ? esc_attr( $settings['title_gap_description'] ) : '5'; | |
| 1754 | + | |
| 1755 | + // title letter spacing | |
| 1756 | + $settings['title_letter_spacing'] = (isset( $settings['title_letter_spacing'] ) && $settings['title_letter_spacing'] != '') ? esc_attr( $settings['title_letter_spacing'] ) : 0; | |
| 1757 | + | |
| 1758 | + // title position | |
| 1759 | + $settings['title_position'] = isset( $settings['title_position'] ) && $settings['title_position'] != '' ? esc_attr( $settings['title_position'] ) : 'left'; | |
| 1760 | + | |
| 1761 | + // title text transform | |
| 1762 | + $settings['title_text_transform'] = isset( $settings['title_text_transform'] ) && $settings['title_text_transform'] != '' ? esc_attr( $settings['title_text_transform'] ) : 'none'; | |
| 1763 | + | |
| 1764 | + // title text decoration | |
| 1765 | + $settings['title_text_decoration'] = isset( $settings['title_text_decoration'] ) && $settings['title_text_decoration'] != '' ? esc_attr( $settings['title_text_decoration'] ) : 'none'; | |
| 1766 | + | |
| 1767 | + // description color | |
| 1768 | + $settings['description_color'] = isset( $settings['description_color'] ) && $settings['description_color'] != '' ? esc_attr( $settings['description_color'] ) : '#4c4c4c'; | |
| 1769 | + | |
| 1770 | + // description font size | |
| 1771 | + $settings['description_font_size'] = (isset( $settings['description_font_size'] ) && $settings['description_font_size'] != '') ? esc_attr( $settings['description_font_size'] ) : '16'; | |
| 1772 | + | |
| 1773 | + // description Bold text | |
| 1774 | + $settings['description_bold'] = ( isset( $settings['description_bold'] ) && $settings['description_bold'] != '' ) ? esc_attr($settings['description_bold']) : 'off'; | |
| 1775 | + $settings['description_bold'] = isset( $settings['description_bold'] ) && $settings['description_bold'] != 'on'? 'normal' : 'bold'; | |
| 1776 | + | |
| 1777 | + // description text shadow | |
| 1778 | + $settings['description_text_shadow'] = ( isset( $settings['description_text_shadow'] ) && $settings['description_text_shadow'] != '' ) ? esc_attr($settings['description_text_shadow']) : 'off'; | |
| 1779 | + $settings['description_text_shadow'] = isset( $settings['description_text_shadow'] ) && $settings['description_text_shadow'] == 'on' ? 'checked' : ''; | |
| 1780 | + | |
| 1781 | + // description color | |
| 1782 | + $settings['description_shadow_color'] = isset( $settings['description_shadow_color'] ) && $settings['description_shadow_color'] != '' ? esc_attr( $settings['description_shadow_color'] ) : $settings['description_color']; | |
| 1783 | + | |
| 1784 | + // desctiption italic text | |
| 1785 | + $settings['description_italic'] = ( isset( $settings['description_italic'] ) && $settings['description_italic'] != '' ) ? esc_attr($settings['description_italic']) : 'off'; | |
| 1786 | + $settings['description_italic'] = isset( $settings['description_italic'] ) && $settings['description_italic'] != 'on'? 'normal' : 'italic'; | |
| 1787 | + | |
| 1788 | + // description position | |
| 1789 | + $settings['description_position'] = isset( $settings['description_position'] ) && $settings['description_position'] != '' ? esc_attr( $settings['description_position'] ) : 'left'; | |
| 1790 | + | |
| 1791 | + // description text transform | |
| 1792 | + $settings['description_text_transform'] = isset( $settings['description_text_transform'] ) && $settings['description_text_transform'] != '' ? esc_attr( $settings['description_text_transform'] ) : 'none'; | |
| 1793 | + | |
| 1794 | + // description letter spacing | |
| 1795 | + $settings['description_letter_spacing'] = isset( $settings['description_letter_spacing'] ) && $settings['description_letter_spacing'] != '' ? esc_attr( $settings['description_letter_spacing'] ) : 0; | |
| 1796 | + | |
| 1797 | + // description text decoration | |
| 1798 | + $settings['description_text_decoration'] = isset( $settings['description_text_decoration'] ) && $settings['description_text_decoration'] != '' ? esc_attr( $settings['description_text_decoration'] ) : 'none'; | |
| 1799 | + | |
| 1800 | + // Box shadow | |
| 1801 | + $settings['box_shadow'] = isset( $settings['box_shadow'] ) && $settings['box_shadow'] != '' ? esc_attr( $settings['box_shadow'] ) : 'off'; | |
| 1802 | + $settings['box_shadow'] = isset( $settings['box_shadow'] ) && $settings['box_shadow'] == 'on' ? 'checked' : ''; | |
| 1803 | + | |
| 1804 | + // Border width | |
| 1805 | + $settings['border_width'] = isset( $settings['border_width'] ) && $settings['border_width'] != '' ? esc_attr( $settings['border_width'] ) : '0'; | |
| 1806 | + | |
| 1807 | + // Border radius | |
| 1808 | + $settings['border_radius'] = isset( $settings['border_radius'] ) && $settings['border_radius'] != '' ? esc_attr( $settings['border_radius'] ) : '0'; | |
| 1809 | + | |
| 1810 | + // Border color | |
| 1811 | + $settings['border_color'] = isset( $settings['border_color'] ) && $settings['border_color'] != '' ? esc_attr( $settings['border_color'] ) : '#000000'; | |
| 1812 | + | |
| 1813 | + //Box shadow color | |
| 1814 | + $settings['box_shadow_color'] = isset( $settings['box_shadow_color'] ) && $settings['box_shadow_color'] != '' ? esc_attr( $settings['box_shadow_color'] ) : $settings['border_color']; | |
| 1815 | + | |
| 1816 | + // Border style | |
| 1817 | + $settings['border_style'] = isset( $settings['border_style'] ) && $settings['border_style'] != '' ? esc_attr( $settings['border_style'] ) : 'solid'; | |
| 1818 | + | |
| 1819 | + // Background color | |
| 1820 | + $settings['background_color_chart'] = isset( $settings['background_color_chart'] ) && $settings['background_color_chart'] != '' ? esc_attr( $settings['background_color_chart'] ) : '#ffffff'; | |
| 1821 | + | |
| 1822 | + // Border width with title | |
| 1823 | + $settings['border_width_with_title'] = isset( $settings['border_width_with_title'] ) && $settings['border_width_with_title'] != '' ? esc_attr( $settings['border_width_with_title'] ) : '0'; | |
| 1824 | + | |
| 1825 | + // Border radius with title | |
| 1826 | + $settings['border_radius_with_title'] = isset( $settings['border_radius_with_title'] ) && $settings['border_radius_with_title'] != '' ? esc_attr( $settings['border_radius_with_title'] ) : '0'; | |
| 1827 | + | |
| 1828 | + // Border color with title | |
| 1829 | + $settings['border_color_with_title'] = isset( $settings['border_color_with_title'] ) && $settings['border_color_with_title'] != '' ? esc_attr( $settings['border_color_with_title'] ) : '#000000'; | |
| 1830 | + | |
| 1831 | + // Border style with title | |
| 1832 | + $settings['border_style_with_title'] = isset( $settings['border_style_with_title'] ) && $settings['border_style_with_title'] != '' ? esc_attr( $settings['border_style_with_title'] ) : 'solid'; | |
| 1833 | + | |
| 1834 | + // Padding outer | |
| 1835 | + $settings['padding_outer'] = isset( $settings['padding_outer'] ) && $settings['padding_outer'] != '' ? esc_attr( $settings['padding_outer'] ) : '0'; | |
| 1836 | + | |
| 1837 | + // outer_radius | |
| 1838 | + $settings['outer_radius'] = isset( $settings['outer_radius'] ) && $settings['outer_radius'] != '' ? esc_attr( absint($settings['outer_radius']) ) : 100; | |
| 1839 | + | |
| 1840 | + // slice_spacing | |
| 1841 | + $settings['slice_spacing'] = isset( $settings['slice_spacing'] ) && $settings['slice_spacing'] != '' ? esc_attr( absint($settings['slice_spacing']) ) : 1; | |
| 1842 | + | |
| 1843 | + // circumference | |
| 1844 | + $settings['circumference'] = isset( $settings['circumference'] ) && $settings['circumference'] != '' ? esc_attr( absint($settings['circumference']) ) : 360; | |
| 1845 | + | |
| 1846 | + // start_angle | |
| 1847 | + $settings['start_angle'] = isset( $settings['start_angle'] ) && $settings['start_angle'] != '' ? esc_attr( absint($settings['start_angle']) ) : 0; | |
| 1848 | + | |
| 1849 | + // rotation_degree | |
| 1850 | + $settings['rotation_degree'] = isset( $settings['rotation_degree'] ) && $settings['rotation_degree'] != '' ? esc_attr( absint($settings['rotation_degree']) ) : 0; | |
| 1851 | + | |
| 1852 | + // Tooltip text | |
| 1853 | + $settings['tooltip_text'] = isset( $settings['tooltip_text'] ) && $settings['tooltip_text'] != '' ? esc_attr( $settings['tooltip_text'] ) : 'value'; | |
| 1854 | + | |
| 1855 | + // Data grouping settings | |
| 1856 | + $settings['data_grouping_limit'] = isset( $settings['data_grouping_limit'] ) && $settings['data_grouping_limit'] != '' ? esc_attr( $settings['data_grouping_limit'] ) : '0.5'; | |
| 1857 | + $settings['data_grouping_label'] = isset( $settings['data_grouping_label'] ) && $settings['data_grouping_label'] != '' ? esc_attr( $settings['data_grouping_label'] ) : 'Other'; | |
| 1858 | + $settings['data_grouping_color'] = isset( $settings['data_grouping_color'] ) && $settings['data_grouping_color'] != '' ? esc_attr( $settings['data_grouping_color'] ) : '#ccc'; | |
| 1859 | + | |
| 1860 | + $count_slices = (isset($chartData['source']) && !is_null($chartData['source']) && count($chartData['source']) > 0) ? count($chartData['source']) - 1 : 0; | |
| 1861 | + // Slices settings | |
| 1862 | + $settings['slice_colors_default'] = $chart_default_colors; | |
| 1863 | + $settings['slice_color'] = isset( $settings['slice_color'] ) && $settings['slice_color'] != '' ? json_decode($settings['slice_color'], true) : $chart_default_colors; | |
| 1864 | + | |
| 1865 | + // Slice border color | |
| 1866 | + $settings['slice_border_color'] = isset( $settings['slice_border_color'] ) && $settings['slice_border_color'] != '' ? esc_attr( $settings['slice_border_color'] ) : '#ffffff'; | |
| 1867 | + | |
| 1868 | + // Slice border color | |
| 1869 | + $settings['slices_border_color'] = isset( $settings['slices_border_color'] ) && $settings['slices_border_color'] != '' ? json_decode($settings['slices_border_color'], true) : array_fill(0, $count_slices, $settings['slice_border_color']); | |
| 1870 | + | |
| 1871 | + // Slices border width | |
| 1872 | + $settings['slice_border_width'] = isset( $settings['slice_border_width'] ) && $settings['slice_border_width'] != '' ? esc_attr( $settings['slice_border_width'] ) : '1'; | |
| 1873 | + | |
| 1874 | + // Tooltip text color | |
| 1875 | + $settings['tooltip_text_color'] = isset( $settings['tooltip_text_color'] ) && $settings['tooltip_text_color'] != '' ? esc_attr( $settings['tooltip_text_color'] ) : '#fff'; | |
| 1876 | + | |
| 1877 | + // Tooltip font size | |
| 1878 | + $settings['tooltip_font_size'] = isset( $settings['tooltip_font_size'] ) && intval($settings['tooltip_font_size']) > 0 ? esc_attr( $settings['tooltip_font_size'] ) : 12; | |
| 1879 | + | |
| 1880 | + // Show color code | |
| 1881 | + $settings['show_color_code'] = isset( $settings['show_color_code'] ) && $settings['show_color_code'] != '' ? esc_attr( $settings['show_color_code'] ) : 'off'; | |
| 1882 | + $settings['show_color_code'] = isset( $settings['show_color_code'] ) && $settings['show_color_code'] == 'on' ? 'checked' : ''; | |
| 1883 | + | |
| 1884 | + // Tooltip Italic text | |
| 1885 | + $settings['tooltip_italic'] = ( isset( $settings['tooltip_italic'] ) && $settings['tooltip_italic'] != '' ) ? $settings['tooltip_italic'] : 'off'; | |
| 1886 | + //$settings['tooltip_italic'] = isset( $settings['tooltip_italic'] ) && $settings['tooltip_italic'] == 'checked' ? 'italic' : 'normal'; | |
| 1887 | + $settings['tooltip_italic'] = ( isset( $settings['tooltip_italic'] ) && ($settings['tooltip_italic'] == 'checked' || $settings['tooltip_italic'] == 'on') ) ? 'italic' : 'normal'; | |
| 1888 | + // Legend font color | |
| 1889 | + $settings['legend_color'] = isset( $settings['legend_color'] ) && $settings['legend_color'] != '' ? esc_attr( $settings['legend_color'] ) : '#000000'; | |
| 1890 | + | |
| 1891 | + // Legend font size | |
| 1892 | + $settings['legend_font_size'] = isset( $settings['legend_font_size'] ) && intval($settings['legend_font_size']) > 0 ? esc_attr( $settings['legend_font_size'] ) : 12; | |
| 1893 | + | |
| 1894 | + // Legend position | |
| 1895 | + $settings['legend_position'] = isset( $settings['legend_position'] ) && $settings['legend_position'] != '' ? esc_attr( $settings['legend_position'] ) : 'top'; | |
| 1896 | + | |
| 1897 | + // Legend Italic text | |
| 1898 | + $settings['legend_italic'] = ( isset( $settings['legend_italic'] ) && $settings['legend_italic'] != '' ) ? $settings['legend_italic'] : 'off'; | |
| 1899 | + | |
| 1900 | + // Legend Bold text | |
| 1901 | + $settings['legend_bold'] = ( isset( $settings['legend_bold'] ) && $settings['legend_bold'] != '' ) ? $settings['legend_bold'] : 'off'; | |
| 1902 | + | |
| 1903 | + // Legend reverse | |
| 1904 | + $settings['legend_reverse'] = ( isset( $settings['legend_reverse'] ) && $settings['legend_reverse'] != '' ) ? $settings['legend_reverse'] : 'off'; | |
| 1905 | + | |
| 1906 | + return $settings; | |
| 1907 | + | |
| 1908 | + } | |
| 1909 | + } | |
| 1910 | +} | |
| 1911 | + | |
| 1912 | +if( ! function_exists( 'CBFunctions' ) ){ | |
| 1913 | + /** | |
| 1914 | + * Function for quick access to Chart_Builder_Functions class | |
| 1915 | + * | |
| 1916 | + * @since 1.0.0 | |
| 1917 | + * @return Chart_Builder_Functions | |
| 1918 | + */ | |
| 1919 | + function CBFunctions(){ | |
| 1920 | + | |
| 1921 | + static $instance = null; | |
| 1922 | + | |
| 1923 | + if( $instance === null ){ | |
| 1924 | + $instance = Chart_Builder_Functions::get_instance( CHART_BUILDER_NAME ); | |
| 1925 | + } | |
| 1926 | + | |
| 1927 | + if( $instance instanceof Chart_Builder_Functions ){ | |
| 1928 | + return $instance; | |
| 1929 | + } | |
| 1930 | + | |
| 1931 | + return Chart_Builder_Functions::get_instance( CHART_BUILDER_NAME ); | |
| 1932 | + } | |
| 342 | 1933 | } |