*/
class Chart_Builder_Admin {
/**
* The ID of this plugin.
*
* @since 1.0.0
* @access private
* @var string $plugin_name The ID of this plugin.
*/
private $plugin_name;
/**
* The version of this plugin.
*
* @since 1.0.0
* @access private
* @var string $version The current version of this plugin.
*/
private $version;
/**
* The capability of this plugin.
*
* @since 1.0.0
* @access private
* @var string $capability The capability for users access to this plugin.
*/
private $capability;
/**
* @var Chart_Builder_DB_Actions
*/
private $db_obj;
/**
* @var Chart_Builder_Settings_DB_Actions
*/
private $settings_obj;
/**
* Initialize the class and set its properties.
*
* @since 1.0.0
* @param string $plugin_name The name of this plugin.
* @param string $version The version of this plugin.
*/
public function __construct( $plugin_name, $version ) {
$this->plugin_name = $plugin_name;
$this->version = $version;
add_filter('set-screen-option', array(__CLASS__, 'set_screen'), 10, 3);
add_filter('set_screen_option_cb_charts_per_page', array(__CLASS__, 'set_screen'), 10, 3);
}
/**
* Register the stylesheets for the admin area.
*
* @since 1.0.0
*/
public function enqueue_styles($hook_suffix) {
wp_enqueue_style( $this->plugin_name . '-admin', plugin_dir_url(__FILE__) . 'css/admin.css', array(), $this->version, 'all');
// Not enqueue styles if they are not on the current plugin page
if (false === strpos($hook_suffix, $this->plugin_name)) return;
//
wp_enqueue_style( $this->plugin_name . '-normalize', plugin_dir_url( __FILE__ ) . 'css/normalize.css', array(), $this->version . time(), 'all' );
wp_enqueue_style( $this->plugin_name . '-admin-general', plugin_dir_url( __FILE__ ) . 'css/admin-general.css', array(), $this->version, 'all' );
wp_enqueue_style( $this->plugin_name . '-banner', plugin_dir_url( __FILE__ ) . 'css/banner.css', array(), $this->version, 'all' );
// wp_enqueue_style( $this->plugin_name . '-chart-builder-banner.css', plugin_dir_url(__FILE__) . 'css/chart-builder-banner.css', array(), $this->version, 'all');
wp_enqueue_style( $this->plugin_name . '-animate', plugin_dir_url(__FILE__) . 'css/animate.css', array(), $this->version, 'all');
wp_enqueue_style( $this->plugin_name . '-font-awesome', plugin_dir_url(__FILE__) . 'css/ays-font-awesome.min.css', array(), $this->version, 'all');
wp_enqueue_style( $this->plugin_name . '-font-awesome-icons', plugin_dir_url(__FILE__) . 'css/ays-font-awesome-icons.css', array(), $this->version, 'all');
wp_enqueue_style( $this->plugin_name . '-select2', plugin_dir_url(__FILE__) . 'css/ays-select2.min.css', array(), $this->version, 'all');
wp_enqueue_style( $this->plugin_name . '-chosen', plugin_dir_url(__FILE__) . 'css/chosen.min.css', array(), $this->version, 'all');
wp_enqueue_style( $this->plugin_name . '-bootstrap', plugin_dir_url(__FILE__) . 'css/bootstrap.min.css', array(), $this->version, 'all');
wp_enqueue_style( $this->plugin_name . '-data-bootstrap', plugin_dir_url(__FILE__) . 'css/dataTables.bootstrap4.min.css', array(), $this->version, 'all');
wp_enqueue_style( $this->plugin_name . '-jquery-ui.min', plugin_dir_url(__FILE__) . 'css/jquery-ui.min.css', array(), $this->version, 'all');
wp_enqueue_style( $this->plugin_name . '-layer', plugin_dir_url( __FILE__ ) . 'css/chart-builder-admin-layer.css', array(), $this->version, 'all' );
wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/chart-builder-admin.css', array(), $this->version . time(), 'all' );
wp_enqueue_style( $this->plugin_name . "-pro-features", plugin_dir_url( __FILE__ ) . 'css/chart-builder-pro-features.css', array(), $this->version . time(), 'all' );
}
/**
* Register the JavaScript for the admin area.
*
* @since 1.0.0
*/
public function enqueue_scripts($hook_suffix) {
if (false !== strpos($hook_suffix, "plugins.php")){
wp_enqueue_script( $this->plugin_name . '-sweetalert-js', plugin_dir_url( __FILE__ ) . 'js/chart-builder-sweetalert2.all.min.js', array('jquery'), $this->version, true );
wp_enqueue_script($this->plugin_name . '-admin', plugin_dir_url(__FILE__) . 'js/admin.js', array('jquery'), $this->version, true);
wp_localize_script($this->plugin_name . '-admin', 'chart_builder_admin_ajax', array('ajax_url' => admin_url('admin-ajax.php')));
}
// Not enqueue scripts if they are not on the current plugin page
if (false === strpos($hook_suffix, $this->plugin_name)) return;
//
global $wp_version;
$version1 = $wp_version;
$operator = '>=';
$version2 = '5.5';
$versionCompare = CBFunctions()->versionCompare( $version1, $operator, $version2 );
if ( $versionCompare ) {
wp_enqueue_script( $this->plugin_name.'-wp-load-scripts', plugin_dir_url(__FILE__) . 'js/load-scripts.js', array(), $this->version, true);
}
wp_enqueue_script( 'jquery' );
/*
==========================================
* Bootstrap
* select2
* jQuery DataTables
==========================================
*/
wp_enqueue_script( $this->plugin_name . "-popper", plugin_dir_url(__FILE__) . 'js/popper.min.js', array( 'jquery' ), $this->version, true );
wp_enqueue_script( $this->plugin_name . "-bootstrap", plugin_dir_url(__FILE__) . 'js/bootstrap.min.js', array( 'jquery' ), $this->version, true );
wp_enqueue_script( $this->plugin_name . '-select2js', plugin_dir_url( __FILE__ ) . 'js/ays-select2.min.js', array('jquery'), $this->version, true);
wp_enqueue_script( $this->plugin_name . '-chosen', plugin_dir_url( __FILE__ ) . 'js/chosen.jquery.min.js', array('jquery'), $this->version, true);
wp_enqueue_script( $this->plugin_name . '-datatable-min', plugin_dir_url( __FILE__ ) . 'js/chart-builder-datatable.min.js', array('jquery'), $this->version, true);
wp_enqueue_script( $this->plugin_name . "-db4.min.js", plugin_dir_url( __FILE__ ) . 'js/dataTables.bootstrap4.min.js', array( 'jquery' ), $this->version, true );
wp_enqueue_script( $this->plugin_name . "-jquery-ui.min.js", plugin_dir_url( __FILE__ ) . 'js/jquery-ui.min.js', array( 'jquery' ), $this->version, true );
wp_enqueue_script( $this->plugin_name . '-sweetalert-js', plugin_dir_url( __FILE__ ) . 'js/chart-builder-sweetalert2.all.min.js', array('jquery'), $this->version, true );
wp_enqueue_script( $this->plugin_name . "-treeSortable", plugin_dir_url( __FILE__ ) . 'js/treeSortable.js', array( 'jquery' ), $this->version, true );
wp_enqueue_script( $this->plugin_name . "-tippy-bundle", plugin_dir_url( __FILE__ ) . 'js/tippy-bundle.umd.js', array( 'jquery' ), $this->version, true );
$table_col_mapping = CBFunctions()->get_all_db_tables_column_mapping( 1 );
$chart_banner_date = $this->ays_chart_update_banner_time();
wp_enqueue_code_editor(
array(
'type' => 'sql',
'codemirror' => array(
'autofocus' => true,
'lineWrapping' => true,
'dragDrop' => false,
'matchBrackets' => true,
'autoCloseBrackets' => true,
'extraKeys' => array( 'Ctrl-Space' => 'autocomplete' ),
'hintOptions' => array( 'tables' => $table_col_mapping ),
),
)
);
wp_enqueue_script( $this->plugin_name . '-charts-google', plugin_dir_url(__FILE__) . 'js/google-chart.js', array('jquery'), $this->version, true);
wp_enqueue_script( $this->plugin_name . '-chart-js', plugin_dir_url(__FILE__) . 'js/chart-js.js', array('jquery'), $this->version, true);
wp_enqueue_script( $this->plugin_name . '-functions', plugin_dir_url( __FILE__ ) . 'js/functions.js', array( 'jquery' ), $this->version, true );
wp_register_script( $this->plugin_name . '-localized', '' , array('jquery'), $this->version, true);
wp_localize_script( $this->plugin_name . '-localized', 'aysChartBuilderAdmin', array(
'ajaxUrl' => admin_url( 'admin-ajax.php' ),
'selectUser' => __( 'Select author', "chart-builder" ),
'pleaseEnterMore' => __( "Please enter 1 or more characters", "chart-builder" ),
'searching' => __( "Searching...", "chart-builder" ),
'chartBannerDate' => $chart_banner_date,
'selectUserRoles' => __( 'Select user roles', "chart-builder" ),
'delete' => __( 'Delete', "chart-builder" ),
'selectQuestionDefaultType' => __( 'Select question default type', "chart-builder" ),
'yes' => __( 'Yes', "chart-builder" ),
'cancel' => __( 'Cancel', "chart-builder" ),
'somethingWentWrong' => __( "Maybe something went wrong.", "chart-builder" ),
'failed' => __( 'Failed', "chart-builder" ),
'selectPage' => __( 'Select page', "chart-builder" ),
'selectPostType' => __( 'Select post type', "chart-builder" ),
'copied' => __( 'Copied!', "chart-builder"),
'clickForCopy' => __( 'Click to copy', "chart-builder"),
'selectForm' => __( 'Select form', "chart-builder"),
'addImage' => __( 'Add Image', "chart-builder"),
'editImage' => __( 'Edit Image', "chart-builder"),
'confirmDelete' => __( 'Are you sure you want to delete the chart(s)?', "chart-builder"),
'confirmRowDelete' => __( 'Are you sure you want to delete the row?', "chart-builder"),
'confirmColDelete' => __( 'Are you sure you want to delete the column?', "chart-builder"),
'minRowNotice' => __( 'Sorry, minimum count of rows should be 1', "chart-builder"),
'minColNotice' => __( 'Sorry, minimum count of columns should be 1', "chart-builder"),
'activated' => __( "Activated", "chart-builder" ),
'errorMsg' => __( "Error", "chart-builder" ),
'loadResource' => __( "Can't load resource.", "chart-builder" ),
'somethingWentWrong' => __( "Maybe something went wrong.", "chart-builder" ),
'successCopyCoupon' => esc_html__( "Coupon code copied!", 'chart-builder' ),
'failedCopyCoupon' => esc_html__( "Failed to copy coupon code", 'chart-builder' ),
) );
wp_localize_script( $this->plugin_name . '-localized', 'aysChartBuilderChartSettings', array(
'types' => CBFunctions()->getAllowedTypes(),
'max_selected_options' => 2,
'l10n' => array(
'invalid_source' => esc_html__( 'You have entered invalid URL. Please, insert proper URL.', "chart-builder" ),
'loading' => esc_html__( 'Loading...', "chart-builder" ),
'filter_config_error' => esc_html__( 'Please check the filters you have configured.', "chart-builder" ),
'select_columns' => esc_html__( 'Please select a few columns to include in the chart.', "chart-builder" ),
'save_settings' => __( 'You have modified the chart\'s settings. To modify the source/data again, you must save this chart and reopen it for editing. If you continue without saving the chart, you may lose your changes.', "chart-builder" ),
),
'ajax' => array(
'url' => admin_url( 'admin-ajax.php' ),
'nonces' => array(
'filter_get_props' => wp_create_nonce( 'cbuilder-fetch-post-type-props' ),
'filter_get_data' => wp_create_nonce( 'cbuilder-fetch-post-type-data' ),
'quiz_maker_get_data' => wp_create_nonce( 'cbuilder-fetch-quiz-maker-data' ),
'quiz_maker_save_data' => wp_create_nonce( 'cbuilder-save-quiz-maker-data' ),
'author_user_search' => wp_create_nonce( 'cbuilder-author-user-search' ),
),
'actions' => array(
'filter_get_props' => 'fetch_post_type_props',
'filter_get_data' => 'fetch_post_type_data',
'quiz_maker_get_data' => 'fetch_quiz_maker_data',
'quiz_maker_save_data' => 'save_quiz_maker_data',
'author_user_search' => 'author_user_search'
),
),
'db_query' => array(
'tables' => $table_col_mapping,
),
) );
wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/chart-builder-admin.js', array( 'jquery', $this->plugin_name . '-localized' ), $this->version . time(), true );
wp_enqueue_script( $this->plugin_name . '-google', plugin_dir_url( __FILE__ ) . 'js/chart-builder-admin-google.js', array( 'jquery', $this->plugin_name . '-localized' ), $this->version . time(), true );
wp_enqueue_script( $this->plugin_name . '-chartjs', plugin_dir_url( __FILE__ ) . 'js/chart-builder-admin-chartjs.js', array( 'jquery', $this->plugin_name . '-localized' ), $this->version . time(), true );
wp_enqueue_script( $this->plugin_name . '-general-js', plugin_dir_url( __FILE__ ) . 'js/chart-builder-admin-general.js', array( 'jquery', $this->plugin_name . '-localized' ), $this->version . time(), true );
if ( false !== strpos( $hook_suffix, 'settings' ) ) {
wp_enqueue_script( $this->plugin_name . '-settings', plugin_dir_url( __FILE__ ) . 'js/chart-builder-admin-settings.js', array( 'jquery' ), $this->version, true );
wp_localize_script( $this->plugin_name . '-settings', 'aysChartBuilderAdminSettings', array(
'ajaxUrl' => admin_url( 'admin-ajax.php' ),
'selectUserRoles' => __( 'Select user roles', 'chart-builder' ),
'delete' => __( 'Delete', 'chart-builder' ),
'selectQuestionDefaultType' => __( 'Select question default type', 'chart-builder' ),
'yes' => __( 'Yes', 'chart-builder' ),
'cancel' => __( 'Cancel', 'chart-builder' ),
'somethingWentWrong' => __( "Maybe something went wrong.", 'chart-builder' ),
'failed' => __( 'Failed', 'chart-builder' ),
'selectPage' => __( 'Select page', 'chart-builder' ),
'selectPostType' => __( 'Select post type', 'chart-builder' ),
'copied' => __( 'Copied!', 'chart-builder'),
'clickForCopy' => __( 'Click to copy', 'chart-builder'),
'selectForm' => __( 'Select form', 'chart-builder'),
) );
}
}
/**
* De-register JavaScript files for the admin area.
*
* @since 1.0.0
*/
public function disable_scripts($hook_suffix) {
if (false !== strpos($hook_suffix, $this->plugin_name)) {
if (is_plugin_active('ai-engine/ai-engine.php')) {
wp_deregister_script('mwai');
wp_deregister_script('mwai-vendor');
wp_dequeue_script('mwai');
wp_dequeue_script('mwai-vendor');
}
if (is_plugin_active('html5-video-player/html5-video-player.php')) {
wp_dequeue_style('h5vp-admin');
wp_dequeue_style('fs_common');
}
if (is_plugin_active('panorama/panorama.php')) {
wp_dequeue_style('bppiv_admin_custom_css');
wp_dequeue_style('bppiv-custom-style');
}
if (is_plugin_active('wp-social/wp-social.php')) {
wp_dequeue_style('wp_social_select2_css');
wp_deregister_script('wp_social_select2_js');
wp_dequeue_script('wp_social_select2_js');
}
if (is_plugin_active('real-media-library-lite/index.php')) {
wp_dequeue_style('real-media-library-lite-rml');
}
// Theme | Phlox 2.17.6
wp_dequeue_style('auxin-admin-style');
// Theme | Pixel Ebook Store
wp_dequeue_style('pixel-ebook-store-free-demo-content-style');
// Theme | Interactive Education
wp_dequeue_style('interactive-education-free-demo-content-style');
}
}
/**
* Register the administration menu for this plugin into the WordPress Dashboard menu.
*
* @since 1.0.0
*/
public function add_plugin_admin_menu(){
/*
* Add a settings page for this plugin to the Settings menu.
*
* NOTE: Alternative menu locations are available via WordPress administration menu functions.
*
* Administration Menus: http://codex.wordpress.org/Administration_Menus
*
*/
global $wpdb;
$menu_item = __( 'Chart Builder', "chart-builder" );
$this->capability = 'manage_options';
add_menu_page(
__( 'Chart Builder', "chart-builder" ),
$menu_item,
$this->capability,
$this->plugin_name,
array($this, 'display_plugin_charts_page'),
CHART_BUILDER_ADMIN_URL . '/images/icons/ays_chart_logo_icon_bw.svg',
'6.22'
);
}
public function add_plugin_charts_submenu(){
$hook_page_view = add_submenu_page(
$this->plugin_name,
__('All Charts', 'chart-builder'),
__('All Charts', 'chart-builder'),
'manage_options',
$this->plugin_name,
array($this, 'display_plugin_charts_page')
);
add_action( "load-$hook_page_view", array( $this, 'screen_option_charts' ) );
}
public function add_plugin_add_new_submenu(){
$hook_charts = add_submenu_page(
$this->plugin_name,
__('Add New', 'chart-builder'),
__('Add New', 'chart-builder'),
'manage_options',
$this->plugin_name."&action=add",
array($this, 'display_plugin_addnew_page')
);
add_action("load-$hook_charts", array( $this, 'add_tabs' ));
}
public function add_plugin_dashboard_submenu(){
$hook_charts = add_submenu_page(
$this->plugin_name,
__('How to use', 'chart-builder'),
__('How to use', 'chart-builder'),
'manage_options',
$this->plugin_name . '-dashboard',
array($this, 'display_plugin_setup_page')
);
add_action("load-$hook_charts", array( $this, 'add_tabs' ));
}
public function add_plugin_general_settings_submenu(){
$hook_settings = add_submenu_page( $this->plugin_name,
__('General Settings', 'chart-builder'),
__('General Settings', 'chart-builder'),
'manage_options',
$this->plugin_name . '-settings',
array($this, 'display_plugin_settings_page')
);
add_action("load-$hook_settings", array($this, 'screen_option_settings'));
}
public function add_plugin_featured_plugins_submenu(){
$hook_our_products = add_submenu_page( $this->plugin_name,
__('Our products', 'chart-builder'),
__('Our products', 'chart-builder'),
'manage_options',
$this->plugin_name . '-featured-plugins',
array($this, 'display_plugin_featured_plugins_page')
);
add_action("load-$hook_our_products", array( $this, 'add_tabs' ));
}
public function add_plugin_chart_features_submenu(){
$hook_pro_features = add_submenu_page(
$this->plugin_name,
__('PRO Features', 'chart-builder'),
__('PRO Features', 'chart-builder'),
'manage_options',
$this->plugin_name . '-chart-features',
array($this, 'display_plugin_chart_features_page')
);
add_action("load-$hook_pro_features", array( $this, 'add_tabs' ));
}
public function screen_option_charts(){
$option = 'per_page';
$args = array(
'label' => __('Charts', "chart-builder"),
'default' => 5,
'option' => 'cb_charts_per_page'
);
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
if( ! ( isset( $_GET['action'] ) && ( $_GET['action'] == 'add' || $_GET['action'] == 'edit' ) ) ){
add_screen_option( $option, $args );
}
$this->db_obj = new Chart_Builder_DB_Actions( $this->plugin_name );
}
public function screen_option_settings(){
$this->settings_obj = new Chart_Builder_Settings_DB_Actions( $this->plugin_name );
}
public function add_tabs() {
$screen = get_current_screen();
if ( ! $screen) {
return;
}
}
private function check_permissions_and_nonce($nonce_action) {
if (!is_user_logged_in() || !current_user_can('manage_options')) {
wp_die(__('Access denied.', 'chart-builder'));
}
if (!isset($_REQUEST['_wpnonce']) || !wp_verify_nonce($_REQUEST['_wpnonce'], $this->plugin_name . '-' . $nonce_action)) {
wp_die(__('Security check failed. Invalid or missing nonce.', 'chart-builder'));
}
}
public function display_plugin_charts_page(){
global $ays_chart_db_actions;
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$action = ( isset( $_GET['action'] ) ) ? sanitize_text_field( wp_unslash( $_GET['action'] ) ) : '';
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$id = (isset($_GET['id'])) ? absint( wp_unslash( $_GET['id'] ) ) : 0;
if (isset($_POST['bulk_delete_confirm'])) {
$this->check_permissions_and_nonce('bulk-delete');
if (isset($_POST['bulk-delete']) && !empty($_POST['bulk-delete'])) {
$ids = wp_unslash( $_POST['bulk-delete'] );
$ids = array_map( 'absint', (array) $ids );
foreach ($ids as $id) {
if ($id > 0) {
$this->db_obj->delete_item( $id );
}
}
$url = remove_query_arg( array('action', 'id', '_wpnonce') );
$url = esc_url_raw( add_query_arg( array(
"status" => 'all-deleted'
), $url ) );
wp_redirect( $url );
exit;
}
}
switch ($action) {
case 'trash':
$this->check_permissions_and_nonce('trash-item');
if ($id > 0){
$this->db_obj->trash_item( $id );
$url = remove_query_arg( array('action', 'id', '_wpnonce') );
$url = esc_url_raw( add_query_arg( array(
"status" => 'trashed'
), $url ) );
wp_redirect( $url );
exit;
}
break;
case 'restore':
$this->check_permissions_and_nonce('delete-item');
if ($id > 0 ) {
$this->db_obj->restore_item( $id );
$url = remove_query_arg( array('action', 'id', '_wpnonce') );
$url = esc_url_raw( add_query_arg( array(
"status" => 'restored'
), $url ) );
wp_redirect( $url );
exit;
}
break;
case 'delete':
$this->check_permissions_and_nonce('delete-item');
if ($id > 0) {
$this->db_obj->delete_item( $id );
$url = remove_query_arg( array('action', 'id', '_wpnonce') );
$url = esc_url_raw( add_query_arg( array(
"status" => 'deleted'
), $url ) );
wp_redirect( $url );
exit;
}
break;
case 'publish':
$this->check_permissions_and_nonce('publish-item');
if ($id > 0) {
$this->db_obj->publish_item( $id );
$url = remove_query_arg( array('action', 'id', '_wpnonce') );
$url = esc_url_raw( add_query_arg( array(
"status" => 'published'
), $url ) );
wp_redirect( $url );
exit;
}
break;
case 'unpublish':
$this->check_permissions_and_nonce('unpublish-item');
if ($id > 0) {
$this->db_obj->restore_item( $id );
$url = remove_query_arg( array('action', 'id', '_wpnonce') );
$url = esc_url_raw( add_query_arg( array(
"status" => 'unpublished'
), $url ) );
wp_redirect( $url );
exit;
}
break;
case 'duplicate':
$this->check_permissions_and_nonce('duplicate-item');
if ($id > 0) {
$this->db_obj->duplicate_item( $id );
$url = remove_query_arg( array('action', 'id', '_wpnonce') );
$url = esc_url_raw( add_query_arg( array(
"status" => 'duplicated'
), $url ) );
wp_redirect( $url );
exit;
}
break;
case 'add':
include_once('partials/charts/actions/chart-builder-charts-actions.php');
break;
case 'edit':
include_once('partials/charts/actions/chart-builder-charts-actions.php');
break;
default:
include_once('partials/charts/chart-builder-charts-display.php');
}
}
public static function chart_builder_svg_sanitize_allowed_properties(){
$allowed_properties = array(
'div' => array(
'id' => true,
'class' => true,
'style' => true,
),
'svg' => array(
'class' => true,
'version' => true,
'overflow' => true,
'preserveAspectRatio' => true,
'preserveaspectratio' => true,
'fill' => true,
'viewBox' => true,
'viewbox' => true,
'height' => true,
'width' => true,
'xmlns' => true,
'xmlns:xlink' => true,
'id' => true,
'title' => true,
),
'g' => array(
'id' => true,
'class' => true,
'stroke-width' => true,
'stroke-linecap' => true,
'stroke-linejoin' => true,
),
'path' => array(
'id' => true,
'class' => true,
'd' => true,
'fill' => true,
'vector-effect' => true,
'xmlns:default' => true,
),
'span' => array(
'class' => true,
),
'img' => array(
'src' => true,
'alt' => true,
),
);
return $allowed_properties;
}
public static function get_allowed_tags_for_loader() {
return array(
'span' => array('class' => array()),
'img' => array('src' => array(), 'alt' => array()),
);
}
public function display_plugin_setup_page(){
include_once('partials/chart-builder-admin-display.php');
}
public function display_plugin_addnew_page(){
// $url = remove_query_arg( array('action', 'id', '_wpnonce') );
// $url = esc_url_raw( add_query_arg( array(
// "action" => 'add'
// ), $url ) );
// wp_redirect( $url );
}
public function display_plugin_settings_page(){
include_once('partials/settings/chart-builder-settings.php');
}
public function display_plugin_featured_plugins_page(){
include_once('partials/features/chart-builder-plugin-featured-display.php');
}
public function display_plugin_chart_features_page(){
include_once('partials/features/chart-builder-features-display.php');
}
/**
* Add settings action link to the plugins page.
*
* @since 1.0.0
*/
public function add_action_links( $links ){
$chart_ajax_deactivate_plugin_nonce = wp_create_nonce( 'chart-ajax-deactivate-plugin-nonce' );
/*
* Documentation : https://codex.wordpress.org/Plugin_API/Filter_Reference/plugin_action_links_(plugin_file_name)
*/
$settings_link = array(
'' . __('Settings', "chart-builder") . ' ',
'' . __('Demo', "chart-builder") . ' ',
// '' . __('Upgrade', "chart-builder") . ' ',
'' . __('Upgrade 30% Sale', "chart-builder") . '
',
);
return array_merge( $settings_link, $links );
}
public static function set_screen($status, $option, $value){
return $value;
}
public function ays_admin_ajax(){
global $wpdb;
$response = array(
"status" => false
);
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$function = isset( $_REQUEST['function'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['function'] ) ) : null;
if($function !== null){
$response = array();
if( is_callable( array( $this, $function ) ) ){
$allowed_functions = array(
"deactivate_plugin_option",
"ays_chart_dismiss_button",
"author_user_search",
"ays_chart_activate_plugin",
"ays_chart_install_plugin",
"fetch_quiz_maker_data",
"save_quiz_maker_data",
"fetch_post_type_props",
"fetch_post_type_data",
);
if (in_array($function, $allowed_functions, true)) {
$response = $this->$function();
}
ob_end_clean();
$ob_get_clean = ob_get_clean();
echo json_encode( $response );
wp_die();
}
}
ob_end_clean();
$ob_get_clean = ob_get_clean();
echo json_encode( $response );
wp_die();
}
public function deactivate_plugin_option(){
// Run a security check.
if ( isset( $_REQUEST['_ajax_nonce'] ) ) {
check_ajax_referer( 'chart-ajax-deactivate-plugin-nonce', sanitize_key( $_REQUEST['_ajax_nonce'] ) );
} else {
wp_die();
}
// Check for permissions.
if ( ! current_user_can( 'manage_options' ) ) {
ob_end_clean();
$ob_get_clean = ob_get_clean();
echo json_encode(array(
'option' => ''
));
wp_die();
}
if( is_user_logged_in() ) {
$request_value = isset( $_REQUEST['upgrade_plugin'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['upgrade_plugin'] ) ) : '';
$upgrade_option = get_option( 'ays_chart_builder_upgrade_plugin', '' );
if ( $upgrade_option === '' ) {
add_option( 'ays_chart_builder_upgrade_plugin', $request_value );
} else {
update_option( 'ays_chart_builder_upgrade_plugin', $request_value );
}
$response = array(
'option' => get_option( 'ays_chart_builder_upgrade_plugin', '' ),
);
wp_send_json_success( $response );
} else {
ob_end_clean();
$ob_get_clean = ob_get_clean();
echo json_encode(array(
'option' => ''
));
wp_die();
}
}
public function chart_builder_admin_footer($a){
if(isset($_REQUEST['page'])){// phpcs:ignore WordPress.Security.NonceVerification.Recommended
if(false !== strpos( sanitize_text_field( wp_unslash( $_REQUEST['page'] ) ), $this->plugin_name)){// phpcs:ignore WordPress.Security.NonceVerification.Recommended
?>
WordPress.org
widgets_manager ) ) {
if ( method_exists( $elementor->widgets_manager, 'register_widget_type' ) ) {
wp_enqueue_style($this->plugin_name . '-admin', plugin_dir_url(__FILE__) . 'css/admin.css', array(), $this->version, 'all');
$widget_file = 'plugins/elementor/chart-builder-elementor.php';
$template_file = locate_template( $widget_file );
if ( !$template_file || !is_readable( $template_file ) ) {
$template_file = CHART_BUILDER_DIR . 'pb_templates/chart-builder-elementor.php';
}
if ( $template_file && is_readable( $template_file ) ) {
require_once $template_file;
Elementor\Plugin::instance()->widgets_manager->register_widget_type( new Elementor\Widget_Chart_Builder_Elementor() );
}
}
}
}
}
}
}
public function fetch_post_type_props(){
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$nonce = isset( $_POST['nonce'] ) ? wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce'] ) ), 'cbuilder-fetch-post-type-props' ) : '';
if ( $nonce ) {// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$results = isset($_POST['post_type']) ? CBFunctions()->get_post_type_properties( sanitize_text_field( wp_unslash($_POST['post_type']) ) ) : '';
return array(
'success' => true,
'fields' => $results,
);
}
return array(
'success' => false,
);
}
public static function get_max_id( $table ) {
global $wpdb;
$db_table = $wpdb->prefix . CHART_BUILDER_DB_PREFIX . $table;
$sql = "SELECT MAX(id) FROM {$db_table}";
$result = intval( $wpdb->get_var( $sql ) );
return $result;
}
public static function ays_restriction_string($type, $x, $length){
$output = "";
switch($type){
case "char":
if(strlen($x)<=$length){
$output = $x;
} else {
$output = substr($x,0,$length) . '...';
}
break;
case "word":
$res = explode(" ", $x);
if(count($res)<=$length){
$output = implode(" ",$res);
} else {
$res = array_slice($res,0,$length);
$output = implode(" ",$res) . '...';
}
break;
}
return $output;
}
public function ays_chart_sale_banner(){
// if(isset($_POST['ays_chart_sale_btn']) && (isset( $_POST[CHART_BUILDER_NAME . '-sale-banner'] ) && wp_verify_nonce( $_POST[CHART_BUILDER_NAME . '-sale-banner'], CHART_BUILDER_NAME . '-sale-banner' )) && current_user_can( 'manage_options' )) {
// update_option('ays_chart_sale_btn', 1);
// update_option('ays_chart_sale_date', current_time( 'mysql' ));
// }
$ays_chart_sale_date = get_option('ays_chart_sale_date');
$val = 60*60*24*5;
$current_date = current_time( 'mysql' );
$date_diff = strtotime($current_date) - intval(strtotime($ays_chart_sale_date)) ;
$days_diff = $date_diff / $val;
if(intval($days_diff) > 0 ){
update_option('ays_chart_sale_btn', 0);
}
$ays_chart_builder_flag = intval(get_option('ays_chart_sale_btn'));
if( $ays_chart_builder_flag == 0 ){
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( isset( $_GET['page'] ) && strpos( sanitize_text_field( wp_unslash( $_GET['page'] ) ), CHART_BUILDER_NAME ) !== false ) {
if( !(Chart_Builder_Admin::get_max_id('charts') <= 2) ){
// $this->ays_chart_sale_message20($ays_chart_builder_flag);
// $this->ays_chart_discounted_licenses_banner_message();
// $this->ays_chart_new_silver_bundle_message_2025($ays_chart_builder_flag);
$this->ays_chart_footer_sale_banner_2026($ays_chart_builder_flag);
// $this->ays_chart_helloween_message($ays_chart_builder_flag);
// $this->ays_chart_christmas_message($ays_chart_builder_flag);
// $this->ays_chart_silver_bundle_message($ays_chart_builder_flag);
// $this->ays_chart_black_friday_message_2024($ays_chart_builder_flag);
// $this->ays_chart_christmas_message_2024($ays_chart_builder_flag);
// $this->ays_chart_new_halloween_bundle_message_2025($ays_chart_builder_flag);
// $this->ays_chart_black_friday_message($ays_chart_builder_flag);
// $this->ays_chart_christmas_banner_message_2025($ays_chart_builder_flag);
}
}
}
}
public function ays_chart_footer_sale_banner_2026($ishmar){
if($ishmar == 0 ){
$content = array();
$chart_cta_button_link = esc_url('https://ays-pro.com/wordpress/chart-builder?utm_source=dashboard&utm_medium=chart-builder-free&utm_campaign=private-offer-20-off-' . CHART_BUILDER_VERSION);
$content[] = '
';
$content[] = '';
$content[] = '';
$content[] = '';
$content = implode( '', $content );
echo ($content);
}
}
public function ays_chart_dismiss_button(){
$data = array(
'status' => false,
);
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'ays_chart_dismiss_button') {
if ( isset( $_REQUEST['_ajax_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['_ajax_nonce'] ) ), $this->plugin_name . '-sale-banner' ) && current_user_can( 'manage_options' ) ) {
update_option('ays_chart_sale_btn', 1);
update_option('ays_chart_sale_date', current_time( 'mysql' ));
$data['status'] = true;
}
}
ob_end_clean();
$ob_get_clean = ob_get_clean();
echo json_encode($data);
wp_die();
}
public function ays_chart_discounted_licenses_banner_message(){
$content = array();
$date = time() + (int) ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS);
$now_date = date('M d, Y H:i:s', $date);
$start_date = strtotime('2025-09-24');
$end_date = strtotime('2025-10-25');
$diff_end = $end_date - $date;
$style_attr = '';
if( $diff_end < 0 ){
$style_attr = 'style="display:none;"';
}
$total_licenses = 50;
$progression_pattern = array(3, 2, 1, 4, 2, 3, 1, 2, 4, 3, 2, 1, 3, 2, 4, 1, 3, 2, 2, 3, 1, 2);
$days_passed = floor(($date - $start_date) / (24 * 60 * 60));
$used_licenses = 0;
for ($i = 0; $i < min($days_passed, count($progression_pattern)); $i++) {
$used_licenses += $progression_pattern[$i];
}
$used_licenses = min($used_licenses, $total_licenses);
$remaining_licenses = $total_licenses - $used_licenses;
$progress_percentage = ($used_licenses / $total_licenses) * 100;
$ays_chart_cta_button_link = esc_url('https://ays-pro.com/wordpress/chart-builder?utm_source=dashboard&utm_medium=chart-free&utm_campaign=chart-maker-license-banner-' . CHART_BUILDER_VERSION);
$content[] = '';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
' . sprintf( __('Get the Pro Version of %s Chart Builder%s – 20%% OFF', 'chart-builder'), '', ' ' ) . ' ';
$content[] = '
' . __('Unlock advanced features + 30 day Money Back Guarantee', 'chart-builder') . '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
FREE2PRO20 ';
$content[] = '
';
$content[] = ' ';
$content[] = ' ';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
' . __('Only', 'chart-builder') . ' ' . $remaining_licenses . ' ' . __('of 50 discounted licenses left', 'chart-builder') . '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
if( current_user_can( 'manage_options' ) ){
$content[] = '
';
$content[] = '';
$content[] = '
';
}
$content[] = '
';
// Fox LMS Pro Banner Styles
$content[] = '';
$content = implode( '', $content );
echo ($content);
}
// 30% Sale Emma
public function ays_chart_sale_message_30_emma($ishmar){
if($ishmar == 0 ){
$content = array();
$content[] = '';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';// phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage
$content[] = '
30 Day Money Back Guarantee ';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = __( "Offer ends in:", "chart-builder" );
$content[] = '
';
$content[] = '
';
$content[] = ' days ';
$content[] = ' Hours ';
$content[] = ' Minutes ';
$content[] = ' Seconds ';
$content[] = ' ';
$content[] = '
';
$content[] = '
';
$content[] = '🚀 ';
$content[] = '⌛ ';
$content[] = '🔥 ';
$content[] = '💣 ';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content = implode( '', $content );
echo wp_kses_post( html_entity_decode( $content, ENT_QUOTES, 'UTF-8' ) );
}
}
// Self 20% sale
public static function ays_chart_sale_message20($ishmar){
if($ishmar == 0 ){
$content = array();
$content[] = '';
$content[] = '
';
// $content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
// Translators: %s is the URL to the Chart Builder plugin page.
$content[] = sprintf(
/* translators: %s is the Chart Builder plugin URL. */
__(
"Chart Builder ",
'chart-builder'
),
"https://ays-pro.com/wordpress/chart-builder?utm_source=chart-free-dashboard&utm_medium=chart-sale-banner&utm_campaign=chart-sale-plugin-name" . CHART_BUILDER_VERSION
);
$content[] = ' ';
$content[] = '
';
$content[] = '
';// phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = ' '; // phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage
$content[] = esc_html__( "30 Days Money Back Guarantee", 'chart-builder' );
$content[] = ' ';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = esc_html__( "Offer ends in:", 'chart-builder' );
$content[] = '
';
$content[] = '0 ' . esc_html__( 'Days', 'chart-builder' ) . ' ';
$content[] = '0 ' . esc_html__( 'Hours', 'chart-builder' ) . ' ';
$content[] = '0 ' . esc_html__( 'Minutes', 'chart-builder' ) . ' ';
$content[] = '0 ' . esc_html__( 'Seconds', 'chart-builder' ) . ' ';
$content[] = ' ';
$content[] = '
';
$content[] = '
';
$content[] = '🚀 ';
$content[] = '⌛ ';
$content[] = '🔥 ';
$content[] = '💣 ';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content = implode( '', $content );
echo wp_kses_post( html_entity_decode( $content, ENT_QUOTES, 'UTF-8' ) );
}
}
// Helloween banner
public static function ays_chart_helloween_message($ishmar){
if($ishmar == 0 ){
$content = array();
$content[] = '';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = __( "Limited Time
30%
SALE on
Chart Builder
", 'chart-builder' );
$content[] = '
';
$content[] = '
';
$content[] = __( "Hurry up!
Check it out!
", 'chart-builder' );
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = 'days
';
$content[] = 'Hours
';
$content[] = 'Mins
';
$content[] = 'Secs
';
$content[] = ' ';
$content[] = '
';
$content[] = '
';
$content[] = '🚀 ';
$content[] = '⌛ ';
$content[] = '🔥 ';
$content[] = '💣 ';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
// $content[] = '
';
// $content[] = ' ';
$content[] = '
';
$content = implode( '', $content );
echo wp_kses_post( html_entity_decode( $content, ENT_QUOTES, 'UTF-8' ) );
}
}
// Christmas banner
public static function ays_chart_christmas_message($ishmar){
if($ishmar == 0 ){
$content = array();
$content[] = '';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
' . __( 'Chart Builder Plugin', 'chart-builder' ) . '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = ' ' . __( 'Days', 'chart-builder' ) . ' ';
$content[] = ' ' . __( 'Hours', 'chart-builder' ) . ' ';
$content[] = ' ' . __( 'Minutes', 'chart-builder' ) . ' ';
$content[] = ' ' . __( 'Seconds', 'chart-builder' ) . ' ';
$content[] = ' ';
$content[] = '
';
$content[] = '
';
$content[] = '🚀 ';
$content[] = '⌛ ';
$content[] = '🔥 ';
$content[] = '💣 ';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content = implode( '', $content );
echo wp_kses_post( html_entity_decode( $content, ENT_QUOTES, 'UTF-8' ) );
}
}
// Silver Bundle
public function ays_chart_silver_bundle_message($ishmar){
if($ishmar == 0 ){
$content = array();
$content[] = '';
$content[] = '
';
$content[] = '
';// phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage
$content[] = '
';
$content[] = '
';
$content[] = __( "Limited Time 50% SALE on Silver Bundle (Quiz + Chart + Form)!", 'chart-builder' );
$content[] = ' ';
$content[] = '
';
$content[] = '
';
$content[] = __( "Hurry up! Check it out! ", 'chart-builder' );
$content[] = ' ';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = ' days ';
$content[] = ' Hours ';
$content[] = ' Minutes ';
$content[] = ' Seconds ';
$content[] = ' ';
$content[] = '
';
$content[] = '
';
$content[] = '🚀 ';
$content[] = '⌛ ';
$content[] = '🔥 ';
$content[] = '💣 ';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
' . __( 'Buy Now !', 'chart-builder' ) . ' ';
$content[] = '
';
$content[] = '
';
$content = implode( '', $content );
echo wp_kses_post( html_entity_decode( $content, ENT_QUOTES, 'UTF-8' ) );
}
}
//silver bundle
public function ays_chart_new_silver_bundle_message_2025($ishmar){
$content = array();
$date = time() + (int) ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS);
$now_date = date('M d, Y H:i:s', $date);
$chart_banner_date = strtotime( $this->ays_chart_update_banner_time() );
$diff = $chart_banner_date - $date;
$style_attr = '';
if( $diff < 0 ){
$style_attr = 'style="display:none;"';
}
$chart_cta_button_link = esc_url( 'https://ays-pro.com/silver-bundle?utm_source=dashboard&utm_medium=chart-free&utm_campaign=silver-bundle-sale-banner-' . CHART_BUILDER_VERSION );
$content[] = '';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = sprintf(
/* translators: 1: opening link wrapper with tag, 2: closing tag */
__( '%1$s Silver Bundle %2$s (Quiz + Form + Chart)', 'chart-builder' ),
'',
' '
);
$content[] = ' ';
$content[] = '';
$content[] = '
';
$content[] = __( "30 Day Money Back Guarantee", 'chart-builder' );
$content[] = ' ';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = ' ';
$content[] = ' ';
$content[] = ' ';
$content[] = ' ';
$content[] = ' ';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
// /* New Mega Bundle Banner Quiz | Start */
$content[] = '';
// /* New Mega Bundle Banner Quiz | End */
$content = implode( '', $content );
echo ($content);
}
// Christmas Top Banner 2024
public function ays_chart_christmas_message_2024($ishmar){
if($ishmar == 0 ){
$content = array();
$content[] = '';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = __( "Offer ends in:", 'chart-builder' );
$content[] = '
';
$content[] = '
';
$content[] = ' '. __( "Days", 'chart-builder' ) .' ';
$content[] = ' '. __( "Hours", 'chart-builder' ) .' ';
$content[] = ' '. __( "Minutes", 'chart-builder' ) .' ';
$content[] = ' '. __( "Seconds", 'chart-builder' ) .' ';
$content[] = ' ';
$content[] = '
';
$content[] = '
';
$content[] = '🚀 ';
$content[] = '⌛ ';
$content[] = '🔥 ';
$content[] = '💣 ';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = sprintf(
/* translators: %s is the Chart Builder plugin URL with version parameter. */
__(
"Christmas Sale ",
'chart-builder'
),
"https://ays-pro.com/wordpress/chart-builder?utm_source=dashboard&utm_medium=chart-free&utm_campaign=christmas-sale-banner" . CHART_BUILDER_VERSION
);
$content[] = ' ';
$content[] = '';
$content[] = '
';
$content[] = '';
$content[] = __( "20% Extra OFF", 'chart-builder' );
$content[] = ' ';
$content[] = ' ';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = 'xmas20off';
$content[] = '
';
$content[] = '
';
$content[] = __( '20% Extra Discount Coupon', 'chart-builder' );
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content = implode( '', $content );
echo wp_kses_post( html_entity_decode( $content, ENT_QUOTES, 'UTF-8' ) );
}
}
// Halloween Bundle 2025
public function ays_chart_new_halloween_bundle_message_2025($ishmar){
if($ishmar == 0 ){
$content = array();
$date = time() + (int) ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS);
$now_date = date('M d, Y H:i:s', $date);
$start_date = strtotime('2025-09-08');
$end_date = strtotime('2025-10-31');
$diff_end = $end_date - $date;
$style_attr = '';
if( $diff_end < 0 ){
$style_attr = 'style="display:none;"';
}
$ays_chart_cta_button_link = esc_url('https://ays-pro.com/wordpress/chart-builder?utm_source=dashboard&utm_medium=chart-free&utm_campaign=chart-halloween-banner-' . CHART_BUILDER_VERSION);
$content[] = '
Boo! Grab Your Halloween Deal Before It Vanishes!
Don’t get spooked by missing out! Get 25% discount using the coupon code while the magic lasts!
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
00
';
$content[] = '
' . __('days', 'chart-builder') . '
';
$content[] = '
';
$content[] = '
:
';
$content[] = '
';
$content[] = '
00
';
$content[] = '
' . __('hours', 'chart-builder') . '
';
$content[] = '
';
$content[] = '
:
';
$content[] = '
';
$content[] = '
00
';
$content[] = '
' . __('minutes', 'chart-builder') . '
';
$content[] = '
';
$content[] = '
:
';
$content[] = '
';
$content[] = '
00
';
$content[] = '
' . __('seconds', 'chart-builder') . '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
if( current_user_can( 'manage_options' ) ){
$content[] = '
';
$content[] = '';
$content[] = '
';
}
$content[] = '
';
$content[] = '';
$content[] = '';
$content = implode( '', $content );
echo ($content);
}
}
// Black Friday
public static function ays_chart_black_friday_message($ishmar){
if($ishmar == 0 ){
$content = array();
$ays_chart_cta_button_link = esc_url('https://ays-pro.com/wordpress/chart-builder?utm_source=dashboard&utm_medium=chart-free&utm_campaign=black-friday-sale-banner-' . CHART_BUILDER_VERSION);
$content[] = '';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
' . __( 'Coupon Code', "ays-popup-box" ) .' ' . '
';
$content[] = '
';
$content[] = '
FREE2PROBF
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
' . '30% off' . '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = ' ' . __( 'Days', "ays-popup-box" ) . ' ';
$content[] = ' ' . __( 'Hours', "ays-popup-box" ) . ' ';
$content[] = ' ' . __( 'Minutes', "ays-popup-box" ) . ' ';
$content[] = ' ' . __( 'Seconds', "ays-popup-box" ) . ' ';
$content[] = ' ';
$content[] = '
';
$content[] = '
';
$content[] = ' ';
$content[] = ' ';
$content[] = ' ';
$content[] = ' ';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '';
$content[] = '';
$content = implode( '', $content );
echo $content;
}
}
// Christmas Banner 2025
public static function ays_chart_christmas_banner_message_2025($ishmar){
if($ishmar == 0 ){
$content = array();
$svg_icon = '
';
$ays_chart_cta_button_link = esc_url('https://ays-pro.com/wordpress/chart-builder?utm_source=dashboard&utm_medium=chart-free&utm_campaign=christmas-sale-banner-' . CHART_BUILDER_VERSION);
$content[] = '';
$content[] = '
';
// Background effects
$content[] = '
';
$content[] = '
';
$content[] = '
';
// Snowflakes
$content[] = '
'. $svg_icon .'
';
$content[] = '
'. $svg_icon .'
';
$content[] = '
'. $svg_icon .'
';
$content[] = '
'. $svg_icon .'
';
$content[] = '
'. $svg_icon .'
';
$content[] = '
'. $svg_icon .'
';
// Sparkles
$content[] = '
';
$content[] = ' ';
$content[] = ' ';
$content[] = '
';
$content[] = ' ';
$content[] = ' ';
$content[] = '
';
$content[] = ' ';
$content[] = ' ';
$content[] = '
';
// Main content
$content[] = '
';
$content[] = '
';
// Gift icon with hat
$content[] = '
';
$content[] = '
';
$content[] = ' ';
$content[] = ' ';
$content[] = ' ';
$content[] = ' ';
$content[] = ' ';
$content[] = '
';
$content[] = '
';
$content[] = ' ';
$content[] = ' ';
$content[] = ' ';
$content[] = ' ';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
✦ ' . __( 'CHRISTMAS SPECIAL', "chart-builder" ) . ' ✦
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
25% OFF
';
$content[] = '
' . __( 'Limited time offer', "chart-builder" ) . '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
if( current_user_can( 'manage_options' ) ){
$content[] = '
';
$content[] = '';
$content[] = '
';
}
$content[] = '
';
$content[] = '';
$content[] = '';
$content = implode( '', $content );
echo $content;
}
}
public function ays_chart_update_banner_time(){
if (!current_user_can('manage_options')) {
return array('error' => 'Insufficient permissions');
}
$date = time() + ( 3 * 24 * 60 * 60 ) + (int) ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS);
// $date = time() + ( 60 ) + (int) ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS); // for testing | 1 min
$next_3_days = gmdate('M d, Y H:i:s', $date);
$ays_chart_banner_time = get_option('ays_chart_20_bundle_banner_time');
if ( !$ays_chart_banner_time || is_null( $ays_chart_banner_time ) ) {
update_option('ays_chart_20_bundle_banner_time', $next_3_days );
}
$get_ays_chart_banner_time = get_option('ays_chart_20_bundle_banner_time');
$val = 60*60*24*0.5; // half day
// $val = 60; // for testing | 1 min
$current_date = current_time( 'mysql' );
$date_diff = strtotime($current_date) - intval(strtotime($get_ays_chart_banner_time));
$days_diff = $date_diff / $val;
if(intval($days_diff) > 0 ){
update_option('ays_chart_20_bundle_banner_time', $next_3_days);
$get_ays_chart_banner_time = get_option('ays_chart_20_bundle_banner_time');
}
return $get_ays_chart_banner_time;
}
public function ays_chart_add_body_class( $classes ) {
global $pagenow;
if ( $pagenow === 'admin.php' ) {
$page = isset( $_GET['page'] ) ? sanitize_key( $_GET['page'] ) : '';
if ( strpos( $page, $this->plugin_name ) === 0 ) {
$classes .= ' ays-chart-builder-admin';
}
}
return $classes;
}
public function author_user_search() {
check_ajax_referer( 'cbuilder-author-user-search', 'security' );
$params = isset($_REQUEST['params']) ? sanitize_text_field(wp_unslash($_REQUEST['params'])) : array();
$search = isset($params['search']) && $params['search'] != '' ? sanitize_text_field( $params['search'] ) : null;
$checked = isset($params['val']) && $params['val'] !='' ? sanitize_text_field( $params['val'] ) : null;
$args = 'search=';
if ($search !== null) {
$args .= '*';
$args .= $search;
$args .= '*';
}
$users = get_users($args);
$content_text = array(
'results' => array()
);
foreach ($users as $key => $value) {
if ($checked !== null) {
if ( !is_array( $checked ) ) {
$checked2 = $checked;
$checked = array();
$checked[] = absint($checked2);
}
if (in_array($value->ID, $checked)) {
continue;
} else {
$content_text['results'][] = array(
'id' => $value->ID,
'text' => $value->data->display_name,
);
}
} else {
$content_text['results'][] = array(
'id' => $value->ID,
'text' => $value->data->display_name,
);
}
}
ob_end_clean();
echo json_encode($content_text);
wp_die();
}
/**
* Determine if the plugin/addon installations are allowed.
*
* @since 6.4.0.4
*
* @param string $type Should be `plugin` or `addon`.
*
* @return bool
*/
public static function ays_chart_can_install( $type ) {
return self::ays_chart_can_do( 'install', $type );
}
/**
* Determine if the plugin/addon activations are allowed.
*
* @since 6.4.0.4
*
* @param string $type Should be `plugin` or `addon`.
*
* @return bool
*/
public static function ays_chart_can_activate( $type ) {
return self::ays_chart_can_do( 'activate', $type );
}
/**
* Determine if the plugin/addon installations/activations are allowed.
*
* @since 6.4.0.4
*
* @param string $what Should be 'activate' or 'install'.
* @param string $type Should be `plugin` or `addon`.
*
* @return bool
*/
public static function ays_chart_can_do( $what, $type ) {
if ( ! in_array( $what, array( 'install', 'activate' ), true ) ) {
return false;
}
if ( ! in_array( $type, array( 'plugin', 'addon' ), true ) ) {
return false;
}
$capability = $what . '_plugins';
if ( ! current_user_can( $capability ) ) {
return false;
}
// Determine whether file modifications are allowed and it is activation permissions checking.
if ( $what === 'install' && ! wp_is_file_mod_allowed( 'ays_chart_can_install' ) ) {
return false;
}
// All plugin checks are done.
if ( $type === 'plugin' ) {
return true;
}
return false;
}
/**
* Activate plugin.
*
* @since 1.0.0
* @since 6.4.0.4 Updated the permissions checking.
*/
public function ays_chart_activate_plugin() {
// Run a security check.
check_ajax_referer( $this->plugin_name . '-install-plugin-nonce', '_ajax_nonce' );
// Check for permissions.
if ( ! current_user_can( 'activate_plugins' ) ) {
wp_send_json_error( esc_html__( 'Plugin activation is disabled for you on this site.', 'chart-builder' ) );
}
$type = 'addon';
if ( isset( $_POST['plugin'] ) ) {
if ( ! empty( $_POST['type'] ) ) {
$type = sanitize_key( $_POST['type'] );
}
$plugin = sanitize_text_field( wp_unslash( $_POST['plugin'] ) );
$activate = activate_plugins( $plugin );
if ( ! is_wp_error( $activate ) ) {
if ( $type === 'plugin' ) {
wp_send_json_success( esc_html__( 'Plugin activated.', 'chart-builder' ) );
} else {
( esc_html__( 'Addon activated.', 'chart-builder' ) );
}
}
}
if ( $type === 'plugin' ) {
wp_send_json_error( esc_html__( 'Could not activate the plugin. Please activate it on the Plugins page.', 'chart-builder' ) );
}
wp_send_json_error( esc_html__( 'Could not activate the addon. Please activate it on the Plugins page.', 'chart-builder' ) );
}
/**
* Install addon.
*
* @since 1.0.0
* @since 6.4.0.4 Updated the permissions checking.
*/
public function ays_chart_install_plugin() {
// Run a security check.
check_ajax_referer( $this->plugin_name . '-install-plugin-nonce', '_ajax_nonce' );
$generic_error = esc_html__( 'There was an error while performing your request.', 'chart-builder' );
$type = ! empty( $_POST['type'] ) ? sanitize_key( $_POST['type'] ) : '';
// Check if new installations are allowed.
if ( ! self::ays_chart_can_install( $type ) ) {
wp_send_json_error( $generic_error );
}
$error = $type === 'plugin'
? esc_html__( 'Could not install the plugin. Please download and install it manually.', 'chart-builder' )
: "";
$plugin_url = ! empty( $_POST['plugin'] ) ? esc_url_raw( wp_unslash( $_POST['plugin'] ) ) : '';
if ( empty( $plugin_url ) ) {
wp_send_json_error( $error );
}
// Prepare variables.
$url = esc_url_raw(
add_query_arg(
[
'page' => 'chart-builder-featured-plugins',
],
admin_url( 'admin.php' )
)
);
ob_start();
$creds = request_filesystem_credentials( $url, '', false, false, null );
// Hide the filesystem credentials form.
ob_end_clean();
// Check for file system permissions.
if ( $creds === false ) {
wp_send_json_error( $error );
}
if ( ! WP_Filesystem( $creds ) ) {
wp_send_json_error( $error );
}
/*
* We do not need any extra credentials if we have gotten this far, so let's install the plugin.
*/
require_once CHART_BUILDER_DIR . 'includes/admin/class-chart-builder-upgrader.php';
require_once CHART_BUILDER_DIR . 'includes/admin/class-chart-builder-install-skin.php';
require_once CHART_BUILDER_DIR . 'includes/admin/class-chart-builder-skin.php';
// Do not allow WordPress to search/download translations, as this will break JS output.
remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 );
// Create the plugin upgrader with our custom skin.
$installer = new ChartBuilder\Helpers\ChartBuilderPluginSilentUpgrader( new Chart_Builder_Install_Skin() );
// Error check.
if ( ! method_exists( $installer, 'install' ) ) {
wp_send_json_error( $error );
}
$installer->install( $plugin_url );
// Flush the cache and return the newly installed plugin basename.
wp_cache_flush();
$plugin_basename = $installer->plugin_info();
if ( empty( $plugin_basename ) ) {
wp_send_json_error( $error );
}
$result = array(
'msg' => $generic_error,
'is_activated' => false,
'basename' => $plugin_basename,
);
// Check for permissions.
if ( ! current_user_can( 'activate_plugins' ) ) {
$result['msg'] = $type === 'plugin' ? esc_html__( 'Plugin installed.', 'chart-builder' ) : "";
wp_send_json_success( $result );
}
// Activate the plugin silently.
$activated = activate_plugin( $plugin_basename );
remove_action( 'activated_plugin', array( 'ays_sccp_activation_redirect_method', 'gallery_p_gallery_activation_redirect_method', 'poll_maker_activation_redirect_method' ), 100 );
if ( ! is_wp_error( $activated ) ) {
$result['is_activated'] = true;
$result['msg'] = $type === 'plugin' ? esc_html__( 'Plugin installed and activated.', 'chart-builder' ) : esc_html__( 'Addon installed and activated.', 'chart-builder' );
wp_send_json_success( $result );
}
// Fallback error just in case.
wp_send_json_error( $result );
}
/**
* List of AM plugins that we propose to install.
*
* @since 6.4.0.4
*
* @return array
*/
protected function get_am_plugins() {
if ( !isset( $_SESSION ) ) {
session_start();
}
$images_url = CHART_BUILDER_ADMIN_URL . '/images/icons/';
$plugin_slug = array(
'fox-lms',
'quiz-maker',
'survey-maker',
'poll-maker',
'chart-builder',
'ays-popup-box',
'secure-copy-content-protection',
'gallery-photo-gallery',
'ays-chatgpt-assistant',
'easy-form',
);
$plugin_url_arr = array();
foreach ($plugin_slug as $key => $slug) {
if ( isset( $_SESSION['ays_chart_our_product_links'] ) && !empty( $_SESSION['ays_chart_our_product_links'] )
&& isset( $_SESSION['ays_chart_our_product_links'][$slug] ) && !empty( $_SESSION['ays_chart_our_product_links'][$slug] ) ) {
$plugin_url = (isset( $_SESSION['ays_chart_our_product_links'][$slug] ) && $_SESSION['ays_chart_our_product_links'][$slug] != "") ? esc_url_raw(sanitize_text_field($_SESSION['ays_chart_our_product_links'][$slug])) : "";
} else {
$latest_version = $this->ays_chart_get_latest_plugin_version($slug);
$plugin_url = 'https://downloads.wordpress.org/plugin/'. $slug .'.zip';
if ( $latest_version != '' ) {
$plugin_url = 'https://downloads.wordpress.org/plugin/'. $slug .'.'. $latest_version .'.zip';
$_SESSION['ays_chart_our_product_links'][$slug] = $plugin_url;
}
}
$plugin_url_arr[$slug] = $plugin_url;
}
$plugins_array = array(
'fox-lms/fox-lms.php' => array(
'icon' => $images_url . 'icon-fox-lms-128x128.png',
'name' => __( 'Fox LMS', 'chart-builder' ),
'desc' => __( 'Build and manage online courses directly on your WordPress site.', 'chart-builder' ),
'desc_hidden' => __( 'With the FoxLMS plugin, you can create, sell, and organize courses, lessons, and quizzes, transforming your website into a dynamic e-learning platform.', 'chart-builder' ),
'wporg' => 'https://wordpress.org/plugins/fox-lms/',
'buy_now' => 'https://foxlms.com/pricing/?utm_source=dashboard&utm_medium=chart-free&utm_campaign=fox-lms-our-products-page',
'url' => $plugin_url_arr['fox-lms'],
),
'quiz-maker/quiz-maker.php' => array(
'icon' => $images_url . 'icon-quiz-128x128.png',
'name' => __( 'Quiz Maker', 'chart-builder' ),
'desc' => __( 'Create powerful and engaging quizzes, tests, and exams in minutes.', 'chart-builder' ),
'desc_hidden' => __( 'Build an unlimited number of quizzes and questions.', 'chart-builder' ),
'wporg' => 'https://wordpress.org/plugins/quiz-maker/',
'buy_now' => 'https://ays-pro.com/wordpress/quiz-maker/',
'url' => $plugin_url_arr['quiz-maker'],
),
'survey-maker/survey-maker.php' => array(
'icon' => $images_url . 'icon-survey-128x128.png',
'name' => __( 'Survey Maker', 'chart-builder' ),
'desc' => __( 'Make amazing online surveys and get real-time feedback quickly and easily.', 'chart-builder' ),
'desc_hidden' => __( 'Learn what your website visitors want, need, and expect with the help of Survey Maker. Build surveys without limiting your needs.', 'chart-builder' ),
'wporg' => 'https://wordpress.org/plugins/survey-maker/',
'buy_now' => 'https://ays-pro.com/wordpress/survey-maker',
'url' => $plugin_url_arr['survey-maker'],
),
'poll-maker/poll-maker-ays.php' => array(
'icon' => $images_url . 'icon-poll-128x128.png',
'name' => __( 'Poll Maker', 'chart-builder' ),
'desc' => __( 'Create amazing online polls for your WordPress website super easily.', 'chart-builder' ),
'desc_hidden' => __( 'Build up various types of polls in a minute and get instant feedback on any topic or product.', 'chart-builder' ),
'wporg' => 'https://wordpress.org/plugins/poll-maker/',
'buy_now' => 'https://ays-pro.com/wordpress/poll-maker/',
'url' => $plugin_url_arr['poll-maker'],
),
'ays-popup-box/ays-pb.php' => array(
'icon' => $images_url . 'icon-popup-128x128.png',
'name' => __( 'Popup Box', 'chart-builder' ),
'desc' => __( 'Popup everything you want! Create informative and promotional popups all in one plugin.', 'chart-builder' ),
'desc_hidden' => __( 'Attract your visitors and convert them into email subscribers and paying customers.', 'chart-builder' ),
'wporg' => 'https://wordpress.org/plugins/ays-popup-box/',
'buy_now' => 'https://ays-pro.com/wordpress/popup-box/',
'url' => $plugin_url_arr['ays-popup-box'],
),
'secure-copy-content-protection/secure-copy-content-protection.php' => array(
'icon' => $images_url . 'icon-sccp-128x128.png',
'name' => __( 'Secure Copy Content Protection', 'chart-builder' ),
'desc' => __( 'Disable the right click, copy paste, content selection and copy shortcut keys on your website.', 'chart-builder' ),
'desc_hidden' => __( 'Protect web content from being plagiarized. Prevent plagiarism from your website with this easy to use plugin.', 'chart-builder' ),
'wporg' => 'https://wordpress.org/plugins/secure-copy-content-protection/',
'buy_now' => 'https://ays-pro.com/wordpress/secure-copy-content-protection/',
'url' => $plugin_url_arr['secure-copy-content-protection'],
),
'gallery-photo-gallery/gallery-photo-gallery.php' => array(
'icon' => $images_url . 'icon-gallery-128x128.png',
'name' => __( 'Gallery Photo Gallery', 'chart-builder' ),
'desc' => __( 'Create unlimited galleries and include unlimited images in those galleries.', 'chart-builder' ),
'desc_hidden' => __( 'Represent images in an attractive way. Attract people with your own single and multiple free galleries from your photo library.', 'chart-builder' ),
'wporg' => 'https://wordpress.org/plugins/gallery-photo-gallery/',
'buy_now' => 'https://ays-pro.com/wordpress/photo-gallery/',
'url' => $plugin_url_arr['gallery-photo-gallery'],
),
'ays-chatgpt-assistant/ays-chatgpt-assistant.php' => array(
'icon' => $images_url . 'icon-chatgpt-128x128.png',
'name' => __( 'AI Assistant with ChatGPT', 'chart-builder' ),
'desc' => __( 'ChatGPT AI Assistant plugin gives you the ability to automate various tasks related to content creation and programming.', 'chart-builder' ),
'desc_hidden' => __( 'The ChatGPT AI Assistant plugin is here to empower your WordPress website. Have your personal chatbot, content generator right on your front end and backend.', 'chart-builder' ),
'wporg' => 'https://wordpress.org/plugins/ays-chatgpt-assistant/',
'buy_now' => 'https://ays-pro.com/wordpress/chatgpt-assistant',
'url' => $plugin_url_arr['ays-chatgpt-assistant'],
),
'easy-form/easy-form.php' => array(
'icon' => $images_url . 'icon-form-128x128.png',
'name' => __( 'Easy Form', 'chart-builder' ),
'desc' => __( 'Choose the best WordPress form builder plugin. ', 'chart-builder' ),
'desc_hidden' => __( 'Create contact forms, payment forms, surveys, and many more custom forms. Build forms easily with us.', 'chart-builder' ),
'wporg' => 'https://wordpress.org/plugins/easy-form/',
'buy_now' => 'https://ays-pro.com/wordpress/easy-form',
'url' => $plugin_url_arr['easy-form'],
),
);
return $plugins_array;
}
protected function ays_chart_get_latest_plugin_version( $slug ){
if ( is_null( $slug ) || empty($slug) ) {
return "";
}
$version_latest = "";
if ( ! function_exists( 'plugins_api' ) ) {
require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
}
// set the arguments to get latest info from repository via API ##
$args = array(
'slug' => $slug,
'fields' => array(
'version' => true,
)
);
/** Prepare our query */
$call_api = plugins_api( 'plugin_information', $args );
/** Check for Errors & Display the results */
if ( is_wp_error( $call_api ) ) {
$api_error = $call_api->get_error_message();
} else {
//echo $call_api;
// everything ##
if ( ! empty( $call_api->version ) ) {
$version_latest = $call_api->version;
}
}
return $version_latest;
}
/**
* Get AM plugin data to display in the Addons section of About tab.
*
* @since 6.4.0.4
*
* @param string $plugin Plugin slug.
* @param array $details Plugin details.
* @param array $all_plugins List of all plugins.
*
* @return array
*/
protected function get_plugin_data( $plugin, $details, $all_plugins ) {
$have_pro = ( ! empty( $details['pro'] ) && ! empty( $details['pro']['plug'] ) );
$show_pro = false;
$plugin_data = array();
if ( $have_pro ) {
if ( array_key_exists( $plugin, $all_plugins ) ) {
if ( is_plugin_active( $plugin ) ) {
$show_pro = true;
}
}
if ( array_key_exists( $details['pro']['plug'], $all_plugins ) ) {
$show_pro = true;
}
if ( $show_pro ) {
$plugin = $details['pro']['plug'];
$details = $details['pro'];
}
}
if ( array_key_exists( $plugin, $all_plugins ) ) {
if ( is_plugin_active( $plugin ) ) {
// Status text/status.
$plugin_data['status_class'] = 'status-active';
$plugin_data['status_text'] = esc_html__( 'Active', 'chart-builder' );
// Button text/status.
$plugin_data['action_class'] = $plugin_data['status_class'] . ' ays-chart-card__btn-info disabled';
$plugin_data['action_text'] = esc_html__( 'Activated', 'chart-builder' );
$plugin_data['plugin_src'] = esc_attr( $plugin );
} else {
// Status text/status.
$plugin_data['status_class'] = 'status-installed';
$plugin_data['status_text'] = esc_html__( 'Inactive', 'chart-builder' );
// Button text/status.
$plugin_data['action_class'] = $plugin_data['status_class'] . ' ays-chart-card__btn-info';
$plugin_data['action_text'] = esc_html__( 'Activate', 'chart-builder' );
$plugin_data['plugin_src'] = esc_attr( $plugin );
}
} else {
// Doesn't exist, install.
// Status text/status.
$plugin_data['status_class'] = 'status-missing';
if ( isset( $details['act'] ) && 'go-to-url' === $details['act'] ) {
$plugin_data['status_class'] = 'status-go-to-url';
}
$plugin_data['status_text'] = esc_html__( 'Not Installed', 'chart-builder' );
// Button text/status.
$plugin_data['action_class'] = $plugin_data['status_class'] . ' ays-chart-card__btn-info';
$plugin_data['action_text'] = esc_html__( 'Install Plugin', 'chart-builder' );
$plugin_data['plugin_src'] = esc_url( $details['url'] );
}
$plugin_data['details'] = $details;
return $plugin_data;
}
/**
* Display the Addons section of About tab.
*
* @since 6.4.0.4
*/
public function output_about_addons() {
if ( ! function_exists( 'get_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$all_plugins = get_plugins();
$am_plugins = $this->get_am_plugins();
$can_install_plugins = self::ays_chart_can_install( 'plugin' );
$can_activate_plugins = self::ays_chart_can_activate( 'plugin' );
$content = '';
$content.= '';
foreach ( $am_plugins as $plugin => $details ){
$plugin_data = $this->get_plugin_data( $plugin, $details, $all_plugins );
$plugin_ready_to_activate = $can_activate_plugins
&& isset( $plugin_data['status_class'] )
&& $plugin_data['status_class'] === 'status-installed';
$plugin_not_activated = ! isset( $plugin_data['status_class'] )
|| $plugin_data['status_class'] !== 'status-active';
$plugin_action_class = ( isset( $plugin_data['action_class'] ) && esc_attr( $plugin_data['action_class'] ) != "" ) ? esc_attr( $plugin_data['action_class'] ) : "";
$plugin_action_class_disbaled = "";
if ( strpos($plugin_action_class, 'status-active') !== false ) {
$plugin_action_class_disbaled = "disbaled='true'";
}
$content .= '
'. esc_html( $plugin_data['details']['name'] ) .'
'. wp_kses_post( $plugin_data['details']['desc'] ) .'
'. wp_kses_post( $plugin_data['details']['desc_hidden'] ) .'
';
}
$install_plugin_nonce = wp_create_nonce( $this->plugin_name . '-install-plugin-nonce' );
$content.= '
';
$content.= '
';
echo html_entity_decode($content);
}
/**
* Returns the data from Quiz maker.
*
* @access public
*/
public function fetch_quiz_maker_data(){
check_ajax_referer( 'cbuilder-fetch-quiz-maker-data', 'security' );
$params = isset($_REQUEST['params']) ? $_REQUEST['params'] : array();
if ( !isset($params) || empty($params) ) {
return array(
'success' => false,
'data' => array(
'msg' => __( "Something went wrong.", "chart-builder" )
)
);
}
$query = isset($params['query']) && $params['query'] !== '' ? $params['query'] : '';
if ( $query == '' ) {
return array(
'success' => false,
'data' => array(
'msg' => __( "No data given.", "chart-builder" )
)
);
}
$quiz_id = isset($params['quizID']) && $params['quizID'] !== '' ? $params['quizID'] : null;
$user_id = get_current_user_id();
$return_results = CBFunctions()->get_quiz_query($query, $quiz_id, $user_id);
if (empty($return_results)) {
return array(
'success' => false,
'data' => array(
'msg' => __( "Something went wrong.", "chart-builder" )
)
);
}
$result_values = $return_results['result'];
$query = $return_results['query'];
if (empty($result_values)) {
return array(
'success' => false,
'data' => array(
'msg' => $return_results['message']
)
);
}
if (count($return_results['result'][0]) != 1 ) {
$results = array();
$headers = array();
if ( $result_values ) {
$row_num = 0;
foreach ( $result_values as $row ) {
$result = array();
foreach ( $row as $k => $v ) {
$result[] = $v;
if ( $row_num === 0 ) {
$headers[] = $k;
}
}
$results[] = $result;
$row_num++;
}
}
} else if (count($return_results['result'][0]) == 1) {
$results = array();
$headers = array();
if ( $result_values ) {
$row_num = 0;
foreach ( $result_values as $index => $row ) {
$result = array();
foreach ( $row as $k => $v ) {
$result[] = strval($index) + 1;
$result[] = $v;
if ( $row_num === 0 ) {
$headers[] = 'Quiz';
$headers[] = $k;
}
}
$results[] = $result;
$row_num++;
}
}
}
if (empty($results)) {
return array(
'success' => false,
'data' => array(
'msg' => $return_results['message']
)
);
}
foreach ($results as $key => $value) {
if (!isset($value) || count($value) <= 1 && $key != 0) {
unset($results[$key]);
}
}
array_unshift($results, $headers);
$results = array_values( $results );
$data = $results;
$headers = $results[0];
unset( $results[0] );
$html = CBFunctions()->get_table_html( $headers, $results );
return array(
'success' => true,
'data' => array(
'table' => $html,
'data' => $data
)
);
}
/**
* Saves the Quiz maker data.
*
* @access public
*/
public function save_quiz_maker_data() {
check_ajax_referer( 'cbuilder-save-quiz-maker-data', 'security' );
$params = isset($_REQUEST['params']) ? $_REQUEST['params'] : array();
if ( !isset($params) || empty($params) ) {
return array(
'success' => false,
'data' => array(
'msg' => __( "Something went wrong.", "chart-builder" )
)
);
}
$query_id = isset($params['query']) && $params['query'] !== '' ? $params['query'] : '';
if ( $query_id == '' ) {
return array(
'success' => false,
'data' => array(
'msg' => __( "No data given.", "chart-builder" )
)
);
}
$chart_id = isset( $params['chart_id'] ) ? absint( $params['chart_id'] ) : 0;
$quiz_id = isset($params['quizID']) && $params['quizID'] !== '' ? $params['quizID'] : 0;
$user_id = get_current_user_id();
if ( $chart_id >= 0 ) {
$return_results = CBFunctions()->get_quiz_query($query_id, $quiz_id, $user_id);
if (empty($return_results)) {
return array(
'success' => false,
'data' => array(
'msg' => __( "Something went wrong.", "chart-builder" )
)
);
}
$result_values = $return_results['result'];
$query = $return_results['query'];
if (empty($result_values)) {
return array(
'success' => false,
'data' => array(
'msg' => $return_results['message']
)
);
}
if ( !empty($result_values) && count($return_results['result'][0]) != 1 ) {
$results = array();
$headers = array();
if ( $result_values ) {
$row_num = 0;
foreach ( $result_values as $row ) {
$result = array();
foreach ( $row as $k => $v ) {
$result[] = $v;
if ( $row_num === 0 ) {
$headers[] = $k;
}
}
$results[] = $result;
$row_num++;
}
}
} else if (count($return_results['result'][0]) == 1) {
$results = array();
$headers = array();
if ( $result_values ) {
$row_num = 0;
foreach ( $result_values as $index => $row ) {
$result = array();
foreach ( $row as $k => $v ) {
$result[] = strval($index) + 1;
$result[] = $v;
if ( $row_num === 0 ) {
$headers[] = 'Quiz';
$headers[] = $k;
}
}
$results[] = $result;
$row_num++;
}
}
}
$source_type = 'quiz_maker';
$option_name_for_data = $chart_id == 0 ? 'ays_chart_quiz_maker_results_temp' : 'ays_chart_quiz_maker_results_' . $chart_id;
$option_name_for_quiz = $chart_id == 0 ? 'ays_chart_quiz_maker_quiz_data_temp' : 'ays_chart_quiz_maker_quiz_data_' . $chart_id;
update_option( $option_name_for_data, array(
'source_type' => $source_type,
'source' => $query,
'data' => $results,
) );
update_option( $option_name_for_quiz, array(
'quiz_query' => $query_id,
'quiz_id' => $quiz_id
) );
} else {
return array(
'success' => false,
'data' => array(
'msg' => __( 'Given incorrect Chart ID.', "chart-builder")
)
);
}
return array(
'success' => true,
'data' => array(
'msg' => __( 'Data was successfully saved.', "chart-builder" )
)
);
}
/**
* Chart page action hooks
*/
/**
* Chart page sources contents
* @param $args
*/
public function ays_chart_page_source_contents( $args ){
$chart_source_type = $args['chart_source_type'];
if ($chart_source_type === 'chart-js') {
$sources_contents = apply_filters( 'ays_cb_chart_page_sources_contents_settings_chartjs', array(), $args );
} else {
$sources_contents = apply_filters( 'ays_cb_chart_page_sources_contents_settings', array(), $args );
}
$source_type = $args['source_type'];
$sources = array();
foreach ( $sources_contents as $key => $sources_content ) {
$collapsed = $key == $source_type ? 'false' : 'true';
$content = '';
if( isset( $sources_content['title'] ) ){
$content .= '';
}
$content .= '';
$content .= $sources_content['content'];
$content .= '
';
$content .= ' ';
$sources[] = $content;
}
$content_for_escape = implode('' , $sources );
echo html_entity_decode( esc_html($content_for_escape) );
}
public function source_contents_import_from_csv_settings( $sources, $args ){
$html_class_prefix = $args['html_class_prefix'];
$html_name_prefix = $args['html_name_prefix'];
ob_start();
?>
';
$sources['file_import'] = array(
'content' => $content,
'title' => $title
);
return $sources;
}
public function source_contents_import_from_db_settings( $sources, $args ){
$html_class_prefix = $args['html_class_prefix'];
$html_name_prefix = $args['html_name_prefix'];
ob_start();
?>
';
$sources['import_from_db'] = array(
'content' => $content,
'title' => $title
);
return $sources;
}
public function source_contents_import_from_external_db_settings( $sources, $args ){
$html_class_prefix = $args['html_class_prefix'];
$html_name_prefix = $args['html_name_prefix'];
ob_start();
?>
';
$sources['import_from_external_db'] = array(
'content' => $content,
'title' => $title
);
return $sources;
}
public function source_contents_quiz_maker_integration_settings( $sources, $args ){
global $wpdb;
$chart_id = $args['chart_id'];
$html_class_prefix = $args['html_class_prefix'];
$html_name_prefix = $args['html_name_prefix'];
$source = $args['source'];
$settings = $args['settings'];
$quiz_queries = $args['quiz_queries'];
$quiz_query_tooltips = $args['quiz_query_tooltips'];
$quiz_id = $args['quiz_id'];
$quiz_query = $args['quiz_query'];
if ( !is_plugin_active('quiz-maker/quiz-maker.php') ) {
// $title = sprintf( __( 'Get Quiz Maker data', "chart-builder" ) . '
//
// ', ' ', '', ' ');
// $content = $this->blockquote_content_quiz;
// $sources['quiz_maker'] = array(
// 'content' => $content,
// 'title' => $title
// );
return $sources;
}
$quizes = $wpdb->get_results( // phpcs:ignore
$wpdb->prepare(
"SELECT `title`, `id` FROM {$wpdb->prefix}aysquiz_quizes
WHERE `published` = %d AND `question_ids` <> %s",
1,
''
),
ARRAY_A
);
ob_start();
?>
',
' ', '', ' '
);
$sources['quiz_maker'] = array(
'content' => $content,
'title' => $title
);
return $sources;
}
public function source_contents_woocommerce_integration_settings( $sources, $args ){
if ( !is_plugin_active('woocommerce/woocommerce.php') ) {
return $sources;
}
$chart_id = $args['chart_id'];
$html_class_prefix = $args['html_class_prefix'];
$html_name_prefix = $args['html_name_prefix'];
ob_start();
?>
',
' ', '', ' '
);
$sources['woocommerce'] = array(
'content' => $content,
'title' => $title
);
return $sources;
}
public function source_contents_manual_settings( $sources, $args ){
$html_class_prefix = $args['html_class_prefix'];
$html_name_prefix = $args['html_name_prefix'];
$source = $args['source'];
$source = isset($source["commonTypeCharts"]) ? $source["commonTypeCharts"] : $source;
$settings = $args['settings'];
$source_chart_type = $args['source_chart_type'];
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$action = isset($_GET['action']) ? sanitize_text_field(wp_unslash($_GET['action'])) : 'add';
if (isset($source) && !empty($source)) {
if ( !isset( $source[0] ) ) {
if (count($source[1]) > 2) {
$titles = array();
for ($i = 0; $i < count($source[1]); $i++) {
array_push($titles, __("Title", 'chart-builder').$i);
}
$source[0] = $titles;
} else {
$source[0] = array(
__("Country", 'chart-builder'),
__("Population", 'chart-builder'),
);
}
ksort($source);
}
}
if ($action == 'add') {
foreach ($source as $key => $row) {
$source[$key] = array_slice($row, 0, 2);
}
} else if ($action == 'edit') {
if ($source_chart_type == 'pie_chart' || $source_chart_type == 'donut_chart') {
foreach ($source as $key => $row) {
$source[$key] = array_slice($row, 0, 2);
}
}
}
ob_start();
?>
$source_value):
if(!empty($source_value) ):
if ($source_id == 0): ?>
';
$sources['manual'] = array(
'content' => $content,
'title' => $title
);
return $sources;
}
public function source_contents_manual_settings_chartjs( $sources, $args ){
$html_class_prefix = $args['html_class_prefix'];
$html_name_prefix = $args['html_name_prefix'];
$source = $args['source'];
$source = isset($source["commonTypeCharts"]) ? $source["commonTypeCharts"] : $source;
$settings = $args['settings'];
$source_chart_type = $args['source_chart_type'];
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$action = isset($_GET['action']) ? sanitize_text_field((wp_unslash($_GET['action']))) : 'add';
ob_start();
?>
$source_value):
if(!empty($source_value) ):
if ($source_id == 0): ?>
';
$sources['manual'] = array(
'content' => $content,
'title' => $title
);
return $sources;
}
/**
* Chart page settings contents
* @param $args
*/
public function ays_chart_page_settings_contents( $args ){
$chart_source_type = $args['chart_source_type'];
if ($chart_source_type === 'chart-js') {
$sources_contents = apply_filters( 'ays_cb_chart_page_settings_contents_settings_chartjs', array(), $args );
} else {
$sources_contents = apply_filters( 'ays_cb_chart_page_settings_contents_settings', array(), $args );
}
$sources = array();
foreach ( $sources_contents as $key => $sources_content ) {
$collapsed = $key == 'general_settings' ? 'false' : 'true';
$content = '';
if(isset($sources_content['title'])){
$content .= '';
}
$content .= '';
$content .= $sources_content['content'];
$content .= '
';
$content .= ' ';
$sources[] = $content;
}
$content_for_escape = implode('' , $sources );
echo html_entity_decode( $content_for_escape );
}
public function settings_contents_general_settings( $sources, $args ){
$html_class_prefix = $args['html_class_prefix'];
$html_name_prefix = $args['html_name_prefix'];
$chart_description = $args['chart_description'];
$create_author_data = $args['create_author_data'];
$status = $args['status'];
$settings = $args['settings'];
$show_title = $settings['show_title'];
$show_description = $settings['show_description'];
$enable_interactivity = $settings['enable_interactivity'];
$maximized_view = $settings['maximized_view'];
ob_start();
?>
$content,
'title' => $title
);
return $sources;
}
public function settings_contents_general_settings_chartjs( $sources, $args ){
$html_class_prefix = $args['html_class_prefix'];
$html_name_prefix = $args['html_name_prefix'];
$chart_description = $args['chart_description'];
$create_author_data = $args['create_author_data'];
$status = $args['status'];
$settings = $args['settings'];
$show_title = $settings['show_title'];
$show_description = $settings['show_description'];
$enable_interactivity = $settings['enable_interactivity'];
ob_start();
?>
$content,
'title' => $title
);
return $sources;
}
public function settings_contents_tooltip_settings( $sources, $args ){
$html_class_prefix = $args['html_class_prefix'];
$html_name_prefix = $args['html_name_prefix'];
$settings = $args['settings'];
$tooltip_trigger_options = $settings['tooltip_trigger_options'];
$tooltip_trigger = $settings['tooltip_trigger'];
$show_color_code = $settings['show_color_code'];
$tooltip_italic = $settings['tooltip_italic'];
$tooltip_bold = $settings['tooltip_bold'];
$tooltip_bold_options = $settings['tooltip_bold_options'];
$tooltip_text_color = $settings['tooltip_text_color'];
$tooltip_font_size = $settings['tooltip_font_size'];
ob_start();
?>
$content,
'title' => $title
);
return $sources;
}
public function settings_contents_tooltip_settings_chartjs( $sources, $args ){
$html_class_prefix = $args['html_class_prefix'];
$html_name_prefix = $args['html_name_prefix'];
$settings = $args['settings'];
$tooltip_text_color = $settings['tooltip_text_color'];
$show_color_code = $settings['show_color_code'];
$tooltip_italic = $settings['tooltip_italic'];
$tooltip_font_size = $settings['tooltip_font_size'];
$tooltip_bold = $settings['tooltip_bold'];
$tooltip_bold_options = $settings['tooltip_bold_options'];
ob_start();
?>
$content,
'title' => $title
);
return $sources;
}
public function settings_contents_legend_settings( $sources, $args ){
$html_class_prefix = $args['html_class_prefix'];
$html_name_prefix = $args['html_name_prefix'];
$settings = $args['settings'];
$legend_positions = $settings['legend_positions'];
$legend_position = $settings['legend_position'];
$legend_alignments = $settings['legend_alignments'];
$legend_alignment = $settings['legend_alignment'];
$legend_color = $settings['legend_color'];
$legend_font_size = $settings['legend_font_size'];
$legend_bold = $settings['legend_bold'];
$legend_italic = $settings['legend_italic'];
ob_start();
?>
$content,
'title' => $title
);
return $sources;
}
public function settings_contents_legend_settings_chartjs( $sources, $args ){
$html_class_prefix = $args['html_class_prefix'];
$html_name_prefix = $args['html_name_prefix'];
$settings = $args['settings'];
$legend_positions = $settings['legend_positions'];
$legend_position = $settings['legend_position'];
$legend_alignments = $settings['legend_alignments'];
$legend_alignment = $settings['legend_alignment'];
$legend_color = $settings['legend_color'];
$legend_font_size = $settings['legend_font_size'];
$legend_reverse = $settings['legend_reverse'];
$legend_bold = $settings['legend_bold'];
$legend_italic = $settings['legend_italic'];
ob_start();
?>
$content,
'title' => $title
);
return $sources;
}
public function settings_contents_horizontal_axis_settings( $sources, $args ){
$html_class_prefix = $args['html_class_prefix'];
$html_name_prefix = $args['html_name_prefix'];
$settings = $args['settings'];
$haxis_title = $settings['haxis_title'];
$axes_text_positions = $settings['axes_text_positions'];
$haxis_text_position = $settings['haxis_text_position'];
$haxis_direction = $settings['haxis_direction'];
$haxis_text_color = $settings['haxis_text_color'];
$haxis_baseline_color = $settings['haxis_baseline_color'];
$haxis_slanted_options = $settings['haxis_slanted_options'];
$haxis_slanted = $settings['haxis_slanted'];
$haxis_slanted_text_angle = $settings['haxis_slanted_text_angle'];
$haxis_show_text_every = $settings['haxis_show_text_every'];
$haxis_format_options = $settings['axes_format_options'];
$haxis_format = $settings['haxis_format'];
$haxis_enable_divide_percent = $settings['haxis_enable_divide_percent'];
$haxis_label_font_size = $settings['haxis_label_font_size'];
$haxis_max_value = $settings['haxis_max_value'];
$haxis_min_value = $settings['haxis_min_value'];
$haxis_text_font_size = $settings['haxis_text_font_size'];
$haxis_label_color = $settings['haxis_label_color'];
$haxis_bold = $settings['haxis_bold'];
$haxis_italic = $settings['haxis_italic'];
$haxis_title_bold = $settings['haxis_title_bold'];
$haxis_title_italic = $settings['haxis_title_italic'];
$haxis_gridlines_count = $settings['haxis_gridlines_count'];
$haxis_gridlines_color = $settings['haxis_gridlines_color'];
$haxis_minor_gridlines_color = $settings['haxis_minor_gridlines_color'];
ob_start();
?>
Label
Text
Gridlines
Format
$content,
'title' => $title
);
return $sources;
}
public function settings_contents_vertical_axis_settings( $sources, $args ){
$html_class_prefix = $args['html_class_prefix'];
$html_name_prefix = $args['html_name_prefix'];
$settings = $args['settings'];
$vaxis_title = $settings['vaxis_title'];
$axes_text_positions = $settings['axes_text_positions'];
$vaxis_text_position = $settings['vaxis_text_position'];
$vaxis_direction = $settings['vaxis_direction'];
$vaxis_text_color = $settings['vaxis_text_color'];
$vaxis_baseline_color = $settings['vaxis_baseline_color'];
$vaxis_format_options = $settings['axes_format_options'];
$vaxis_format = $settings['vaxis_format'];
$vaxis_enable_divide_percent = $settings['vaxis_enable_divide_percent'];
$vaxis_label_font_size = $settings['vaxis_label_font_size'];
$vaxis_max_value = $settings['vaxis_max_value'];
$vaxis_min_value = $settings['vaxis_min_value'];
$vaxis_text_font_size = $settings['vaxis_text_font_size'];
$vaxis_label_color = $settings['vaxis_label_color'];
$vaxis_bold = $settings['vaxis_bold'];
$vaxis_italic = $settings['vaxis_italic'];
$vaxis_title_bold = $settings['vaxis_title_bold'];
$vaxis_title_italic = $settings['vaxis_title_italic'];
$vaxis_gridlines_count = $settings['vaxis_gridlines_count'];
$vaxis_gridlines_color = $settings['vaxis_gridlines_color'];
$vaxis_minor_gridlines_color = $settings['vaxis_minor_gridlines_color'];
ob_start();
?>
Label
Text
Gridlines
Format
$content,
'title' => $title
);
return $sources;
}
public function settings_contents_animation_settings( $sources, $args ) {
$html_class_prefix = $args['html_class_prefix'];
$html_name_prefix = $args['html_name_prefix'];
$settings = $args['settings'];
$enable_animation = $settings['enable_animation'];
$animation_duration = $settings['animation_duration'];
$animation_startup = $settings['animation_startup'];
$animation_easing_options = $settings['animation_easing_options'];
$animation_easing = $settings['animation_easing'];
ob_start();
?>
$content,
'title' => $title
);
return $sources;
}
public function settings_contents_live_chart_settings( $sources, $args ) {
$html_class_prefix = $args['html_class_prefix'];
$html_name_prefix = $args['html_name_prefix'];
ob_start();
?>
$content,
'title' => $title
);
return $sources;
}
public function settings_contents_export_options( $sources, $args ){
$html_class_prefix = $args['html_class_prefix'];
$html_name_prefix = $args['html_name_prefix'];
$settings = $args['settings'];
$enable_img = $settings['enable_img'];
ob_start();
?>
$content,
'title' => $title
);
return $sources;
}
/**
* Chart page styles contents
* @param $args
*/
public function ays_chart_page_styles_contents( $args ){
$chart_source_type = $args['chart_source_type'];
if ($chart_source_type === 'chart-js') {
$sources_contents = apply_filters( 'ays_cb_chart_page_styles_contents_settings_chartjs', array(), $args );
} else {
$sources_contents = apply_filters( 'ays_cb_chart_page_styles_contents_settings', array(), $args );
}
$sources = array();
foreach ( $sources_contents as $key => $sources_content ) {
$collapsed = $key == 'chart' ? 'false' : 'true';
$content = '
';
if(isset($sources_content['title'])){
$content .= '';
}
$content .= '';
$content .= $sources_content['content'];
$content .= '
';
$content .= ' ';
$sources[] = $content;
}
$content_for_escape = implode('' , $sources );
echo html_entity_decode( esc_html($content_for_escape) );
}
public function settings_contents_chart_styles_settings( $sources, $args ){
$html_class_prefix = $args['html_class_prefix'];
$html_name_prefix = $args['html_name_prefix'];
$settings = $args['settings'];
$width = $settings['width'];
$width_format = $settings['width_format'];
$title_positions = $settings['title_positions'];
$position = $settings['position'];
$width_format_options = $settings['width_format_options'];
$responsive_width = $settings['responsive_width'];
$height = $settings['height'];
$height_format = $settings['height_format'];
$font_size = $settings['font_size'];
$org_chart_font_size_options = $settings['org_chart_font_size_options'];
$org_chart_font_size = $settings['org_chart_font_size'];
$background_color = $settings['background_color'];
$transparent_background = $settings['transparent_background'];
$border_width = $settings['border_width'];
$border_width_with_title = $settings['border_width_with_title'];
$border_radius_with_title = $settings['border_radius_with_title'];
$border_color_with_title = $settings['border_color_with_title'];
$border_style_with_title = $settings['border_style_with_title'];
$border_style = $settings['border_style'];
$border_styles = $settings['border_styles'];
$border_radius = $settings['border_radius'];
$border_color = $settings['border_color'];
$box_shadow = $settings['box_shadow'];
$box_shadow_color = $settings['box_shadow_color'];
$padding_outer = $settings['padding_outer'];
ob_start();
?>
$content,
'title' => $title
);
return $sources;
}
public function settings_contents_chart_styles_settings_chartjs( $sources, $args ){
$html_class_prefix = $args['html_class_prefix'];
$html_name_prefix = $args['html_name_prefix'];
$settings = $args['settings'];
$border_width_with_title = $settings['border_width_with_title'];
$border_radius_with_title = $settings['border_radius_with_title'];
$border_color_with_title = $settings['border_color_with_title'];
$border_style_with_title = $settings['border_style_with_title'];
$width = $settings['width'];
$width_format = $settings['width_format'];
$height = $settings['height'];
$height_format = $settings['height_format'];
$width_format_options = $settings['width_format_options'];
$border_width = $settings['border_width'];
$border_radius = $settings['border_radius'];
$border_color = $settings['border_color'];
$background_color_chart = $settings['background_color_chart'];
$border_style = $settings['border_style'];
$border_styles = $settings['border_styles'];
$box_shadow = $settings['box_shadow'];
$box_shadow_color = $settings['box_shadow_color'];
$padding_outer = $settings['padding_outer'];
ob_start();
?>
$content,
'title' => $title
);
return $sources;
}
public function settings_contents_chart_area_styles_settings( $sources, $args ){
$html_class_prefix = $args['html_class_prefix'];
$html_name_prefix = $args['html_name_prefix'];
$settings = $args['settings'];
$chart_background_color = $settings['chart_background_color'];
$chart_border_color = $settings['chart_border_color'];
$chart_left_margin = $settings['chart_left_margin'];
$chart_right_margin = $settings['chart_right_margin'];
$chart_top_margin = $settings['chart_top_margin'];
$chart_bottom_margin = $settings['chart_bottom_margin'];
$chart_border_width = $settings['chart_border_width'];
ob_start();
?>
$content,
'title' => $title
);
return $sources;
}
public function settings_contents_title_styles_settings( $sources, $args ){
$html_class_prefix = $args['html_class_prefix'];
$html_name_prefix = $args['html_name_prefix'];
$settings = $args['settings'];
$title_color = $settings['title_color'];
$title_shadow_color = $settings['title_shadow_color'];
$title_font_size = $settings['title_font_size'];
$title_gap = $settings['title_gap'];
$title_gap_description = $settings['title_gap_description'];
$title_positions = $settings['title_positions'];
$title_position = $settings['title_position'];
$title_bold = $settings['title_bold'];
$title_text_shadow = $settings['title_text_shadow'];
$title_italic = $settings['title_italic'];
$text_transforms = $settings['text_transforms'];
$text_decorations = $settings['text_decorations'];
$title_text_transform = $settings['title_text_transform'];
$title_text_decoration = $settings['title_text_decoration'];
$title_letter_spacing = $settings['title_letter_spacing'];
ob_start();
?>
$content,
'title' => $title
);
return $sources;
}
public function settings_contents_title_styles_settings_chartjs( $sources, $args ){
$html_class_prefix = $args['html_class_prefix'];
$html_name_prefix = $args['html_name_prefix'];
$settings = $args['settings'];
$title_color = $settings['title_color'];
$title_shadow_color = $settings['title_shadow_color'];
$title_font_size = $settings['title_font_size'];
$title_gap = $settings['title_gap'];
$title_gap_description = $settings['title_gap_description'];
$title_positions = $settings['title_positions'];
$title_position = $settings['title_position'];
$title_bold = $settings['title_bold'];
$title_text_shadow = $settings['title_text_shadow'];
$title_italic = $settings['title_italic'];
$text_transforms = $settings['text_transforms'];
$text_decorations = $settings['text_decorations'];
$title_text_transform = $settings['title_text_transform'];
$title_text_decoration = $settings['title_text_decoration'];
$title_letter_spacing = $settings['title_letter_spacing'];
ob_start();
?>
$content,
'title' => $title
);
return $sources;
}
public function settings_contents_description_styles_settings( $sources, $args ){
$html_class_prefix = $args['html_class_prefix'];
$html_name_prefix = $args['html_name_prefix'];
$settings = $args['settings'];
$description_color = $settings['description_color'];
$description_font_size = $settings['description_font_size'];
$title_positions = $settings['title_positions'];
$description_position = $settings['description_position'];
$description_bold = $settings['description_bold'];
$description_text_shadow = $settings['description_text_shadow'];
$description_shadow_color = $settings['description_shadow_color'];
$description_italic = $settings['description_italic'];
$text_transforms = $settings['text_transforms'];
$text_decorations = $settings['text_decorations'];
$description_text_transform = $settings['description_text_transform'];
$description_text_decoration = $settings['description_text_decoration'];
$description_letter_spacing = $settings['description_letter_spacing'];
ob_start();
?>
$content,
'title' => $title
);
return $sources;
}
public function settings_contents_description_styles_settings_chartjs( $sources, $args ){
$html_class_prefix = $args['html_class_prefix'];
$html_name_prefix = $args['html_name_prefix'];
$settings = $args['settings'];
$description_color = $settings['description_color'];
$description_font_size = $settings['description_font_size'];
$title_positions = $settings['title_positions'];
$description_position = $settings['description_position'];
$description_bold = $settings['description_bold'];
$description_text_shadow = $settings['description_text_shadow'];
$description_shadow_color = $settings['description_shadow_color'];
$description_italic = $settings['description_italic'];
$text_transforms = $settings['text_transforms'];
$text_decorations = $settings['text_decorations'];
$description_text_transform = $settings['description_text_transform'];
$description_text_decoration = $settings['description_text_decoration'];
$description_letter_spacing = $settings['description_letter_spacing'];
ob_start();
?>
$content,
'title' => $title
);
return $sources;
}
/**
* Chart page settings contents
* @param $args
*/
public function ays_chart_page_advanced_settings_contents( $args ){
$chart_source_type = $args['chart_source_type'];
if ($chart_source_type === 'chart-js') {
if ($args['source_chart_type'] !== 'pie_chart') {return;}
$sources_contents = apply_filters( 'ays_cb_chart_page_advanced_settings_contents_settings_chartjs', array(), $args );
} else {
$sources_contents = apply_filters( 'ays_cb_chart_page_advanced_settings_contents_settings', array(), $args );
}
$sources = array();
foreach ( $sources_contents as $key => $sources_content ) {
$collapsed = $key == 'advanced_settings' ? 'false' : 'true';
$content = '
';
if(isset($sources_content['title'])){
$content .= '';
}
$content .= '';
$content .= $sources_content['content'];
$content .= '
';
$content .= ' ';
$sources[] = $content;
}
$content_for_escape = implode('' , $sources );
echo html_entity_decode( esc_html($content_for_escape) );
}
public function settings_contents_advanced_settings( $sources, $args ){
$html_class_prefix = $args['html_class_prefix'];
$html_name_prefix = $args['html_name_prefix'];
$settings = $args['settings'];
$tab_title = $args['tab_name'];
$rotation_degree = $settings['rotation_degree'];
$reverse_categories = $settings['reverse_categories'];
$slice_border_color = $settings['slice_border_color'];
$slice_texts = $settings['slice_texts'];
$slice_text = $settings['slice_text'];
$tooltip_text_options = $settings['tooltip_text_options'];
$tooltip_text = $settings['tooltip_text'];
$is_stacked = $settings['is_stacked'];
$focus_target_options = $settings['focus_target_options'];
$focus_target = $settings['focus_target'];
$multiple_data_format_options = $settings['multiple_data_format_options'];
$multiple_data_format = $settings['multiple_data_format'];
$opacity = $settings['opacity'];
$group_width = $settings['group_width'];
$group_width_format = $settings['group_width_format'];
$group_width_format_options = $settings['group_width_format_options'];
$line_width = $settings['line_width'];
$data_grouping_limit = $settings['data_grouping_limit'];
$data_grouping_label = $settings['data_grouping_label'];
$data_grouping_color = $settings['data_grouping_color'];
$multiple_selection = $settings['multiple_selection'];
$point_shape_options = $settings['point_shape_options'];
$point_shape = $settings['point_shape'];
$crosshair_trigger_options = $settings['crosshair_trigger_options'];
$crosshair_trigger = $settings['crosshair_trigger'];
$crosshair_orientation_options = $settings['crosshair_orientation_options'];
$crosshair_orientation = $settings['crosshair_orientation'];
$crosshair_opacity = $settings['crosshair_opacity'];
$dash_style = $settings['dash_style'];
$point_size = $settings['point_size'];
$donut_hole_size = $settings['donut_hole_size'];
$orientation = $settings['orientation'];
$fill_nulls = $settings['fill_nulls'];
$allow_collapse = $settings['allow_collapse'];
$org_classname = $settings['org_classname'];
$org_node_background_color = $settings['org_node_background_color'];
$org_node_padding = $settings['org_node_padding'];
$org_node_border_radius = $settings['org_node_border_radius'];
$org_node_border_width = $settings['org_node_border_width'];
$org_node_border_color = $settings['org_node_border_color'];
$org_node_text_color = $settings['org_node_text_color'];
$org_node_text_font_size = $settings['org_node_text_font_size'];
$org_node_description_font_color = $settings['org_node_description_font_color'];
$org_node_description_font_size = $settings['org_node_description_font_size'];
$org_selected_classname = $settings['org_selected_classname'];
$org_selected_node_background_color = $settings['org_selected_node_background_color'];
$org_selected_node_text_color = $settings['org_selected_node_text_color'];
ob_start();
?>
$content,
'title' => $tab_title
);
return $sources;
}
public function settings_contents_advanced_settings_chartjs( $sources, $args ){
$html_class_prefix = $args['html_class_prefix'];
$html_name_prefix = $args['html_name_prefix'];
$settings = $args['settings'];
$tab_title = $args['tab_name'];
$outer_radius = $settings['outer_radius'];
$slice_spacing = $settings['slice_spacing'];
$circumference = $settings['circumference'];
$start_angle = $settings['start_angle'];
$slice_border_color = $settings['slice_border_color'];
$slice_border_width = $settings['slice_border_width'];
// $index_axis = $settings['index_axis'];
ob_start();
?>
$content,
'title' => $tab_title
);
return $sources;
}
public function settings_contents_slices_settings( $sources, $args ){
$html_class_prefix = $args['html_class_prefix'];
$html_name_prefix = $args['html_name_prefix'];
$settings = $args['settings'];
$source = $args['source'];
$source = isset($source["commonTypeCharts"]) ? $source["commonTypeCharts"] : $source;
$source_chart_type = $args['source_chart_type'];
$settings = $args['settings'];
$title_row = array_shift($source);
if (isset($source) && !empty($source)) {
if ( !isset( $source[0] ) ) {
if (count($source[1]) > 2) {
$titles = array();
for ($i = 0; $i < count($source[1]); $i++) {
array_push($titles, __("Title", 'chart-builder').$i);
}
$source[0] = $titles;
} else {
$source[0] = array(
__("Country", 'chart-builder'),
__("Population", 'chart-builder'),
);
}
ksort($source);
}
}
if ($source_chart_type == 'pie_chart' || $source_chart_type == 'donut_chart') {
foreach ($source as $key => $row) {
$source[$key] = array_slice($row, 0, 2);
}
}
ob_start();
if ($source_chart_type == 'pie_chart' || $source_chart_type == 'donut_chart') {
$slice_color = $settings['slice_color'];
$slice_colors_default = $settings['slice_colors_default'];
$slice_offset = $settings['slice_offset'];
$slice_text_color = $settings['slice_text_color'];
?>
$content,
'title' => $title
);
return $sources;
}
public function settings_contents_slices_settings_chartjs( $sources, $args ){
$html_class_prefix = $args['html_class_prefix'];
$html_name_prefix = $args['html_name_prefix'];
$settings = $args['settings'];
$source = $args['source'];
$source = isset($source["commonTypeCharts"]) ? $source["commonTypeCharts"] : $source;
$source_chart_type = $args['source_chart_type'];
$settings = $args['settings'];
$title_row = array_shift($source);
if (isset($source) && !empty($source)) {
if ( !isset( $source[0] ) ) {
if (count($source[1]) > 2) {
$titles = array();
for ($i = 0; $i < count($source[1]); $i++) {
array_push($titles, __("Title", 'chart-builder').$i);
}
$source[0] = $titles;
} else {
$source[0] = array(
__("Country", 'chart-builder'),
__("Population", 'chart-builder'),
);
}
ksort($source);
}
}
if ($source_chart_type == 'pie_chart') {
foreach ($source as $key => $row) {
$source[$key] = array_slice($row, 0, 2);
}
}
ob_start();
if ($source_chart_type == 'pie_chart') {
$slice_color = $settings['slice_color'];
$slices_border_color = $settings['slices_border_color'];
$slice_colors_default = $settings['slice_colors_default'];
?>
$content,
'title' => $title
);
return $sources;
}
public function settings_contents_series_settings( $sources, $args ){
$html_class_prefix = $args['html_class_prefix'];
$html_name_prefix = $args['html_name_prefix'];
$settings = $args['settings'];
$source = $args['source'];
$source = isset($source["commonTypeCharts"]) ? $source["commonTypeCharts"] : $source;
$source_chart_type = $args['source_chart_type'];
$line_width = $settings['line_width'];
$point_size = $settings['point_size'];
$point_shape_options = $settings['point_shape_options'];
$point_shape = $settings['point_shape'];
if (isset($source) && !empty($source)) {
if ( !isset( $source[0] ) ) {
if (count($source[1]) > 2) {
$titles = array();
for ($i = 0; $i < count($source[1]); $i++) {
array_push($titles, __("Title", "chart-builder").$i);
}
$source[0] = $titles;
} else {
$source[0] = array(
__("Country", "chart-builder"),
__("Population", "chart-builder"),
);
}
ksort($source);
}
}
if ($source_chart_type == 'pie_chart' || $source_chart_type == 'donut_chart') {
foreach ($source as $key => $row) {
$source[$key] = array_slice($row, 0, 2);
}
}
ob_start();
if ($source_chart_type == 'pie_chart' || $source_chart_type == 'line_chart' || $source_chart_type == 'bar_chart' || $source_chart_type == 'column_chart') {
$series_row = array_shift($source);
$title = array_shift($series_row);
$series_color = $settings['series_color'];
$series_colors_default = $settings['series_colors_default'];
$series_format = $settings['series_format'];
$series_visible_in_legend = $settings['series_visible_in_legend'];
$series_line_width = $settings['series_line_width'];
$series_point_size = $settings['series_point_size'];
$series_point_shape = $settings['series_point_shape'];
?>
tag, %2$s: Closing tag */
esc_html(__( '%1$sNote:%2$s If you are not able to set the options, disable the row settings feature.', 'chart-builder' )),
'',
' '
); ?>
$content,
'title' => $title
);
return $sources;
}
public function settings_contents_row_settings( $sources, $args ){
$html_class_prefix = $args['html_class_prefix'];
$html_name_prefix = $args['html_name_prefix'];
$settings = $args['settings'];
$source = $args['source'];
$source = isset($source["commonTypeCharts"]) ? $source["commonTypeCharts"] : $source;
$source_chart_type = $args['source_chart_type'];
if (isset($source) && !empty($source)) {
if ( !isset( $source[0] ) ) {
if (count($source[1]) > 2) {
$titles = array();
for ($i = 0; $i < count($source[1]); $i++) {
array_push($titles, __("Title", 'chart-builder').$i);
}
$source[0] = $titles;
} else {
$source[0] = array(
__("Country", 'chart-builder'),
__("Population", 'chart-builder'),
);
}
ksort($source);
}
}
array_shift($source);
$rows = array_column($source, 0);
$enable_row_settings = $settings['enable_row_settings'];
$series_color = $settings['series_color'][0] ?? '#3366cc';
$rows_color = $settings['rows_color'];
$rows_opacity = $settings['rows_opacity'];
ob_start();
?>
$val ):
?>
tag, %2$s: Closing tag */
esc_html(__( '%1$sNote:%2$s The applied styles will work only if the chart has one column.', 'chart-builder' )),
'',
' '
); ?>
tag, %2$s: Closing tag */
esc_html(__( '%1$sNote:%2$s If this option is disabled, the general options will be set from the series settings.', 'chart-builder' )),
'',
' '
); ?>
$content,
'title' => $title
);
return $sources;
}
public function ays_chart_disable_all_notice_from_plugin() {
if (!function_exists('get_current_screen')) {
return;
}
$screen = get_current_screen();
if (empty($screen) || strpos($screen->id, $this->plugin_name) === false) {
return;
}
global $wp_filter;
// Keep plugin-specific notices
$our_plugin_notices = array();
$exclude_functions = [
'chart_builder_general_admin_notice',
];
if (!empty($wp_filter['admin_notices'])) {
foreach ($wp_filter['admin_notices']->callbacks as $priority => $callbacks) {
foreach ($callbacks as $key => $callback) {
// For class-based methods
if (
is_array($callback['function']) &&
is_object($callback['function'][0]) &&
get_class($callback['function'][0]) === __CLASS__
) {
$our_plugin_notices[$priority][$key] = $callback;
}
// For standalone functions
elseif (
is_string($callback['function']) &&
in_array($callback['function'], $exclude_functions)
) {
$our_plugin_notices[$priority][$key] = $callback;
}
}
}
}
// Remove all notices
remove_all_actions('admin_notices');
remove_all_actions('all_admin_notices');
// Re-add only your plugin's notices
foreach ($our_plugin_notices as $priority => $callbacks) {
foreach ($callbacks as $callback) {
add_action('admin_notices', $callback['function'], $priority);
}
}
}
}