| @@ -67,12 +67,71 @@ | ||
| 67 | 67 | $this->_addFilter( 'wp_revisions_to_keep', 'limitRevisions', null, 10, 2 ); |
| 68 | 68 | $this->_addAction( '_wp_put_post_revision', 'addRevision', null, 10, 1 ); |
| 69 | 69 | $this->_addAction( 'wp_restore_post_revision', 'restoreRevision', null, 10, 2 ); |
| 70 | 70 | |
| 71 | + $this->_addAction( 'visualizer_chart_schedules_spl', 'addSplChartSchedules', null, 10, 3 ); | |
| 72 | + | |
| 71 | 73 | $this->_addAction( 'admin_init', 'init' ); |
| 72 | 74 | } |
| 73 | 75 | |
| 76 | + | |
| 74 | 77 | /** |
| 78 | + * Add disabled `optgroup` schedules to the drop downs. | |
| 79 | + * | |
| 80 | + * @since ? | |
| 81 | + * | |
| 82 | + * @access public | |
| 83 | + * | |
| 84 | + * @param string $feature The feature for which to add schedules. | |
| 85 | + * @param int $chart_id The chart ID. | |
| 86 | + * @param int $plan The plan number. | |
| 87 | + */ | |
| 88 | + public function addSplChartSchedules( $feature, $chart_id, $plan ) { | |
| 89 | + if ( apply_filters( 'visualizer_is_business', false ) ) { | |
| 90 | + return; | |
| 91 | + } | |
| 92 | + | |
| 93 | + $license = __( 'PRO', 'visualizer' ); | |
| 94 | + if ( Visualizer_Module::is_pro() ) { | |
| 95 | + switch ( $plan ) { | |
| 96 | + case 1: | |
| 97 | + $license = __( 'Developer', 'visualizer' ); | |
| 98 | + break; | |
| 99 | + } | |
| 100 | + } | |
| 101 | + | |
| 102 | + $hours = array( | |
| 103 | + '0' => __( 'Live', 'visualizer' ), | |
| 104 | + '1' => __( 'Each hour', 'visualizer' ), | |
| 105 | + '12' => __( 'Each 12 hours', 'visualizer' ), | |
| 106 | + '24' => __( 'Each day', 'visualizer' ), | |
| 107 | + '72' => __( 'Each 3 days', 'visualizer' ), | |
| 108 | + ); | |
| 109 | + | |
| 110 | + switch ( $feature ) { | |
| 111 | + case 'json': | |
| 112 | + case 'csv': | |
| 113 | + // no more schedules if pro is already active. | |
| 114 | + if ( Visualizer_Module::is_pro() ) { | |
| 115 | + return; | |
| 116 | + } | |
| 117 | + break; | |
| 118 | + case 'wp': | |
| 119 | + // fall-through. | |
| 120 | + case 'db': | |
| 121 | + break; | |
| 122 | + default: | |
| 123 | + return; | |
| 124 | + } | |
| 125 | + | |
| 126 | + echo '<optgroup disabled label="' . sprintf( __( 'More in the %s version', 'visualizer' ), $license ) . '">'; | |
| 127 | + foreach ( $hours as $hour => $desc ) { | |
| 128 | + echo '<option disabled>' . $desc . '</option>'; | |
| 129 | + } | |
| 130 | + echo '</optgroup>'; | |
| 131 | + } | |
| 132 | + | |
| 133 | + /** | |
| 75 | 134 | * No limits on revisions. |
| 76 | 135 | */ |
| 77 | 136 | public function limitRevisions( $num, $post ) { |
| 78 | 137 | if ( Visualizer_Plugin::CPT_VISUALIZER === $post->post_type ) { |
| @@ -332,8 +391,14 @@ | ||
| 332 | 391 | 'name' => esc_html__( 'Column', 'visualizer' ), |
| 333 | 392 | 'enabled' => true, |
| 334 | 393 | 'supports' => array( 'Google Charts', 'ChartJS' ), |
| 335 | 394 | ), |
| 395 | + 'bubble' => array( | |
| 396 | + 'name' => esc_html__( 'Bubble', 'visualizer' ), | |
| 397 | + 'enabled' => true, | |
| 398 | + // chartjs' bubble is ugly looking (and it won't work off the default bubble.csv) so it is being excluded for the time being. | |
| 399 | + 'supports' => array( 'Google Charts' ), | |
| 400 | + ), | |
| 336 | 401 | 'scatter' => array( |
| 337 | 402 | 'name' => esc_html__( 'Scatter', 'visualizer' ), |
| 338 | 403 | 'enabled' => true, |
| 339 | 404 | 'supports' => array( 'Google Charts' ), |
| @@ -725,9 +790,12 @@ | ||
| 725 | 790 | if ( ! empty( $atts['settings'] ) ) { |
| 726 | 791 | $settings = apply_filters( $atts['settings'], $settings, $chart->ID, $type ); |
| 727 | 792 | } |
| 728 | 793 | |
| 729 | - unset( $settings['height'], $settings['width'], $settings['chartArea'] ); | |
| 794 | + if ( $settings ) { | |
| 795 | + unset( $settings['height'], $settings['width'], $settings['chartArea'] ); | |
| 796 | + } | |
| 797 | + | |
| 730 | 798 | $series = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_SERIES, get_post_meta( $chart->ID, Visualizer_Plugin::CF_SERIES, true ), $chart->ID, $type ); |
| 731 | 799 | $data = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_DATA, unserialize( html_entity_decode( $chart->post_content ) ), $chart->ID, $type ); |
| 732 | 800 | |
| 733 | 801 | $library = $this->load_chart_type( $chart->ID ); |