| @@ -6,100 +6,8 @@ | ||
| 6 | 6 | * @author ConvertKit |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | - * Runs the activation and update routines when the plugin is activated. | |
| 11 | - * | |
| 12 | - * @since 1.9.7.4 | |
| 13 | - * | |
| 14 | - * @param bool $network_wide Is network wide activation. | |
| 15 | - */ | |
| 16 | -function convertkit_plugin_activate( $network_wide ) { | |
| 17 | - | |
| 18 | - // Initialise Plugin. | |
| 19 | - $convertkit = WP_ConvertKit(); | |
| 20 | - | |
| 21 | - // Check if we are on a multisite install, activating network wide, or a single install. | |
| 22 | - if ( ! is_multisite() || ! $network_wide ) { | |
| 23 | - // Single Site activation. | |
| 24 | - $convertkit->get_class( 'setup' )->activate(); | |
| 25 | - | |
| 26 | - // Set a transient for 30 seconds to redirect to the setup screen on activation. | |
| 27 | - set_transient( 'convertkit-setup', true, 30 ); | |
| 28 | - } else { | |
| 29 | - // Multisite network wide activation. | |
| 30 | - $sites = get_sites( | |
| 31 | - array( | |
| 32 | - 'number' => 0, | |
| 33 | - ) | |
| 34 | - ); | |
| 35 | - foreach ( $sites as $site ) { | |
| 36 | - switch_to_blog( (int) $site->blog_id ); | |
| 37 | - $convertkit->get_class( 'setup' )->activate(); | |
| 38 | - restore_current_blog(); | |
| 39 | - } | |
| 40 | - } | |
| 41 | - | |
| 42 | -} | |
| 43 | - | |
| 44 | -/** | |
| 45 | - * Runs the activation and update routines when the plugin is activated | |
| 46 | - * on a WordPress multisite setup. | |
| 47 | - * | |
| 48 | - * @since 1.9.7.4 | |
| 49 | - * | |
| 50 | - * @param WP_Site|int $site_or_blog_id WP_Site or Blog ID. | |
| 51 | - */ | |
| 52 | -function convertkit_plugin_activate_new_site( $site_or_blog_id ) { | |
| 53 | - | |
| 54 | - // Check if $site_or_blog_id is a WP_Site or a blog ID. | |
| 55 | - if ( is_a( $site_or_blog_id, 'WP_Site' ) ) { | |
| 56 | - $site_or_blog_id = $site_or_blog_id->blog_id; | |
| 57 | - } | |
| 58 | - | |
| 59 | - // Initialise Plugin. | |
| 60 | - $convertkit = WP_ConvertKit(); | |
| 61 | - | |
| 62 | - // Run installation routine. | |
| 63 | - switch_to_blog( $site_or_blog_id ); | |
| 64 | - $convertkit->get_class( 'setup' )->activate(); | |
| 65 | - restore_current_blog(); | |
| 66 | - | |
| 67 | -} | |
| 68 | - | |
| 69 | -/** | |
| 70 | - * Runs the deactivation routine when the plugin is deactivated. | |
| 71 | - * | |
| 72 | - * @since 1.9.7.4 | |
| 73 | - * | |
| 74 | - * @param bool $network_wide Is network wide deactivation. | |
| 75 | - */ | |
| 76 | -function convertkit_plugin_deactivate( $network_wide ) { | |
| 77 | - | |
| 78 | - // Initialise Plugin. | |
| 79 | - $convertkit = WP_ConvertKit(); | |
| 80 | - | |
| 81 | - // Check if we are on a multisite install, activating network wide, or a single install. | |
| 82 | - if ( ! is_multisite() || ! $network_wide ) { | |
| 83 | - // Single Site activation. | |
| 84 | - $convertkit->get_class( 'setup' )->deactivate(); | |
| 85 | - } else { | |
| 86 | - // Multisite network wide activation. | |
| 87 | - $sites = get_sites( | |
| 88 | - array( | |
| 89 | - 'number' => 0, | |
| 90 | - ) | |
| 91 | - ); | |
| 92 | - foreach ( $sites as $site ) { | |
| 93 | - switch_to_blog( (int) $site->blog_id ); | |
| 94 | - $convertkit->get_class( 'setup' )->deactivate(); | |
| 95 | - restore_current_blog(); | |
| 96 | - } | |
| 97 | - } | |
| 98 | - | |
| 99 | -} | |
| 100 | - | |
| 101 | -/** | |
| 102 | 10 | * Helper method to get supported Post Types. |
| 103 | 11 | * |
| 104 | 12 | * @since 1.9.6 |
| 105 | 13 | * |
| @@ -125,34 +33,8 @@ | ||
| 125 | 33 | |
| 126 | 34 | } |
| 127 | 35 | |
| 128 | 36 | /** |
| 129 | - * Helper method to get supported Post Types for Restricted Content (Member's Content) | |
| 130 | - * | |
| 131 | - * @since 2.1.0 | |
| 132 | - * | |
| 133 | - * @return array Post Types | |
| 134 | - */ | |
| 135 | -function convertkit_get_supported_restrict_content_post_types() { | |
| 136 | - | |
| 137 | - $post_types = array( | |
| 138 | - 'page', | |
| 139 | - ); | |
| 140 | - | |
| 141 | - /** | |
| 142 | - * Defines the Post Types that support Restricted Content / Members Content functionality. | |
| 143 | - * | |
| 144 | - * @since 2.0.0 | |
| 145 | - * | |
| 146 | - * @param array $post_types Post Types | |
| 147 | - */ | |
| 148 | - $post_types = apply_filters( 'convertkit_get_supported_restrict_content_post_types', $post_types ); | |
| 149 | - | |
| 150 | - return $post_types; | |
| 151 | - | |
| 152 | -} | |
| 153 | - | |
| 154 | -/** | |
| 155 | 37 | * Helper method to get registered Shortcodes. |
| 156 | 38 | * |
| 157 | 39 | * @since 1.9.6.5 |
| 158 | 40 | * |
| @@ -199,32 +81,8 @@ | ||
| 199 | 81 | |
| 200 | 82 | } |
| 201 | 83 | |
| 202 | 84 | /** |
| 203 | - * Helper method to get registered Block formatters for Gutenberg. | |
| 204 | - * | |
| 205 | - * @since 2.2.0 | |
| 206 | - * | |
| 207 | - * @return array Block formatters | |
| 208 | - */ | |
| 209 | -function convertkit_get_block_formatters() { | |
| 210 | - | |
| 211 | - $block_formatters = array(); | |
| 212 | - | |
| 213 | - /** | |
| 214 | - * Registers block formatters in Gutenberg for the ConvertKit Plugin. | |
| 215 | - * | |
| 216 | - * @since 2.2.0 | |
| 217 | - * | |
| 218 | - * @param array $block_formatters Block formatters. | |
| 219 | - */ | |
| 220 | - $block_formatters = apply_filters( 'convertkit_get_block_formatters', $block_formatters ); | |
| 221 | - | |
| 222 | - return $block_formatters; | |
| 223 | - | |
| 224 | -} | |
| 225 | - | |
| 226 | -/** | |
| 227 | 85 | * Helper method to return the Plugin Settings Link |
| 228 | 86 | * |
| 229 | 87 | * @since 1.9.6 |
| 230 | 88 | * |
| @@ -244,49 +102,8 @@ | ||
| 244 | 102 | |
| 245 | 103 | } |
| 246 | 104 | |
| 247 | 105 | /** |
| 248 | - * Helper method to return the Plugin Settings Link | |
| 249 | - * | |
| 250 | - * @since 2.2.4 | |
| 251 | - * | |
| 252 | - * @param array $query_args Optional Query Args. | |
| 253 | - * @return string Settings Link | |
| 254 | - */ | |
| 255 | -function convertkit_get_setup_wizard_plugin_link( $query_args = array() ) { | |
| 256 | - | |
| 257 | - $query_args = array_merge( | |
| 258 | - $query_args, | |
| 259 | - array( | |
| 260 | - 'page' => 'convertkit-setup', | |
| 261 | - ) | |
| 262 | - ); | |
| 263 | - | |
| 264 | - return add_query_arg( $query_args, admin_url( 'index.php' ) ); | |
| 265 | - | |
| 266 | -} | |
| 267 | - | |
| 268 | -/** | |
| 269 | - * Helper method to return the URL the user needs to visit to register a ConvertKit account. | |
| 270 | - * | |
| 271 | - * @since 1.9.8.4 | |
| 272 | - * | |
| 273 | - * @return string ConvertKit Registration URL. | |
| 274 | - */ | |
| 275 | -function convertkit_get_registration_url() { | |
| 276 | - | |
| 277 | - return add_query_arg( | |
| 278 | - array( | |
| 279 | - 'utm_source' => 'wordpress', | |
| 280 | - 'utm_term' => get_locale(), | |
| 281 | - 'utm_content' => 'convertkit', | |
| 282 | - ), | |
| 283 | - 'https://app.convertkit.com/users/signup' | |
| 284 | - ); | |
| 285 | - | |
| 286 | -} | |
| 287 | - | |
| 288 | -/** | |
| 289 | 106 | * Helper method to return the URL the user needs to visit to sign in to their ConvertKit account. |
| 290 | 107 | * |
| 291 | 108 | * @since 1.9.6.1 |
| 292 | 109 | * |
| @@ -293,40 +110,13 @@ | ||
| 293 | 110 | * @return string ConvertKit Login URL. |
| 294 | 111 | */ |
| 295 | 112 | function convertkit_get_sign_in_url() { |
| 296 | 113 | |
| 297 | - return add_query_arg( | |
| 298 | - array( | |
| 299 | - 'utm_source' => 'wordpress', | |
| 300 | - 'utm_term' => get_locale(), | |
| 301 | - 'utm_content' => 'convertkit', | |
| 302 | - ), | |
| 303 | - 'https://app.convertkit.com/' | |
| 304 | - ); | |
| 114 | + return 'https://app.convertkit.com/?utm_source=wordpress&utm_content=convertkit'; | |
| 305 | 115 | |
| 306 | 116 | } |
| 307 | 117 | |
| 308 | 118 | /** |
| 309 | - * Helper method to return the URL the user needs to visit to manage thier billing. | |
| 310 | - * | |
| 311 | - * @since 2.2.7 | |
| 312 | - * | |
| 313 | - * @return string ConvertKit Billing URL. | |
| 314 | - */ | |
| 315 | -function convertkit_get_billing_url() { | |
| 316 | - | |
| 317 | - return add_query_arg( | |
| 318 | - array( | |
| 319 | - 'utm_source' => 'wordpress', | |
| 320 | - 'utm_term' => get_locale(), | |
| 321 | - 'utm_content' => 'convertkit', | |
| 322 | - ), | |
| 323 | - 'https://app.convertkit.com/account_settings/billing/' | |
| 324 | - ); | |
| 325 | - | |
| 326 | -} | |
| 327 | - | |
| 328 | -/** | |
| 329 | 119 | * Helper method to return the URL the user needs to visit on the ConvertKit app to obtain their API Key and Secret. |
| 330 | 120 | * |
| 331 | 121 | * @since 1.9.6.1 |
| 332 | 122 | * |
| @@ -333,100 +123,13 @@ | ||
| 333 | 123 | * @return string ConvertKit App URL. |
| 334 | 124 | */ |
| 335 | 125 | function convertkit_get_api_key_url() { |
| 336 | 126 | |
| 337 | - return add_query_arg( | |
| 338 | - array( | |
| 339 | - 'utm_source' => 'wordpress', | |
| 340 | - 'utm_term' => get_locale(), | |
| 341 | - 'utm_content' => 'convertkit', | |
| 342 | - ), | |
| 343 | - 'https://app.convertkit.com/account_settings/advanced_settings/' | |
| 344 | - ); | |
| 127 | + return 'https://app.convertkit.com/account_settings/advanced_settings/?utm_source=wordpress&utm_content=convertkit'; | |
| 345 | 128 | |
| 346 | 129 | } |
| 347 | 130 | |
| 348 | 131 | /** |
| 349 | - * Helper method to return the URL the user needs to visit on the ConvertKit app to create a new Form or Landing Page. | |
| 350 | - * | |
| 351 | - * @since 2.2.3 | |
| 352 | - * | |
| 353 | - * @return string ConvertKit App URL | |
| 354 | - */ | |
| 355 | -function convertkit_get_new_form_url() { | |
| 356 | - | |
| 357 | - return add_query_arg( | |
| 358 | - array( | |
| 359 | - 'utm_source' => 'wordpress', | |
| 360 | - 'utm_term' => get_locale(), | |
| 361 | - 'utm_content' => 'convertkit', | |
| 362 | - ), | |
| 363 | - 'https://app.convertkit.com/forms/new/' | |
| 364 | - ); | |
| 365 | - | |
| 366 | -} | |
| 367 | - | |
| 368 | -/** | |
| 369 | - * Helper method to return the URL the user needs to visit to edit ConvertKit forms. | |
| 370 | - * | |
| 371 | - * @since 2.2.3 | |
| 372 | - * | |
| 373 | - * @return string ConvertKit Form Editor URL. | |
| 374 | - */ | |
| 375 | -function convertkit_get_form_editor_url() { | |
| 376 | - | |
| 377 | - return add_query_arg( | |
| 378 | - array( | |
| 379 | - 'utm_source' => 'wordpress', | |
| 380 | - 'utm_term' => get_locale(), | |
| 381 | - 'utm_content' => 'convertkit', | |
| 382 | - ), | |
| 383 | - 'https://app.convertkit.com/forms' | |
| 384 | - ); | |
| 385 | - | |
| 386 | -} | |
| 387 | - | |
| 388 | -/** | |
| 389 | - * Helper method to return the URL the user needs to visit on the ConvertKit app to create a new Broadcast. | |
| 390 | - * | |
| 391 | - * @since 2.2.6 | |
| 392 | - * | |
| 393 | - * @return string ConvertKit App URL. | |
| 394 | - */ | |
| 395 | -function convertkit_get_new_broadcast_url() { | |
| 396 | - | |
| 397 | - return add_query_arg( | |
| 398 | - array( | |
| 399 | - 'utm_source' => 'wordpress', | |
| 400 | - 'utm_term' => get_locale(), | |
| 401 | - 'utm_content' => 'convertkit', | |
| 402 | - ), | |
| 403 | - 'https://app.convertkit.com/campaigns/' | |
| 404 | - ); | |
| 405 | - | |
| 406 | -} | |
| 407 | - | |
| 408 | -/** | |
| 409 | - * Helper method to return the URL the user needs to visit on the ConvertKit app to create a new Product. | |
| 410 | - * | |
| 411 | - * @since 2.2.3 | |
| 412 | - * | |
| 413 | - * @return string ConvertKit App URL. | |
| 414 | - */ | |
| 415 | -function convertkit_get_new_product_url() { | |
| 416 | - | |
| 417 | - return add_query_arg( | |
| 418 | - array( | |
| 419 | - 'utm_source' => 'wordpress', | |
| 420 | - 'utm_term' => get_locale(), | |
| 421 | - 'utm_content' => 'convertkit', | |
| 422 | - ), | |
| 423 | - 'https://app.convertkit.com/products/new/' | |
| 424 | - ); | |
| 425 | - | |
| 426 | -} | |
| 427 | - | |
| 428 | -/** | |
| 429 | 132 | * Helper method to enqueue Select2 scripts for use within the ConvertKit Plugin. |
| 430 | 133 | * |
| 431 | 134 | * @since 1.9.6.4 |
| 432 | 135 | */ |
| @@ -432,9 +135,9 @@ | ||
| 432 | 135 | */ |
| 433 | 136 | function convertkit_select2_enqueue_scripts() { |
| 434 | 137 | |
| 435 | 138 | wp_enqueue_script( 'convertkit-select2', 'https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js', array( 'jquery' ), CONVERTKIT_PLUGIN_VERSION, false ); |
| 436 | - wp_enqueue_script( 'convertkit-admin-select2', CONVERTKIT_PLUGIN_URL . 'resources/backend/js/select2.js', array( 'convertkit-select2' ), CONVERTKIT_PLUGIN_VERSION, false ); | |
| 139 | + wp_enqueue_script( 'convertkit-admin-select2', CONVERTKIT_PLUGIN_URL . '/resources/backend/js/select2.js', array( 'convertkit-select2' ), CONVERTKIT_PLUGIN_VERSION, false ); | |
| 437 | 140 | |
| 438 | 141 | } |
| 439 | 142 | |
| 440 | 143 | /** |
| @@ -444,35 +147,7 @@ | ||
| 444 | 147 | */ |
| 445 | 148 | function convertkit_select2_enqueue_styles() { |
| 446 | 149 | |
| 447 | 150 | wp_enqueue_style( 'convertkit-select2', 'https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css', array(), CONVERTKIT_PLUGIN_VERSION ); |
| 448 | - wp_enqueue_style( 'convertkit-admin-select2', CONVERTKIT_PLUGIN_URL . 'resources/backend/css/select2.css', array(), CONVERTKIT_PLUGIN_VERSION ); | |
| 449 | - | |
| 450 | -} | |
| 451 | - | |
| 452 | -/** | |
| 453 | - * Return the contents of the given local file. | |
| 454 | - * | |
| 455 | - * @since 2.2.2 | |
| 456 | - * | |
| 457 | - * @param string $local_file Local file, including path. | |
| 458 | - * @return string File contents. | |
| 459 | - */ | |
| 460 | -function convertkit_get_file_contents( $local_file ) { | |
| 461 | - | |
| 462 | - // Bail if the file doesn't exist. | |
| 463 | - if ( ! file_exists( $local_file ) ) { | |
| 464 | - return ''; | |
| 465 | - } | |
| 466 | - | |
| 467 | - // Read file. | |
| 468 | - $contents = file_get_contents( $local_file ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents | |
| 469 | - | |
| 470 | - // Return an empty string if the contents of the file could not be read. | |
| 471 | - if ( ! $contents ) { | |
| 472 | - return ''; | |
| 473 | - } | |
| 474 | - | |
| 475 | - // Return file's contents. | |
| 476 | - return $contents; | |
| 151 | + wp_enqueue_style( 'convertkit-admin-select2', CONVERTKIT_PLUGIN_URL . '/resources/backend/css/select2.css', array(), CONVERTKIT_PLUGIN_VERSION ); | |
| 477 | 152 | |
| 478 | 153 | } |