PluginProbe
wpDataTables – WordPress Data Table, Dynamic Tables & Table Charts Plugin / trunk
wpDataTables – WordPress Data Table, Dynamic Tables & Table Charts Plugin vtrunk
6.5.1.6 6.5.1.5 6.5.1.4 6.5.1.3 6.5.1.2 6.5.1.1 6.5.0.9 6.5.0.8 6.5.0.7 6.5.0.6 trunk 3.4.2.40 3.4.2.41 3.4.2.42 3.4.2.43 3.4.2.44 3.4.2.45 3.4.2.46 3.4.2.47 3.4.2.48 3.4.2.49 3.4.2.50 6.3.2 6.3.3.1 6.3.3.10 All 46 releases
wpdatatables / source / class.float.wpdatacolumn.php

class.float.wpdatacolumn.php in wpDataTables – WordPress Data Table, Dynamic Tables & Table Charts Plugin trunk, at source/class.float.wpdatacolumn.php

63 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 defined('ABSPATH') or die("Cannot access pages directly.");
4
5 class FloatWDTColumn extends WDTColumn {
6
7 protected $_jsDataType = 'formatted-num';
8 protected $_dataType = 'float';
9
10 /**
11 * FloatWDTColumn constructor.
12 * @param array $properties
13 */
14 public function __construct($properties = array()) {
15 parent::__construct($properties);
16 $this->_dataType = 'float';
17 $this->_filterType = 'number';
18 $this->addCSSClass('numdata float');
19 $this->setDecimalPlaces(WDTTools::defineDefaultValue($properties, 'decimalPlaces', -1));
20 }
21
22 /**
23 * @param $content
24 * @return mixed|string
25 */
26 public function prepareCellOutput($content) {
27
28 $content = apply_filters('wpdatatables_filter_float_cell_before_formatting', $content, $this->getParentTable()->getWpId());
29
30 if ($content === '' || $content === null) {
31 $content = '';
32 return $content;
33 }
34
35 $numberFormat = get_option('wdtNumberFormat') ? get_option('wdtNumberFormat') : 1;
36 $decimalPlaces = $this->getDecimalPlaces() != -1 ? $this->getDecimalPlaces() : get_option('wdtDecimalPlaces');
37
38 if ($numberFormat == 1) {
39 $formattedValue = number_format(
40 (float)$content,
41 $decimalPlaces,
42 ',',
43 '.'
44 );
45 } else {
46 $formattedValue = number_format(
47 (float)$content,
48 $decimalPlaces
49 );
50 }
51
52 return apply_filters('wpdatatables_filter_float_cell', $formattedValue, $this->getParentTable()->getWpId());
53 }
54
55 /**
56 * @return string
57 */
58 public function getGoogleChartColumnType() {
59 return 'number';
60 }
61
62 }
63