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
convertkit / resources / backend / js / quick-edit.js

quick-edit.js in Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages 2.7.4, at resources/backend/js/quick-edit.js

72 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Quick Edit
3 *
4 * @package ConvertKit
5 * @author ConvertKit
6 */
7
8 /**
9 * Copies Quick Edit fields into WordPress' #inline-edit table row on load.
10 *
11 * Populates Quick Edit fields for this Plugin with the values output
12 * in the `add_inline_data` WordPress action when the user clicks
13 * a Quick Edit link in a Post, Page or Custom Post Type WP_List_Table.
14 *
15 * WordPress' built in Quick Edit functionality does not do this automatically
16 * for Plugins that register settings, which is why we have this code here.
17 *
18 * @since 1.9.8.0
19 */
20
21 document.addEventListener(
22 'DOMContentLoaded',
23 function () {
24
25 const convertKitQuickEditWrapper = document.querySelector( 'tr#inline-edit .inline-edit-wrapper fieldset.inline-edit-col-left' ),
26 convertKitQuickEdit = document.querySelector( '#convertkit-quick-edit' ),
27 convertKitInlineEditPost = inlineEditPost.edit;
28
29 if ( convertKitQuickEditWrapper ) {
30 // Move Quick Edit fields from footer into the hidden inline-edit table row.
31 convertKitQuickEditWrapper.appendChild( convertKitQuickEdit );
32
33 // Show the Quick Edit fields, as they are now contained in the inline-edit row which WordPress will show/hide as necessary.
34 convertKitQuickEdit.style.display = 'block';
35
36 // Extend WordPress' inline edit function to load the Plugin's Quick Edit fields.
37 inlineEditPost.edit = function ( id ) {
38
39 // Merge arguments from the original function.
40 convertKitInlineEditPost.apply( this, arguments );
41
42 // Get Post ID.
43 if (typeof id === 'object') {
44 id = parseInt( this.getId( id ) );
45 }
46
47 // Iterate through any ConvertKit inline data, assigning values to Quick Edit fields.
48 document.querySelectorAll( '#inline_' + id + ' .convertkit' ).forEach(
49 function ( element ) {
50 // Get Quick Edit field.
51 let convertKitQuickEditField = document.querySelector( '#convertkit-quick-edit select[name="wp-convertkit[' + element.dataset.setting + ']"]' );
52
53 // If the Quick Edit field doesn't exist for this setting, skip it.
54 // (e.g. we're editing a Post and this is a Landing Page setting, that isn't supported in Posts).
55 if ( convertKitQuickEditField === null ) {
56 return;
57 }
58
59 // Assign the setting's value to the setting's Quick Edit field.
60 convertKitQuickEditField.value = element.dataset.value;
61 }
62 );
63
64 // Bind refresh resource event listeners.
65 convertKitRefreshResourcesInitEventListeners();
66
67 };
68 }
69
70 }
71 );
72