| // +----------------------------------------------------------------------+ /** * 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 = null; if ( isset( $_GET['s'] ) && strlen( $_GET['s'] ) > 0 ) { $filterBy = filter_input( INPUT_GET, 's', FILTER_SANITIZE_STRING ); } // Added by Ash/Upwork echo $this->custom_css; echo '
'; $this->getDisplayForm(); echo '
'; echo '
'; if ( ! empty( $this->charts ) ) { echo '
'; $count = 0; foreach ( $this->charts as $placeholder_id => $chart ) { $this->_renderChartBox( $placeholder_id, $chart['id'] ); // show the sidebar after the first 3 charts. if ( $count++ === 2 ) { $this->_renderSidebar(); } } // 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 ) { $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 = add_query_arg( array( 'action' => Visualizer_Plugin::ACTION_DELETE_CHART, 'nonce' => wp_create_nonce(), 'chart' => $chart_id, ), $ajax_url ); $clone_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 = 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' => '' ); 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 ), '
'; echo '
'; echo ''; echo '
'; echo ''; echo '
'; } /** * Render sidebar. */ private function _renderSidebar() { if ( ! Visualizer_Module::is_pro() ) { echo '
'; echo '
'; echo '

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

'; echo '

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

'; echo '

' . __( 'We offer a 30-day no-questions-asked money back guarantee!', 'visualizer' ) . '

'; echo '

' . __( 'Don\'t see the features you need? Help us improve!', 'visualizer' ) . '

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