| @@ -147,28 +147,8 @@ | ||
| 147 | 147 | |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
| 151 | - * Determines whether the current user can create and publish the given Post Type. | |
| 152 | - * | |
| 153 | - * @since 3.3.9 | |
| 154 | - * | |
| 155 | - * @param string $post_type Post Type. | |
| 156 | - * @return bool User can create and publish Post Type. | |
| 157 | - */ | |
| 158 | -function convertkit_user_can_create_published_post_type( $post_type ) { | |
| 159 | - | |
| 160 | - $post_type_object = get_post_type_object( $post_type ); | |
| 161 | - | |
| 162 | - if ( ! $post_type_object ) { | |
| 163 | - return false; | |
| 164 | - } | |
| 165 | - | |
| 166 | - return current_user_can( $post_type_object->cap->create_posts ) && current_user_can( $post_type_object->cap->publish_posts ); | |
| 167 | - | |
| 168 | -} | |
| 169 | - | |
| 170 | -/** | |
| 171 | 151 | * Helper method to get supported Post Types for Restricted Content (Member's Content) |
| 172 | 152 | * |
| 173 | 153 | * @since 2.1.0 |
| 174 | 154 | * |
| @@ -254,32 +234,8 @@ | ||
| 254 | 234 | |
| 255 | 235 | } |
| 256 | 236 | |
| 257 | 237 | /** |
| 258 | - * Helper method to get registered plugin sidebars. | |
| 259 | - * | |
| 260 | - * @since 3.3.0 | |
| 261 | - * | |
| 262 | - * @return array Plugin sidebars | |
| 263 | - */ | |
| 264 | -function convertkit_get_plugin_sidebars() { | |
| 265 | - | |
| 266 | - $plugin_sidebars = array(); | |
| 267 | - | |
| 268 | - /** | |
| 269 | - * Registers plugin sidebars for the WordPress block editor. | |
| 270 | - * | |
| 271 | - * @since 3.3.0 | |
| 272 | - * | |
| 273 | - * @param array $plugin_sidebars Plugin sidebars. | |
| 274 | - */ | |
| 275 | - $plugin_sidebars = apply_filters( 'convertkit_plugin_sidebars', $plugin_sidebars ); | |
| 276 | - | |
| 277 | - return $plugin_sidebars; | |
| 278 | - | |
| 279 | -} | |
| 280 | - | |
| 281 | -/** | |
| 282 | 238 | * Helper method to get registered pre-publish actions. |
| 283 | 239 | * |
| 284 | 240 | * @since 2.4.0 |
| 285 | 241 | * |
| @@ -302,33 +258,8 @@ | ||
| 302 | 258 | |
| 303 | 259 | } |
| 304 | 260 | |
| 305 | 261 | /** |
| 306 | - * Helper method to get registered importers that can replace third party | |
| 307 | - * form shortcodes and blocks with Kit form shortcodes and blocks. | |
| 308 | - * | |
| 309 | - * @since 3.1.7 | |
| 310 | - * | |
| 311 | - * @return array Importers. | |
| 312 | - */ | |
| 313 | -function convertkit_get_form_importers() { | |
| 314 | - | |
| 315 | - $importers = array(); | |
| 316 | - | |
| 317 | - /** | |
| 318 | - * Registers form importers for the ConvertKit Plugin. | |
| 319 | - * | |
| 320 | - * @since 3.1.7 | |
| 321 | - * | |
| 322 | - * @param array $importers Importers. | |
| 323 | - */ | |
| 324 | - $importers = apply_filters( 'convertkit_get_form_importers', $importers ); | |
| 325 | - | |
| 326 | - return $importers; | |
| 327 | - | |
| 328 | -} | |
| 329 | - | |
| 330 | -/** | |
| 331 | 262 | * Helper method to return the Plugin Settings Link |
| 332 | 263 | * |
| 333 | 264 | * @since 1.9.6 |
| 334 | 265 | * |
| @@ -573,36 +504,8 @@ | ||
| 573 | 504 | |
| 574 | 505 | } |
| 575 | 506 | |
| 576 | 507 | /** |
| 577 | - * Helper method to enqueue the frontend CSS file. | |
| 578 | - * | |
| 579 | - * @since 3.2.0 | |
| 580 | - */ | |
| 581 | -function convertkit_enqueue_frontend_css() { | |
| 582 | - | |
| 583 | - wp_enqueue_style( 'convertkit-frontend', CONVERTKIT_PLUGIN_URL . 'resources/frontend/css/frontend.css', array(), CONVERTKIT_PLUGIN_VERSION ); | |
| 584 | - | |
| 585 | -} | |
| 586 | - | |
| 587 | -/** | |
| 588 | - * Helper method to enqueue the frontend JS file. | |
| 589 | - * | |
| 590 | - * @since 3.2.0 | |
| 591 | - */ | |
| 592 | -function convertkit_enqueue_frontend_js() { | |
| 593 | - | |
| 594 | - wp_enqueue_script( | |
| 595 | - 'convertkit-js', | |
| 596 | - CONVERTKIT_PLUGIN_URL . 'resources/frontend/js/dist/frontend.min.js', | |
| 597 | - array(), | |
| 598 | - CONVERTKIT_PLUGIN_VERSION, | |
| 599 | - true | |
| 600 | - ); | |
| 601 | - | |
| 602 | -} | |
| 603 | - | |
| 604 | -/** | |
| 605 | 508 | * Helper method to enqueue Select2 scripts for use within the ConvertKit Plugin. |
| 606 | 509 | * |
| 607 | 510 | * @since 1.9.6.4 |
| 608 | 511 | */ |
| @@ -738,34 +641,8 @@ | ||
| 738 | 641 | |
| 739 | 642 | } |
| 740 | 643 | |
| 741 | 644 | /** |
| 742 | - * Checks if the given Theme is active. | |
| 743 | - * | |
| 744 | - * @since 3.1.4 | |
| 745 | - * | |
| 746 | - * @param string $theme_name Theme name. | |
| 747 | - * @return bool | |
| 748 | - */ | |
| 749 | -function convertkit_is_theme_active( $theme_name ) { | |
| 750 | - | |
| 751 | - // Assume Theme isn't active if we can't detect it. | |
| 752 | - if ( ! function_exists( 'wp_get_theme' ) ) { | |
| 753 | - return false; | |
| 754 | - } | |
| 755 | - | |
| 756 | - // Check the Parent Theme if we're on a Child Theme. | |
| 757 | - if ( wp_get_theme()->parent() ) { | |
| 758 | - $theme = wp_get_theme()->parent(); | |
| 759 | - } else { | |
| 760 | - $theme = wp_get_theme(); | |
| 761 | - } | |
| 762 | - | |
| 763 | - return strtolower( $theme->get( 'Name' ) ) === strtolower( $theme_name ); | |
| 764 | - | |
| 765 | -} | |
| 766 | - | |
| 767 | -/** | |
| 768 | 645 | * Returns permitted HTML output when using wp_kses( ..., convertkit_kses_allowed_html()). |
| 769 | 646 | * |
| 770 | 647 | * @since 2.8.5 |
| 771 | 648 | */ |
| @@ -812,94 +689,4 @@ | ||
| 812 | 689 | |
| 813 | 690 | return array_merge( $elements, $form_elements ); |
| 814 | 691 | |
| 815 | 692 | } |
| 816 | - | |
| 817 | -/** | |
| 818 | - * Saves the new access token, refresh token and its expiry, and schedules | |
| 819 | - * a WordPress Cron event to refresh the token on expiry. | |
| 820 | - * | |
| 821 | - * @since 3.1.1 | |
| 822 | - * | |
| 823 | - * @param array $result New Access Token, Refresh Token and Expiry. | |
| 824 | - * @param string $client_id OAuth Client ID used for the Access and Refresh Tokens. | |
| 825 | - */ | |
| 826 | -function convertkit_maybe_update_credentials( $result, $client_id ) { | |
| 827 | - | |
| 828 | - // Don't save these credentials if they're not for this Client ID. | |
| 829 | - // They're for another Kit Plugin that uses OAuth. | |
| 830 | - if ( $client_id !== CONVERTKIT_OAUTH_CLIENT_ID ) { | |
| 831 | - return; | |
| 832 | - } | |
| 833 | - | |
| 834 | - $settings = new ConvertKit_Settings(); | |
| 835 | - $settings->update_credentials( $result ); | |
| 836 | - | |
| 837 | -} | |
| 838 | - | |
| 839 | -/** | |
| 840 | - * Deletes the stored access token, refresh token and its expiry from the Plugin settings, | |
| 841 | - * and clears any existing scheduled WordPress Cron event to refresh the token on expiry, | |
| 842 | - * when the user revokes the access token. | |
| 843 | - * | |
| 844 | - * @since 3.2.4 | |
| 845 | - * | |
| 846 | - * @param string $client_id OAuth Client ID used for the Access and Refresh Tokens. | |
| 847 | - */ | |
| 848 | -function convertkit_delete_credentials( $client_id ) { | |
| 849 | - | |
| 850 | - // Don't delete these credentials if they're not for this Client ID. | |
| 851 | - // They're for another Kit Plugin that uses OAuth. | |
| 852 | - if ( $client_id !== CONVERTKIT_OAUTH_CLIENT_ID ) { | |
| 853 | - return; | |
| 854 | - } | |
| 855 | - | |
| 856 | - // Delete Access and Refresh Tokens. | |
| 857 | - $settings = new ConvertKit_Settings(); | |
| 858 | - $settings->delete_credentials(); | |
| 859 | - | |
| 860 | -} | |
| 861 | - | |
| 862 | -/** | |
| 863 | - * Deletes the stored access token, refresh token and its expiry from the Plugin settings, | |
| 864 | - * and clears any existing scheduled WordPress Cron event to refresh the token on expiry, | |
| 865 | - * when either: | |
| 866 | - * - The access token is invalid | |
| 867 | - * - The access token expired, and refreshing failed | |
| 868 | - * | |
| 869 | - * @since 3.1.1 | |
| 870 | - * | |
| 871 | - * @param WP_Error $result Error result. | |
| 872 | - * @param string $client_id OAuth Client ID used for the Access and Refresh Tokens. | |
| 873 | - */ | |
| 874 | -function convertkit_maybe_delete_credentials( $result, $client_id ) { | |
| 875 | - | |
| 876 | - // Don't save these credentials if they're not for this Client ID. | |
| 877 | - // They're for another Kit Plugin that uses OAuth. | |
| 878 | - if ( $client_id !== CONVERTKIT_OAUTH_CLIENT_ID ) { | |
| 879 | - return; | |
| 880 | - } | |
| 881 | - | |
| 882 | - // If the error isn't a 401, don't delete credentials. | |
| 883 | - // This could be e.g. a temporary network error, rate limit or similar. | |
| 884 | - if ( $result->get_error_data( 'convertkit_api_error' ) !== 401 ) { | |
| 885 | - return; | |
| 886 | - } | |
| 887 | - | |
| 888 | - // Persist an error notice in the WordPress Administration until the user fixes the problem. | |
| 889 | - WP_ConvertKit()->get_class( 'admin_notices' )->add( 'authorization_failed' ); | |
| 890 | - | |
| 891 | - $settings = new ConvertKit_Settings(); | |
| 892 | - $settings->delete_credentials(); | |
| 893 | - | |
| 894 | -} | |
| 895 | - | |
| 896 | -// Update Access Token when refreshed by the API class. | |
| 897 | -add_action( 'convertkit_api_get_access_token', 'convertkit_maybe_update_credentials', 10, 2 ); | |
| 898 | -add_action( 'convertkit_api_refresh_token', 'convertkit_maybe_update_credentials', 10, 2 ); | |
| 899 | - | |
| 900 | -// Delete credentials when the user revokes the access and refresh tokens. | |
| 901 | -add_action( 'convertkit_api_revoke_tokens', 'convertkit_delete_credentials', 10, 1 ); | |
| 902 | - | |
| 903 | -// Delete credentials if the API class uses a invalid access token. | |
| 904 | -// This prevents the Plugin making repetitive API requests that will 401. | |
| 905 | -add_action( 'convertkit_api_access_token_invalid', 'convertkit_maybe_delete_credentials', 10, 2 ); | |