PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 1.9.7.4
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v1.9.7.4
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 2.3.3 All 194 releases
convertkit / includes / functions.php

functions.php in Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages 1.9.7.4, at includes/functions.php

243 lines 5.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * ConvertKit general plugin functions.
4 *
5 * @package ConvertKit
6 * @author ConvertKit
7 */
8
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 } else {
26 // Multisite network wide activation.
27 $sites = get_sites(
28 array(
29 'number' => 0,
30 )
31 );
32 foreach ( $sites as $site ) {
33 switch_to_blog( $site->blog_id );
34 $convertkit->get_class( 'setup' )->activate();
35 restore_current_blog();
36 }
37 }
38
39 }
40
41 /**
42 * Runs the activation and update routines when the plugin is activated
43 * on a WordPress multisite setup.
44 *
45 * @since 1.9.7.4
46 *
47 * @param mixed $site_or_blog_id WP_Site or Blog ID.
48 */
49 function convertkit_plugin_activate_new_site( $site_or_blog_id ) {
50
51 // Check if $site_or_blog_id is a WP_Site or a blog ID.
52 if ( is_a( $site_or_blog_id, 'WP_Site' ) ) {
53 $site_or_blog_id = $site_or_blog_id->blog_id;
54 }
55
56 // Initialise Plugin.
57 $convertkit = WP_ConvertKit();
58
59 // Run installation routine.
60 switch_to_blog( $site_or_blog_id );
61 $convertkit->get_class( 'setup' )->activate();
62 restore_current_blog();
63
64 }
65
66 /**
67 * Runs the deactivation routine when the plugin is deactivated.
68 *
69 * @since 1.9.7.4
70 *
71 * @param bool $network_wide Is network wide deactivation.
72 */
73 function convertkit_plugin_deactivate( $network_wide ) {
74
75 // Initialise Plugin.
76 $convertkit = WP_ConvertKit();
77
78 // Check if we are on a multisite install, activating network wide, or a single install.
79 if ( ! is_multisite() || ! $network_wide ) {
80 // Single Site activation.
81 $convertkit->get_class( 'setup' )->deactivate();
82 } else {
83 // Multisite network wide activation.
84 $sites = get_sites(
85 array(
86 'number' => 0,
87 )
88 );
89 foreach ( $sites as $site ) {
90 switch_to_blog( $site->blog_id );
91 $convertkit->get_class( 'setup' )->deactivate();
92 restore_current_blog();
93 }
94 }
95
96 }
97
98 /**
99 * Helper method to get supported Post Types.
100 *
101 * @since 1.9.6
102 *
103 * @return array Post Types
104 */
105 function convertkit_get_supported_post_types() {
106
107 $post_types = array(
108 'page',
109 'post',
110 );
111
112 /**
113 * Defines the Post Types that support ConvertKit Forms.
114 *
115 * @since 1.9.6
116 *
117 * @param array $post_types Post Types
118 */
119 $post_types = apply_filters( 'convertkit_get_supported_post_types', $post_types );
120
121 return $post_types;
122
123 }
124
125 /**
126 * Helper method to get registered Shortcodes.
127 *
128 * @since 1.9.6.5
129 *
130 * @return array Shortcodes
131 */
132 function convertkit_get_shortcodes() {
133
134 $shortcodes = array();
135
136 /**
137 * Registers shortcodes for the ConvertKit Plugin.
138 *
139 * @since 1.9.6.5
140 *
141 * @param array $shortcodes Shortcodes
142 */
143 $shortcodes = apply_filters( 'convertkit_shortcodes', $shortcodes );
144
145 return $shortcodes;
146
147 }
148
149 /**
150 * Helper method to get registered Blocks.
151 *
152 * @since 1.9.6
153 *
154 * @return array Blocks
155 */
156 function convertkit_get_blocks() {
157
158 $blocks = array();
159
160 /**
161 * Registers blocks for the ConvertKit Plugin.
162 *
163 * @since 1.9.6
164 *
165 * @param array $blocks Blocks
166 */
167 $blocks = apply_filters( 'convertkit_blocks', $blocks );
168
169 return $blocks;
170
171 }
172
173 /**
174 * Helper method to return the Plugin Settings Link
175 *
176 * @since 1.9.6
177 *
178 * @param array $query_args Optional Query Args.
179 * @return string Settings Link
180 */
181 function convertkit_get_settings_link( $query_args = array() ) {
182
183 $query_args = array_merge(
184 $query_args,
185 array(
186 'page' => '_wp_convertkit_settings',
187 )
188 );
189
190 return add_query_arg( $query_args, admin_url( 'options-general.php' ) );
191
192 }
193
194 /**
195 * Helper method to return the URL the user needs to visit to sign in to their ConvertKit account.
196 *
197 * @since 1.9.6.1
198 *
199 * @return string ConvertKit Login URL.
200 */
201 function convertkit_get_sign_in_url() {
202
203 return 'https://app.convertkit.com/?utm_source=wordpress&utm_content=convertkit';
204
205 }
206
207 /**
208 * Helper method to return the URL the user needs to visit on the ConvertKit app to obtain their API Key and Secret.
209 *
210 * @since 1.9.6.1
211 *
212 * @return string ConvertKit App URL.
213 */
214 function convertkit_get_api_key_url() {
215
216 return 'https://app.convertkit.com/account_settings/advanced_settings/?utm_source=wordpress&utm_content=convertkit';
217
218 }
219
220 /**
221 * Helper method to enqueue Select2 scripts for use within the ConvertKit Plugin.
222 *
223 * @since 1.9.6.4
224 */
225 function convertkit_select2_enqueue_scripts() {
226
227 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 );
228 wp_enqueue_script( 'convertkit-admin-select2', CONVERTKIT_PLUGIN_URL . '/resources/backend/js/select2.js', array( 'convertkit-select2' ), CONVERTKIT_PLUGIN_VERSION, false );
229
230 }
231
232 /**
233 * Helper method to enqueue Select2 stylesheets for use within the ConvertKit Plugin.
234 *
235 * @since 1.9.6.4
236 */
237 function convertkit_select2_enqueue_styles() {
238
239 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 );
240 wp_enqueue_style( 'convertkit-admin-select2', CONVERTKIT_PLUGIN_URL . '/resources/backend/css/select2.css', array(), CONVERTKIT_PLUGIN_VERSION );
241
242 }
243