| @@ -37,38 +37,19 @@ | ||
| 37 | 37 | * @access protected |
| 38 | 38 | */ |
| 39 | 39 | protected function _renderContent() { |
| 40 | 40 | // Added by Ash/Upwork |
| 41 | - if ( Visualizer_Module::can_show_feature( 'simple-editor' ) ) { | |
| 42 | - Visualizer_Render_Layout::show( 'simple-editor-screen', $this->chart->ID ); | |
| 43 | - } | |
| 44 | - | |
| 45 | - if ( Visualizer_Module::is_pro() ) { | |
| 46 | - do_action( 'visualizer_add_editor_etc', $this->chart->ID ); | |
| 47 | - | |
| 48 | - if ( Visualizer_Module::is_pro() && Visualizer_Module::is_pro_older_than( '1.9.0' ) ) { | |
| 49 | - global $Visualizer_Pro; | |
| 50 | - $Visualizer_Pro->_addEditor( $this->chart->ID ); | |
| 51 | - if ( method_exists( $Visualizer_Pro, '_addFilterWizard' ) ) { | |
| 52 | - $Visualizer_Pro->_addFilterWizard( $this->chart->ID ); | |
| 53 | - } | |
| 41 | + if ( VISUALIZER_PRO ) { | |
| 42 | + global $Visualizer_Pro; | |
| 43 | + $Visualizer_Pro->_addEditor( $this->chart->ID ); | |
| 44 | + if ( method_exists( $Visualizer_Pro, '_addFilterWizard' ) ) { | |
| 45 | + $Visualizer_Pro->_addFilterWizard( $this->chart->ID ); | |
| 54 | 46 | } |
| 55 | 47 | } |
| 56 | - | |
| 57 | - $this->add_additional_content(); | |
| 58 | - | |
| 59 | 48 | // Added by Ash/Upwork |
| 60 | - if ( Visualizer_Module::is_pro() ) { | |
| 61 | - echo '<div id="chart_wrapper_canvas">'; | |
| 62 | - echo '<div id="control_wrapper_canvas"></div>'; | |
| 63 | - } | |
| 64 | 49 | echo '<div id="canvas">'; |
| 65 | 50 | echo '<img src="', VISUALIZER_ABSURL, 'images/ajax-loader.gif" class="loader">'; |
| 66 | 51 | echo '</div>'; |
| 67 | - if ( Visualizer_Module::is_pro() ) { | |
| 68 | - echo '</div>'; | |
| 69 | - } | |
| 70 | - echo $this->custom_css; | |
| 71 | 52 | } |
| 72 | 53 | |
| 73 | 54 | /** |
| 74 | 55 | * Renders sidebar content. |
| @@ -77,45 +58,205 @@ | ||
| 77 | 58 | * |
| 78 | 59 | * @access protected |
| 79 | 60 | */ |
| 80 | 61 | protected function _renderSidebarContent() { |
| 62 | + $upload_link = add_query_arg( array( | |
| 63 | + 'action' => Visualizer_Plugin::ACTION_UPLOAD_DATA, | |
| 64 | + 'nonce' => wp_create_nonce(), | |
| 65 | + 'chart' => $this->chart->ID, | |
| 66 | + ), admin_url( 'admin-ajax.php' ) ); | |
| 67 | + ?> | |
| 68 | + <span id="visualizer-chart-id" data-id="<?php echo $this->chart->ID; ?>"></span> | |
| 69 | + <iframe id="thehole" name="thehole"></iframe> | |
| 70 | + <ul class="group-wrapper full-height"> | |
| 71 | + <li class="group group-category open" id="vz-chart-source"> | |
| 72 | + <div class="group-header"> | |
| 73 | + <h2 class="group-title main-group"><?php _e( 'Chart Data', 'visualizer' ); ?></h2> | |
| 74 | + </div> | |
| 75 | + <ul class="group-content"> | |
| 76 | + <ul class="group-wrapper"> | |
| 77 | + <li class="group"> | |
| 78 | + <h2 class="group-title sub-group visualizer-src-tab"><?php _e( 'Import data from file', 'visualizer' ); ?></h2> | |
| 79 | + <div class="group-content"> | |
| 80 | + <p class="group-description"><?php esc_html_e( 'Select and upload your data CSV file here. The first row of the CSV file should contain the column headings. The second one should contain series type (string, number, boolean, date, datetime, timeofday).', 'visualizer' ); ?></p> | |
| 81 | + <p class="group-description"><?php echo sprintf( __( 'If you are unsure about how to format your data CSV then please take a look at this sample: %1$s %2$s%3$s', 'visualizer' ), '<a href="' . VISUALIZER_ABSURL . 'samples/' . $this->type . '.csv" target="_blank">', $this->type, '.csv</a>' ); ?></p> | |
| 82 | + <form id="vz-csv-file-form" action="<?php echo $upload_link ?>" method="post" | |
| 83 | + target="thehole" enctype="multipart/form-data"> | |
| 84 | + <input type="hidden" id="remote-data" name="remote_data"> | |
| 85 | + <div class=""> | |
| 86 | + <input type="file" id="csv-file" name="local_data"> | |
| 87 | + </div> | |
| 88 | + <input type="button" class="button button-primary" id="vz-import-file" | |
| 89 | + value="<?php _e( 'Import', 'visualizer' ); ?>"> | |
| 90 | + </form> | |
| 91 | + </div> | |
| 92 | + </li> | |
| 93 | + <li class="group visualizer-import-url"> | |
| 94 | + <h2 class="group-title sub-group visualizer-src-tab"><?php _e( 'Import data from URL', 'visualizer' ); ?></h2> | |
| 95 | + <ul class="group-content"> | |
| 96 | + <li class="subsection"> | |
| 97 | + <span class="section-title"><?php _e( 'One time import', 'visualizer' ); ?></span> | |
| 81 | 98 | |
| 82 | - $chartSettings = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_SETTINGS, true ); | |
| 83 | - $hasTitle = isset( $chartSettings['backend-title'] ) && '' !== $chartSettings['backend-title']; | |
| 99 | + <div class="section-items"> | |
| 100 | + <p class="group-description"><?php _e( 'You can use this to import data from a remote CSV file. The first row of the CSV file should contain the column headings. The second one should contain series type (string, number, boolean, date, datetime, timeofday).', 'visualizer' ); ?> </p> | |
| 101 | + <p class="group-description"><?php echo sprintf( __( 'If you are unsure about how to format your data CSV then please take a look at this sample: %1$s %2$s%3$s', 'visualizer' ), '<a href="' . VISUALIZER_ABSURL . 'samples/' . $this->type . '.csv" target="_blank">', $this->type, '.csv</a>' ); ?></p> | |
| 102 | + <p class="group-description"> <?php _e( 'You can also import data from Google Spreadsheet, for more info check <a href="https://github.com/Codeinwp/visualizer/wiki/How-can-I-populate-data-from-Google-Spreadsheet%3F" target="_blank" >this</a> tutorial', 'visualizer' ); ?></p> | |
| 103 | + <form id="vz-one-time-import" action="<?php echo $upload_link ?>" method="post" | |
| 104 | + target="thehole" enctype="multipart/form-data"> | |
| 105 | + <div class="remote-file-section"> | |
| 106 | + <input type="url" id="remote-data" name="remote_data" | |
| 107 | + placeholder="<?php esc_html_e( 'Please enter the URL of CSV file', 'visualizer' ); ?>" | |
| 108 | + class="visualizer-input"> | |
| 84 | 109 | |
| 85 | - ?> | |
| 86 | - <div class="viz-info-panel"> | |
| 87 | - <div class="viz-info-item"> | |
| 88 | - <label for="viz-shortcode"><?php _e( 'Shortcode', 'visualizer' ); ?></label> | |
| 89 | - <div class="viz-info-row"> | |
| 90 | - <input type="text" id="viz-shortcode" value="[visualizer id="<?php echo $this->chart->ID; ?>" class='']" readonly> | |
| 91 | - <button class="button" id="viz-copy-shortcode"><?php _e( 'Copy', 'visualizer' ); ?></button> | |
| 110 | + </div> | |
| 111 | + <input type="button" id="view-remote-file" class="button button-primary" | |
| 112 | + value="<?php _e( 'Import', 'visualizer' ); ?>"> | |
| 113 | + </form> | |
| 114 | + </div> | |
| 115 | + </li> | |
| 116 | + <li class="subsection <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'schedule-chart' ); ?>"> | |
| 117 | + <span class="section-title visualizer-import-url-schedule"><?php _e( 'Schedule Import', 'visualizer' ); ?> | |
| 118 | + <span | |
| 119 | + class="dashicons dashicons-lock"></span></span> | |
| 120 | + <div class="section-items"> | |
| 121 | + <p class="group-description"><?php _e( 'You can choose here to synchronize your chart data with a remote CSV file.', 'visualizer' ); ?> </p> | |
| 122 | + <p class="group-description"> <?php _e( 'You can also synchronize with your Google Spreadsheet file, for more info check <a href="https://github.com/Codeinwp/visualizer/wiki/How-can-I-populate-data-from-Google-Spreadsheet%3F" target="_blank" >this</a> tutorial', 'visualizer' ); ?></p> | |
| 123 | + <p class="group-description"> <?php _e( 'We will update the chart data based on your time interval preference by overwritting the current data with the one from the URL.', 'visualizer' ); ?></p> | |
| 124 | + <form id="vz-schedule-import" action="<?php echo $upload_link ?>" method="post" | |
| 125 | + target="thehole" enctype="multipart/form-data"> | |
| 126 | + <div class="remote-file-section"> | |
| 127 | + <input type="url" id="vz-schedule-url" name="remote_data" | |
| 128 | + value="<?php echo get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_CHART_URL, true ); ?>" | |
| 129 | + placeholder="<?php esc_html_e( 'Please enter the URL of CSV file', 'visualizer' ); ?>" | |
| 130 | + class="visualizer-input visualizer-remote-url"> | |
| 131 | + <p class="group-description"><?php _e( 'How often do you want to check the url', 'visualizer' ); ?></p> | |
| 132 | + <select name="vz-import-time" id="vz-import-time" | |
| 133 | + class="visualizer-select"> | |
| 134 | + <?php | |
| 135 | + $hours = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_CHART_SCHEDULE, true ); | |
| 136 | + $schedules = array( | |
| 137 | + '1' => __( 'Each hour', 'visualizer' ), | |
| 138 | + '12' => __( 'Each 12 hours', 'visualizer' ), | |
| 139 | + '24' => __( 'Each day', 'visualizer' ), | |
| 140 | + '36' => __( 'Each 3 days', 'visualizer' ), | |
| 141 | + ); | |
| 142 | + foreach ( $schedules as $num => $name ) { | |
| 143 | + $extra = $num == $hours ? 'selected' : ''; | |
| 144 | + ?> | |
| 145 | + <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option> | |
| 146 | + <?php | |
| 147 | + } | |
| 148 | + ?> | |
| 149 | + </select> | |
| 150 | + </div> | |
| 151 | + <input type="button" id="vz-save-schedule" class="button button-primary" | |
| 152 | + value="<?php _e( 'Save schedule', 'visualizer' ); ?>"> | |
| 153 | + | |
| 154 | + <?php echo apply_filters( 'visualizer_pro_upsell', '', 'schedule-chart' ); ?> | |
| 155 | + </form> | |
| 156 | + </div> | |
| 157 | + </li> | |
| 158 | + </ul> | |
| 159 | + </li> | |
| 160 | + <li class="group <?php echo apply_filters( 'visualizer_pro_upsell_class' ); ?> "> | |
| 161 | + <h2 class="group-title sub-group" | |
| 162 | + data-current="chart"><?php _e( 'Import from other chart', 'visualizer' ); ?><span | |
| 163 | + class="dashicons dashicons-lock"></span></h2> | |
| 164 | + <div class="group-content edit-data-content"> | |
| 165 | + <div> | |
| 166 | + <p class="group-description"><?php _e( 'You can import here data from your previously created charts', 'visualizer' ); ?></p> | |
| 167 | + <form> | |
| 168 | + <select name="vz-import-from-chart" id="chart-id" class="visualizer-select"> | |
| 169 | + <?php | |
| 170 | + $fetch_link = add_query_arg( array( | |
| 171 | + 'action' => ( VISUALIZER_PRO ) ? Visualizer_Pro::ACTION_FETCH_DATA : '', | |
| 172 | + 'nonce' => wp_create_nonce(), | |
| 173 | + ), admin_url( 'admin-ajax.php' ) ); | |
| 174 | + $query_args_charts = array( | |
| 175 | + 'post_type' => Visualizer_Plugin::CPT_VISUALIZER, | |
| 176 | + 'posts_per_page' => 300, | |
| 177 | + 'no_found_rows' => true, | |
| 178 | + ); | |
| 179 | + $charts = array(); | |
| 180 | + $query = new WP_Query( $query_args_charts ); | |
| 181 | + while ( $query->have_posts() ) { | |
| 182 | + $chart = $query->next_post(); | |
| 183 | + $settings = get_post_meta( $chart->ID, Visualizer_Plugin::CF_SETTINGS, true ); | |
| 184 | + ?> | |
| 185 | + <option value="<?php echo $chart->ID; ?>"><?php echo empty( $settings['title'] ) ? '#' . $chart->ID : $settings['title']; ?></option> | |
| 186 | + <?php | |
| 187 | + } | |
| 188 | + ?> | |
| 189 | + | |
| 190 | + </select> | |
| 191 | + </form> | |
| 192 | + <input type="button" id="existing-chart" class="button button-primary" | |
| 193 | + value="<?php _e( 'Import Chart', 'visualizer' ); ?>" | |
| 194 | + data-viz-link="<?php echo $fetch_link; ?>"> | |
| 195 | + <?php echo apply_filters( 'visualizer_pro_upsell', '' ); ?> | |
| 196 | + </div> | |
| 197 | + </div> | |
| 198 | + </li> | |
| 199 | + | |
| 200 | + <li class="group <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'schedule-chart' ); ?> "> | |
| 201 | + <h2 class="group-title sub-group"><?php _e( 'Import from WordPress', 'visualizer' ); ?><span | |
| 202 | + class="dashicons dashicons-lock"></span></h2> | |
| 203 | + <div class="group-content edit-data-content"> | |
| 204 | + <div> | |
| 205 | + <p class="group-description"><?php _e( 'You can import here data from WordPress', 'visualizer' ); ?></p> | |
| 206 | + <input type="button" id="filter-chart-button" class="button button-primary " | |
| 207 | + value="<?php _e( 'Create Filters', 'visualizer' ); ?>" data-current="chart" | |
| 208 | + data-t-filter="<?php _e( 'Show Chart', 'visualizer' ); ?>" | |
| 209 | + data-t-chart="<?php _e( 'Create Filters', 'visualizer' ); ?>"> | |
| 210 | + <?php echo apply_filters( 'visualizer_pro_upsell', '', 'schedule-chart' ); ?> | |
| 211 | + </div> | |
| 212 | + </div> | |
| 213 | + </li> | |
| 214 | + | |
| 215 | + <li class="group <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature' ); ?>"> | |
| 216 | + <h2 class="group-title sub-group visualizer-editor-tab" | |
| 217 | + data-current="chart"><?php _e( 'Add data manually', 'visualizer' ); ?><span | |
| 218 | + class="dashicons dashicons-lock"></span></h2> | |
| 219 | + <form id="editor-form" action="<?php echo $upload_link ?>" method="post" target="thehole"> | |
| 220 | + <input type="hidden" id="chart-data" name="chart_data"> | |
| 221 | + </form> | |
| 222 | + | |
| 223 | + <div class="group-content edit-data-content"> | |
| 224 | + <div> | |
| 225 | + <p class="group-description"><?php _e( 'You can manually edit the chart data using the spreadsheet like editor.', 'visualizer' ); ?></p> | |
| 226 | + <input type="button" id="editor-chart-button" class="button button-primary " | |
| 227 | + value="<?php _e( 'View Editor', 'visualizer' ); ?>" data-current="chart" | |
| 228 | + data-t-editor="<?php _e( 'Show Chart', 'visualizer' ); ?>" | |
| 229 | + data-t-chart="<?php _e( 'View Editor', 'visualizer' ); ?>"> | |
| 230 | + | |
| 231 | + <?php echo apply_filters( 'visualizer_pro_upsell', '' ); ?> | |
| 232 | + </div> | |
| 233 | + </div> | |
| 234 | + </li> | |
| 235 | + </ul> | |
| 236 | + </li> | |
| 237 | + </ul> | |
| 238 | + <li class="group group-category bottom-fixed " id="vz-chart-settings"> | |
| 239 | + <h2><?php _e( 'Advanced Settings', 'visualizer' ); ?></h2> | |
| 240 | + <div class="group-header"> | |
| 241 | + <button class="customize-section-back" tabindex="0"></button> | |
| 242 | + <h3 class="group-title main-group"><?php _e( 'Chart Settings', 'visualizer' ); ?></h3> | |
| 92 | 243 | </div> |
| 93 | - </div> | |
| 94 | - <div class="viz-info-item"> | |
| 95 | - <label for="viz-backend-name"><?php _e( 'Backend chart title for internal usage', 'visualizer' ); ?></label> | |
| 96 | - <input type="text" id="viz-backend-name" value="<?php echo $hasTitle ? $chartSettings['backend-title'] : ( '#' . esc_attr( $this->chart->ID ) ); ?>"> | |
| 97 | - </div> | |
| 98 | - </div> | |
| 99 | - <div id="viz-tabs"> | |
| 100 | - <ul> | |
| 101 | - <li><a href="#viz-tab-basic-content" id="viz-tab-basic"><?php _e( 'Source', 'visualizer' ); ?></a></li> | |
| 102 | - <li><a href="#viz-tab-advanced-content" id="viz-tab-advanced"><?php _e( 'Settings', 'visualizer' ); ?></a></li> | |
| 103 | - <li><a href="#viz-tab-help-content" id="viz-tab-help"><?php _e( 'Help', 'visualizer' ); ?></a></li> | |
| 104 | - </ul> | |
| 105 | - <div id="viz-tab-basic-content"><?php Visualizer_Render_Layout::show( 'tab-basic', $this->chart->ID ); ?></div> | |
| 106 | - <div id="viz-tab-advanced-content"><?php Visualizer_Render_Layout::show( 'tab-advanced', $this->chart->ID, $this->sidebar ); ?></div> | |
| 107 | - <div id="viz-tab-help-content"><?php Visualizer_Render_Layout::show( 'tab-help', $this->chart->ID ); ?></div> | |
| 108 | - </div> | |
| 109 | - | |
| 110 | - <li class="viz-group bottom-fixed" id="vz-chart-copyright"> | |
| 111 | - <?php _e( 'Hate it? Love it?', 'visualizer' ); ?> <a href="https://wordpress.org/support/plugin/visualizer/reviews/#new-post" target="_blank"><?php _e( 'Rate it!', 'visualizer' ); ?></a> | |
| 244 | + <ul class="group-content"> | |
| 245 | + <form id="settings-form" action="<?php echo add_query_arg( 'nonce', wp_create_nonce() ); ?>" | |
| 246 | + method="post"> | |
| 247 | + <?php echo $this->sidebar; ?> | |
| 248 | + </form> | |
| 249 | + </ul> | |
| 250 | + </li> | |
| 251 | + <li class=" group bottom-fixed" id="vz-chart-review"> | |
| 252 | + <a href="https://wordpress.org/support/plugin/visualizer/reviews/?filter=5#new-post" | |
| 253 | + target="_blank"><?php _e( 'Rate our plugin', 'visualizer' ); ?></a> | |
| 254 | + </li> | |
| 255 | + <li class="group bottom-fixed" id="vz-chart-copyright">Visualizer © 2014</li> | |
| 256 | + </ul> | |
| 112 | 257 | <?php |
| 113 | - // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date, WordPress.DateTime.CurrentTimeTimestamp.Requested | |
| 114 | - echo date( 'Y', current_time( 'timestamp' ) ); | |
| 115 | - ?> | |
| 116 | - </li> | |
| 117 | - <?php | |
| 258 | + // changed by Ash/Upwork | |
| 118 | 259 | } |
| 119 | 260 | |
| 120 | 261 | /** |
| 121 | 262 | * Renders toolbar content. |
| @@ -124,34 +265,16 @@ | ||
| 124 | 265 | * |
| 125 | 266 | * @access protected |
| 126 | 267 | */ |
| 127 | 268 | protected function _renderToolbar() { |
| 128 | - // don't show back button at all. | |
| 129 | - // NOTE: We can't be selective on the post_status here because when a new chart reaches the settings screen, its status changes to publish. | |
| 130 | - if ( ! VISUALIZER_SKIP_CHART_TYPE_PAGE ) { | |
| 131 | - echo '<div class="toolbar-div">'; | |
| 132 | - echo '<a class="button button-large" href="', esc_url( add_query_arg( 'tab', 'types' ) ), '">'; | |
| 133 | - esc_html_e( 'Back', 'visualizer' ); | |
| 134 | - echo '</a>'; | |
| 135 | - echo '</div>'; | |
| 136 | - } | |
| 269 | + // changed by Ash/Upwork | |
| 270 | + echo '<div class="toolbar-div">'; | |
| 271 | + echo '<a class="button button-large" href="', add_query_arg( 'tab', 'types' ), '">'; | |
| 272 | + esc_html_e( 'Back', 'visualizer' ); | |
| 273 | + echo '</a>'; | |
| 274 | + echo '</div>'; | |
| 137 | 275 | echo '<input type="submit" id="settings-button" class="button button-primary button-large push-right" value="', $this->button, '">'; |
| 138 | - if ( isset( $this->cancel_button ) ) { | |
| 139 | - echo '<input type="submit" id="cancel-button" class="button button-secondary button-large push-right" value="', $this->cancel_button, '">'; | |
| 140 | - } | |
| 276 | + echo '</div>'; | |
| 277 | + | |
| 141 | 278 | } |
| 142 | 279 | |
| 143 | - /** | |
| 144 | - * Renders the additional content. | |
| 145 | - * | |
| 146 | - * @access private | |
| 147 | - */ | |
| 148 | - private function add_additional_content() { | |
| 149 | - $source = strtolower( get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_SOURCE, true ) ); | |
| 150 | - $query = ''; | |
| 151 | - if ( 'visualizer_source_query' === $source ) { | |
| 152 | - $query = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_DB_QUERY, true ); | |
| 153 | - } | |
| 154 | - Visualizer_Render_Layout::show( 'db-query', $query, $this->chart->ID ); | |
| 155 | - Visualizer_Render_Layout::show( 'json-screen', $this->chart->ID ); | |
| 156 | - } | |
| 157 | 280 | } |