install( $download_link ); return (bool) $result; } /** * Activate a plugin by slug. * * @param string $slug The slug of the plugin. * * @return bool True if activated, false otherwise. */ public static function activate_plugin( string $slug ): bool { if ( ! self::is_installed( $slug ) ) { return false; // Plugin isn't installed } $plugin_path = self::get_plugin_path( $slug ); $result = activate_plugin( $plugin_path ); if ( is_wp_error( $result ) ) { return $result; } return true; } /** * Deactivate a plugin by slug. * * @param string $slug The slug of the plugin. * * @return bool True if deactivated, false otherwise. */ public static function deactivate_plugin( string $slug ) { if ( ! self::is_activated( $slug ) ) { return false; // Plugin isn't activated } $plugin_path = self::get_plugin_path( $slug ); deactivate_plugins( $plugin_path ); return true; } /** * Get the plugin path by slug. * * @param string $slug The slug of the plugin. * * @return string The path to the plugin file. */ private static function get_plugin_path( string $slug ) { $plugins = get_plugins(); if ( is_array( $plugins ) ) { foreach ( $plugins as $plugin_path => $plugin ) { if ( $plugin['TextDomain'] === $slug ) { return $plugin_path; } } } return false; } /** * Check if the provided file is the main plugin file. * * @param string $file Path to the file. * * @return bool True if it is the main plugin file, false otherwise. */ private static function is_main_plugin_file( string $file ): bool { $plugin_data = get_file_data( $file, array( 'Name' => 'Plugin Name' ) ); return ! empty( $plugin_data['Name'] ); } /** * Get the plugin name by slug. * * @param string $slug Plugin slug (e.g., 'woocommerce). * * @return string|null Returns the plugin name if found, or null if not found. */ public static function get_plugin_name_by_slug( string $slug ) { if ( ! function_exists( 'get_plugins' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $all_plugins = get_plugins(); foreach ( $all_plugins as $plugin_file => $plugin_data ) { if ( strpos( $plugin_file, $slug ) !== false ) { return $plugin_data['Name']; } } return null; } /** * List of all extensions * * @return array */ public static function extensions(): array { return array( 'booktics-stripe-addon' => array( 'name' => 'booktics-stripe-addon', 'slug' => 'booktics-stripe-addon', 'type' => 'addon', 'upgrade' => true, 'upgrade_link' => 'https://themewinter.com/purchase-history', 'status' => 'off', 'is_pro' => false, 'title' => __( 'Booktics Stripe Addon', 'booktics' ), 'description' => __( 'It allows you to use stripe payment.', 'booktics' ), 'icon' => Extension_Icon::get( 'booktics-stripe-addon' ), 'notice' => '', 'demo_link' => 'https://support.themewinter.com/docs/plugins/plugin-docs/integration/booktics-stripe-addon', 'settings_link' => '', 'doc_link' => 'https://support.themewinter.com/docs/plugins/plugin-docs/integration/booktics-stripe-addon', 'download_link' => 'https://products.arraytics.com/booktics-addons/booktics-stripe-addon-1.0.0.zip', ), 'booktics-google-calendar' => array( 'name' => 'booktics-google-calendar', 'slug' => 'booktics-google-calendar', 'type' => 'addon', 'upgrade' => true, 'upgrade_link' => 'https://themewinter.com/purchase-history', 'status' => 'off', 'is_pro' => false, 'title' => __( 'Booktics Google Calendar', 'booktics' ), 'description' => __( 'It allows you to use google calendar.', 'booktics' ), 'icon' => Extension_Icon::get( 'booktics-google-calendar' ), 'notice' => '', 'demo_link' => 'https://support.themewinter.com/docs/plugins/plugin-docs/integration/booktics-google-calendar', 'settings_link' => '', 'doc_link' => 'https://support.themewinter.com/docs/plugins/plugin-docs/integration/booktics-google-calendar', 'download_link' => 'https://products.arraytics.com/booktics-addons/booktics-google-calendar-1.0.0.zip', ), 'booktics-outlook-calendar' => array( 'name' => 'booktics-outlook-calendar', 'slug' => 'booktics-outlook-calendar', 'type' => 'addon', 'upgrade' => true, 'upgrade_link' => 'https://themewinter.com/purchase-history', 'status' => 'off', 'is_pro' => false, 'title' => __( 'Booktics Outlook Calendar', 'booktics' ), 'description' => __( 'It allows you to use outlook calendar.', 'booktics' ), 'icon' => Extension_Icon::get( 'booktics-outlook-calendar' ), 'notice' => '', 'demo_link' => 'https://support.themewinter.com/docs/plugins/plugin-docs/integration/booktics-outlook-calendar-addon', 'settings_link' => '', 'doc_link' => 'https://support.themewinter.com/docs/plugins/plugin-docs/integration/booktics-outlook-calendar-addon', 'download_link' => 'https://products.arraytics.com/booktics-addons/booktics-outlook-calendar-addon-1.0.0.zip', ), 'booktics-fluentcrm-addon' => array( 'name' => 'booktics-fluentcrm-addon', 'slug' => 'booktics-fluentcrm-addon', 'type' => 'addon', 'upgrade' => true, 'upgrade_link' => 'https://themewinter.com/purchase-history', 'status' => 'off', 'is_pro' => false, 'title' => __( 'Booktics FluentCRM Addon', 'booktics' ), 'description' => __( 'It allows you to use FluentCRM.', 'booktics' ), 'icon' => Extension_Icon::get( 'booktics-fluentcrm-addon' ), 'notice' => '', 'demo_link' => 'https://support.themewinter.com/docs/plugins/plugin-docs/integration/booktics-fluentcrm-addon', 'settings_link' => '', 'doc_link' => 'https://support.themewinter.com/docs/plugins/plugin-docs/integration/booktics-fluentcrm-addon', 'download_link' => 'https://products.arraytics.com/booktics-addons/booktics-fluentcrm-addon-1.0.0.zip', ), 'booktics-paypal-addon' => array( 'name' => 'booktics-paypal-addon', 'slug' => 'booktics-paypal-addon', 'type' => 'addon', 'upgrade' => true, 'upgrade_link' => 'https://themewinter.com/purchase-history', 'status' => 'off', 'is_pro' => false, 'title' => __( 'Booktics PayPal Addon', 'booktics' ), 'description' => __( 'It allows you to use PayPal.', 'booktics' ), 'icon' => Extension_Icon::get( 'booktics-paypal-addon' ), 'notice' => '', 'demo_link' => 'https://support.themewinter.com/docs/plugins/plugin-docs/integration/booktics-paypal-addon', 'settings_link' => '', 'doc_link' => 'https://support.themewinter.com/docs/plugins/plugin-docs/integration/booktics-paypal-addon', 'download_link' => 'https://products.arraytics.com/booktics-addons/booktics-paypal-addon-1.0.0.zip', ), ); } }