| @@ -1,12 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace BitCode\BitForm; |
| 4 | 4 | |
| 5 | -if (!defined('ABSPATH')) { | |
| 6 | - exit; | |
| 7 | -} | |
| 8 | - | |
| 9 | 5 | /** |
| 10 | 6 | * Main class for the plugin. |
| 11 | 7 | * |
| 12 | 8 | * @since 1.0.0-alpha |
| @@ -11,8 +7,10 @@ | ||
| 11 | 7 | * |
| 12 | 8 | * @since 1.0.0-alpha |
| 13 | 9 | */ |
| 14 | 10 | |
| 11 | +use BitCode\BitForm\BitApps\WPTelemetry\Telemetry\Telemetry; | |
| 12 | +use BitCode\BitForm\BitApps\WPTelemetry\Telemetry\TelemetryConfig; | |
| 15 | 13 | use BitCode\BitForm\Core\Database\DB; |
| 16 | 14 | use BitCode\BitForm\Core\Database\FormModel; |
| 17 | 15 | use BitCode\BitForm\Core\Fallback\FormFallback; |
| 18 | 16 | use BitCode\BitForm\Core\Hooks\Hooks; |
| @@ -18,9 +16,8 @@ | ||
| 18 | 16 | use BitCode\BitForm\Core\Hooks\Hooks; |
| 19 | 17 | use BitCode\BitForm\Core\Util\Activation; |
| 20 | 18 | use BitCode\BitForm\Core\Util\Deactivation; |
| 21 | 19 | use BitCode\BitForm\Core\Util\Uninstallation; |
| 22 | -use BitCode\BitForm\Widgets\RegisterBitFormElementorWidget; | |
| 23 | 20 | |
| 24 | 21 | final class Plugin |
| 25 | 22 | { |
| 26 | 23 | /** |
| @@ -38,12 +35,13 @@ | ||
| 38 | 35 | */ |
| 39 | 36 | public function register() |
| 40 | 37 | { |
| 41 | 38 | add_action('plugins_loaded', [$this, 'init_plugin']); |
| 42 | - // add_action('init', [$this, 'localization_setup']); | |
| 43 | 39 | (new Activation())->activate(); |
| 44 | 40 | (new Deactivation())->register(); |
| 45 | 41 | (new Uninstallation())->register(); |
| 42 | + | |
| 43 | + $this->initWpTelemetry(); | |
| 46 | 44 | } |
| 47 | 45 | |
| 48 | 46 | private function commaReplace($options, $lbl, $val) |
| 49 | 47 | { |
| @@ -108,9 +106,9 @@ | ||
| 108 | 106 | return; |
| 109 | 107 | } |
| 110 | 108 | |
| 111 | 109 | global $bitforms_db_version; |
| 112 | - $installed_db_version = get_option('bitforms_db_version'); | |
| 110 | + $installed_db_version = get_site_option('bitforms_db_version'); | |
| 113 | 111 | if ($installed_db_version !== $bitforms_db_version) { |
| 114 | 112 | DB::migrate(); |
| 115 | 113 | } |
| 116 | 114 | } |
| @@ -123,9 +121,8 @@ | ||
| 123 | 121 | * @return array |
| 124 | 122 | */ |
| 125 | 123 | public function init_plugin() |
| 126 | 124 | { |
| 127 | - $this->update_tables(); | |
| 128 | 125 | $currentBitFormVersion = BITFORMS_VERSION; |
| 129 | 126 | $installedBitFormVersion = get_option('bitforms_version'); |
| 130 | 127 | if ($currentBitFormVersion !== $installedBitFormVersion) { |
| 131 | 128 | (new FormFallback())->resetJsGeneratedPageIds(); |
| @@ -130,9 +127,9 @@ | ||
| 130 | 127 | if ($currentBitFormVersion !== $installedBitFormVersion) { |
| 131 | 128 | (new FormFallback())->resetJsGeneratedPageIds(); |
| 132 | 129 | } |
| 133 | 130 | Hooks::init_hooks(); |
| 134 | - $this->initWidgets(); | |
| 131 | + $this->update_tables(); | |
| 135 | 132 | do_action('bitform_loaded'); |
| 136 | 133 | } |
| 137 | 134 | |
| 138 | 135 | /** |
| @@ -148,9 +145,9 @@ | ||
| 148 | 145 | } |
| 149 | 146 | |
| 150 | 147 | public function plugin_action_links($links) |
| 151 | 148 | { |
| 152 | - $links[] = '<a href="https://bitapps.pro/docs/bit-form/" target="_blank">' . __('Docs', 'bit-form') . '</a>'; | |
| 149 | + $links[] = '<a href="https://bitapps.pro/docs/bit-form/" target="_blank">' . __('Docs') . '</a>'; | |
| 153 | 150 | |
| 154 | 151 | return $links; |
| 155 | 152 | } |
| 156 | 153 | |
| @@ -171,16 +168,19 @@ | ||
| 171 | 168 | static::$instance->register(); |
| 172 | 169 | return true; |
| 173 | 170 | } |
| 174 | 171 | |
| 175 | - private function initWidgets() | |
| 172 | + private function initWpTelemetry() | |
| 176 | 173 | { |
| 177 | - if (defined('ELEMENTOR_VERSION')) { | |
| 178 | - new RegisterBitFormElementorWidget(); | |
| 179 | - } | |
| 174 | + TelemetryConfig::setSlug(Config::SLUG); | |
| 175 | + TelemetryConfig::setTitle(Config::TITLE); | |
| 176 | + TelemetryConfig::setVersion(Config::VERSION); | |
| 177 | + TelemetryConfig::setPrefix(Config::VAR_PREFIX); | |
| 178 | + | |
| 179 | + TelemetryConfig::setServerBaseUrl('https://wp-api.bitapps.pro/public/'); | |
| 180 | + TelemetryConfig::setTermsUrl('https://bitapps.pro/terms-of-service/'); | |
| 181 | + TelemetryConfig::setPolicyUrl('https://bitapps.pro/privacy-policy/'); | |
| 182 | + | |
| 183 | + Telemetry::report()->addPluginData()->init(); | |
| 184 | + Telemetry::feedback()->init(); | |
| 180 | 185 | } |
| 181 | - | |
| 182 | - // public function localization_setup() | |
| 183 | - // { | |
| 184 | - // // load_plugin_textdomain('bit-form', false, dirname(BITFORMS_PLUGIN_BASENAME) . '/languages'); | |
| 185 | - // } | |
| 186 | 186 | } |