| @@ -234,32 +234,8 @@ | ||
| 234 | 234 | |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | /** |
| 238 | - * Helper method to get registered plugin sidebars. | |
| 239 | - * | |
| 240 | - * @since 3.3.0 | |
| 241 | - * | |
| 242 | - * @return array Plugin sidebars | |
| 243 | - */ | |
| 244 | -function convertkit_get_plugin_sidebars() { | |
| 245 | - | |
| 246 | - $plugin_sidebars = array(); | |
| 247 | - | |
| 248 | - /** | |
| 249 | - * Registers plugin sidebars for the WordPress block editor. | |
| 250 | - * | |
| 251 | - * @since 3.3.0 | |
| 252 | - * | |
| 253 | - * @param array $plugin_sidebars Plugin sidebars. | |
| 254 | - */ | |
| 255 | - $plugin_sidebars = apply_filters( 'convertkit_plugin_sidebars', $plugin_sidebars ); | |
| 256 | - | |
| 257 | - return $plugin_sidebars; | |
| 258 | - | |
| 259 | -} | |
| 260 | - | |
| 261 | -/** | |
| 262 | 238 | * Helper method to get registered pre-publish actions. |
| 263 | 239 | * |
| 264 | 240 | * @since 2.4.0 |
| 265 | 241 | * |
| @@ -282,33 +258,8 @@ | ||
| 282 | 258 | |
| 283 | 259 | } |
| 284 | 260 | |
| 285 | 261 | /** |
| 286 | - * Helper method to get registered importers that can replace third party | |
| 287 | - * form shortcodes and blocks with Kit form shortcodes and blocks. | |
| 288 | - * | |
| 289 | - * @since 3.1.7 | |
| 290 | - * | |
| 291 | - * @return array Importers. | |
| 292 | - */ | |
| 293 | -function convertkit_get_form_importers() { | |
| 294 | - | |
| 295 | - $importers = array(); | |
| 296 | - | |
| 297 | - /** | |
| 298 | - * Registers form importers for the ConvertKit Plugin. | |
| 299 | - * | |
| 300 | - * @since 3.1.7 | |
| 301 | - * | |
| 302 | - * @param array $importers Importers. | |
| 303 | - */ | |
| 304 | - $importers = apply_filters( 'convertkit_get_form_importers', $importers ); | |
| 305 | - | |
| 306 | - return $importers; | |
| 307 | - | |
| 308 | -} | |
| 309 | - | |
| 310 | -/** | |
| 311 | 262 | * Helper method to return the Plugin Settings Link |
| 312 | 263 | * |
| 313 | 264 | * @since 1.9.6 |
| 314 | 265 | * |
| @@ -553,36 +504,8 @@ | ||
| 553 | 504 | |
| 554 | 505 | } |
| 555 | 506 | |
| 556 | 507 | /** |
| 557 | - * Helper method to enqueue the frontend CSS file. | |
| 558 | - * | |
| 559 | - * @since 3.2.0 | |
| 560 | - */ | |
| 561 | -function convertkit_enqueue_frontend_css() { | |
| 562 | - | |
| 563 | - wp_enqueue_style( 'convertkit-frontend', CONVERTKIT_PLUGIN_URL . 'resources/frontend/css/frontend.css', array(), CONVERTKIT_PLUGIN_VERSION ); | |
| 564 | - | |
| 565 | -} | |
| 566 | - | |
| 567 | -/** | |
| 568 | - * Helper method to enqueue the frontend JS file. | |
| 569 | - * | |
| 570 | - * @since 3.2.0 | |
| 571 | - */ | |
| 572 | -function convertkit_enqueue_frontend_js() { | |
| 573 | - | |
| 574 | - wp_enqueue_script( | |
| 575 | - 'convertkit-js', | |
| 576 | - CONVERTKIT_PLUGIN_URL . 'resources/frontend/js/dist/frontend.min.js', | |
| 577 | - array(), | |
| 578 | - CONVERTKIT_PLUGIN_VERSION, | |
| 579 | - true | |
| 580 | - ); | |
| 581 | - | |
| 582 | -} | |
| 583 | - | |
| 584 | -/** | |
| 585 | 508 | * Helper method to enqueue Select2 scripts for use within the ConvertKit Plugin. |
| 586 | 509 | * |
| 587 | 510 | * @since 1.9.6.4 |
| 588 | 511 | */ |
| @@ -718,34 +641,8 @@ | ||
| 718 | 641 | |
| 719 | 642 | } |
| 720 | 643 | |
| 721 | 644 | /** |
| 722 | - * Checks if the given Theme is active. | |
| 723 | - * | |
| 724 | - * @since 3.1.4 | |
| 725 | - * | |
| 726 | - * @param string $theme_name Theme name. | |
| 727 | - * @return bool | |
| 728 | - */ | |
| 729 | -function convertkit_is_theme_active( $theme_name ) { | |
| 730 | - | |
| 731 | - // Assume Theme isn't active if we can't detect it. | |
| 732 | - if ( ! function_exists( 'wp_get_theme' ) ) { | |
| 733 | - return false; | |
| 734 | - } | |
| 735 | - | |
| 736 | - // Check the Parent Theme if we're on a Child Theme. | |
| 737 | - if ( wp_get_theme()->parent() ) { | |
| 738 | - $theme = wp_get_theme()->parent(); | |
| 739 | - } else { | |
| 740 | - $theme = wp_get_theme(); | |
| 741 | - } | |
| 742 | - | |
| 743 | - return strtolower( $theme->get( 'Name' ) ) === strtolower( $theme_name ); | |
| 744 | - | |
| 745 | -} | |
| 746 | - | |
| 747 | -/** | |
| 748 | 645 | * Returns permitted HTML output when using wp_kses( ..., convertkit_kses_allowed_html()). |
| 749 | 646 | * |
| 750 | 647 | * @since 2.8.5 |
| 751 | 648 | */ |
| @@ -792,94 +689,4 @@ | ||
| 792 | 689 | |
| 793 | 690 | return array_merge( $elements, $form_elements ); |
| 794 | 691 | |
| 795 | 692 | } |
| 796 | - | |
| 797 | -/** | |
| 798 | - * Saves the new access token, refresh token and its expiry, and schedules | |
| 799 | - * a WordPress Cron event to refresh the token on expiry. | |
| 800 | - * | |
| 801 | - * @since 3.1.1 | |
| 802 | - * | |
| 803 | - * @param array $result New Access Token, Refresh Token and Expiry. | |
| 804 | - * @param string $client_id OAuth Client ID used for the Access and Refresh Tokens. | |
| 805 | - */ | |
| 806 | -function convertkit_maybe_update_credentials( $result, $client_id ) { | |
| 807 | - | |
| 808 | - // Don't save these credentials if they're not for this Client ID. | |
| 809 | - // They're for another Kit Plugin that uses OAuth. | |
| 810 | - if ( $client_id !== CONVERTKIT_OAUTH_CLIENT_ID ) { | |
| 811 | - return; | |
| 812 | - } | |
| 813 | - | |
| 814 | - $settings = new ConvertKit_Settings(); | |
| 815 | - $settings->update_credentials( $result ); | |
| 816 | - | |
| 817 | -} | |
| 818 | - | |
| 819 | -/** | |
| 820 | - * Deletes the stored access token, refresh token and its expiry from the Plugin settings, | |
| 821 | - * and clears any existing scheduled WordPress Cron event to refresh the token on expiry, | |
| 822 | - * when the user revokes the access token. | |
| 823 | - * | |
| 824 | - * @since 3.2.4 | |
| 825 | - * | |
| 826 | - * @param string $client_id OAuth Client ID used for the Access and Refresh Tokens. | |
| 827 | - */ | |
| 828 | -function convertkit_delete_credentials( $client_id ) { | |
| 829 | - | |
| 830 | - // Don't delete these credentials if they're not for this Client ID. | |
| 831 | - // They're for another Kit Plugin that uses OAuth. | |
| 832 | - if ( $client_id !== CONVERTKIT_OAUTH_CLIENT_ID ) { | |
| 833 | - return; | |
| 834 | - } | |
| 835 | - | |
| 836 | - // Delete Access and Refresh Tokens. | |
| 837 | - $settings = new ConvertKit_Settings(); | |
| 838 | - $settings->delete_credentials(); | |
| 839 | - | |
| 840 | -} | |
| 841 | - | |
| 842 | -/** | |
| 843 | - * Deletes the stored access token, refresh token and its expiry from the Plugin settings, | |
| 844 | - * and clears any existing scheduled WordPress Cron event to refresh the token on expiry, | |
| 845 | - * when either: | |
| 846 | - * - The access token is invalid | |
| 847 | - * - The access token expired, and refreshing failed | |
| 848 | - * | |
| 849 | - * @since 3.1.1 | |
| 850 | - * | |
| 851 | - * @param WP_Error $result Error result. | |
| 852 | - * @param string $client_id OAuth Client ID used for the Access and Refresh Tokens. | |
| 853 | - */ | |
| 854 | -function convertkit_maybe_delete_credentials( $result, $client_id ) { | |
| 855 | - | |
| 856 | - // Don't save these credentials if they're not for this Client ID. | |
| 857 | - // They're for another Kit Plugin that uses OAuth. | |
| 858 | - if ( $client_id !== CONVERTKIT_OAUTH_CLIENT_ID ) { | |
| 859 | - return; | |
| 860 | - } | |
| 861 | - | |
| 862 | - // If the error isn't a 401, don't delete credentials. | |
| 863 | - // This could be e.g. a temporary network error, rate limit or similar. | |
| 864 | - if ( $result->get_error_data( 'convertkit_api_error' ) !== 401 ) { | |
| 865 | - return; | |
| 866 | - } | |
| 867 | - | |
| 868 | - // Persist an error notice in the WordPress Administration until the user fixes the problem. | |
| 869 | - WP_ConvertKit()->get_class( 'admin_notices' )->add( 'authorization_failed' ); | |
| 870 | - | |
| 871 | - $settings = new ConvertKit_Settings(); | |
| 872 | - $settings->delete_credentials(); | |
| 873 | - | |
| 874 | -} | |
| 875 | - | |
| 876 | -// Update Access Token when refreshed by the API class. | |
| 877 | -add_action( 'convertkit_api_get_access_token', 'convertkit_maybe_update_credentials', 10, 2 ); | |
| 878 | -add_action( 'convertkit_api_refresh_token', 'convertkit_maybe_update_credentials', 10, 2 ); | |
| 879 | - | |
| 880 | -// Delete credentials when the user revokes the access and refresh tokens. | |
| 881 | -add_action( 'convertkit_api_revoke_tokens', 'convertkit_delete_credentials', 10, 1 ); | |
| 882 | - | |
| 883 | -// Delete credentials if the API class uses a invalid access token. | |
| 884 | -// This prevents the Plugin making repetitive API requests that will 401. | |
| 885 | -add_action( 'convertkit_api_access_token_invalid', 'convertkit_maybe_delete_credentials', 10, 2 ); | |