PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 2.7.4
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v2.7.4
3.4.2 3.4.1 3.4.0 3.3.9 3.3.8 3.3.7 3.3.6 3.3.5 3.3.4 3.3.3 3.3.2 3.3.1 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 2.3.2 All 195 releases
← All changes | includes/functions.php +0 -266 3.3.92.7.4 View file →
@@ -16,9 +16,8 @@
16 16 function convertkit_plugin_activate( $network_wide ) {
17 17
18 18 // Initialise Plugin.
19 19 $convertkit = WP_ConvertKit();
20 - $convertkit->initialize();
21 20
22 21 // Check if we are on a multisite install, activating network wide, or a single install.
23 22 if ( ! is_multisite() || ! $network_wide ) {
24 23 // Single Site activation.
@@ -58,9 +57,8 @@
58 57 }
59 58
60 59 // Initialise Plugin.
61 60 $convertkit = WP_ConvertKit();
62 - $convertkit->initialize();
63 61
64 62 // Run installation routine.
65 63 switch_to_blog( $site_or_blog_id );
66 64 $convertkit->get_class( 'setup' )->activate();
@@ -78,9 +76,8 @@
78 76 function convertkit_plugin_deactivate( $network_wide ) {
79 77
80 78 // Initialise Plugin.
81 79 $convertkit = WP_ConvertKit();
82 - $convertkit->initialize();
83 80
84 81 // Check if we are on a multisite install, activating network wide, or a single install.
85 82 if ( ! is_multisite() || ! $network_wide ) {
86 83 // Single Site activation.
@@ -147,28 +144,8 @@
147 144
148 145 }
149 146
150 147 /**
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 148 * Helper method to get supported Post Types for Restricted Content (Member's Content)
172 149 *
173 150 * @since 2.1.0
174 151 *
@@ -254,32 +231,8 @@
254 231
255 232 }
256 233
257 234 /**
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 235 * Helper method to get registered pre-publish actions.
283 236 *
284 237 * @since 2.4.0
285 238 *
@@ -302,33 +255,8 @@
302 255
303 256 }
304 257
305 258 /**
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 259 * Helper method to return the Plugin Settings Link
332 260 *
333 261 * @since 1.9.6
334 262 *
@@ -573,36 +501,8 @@
573 501
574 502 }
575 503
576 504 /**
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 505 * Helper method to enqueue Select2 scripts for use within the ConvertKit Plugin.
606 506 *
607 507 * @since 1.9.6.4
608 508 */
@@ -736,170 +636,4 @@
736 636 </script>
737 637 <?php
738 638
739 639 }
740 -
741 -/**
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 - * Returns permitted HTML output when using wp_kses( ..., convertkit_kses_allowed_html()).
769 - *
770 - * @since 2.8.5
771 - */
772 -function convertkit_kses_allowed_html() {
773 -
774 - // Get WordPress' permitted HTML elements.
775 - $elements = wp_kses_allowed_html( 'post' );
776 -
777 - // Add form elements.
778 - $form_elements = array(
779 - 'input' => array(
780 - 'type' => true,
781 - 'id' => true,
782 - 'name' => true,
783 - 'class' => true,
784 - 'value' => true,
785 - 'checked' => true,
786 - 'min' => true,
787 - 'max' => true,
788 - 'step' => true,
789 - 'data-*' => true,
790 - ),
791 - 'select' => array(
792 - 'id' => true,
793 - 'name' => true,
794 - 'class' => true,
795 - 'size' => true,
796 - 'multiple' => true,
797 - 'data-*' => true,
798 - ),
799 - 'option' => array(
800 - 'value' => true,
801 - 'selected' => true,
802 - 'data-*' => true,
803 - ),
804 - 'optgroup' => array(
805 - 'label' => true,
806 - 'data-*' => true,
807 - ),
808 - 'label' => array(
809 - 'for' => true,
810 - ),
811 - );
812 -
813 - return array_merge( $elements, $form_elements );
814 -
815 -}
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 );