| // +----------------------------------------------------------------------+ /** * Renders visualizer library page. * * @category Visualizer * @package Render * * @since 1.0.0 */ class Visualizer_Render_Library extends Visualizer_Render { /** * Renders library page. * * @since 1.0.0 * * @access protected */ protected function _toHTML() { echo '
'; echo '

'; echo '

'; esc_html_e( 'Visualizer Library', 'visualizer' ); echo ' ', esc_html__( 'Add New', 'visualizer' ), ''; if ( Visualizer_Module::is_pro() ) { echo ' ', esc_html__( 'License Settings', 'visualizer' ), ''; } echo '

'; $this->_renderMessages(); $this->_renderLibrary(); echo '
'; } /** * Renders notification messages if need be. * * @since 1.4.2 * * @access private */ private function _renderMessages() { if ( ! filter_var( ini_get( 'allow_url_fopen' ), FILTER_VALIDATE_BOOLEAN ) ) { echo '
'; echo '

'; printf( esc_html__( '%s option is disabled in your php.ini config. Please, enable it by change its value to 1. This option increases the speed of remote CSV uploading.', 'visualizer' ), 'allow_url_fopen' ); echo '

'; echo '
'; } } /** * Displays the search form. */ private function getDisplayForm() { echo '
'; echo ' |
'; } /** * Renders library content. * * @since 1.0.0 * * @access private */ private function _renderLibrary() { // Added by Ash/Upwork $filterBy = ! empty( $_GET['s'] ) ? sanitize_text_field( wp_unslash( $_GET['s'] ) ) : null; // phpcs:ignore WordPress.Security.NonceVerification.Recommended // Added by Ash/Upwork echo $this->custom_css; echo '
'; echo ''; $this->getDisplayForm(); echo '
'; echo '
'; if ( ! empty( $this->charts ) ) { echo '
'; $count = 0; foreach ( $this->charts as $placeholder_id => $chart ) { // show the sidebar after the first 3 charts. $count++; $enable_controls = false; $settings = isset( $chart['settings'] ) ? $chart['settings'] : array(); if ( ! empty( $settings['controls']['controlType'] ) ) { $column_index = $settings['controls']['filterColumnIndex']; $column_label = $settings['controls']['filterColumnLabel']; if ( 'false' !== $column_index || 'false' !== $column_label ) { $enable_controls = true; } } if ( 3 === $count ) { $this->_renderSidebar(); $this->_renderChartBox( $placeholder_id, $chart['id'], $enable_controls ); } else { $this->_renderChartBox( $placeholder_id, $chart['id'], $enable_controls ); } } // show the sidebar if there are less than 3 charts. if ( $count < 3 ) { $this->_renderSidebar(); } echo '
'; } else { echo '
'; echo '
'; echo '
'; echo '
', esc_html__( 'No charts found', 'visualizer' ), '

', esc_html__( 'Add New', 'visualizer' ), '

'; echo '
'; echo ''; echo '
'; $this->_renderSidebar(); echo '
'; } echo '
'; if ( is_array( $this->pagination ) ) { echo ''; } } /** * Renders chart's box block. * * @since 1.0.0 * * @access private * * @param string $placeholder_id The placeholder's id for the chart. * @param int $chart_id The id of the chart. */ private function _renderChartBox( $placeholder_id, $chart_id, $with_filter = false ) { $settings = get_post_meta( $chart_id, Visualizer_Plugin::CF_SETTINGS ); $title = '#' . $chart_id; if ( ! empty( $settings[0]['title'] ) ) { $title = $settings[0]['title']; } // for ChartJS, title is an array. if ( is_array( $title ) && isset( $title['text'] ) ) { $title = $title['text']; } if ( empty( $title ) ) { $title = '#' . $chart_id; } $ajax_url = admin_url( 'admin-ajax.php' ); $delete_url = esc_url( add_query_arg( array( 'action' => Visualizer_Plugin::ACTION_DELETE_CHART, 'nonce' => wp_create_nonce(), 'chart' => $chart_id, ), $ajax_url ) ); $clone_url = esc_url( add_query_arg( array( 'action' => Visualizer_Plugin::ACTION_CLONE_CHART, 'nonce' => wp_create_nonce( Visualizer_Plugin::ACTION_CLONE_CHART ), 'chart' => $chart_id, 'type' => $this->type, ), $ajax_url ) ); $export_link = esc_url( add_query_arg( array( 'action' => Visualizer_Plugin::ACTION_EXPORT_DATA, 'chart' => $chart_id, 'security' => wp_create_nonce( Visualizer_Plugin::ACTION_EXPORT_DATA . Visualizer_Plugin::VERSION ), ), admin_url( 'admin-ajax.php' ) ) ); $chart_status = array( 'date' => get_the_modified_date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $chart_id ), 'error' => get_post_meta( $chart_id, Visualizer_Plugin::CF_ERROR, true ), 'icon' => 'dashicons-yes-alt', 'title' => 'A-OK!' ); if ( ! empty( $chart_status['error'] ) ) { $chart_status['icon'] = 'error dashicons-dismiss'; $chart_status['title'] = __( 'Click to view the error', 'visualizer' ); } $shortcode = sprintf( '[visualizer id="%s" lazy="no" class=""]', $chart_id ); echo '
', esc_html( $title ), '
'; if ( Visualizer_Module::is_pro() && $with_filter ) { echo '
'; echo '
'; } echo '
'; echo ''; echo '
'; if ( Visualizer_Module::is_pro() && $with_filter ) { echo '
'; } echo ''; echo '
'; } /** * Render 2-col sidebar */ private function _renderSidebar() { if ( ! Visualizer_Module::is_pro() ) { echo '
'; echo '
'; echo '
'; echo '
'; echo '

' . __( 'Discover the power of PRO!', 'visualizer' ) . '

    '; if ( Visualizer_Module_Admin::proFeaturesLocked() ) { echo '
  • ' . __( '6 more chart types', 'visualizer' ); } else { echo '
  • ' . __( '11 more chart types', 'visualizer' ) . '
  • '; echo '
  • ' . __( 'Manual Data Editor', 'visualizer' ) . '
  • '; echo '
  • ' . __( 'ChartJS Charts', 'visualizer' ) . '
  • '; echo '
  • ' . __( 'Table Google chart', 'visualizer' ) . '
  • '; echo '
  • ' . __( 'Frontend Actions(Print, Export, Copy, Download)', 'visualizer' ) . '
  • '; } echo '
  • ' . __( 'Spreadsheet like editor', 'visualizer' ) . '
  • '; echo '
  • ' . __( 'Import from other charts', 'visualizer' ) . '
  • '; echo '
  • ' . __( 'Use database query to create charts', 'visualizer' ) . '
  • '; echo '
  • ' . __( 'Create charts from WordPress tables', 'visualizer' ) . '
  • '; echo '
  • ' . __( 'Frontend editor', 'visualizer' ) . '
  • '; echo '
  • ' . __( 'Private charts', 'visualizer' ) . '
  • '; echo '
  • ' . __( 'WPML support for translating charts', 'visualizer' ) . '
  • '; echo '
  • ' . __( 'Integration with Woocommerce Data endpoints', 'visualizer' ) . '
  • '; echo '
  • ' . __( 'Auto-sync with online files', 'visualizer' ) . '
'; echo '

' . __( 'View more features', 'visualizer' ) . '

'; echo '
'; echo '
'; echo '
'; echo '
'; } } }