setModule( Visualizer_Module_Utility::NAME ); $plugin->setModule( Visualizer_Module_Setup::NAME ); $plugin->setModule( Visualizer_Module_Sources::NAME ); $plugin->setModule( Visualizer_Module_Chart::NAME ); if ( is_admin() || defined( 'WP_TESTS_DOMAIN' ) ) { // set admin modules $plugin->setModule( Visualizer_Module_Admin::NAME ); } // set frontend modules $plugin->setModule( Visualizer_Module_Frontend::NAME ); $plugin->setModule( Visualizer_Module_AMP::NAME ); // Set setup wizard module. $plugin->setModule( Visualizer_Module_Wizard::NAME ); // AI Chart Builder module (AJAX endpoints for the React wizard). $plugin->setModule( Visualizer_Module_AIBuilder::NAME ); // Abilities API integration (no-op when the API is not available). $plugin->setModule( Visualizer_Module_Abilities::NAME ); $vendor_file = VISUALIZER_ABSPATH . '/vendor/autoload.php'; if ( is_readable( $vendor_file ) ) { include_once $vendor_file; } $action_scheduler_file = VISUALIZER_ABSPATH . '/vendor/woocommerce/action-scheduler/action-scheduler.php'; if ( visualizer_can_use_action_scheduler() && is_readable( $action_scheduler_file ) ) { require_once $action_scheduler_file; } add_filter( 'themeisle_sdk_products', 'visualizer_register_sdk', 10, 1 ); add_filter( 'pirate_parrot_log', 'visualizer_register_parrot', 10, 1 ); add_filter( 'themeisle_sdk_compatibilities/' . VISUALIZER_DIRNAME, function ( $compatibilities ) { $compatibilities['VisualizerPRO'] = array( 'basefile' => defined( 'VISUALIZER_PRO_BASEFILE' ) ? VISUALIZER_PRO_BASEFILE : '', 'required' => '1.8', 'tested_up' => '2.0', ); return $compatibilities; } ); add_filter( 'visualizer_about_us_metadata', function () { return array( 'logo' => esc_url( VISUALIZER_ABSURL . 'images/visualizer-logo.svg' ), 'location' => 'visualizer', 'has_upgrade_menu' => ! Visualizer_Module::is_pro(), 'upgrade_text' => esc_html__( 'Get Visualizer Pro', 'visualizer' ), 'upgrade_link' => esc_url( tsdk_utmify( Visualizer_Plugin::PRO_TEASER_URL, 'sidebarMenuUpgrade', 'index' ) ), ); } ); add_filter( 'visualizer_ai_connect_metadata', function () { return array( 'name' => 'Visualizer', 'notice_cases' => array( __( 'build a chart from your numbers', 'visualizer' ), __( 'update a table with new data', 'visualizer' ), __( 'refresh charts from their data source', 'visualizer' ), ), 'prompts' => array( __( 'Create a Visualizer pie chart "Traffic by channel" with Organic 5400, Direct 2100 and Social 1300, and add it to my Analytics page.', 'visualizer' ), __( 'Refresh every chart that pulls from a remote CSV, JSON or database source.', 'visualizer' ), __( 'Change my "Monthly sales" chart to a bar chart and add September: 12,400.', 'visualizer' ), ), 'ability_prefix' => 'visualizer', ); } ); if ( ! defined( 'TI_E2E_TESTING' ) && 'yes' === get_option( 'visualizer_logger_flag', 'no' ) ) { add_filter( 'themeisle_sdk_enable_telemetry', '__return_true' ); add_filter( 'themeisle_sdk_telemetry_products', function ( $products ) { $already_registered = false; $license = get_option( 'visualizer_pro_license_data', 'free' ); if ( ! empty( $license ) && is_object( $license ) ) { $license = $license->key ?? 'free'; } $track_hash = 'free' === $license ? 'free' : wp_hash( $license ); foreach ( $products as &$product ) { if ( strstr( $product['slug'], 'visualizer' ) !== false ) { $already_registered = true; $product['trackHash'] = $track_hash; } } if ( $already_registered ) { return $products; } // Add Visualizer to the list of products to track the usage of AI Block. $products[] = array( 'slug' => 'visualizer', 'consent' => 'yes' === get_option( 'visualizer_logger_flag', 'no' ), 'trackHash' => $track_hash, ); return $products; } ); } } /** * Whether the bundled Action Scheduler can run against this wpdb. * * The bundled library calls wpdb::db_server_info() unguarded when it claims a * queue batch, and core only added that method in WordPress 5.5. Loading it * without the method available fatals, so those sites stay on WP-Cron instead. * * @return bool */ function visualizer_can_use_action_scheduler() { global $wpdb; return isset( $wpdb ) && is_callable( array( $wpdb, 'db_server_info' ) ); } /** * Registers with the SDK * * @since 1.0.0 */ function visualizer_register_sdk( $products ) { $products[] = VISUALIZER_BASEFILE; return $products; } /** * Registers with the parrot plugin * * @since 1.0.0 */ function visualizer_register_parrot( $plugins ) { $plugins[] = Visualizer_Plugin::NAME; return $plugins; } // register autoloader function spl_autoload_register( 'visualizer_autoloader' ); // launch the plugin visualizer_launch(); if ( VISUALIZER_LOCAL_DEBUG ) { add_action( 'themeisle_log_event', 'visualizer_themeisle_log_event', 10, 5 ); /** * Redirect themeisle_log_event to error log. */ function visualizer_themeisle_log_event( $name, $msg, $type, $file, $line ) { if ( $name === Visualizer_Plugin::NAME ) { error_log( sprintf( '%s (%s:%d): %s', $type, $file, $line, $msg ) ); } } }