*/ class Chart_Builder_Integrations { /** * 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; private $settings_obj; private $capability; private $blockquote_content; /** * 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; $this->settings_obj = new Chart_Builder_Settings_DB_Actions($this->plugin_name); $settings_url = sprintf( __( "For enabling this option, please go to %s page and fill all options.", $this->plugin_name ), "". __( "this", $this->plugin_name ) ."" ); $blockquote_content = '
'. $settings_url .'
'; $this->blockquote_content = $blockquote_content; } // ===== INTEGRATIONS HOOKS ===== public function ays_chart_page_integrations_content( $args ){ if( ! $this->settings_obj->get_permission_for_editing_plugin() ){ $settings_url = __( "This functionality is disabled.", $this->plugin_name ); $blockquote_content = '
'. $settings_url .'
'; $this->blockquote_content = $blockquote_content; } $integrations_contents = apply_filters( 'ays_cb_chart_page_integrations_contents', array(), $args ); $integrations = array(); foreach ($integrations_contents as $key => $integrations_content) { $content = '
'; if(isset($integrations_content['title'])){ $content .= ''; if(isset($integrations_content['icon'])){ $content .= ''; } $content .= '
'. $integrations_content['title'] .'
'; } $content .= $integrations_content['content']; $content .= '
'; $integrations[] = $content; } echo implode('
', $integrations); } // Integrations settings page action hook public function ays_settings_page_integrations_content( $args ){ $integrations_contents = apply_filters( 'ays_cb_settings_page_integrations_contents', array(), $args ); $integrations = array(); foreach ($integrations_contents as $key => $integrations_content) { $content = '
'; if(isset($integrations_content['title'])){ $content .= ''; if(isset($integrations_content['icon'])){ $content .= ''; } $content .= '
'. $integrations_content['title'] .'
'; } if(isset($integrations_content['content'])){ $content .= $integrations_content['content']; } $content .= '
'; $integrations[] = $content; } echo implode('
', $integrations); } //////////////////////////////////////////////////////////////////////////////////////// //====================================================================================// //////////////////////////////////////////////////////////////////////////////////////// // ===== Google sheet starts ===== public function source_contents_import_from_google_sheet_settings( $sources, $args ){ $html_class_prefix = $args['html_class_prefix']; $html_name_prefix = $args['html_name_prefix']; ob_start(); ?>
plugin_name ) . ' plugin_name) . '"> '; $sources['google_sheet'] = array( 'content' => $content, 'title' => $title ); return $sources; } // Google sheet integration / settings page // Google sheet integration / settings page content public function ays_settings_page_google_sheet_content($integrations, $args){ $icon = CHART_BUILDER_ADMIN_URL . '/images/integrations/google_logo.png'; $title = __( 'Google', $this->plugin_name ); $content = '
'. __("Watch Video" , "chart-builder") .'
'. __("Upgrade", $this->plugin_name) .'

1. '. __("Turn on Your Google Sheet API", $this->plugin_name) .' https://console.developers.google.com

2. '. __("Create ", $this->plugin_name) .''. __("new Google Oauth client ID credentials (if you do not still have)", $this->plugin_name).'

3. '. __("Choose the application type as Web application", $this->plugin_name) .'

4. '. __("Add the following link in the Authorized redirect URIs field", $this->plugin_name) .'

Redirect url

5. '. __("Click on the Create button", $this->plugin_name) .'

6. '. __("Copy the Your Client ID and Your Client Secret from the opened popup and paste them in the corresponding fields.", $this->plugin_name) .'

7. '. __("Click on the Connect button to complete authorization", $this->plugin_name) .'



'; $integrations['google'] = array( 'content' => $content, 'icon' => $icon, 'title' => $title ); return $integrations; } // ===== Google sheet end ===== // ===== Database starts ===== // Database integration / settings page public function ays_settings_page_database_content($integrations, $args) { $actions = $this->settings_obj; // Database settings $databaseb_res = ($actions->get_setting('database') === false) ? json_encode(array()) : $actions->get_setting('database'); $db_settings = json_decode($databaseb_res, true); $db_host = isset($db_settings['host']) ? $db_settings['host'] : ''; $db_name = isset($db_settings['db_name']) ? $db_settings['db_name'] : ''; $db_user = isset($db_settings['user']) ? $db_settings['user'] : ''; $db_password = isset($db_settings['password']) ? openssl_decrypt(base64_decode($db_settings['password']), 'aes-256-cbc', SECURE_AUTH_KEY, 0, substr(md5(SECURE_AUTH_KEY), 0, 16)) : ''; $db_port = isset($db_settings['port']) ? $db_settings['port'] : '3306'; $nonce = wp_create_nonce('ays_test_database_nonce'); // Create the form content for database settings $content = '
'. __("Upgrade", $this->plugin_name) .'

' . __("IP Access:", $this->plugin_name) . '

'. __("In some cases, your database may block connections from unknown IP addresses. You might need to whitelist your IP in the database settings to allow access.", $this->plugin_name) .'

' . __("Database Host:", $this->plugin_name) . ' ' . __("Enter the address of your database (e.g., 'localhost', or a host like 'db.example.com').", $this->plugin_name) . '

' . __("Database Name:", $this->plugin_name) . ' ' . __("Enter the name of the database you want to connect to.", $this->plugin_name) . '

' . __("Database User:", $this->plugin_name) . ' ' . __("Enter the username for accessing the database.", $this->plugin_name) . '

' . __("Database Password:", $this->plugin_name) . ' ' . __("Enter the password for your database user. Make sure this is correct.", $this->plugin_name) . '

' . __("Database Port (Optional):", $this->plugin_name) . ' ' . __("The default MySQL port is '3306'. You can leave this field empty. If your host doesn't specify a port, we'll use the default value.", $this->plugin_name) . '

' . __("Test Connection:", $this->plugin_name) . ' ' . __("Click on the 'Test Connection' button to verify that the connection is successful.", $this->plugin_name) . '

' . __("If the test fails:", $this->plugin_name) . ' ' . __("Please recheck your details or verify if your IP address is whitelisted.", $this->plugin_name) . '






'; $icon = CHART_BUILDER_ADMIN_URL . '/images/integrations/database_logo.png'; $title = __( 'Database', $this->plugin_name ); $integrations['database'] = array( 'content' => $content, 'icon' => $icon, 'title' => $title ); return $integrations; } // ===== Database end ===== //////////////////////////////////////////////////////////////////////////////////////// //====================================================================================// //////////////////////////////////////////////////////////////////////////////////////// }