| 1 |
(function ($) { |
| 2 |
|
| 3 |
$(document).on('ready', function () { |
| 4 |
function getParams(actionName) { |
| 5 |
return { |
| 6 |
type: 'post', |
| 7 |
url: ajaxurl, |
| 8 |
data: { |
| 9 |
'action': 'hostinger_identify_action', |
| 10 |
'action_name': actionName |
| 11 |
}, |
| 12 |
dataType: 'json' |
| 13 |
}; |
| 14 |
} |
| 15 |
|
| 16 |
const onboardingSteps = [ |
| 17 |
{ |
| 18 |
'event': 'click', |
| 19 |
'element': '#customize-control-custom_logo .button-add-media', |
| 20 |
'action': 'logo_upload', |
| 21 |
}, |
| 22 |
{ |
| 23 |
'event': 'click', |
| 24 |
'element': '#wp-media-grid .page-title-action, #file-form #plupload-browse-button', |
| 25 |
'action': 'image_upload', |
| 26 |
}, |
| 27 |
{ 'event': 'input', |
| 28 |
'element': '#_customize-input-blogname', |
| 29 |
'action': 'edit_site_title', |
| 30 |
}, |
| 31 |
{ 'event': 'click', |
| 32 |
'element': '#menu-settings .wp-has-submenu, #menu-settings.wp-has-submenu .wp-submenu .wp-first-item .wp-first-item', |
| 33 |
'action': 'edit_site_title', |
| 34 |
}, |
| 35 |
{ 'event': 'click', |
| 36 |
'element': '.hsr-onboarding-step.edit_description .hsr-btn.hsr-primary-btn,.post-type-post .postbox-container #publish, .post-type-post #the-list .row-title, .post-type-post #the-list .row-actions .edit a', |
| 37 |
'action': 'edit_description', |
| 38 |
}, |
| 39 |
{ 'event': 'click', |
| 40 |
'element': '#wp-admin-bar-new-post,.wp-admin.post-type-post .wrap .page-title-action, #hst-add_post', |
| 41 |
'action': 'add_post', |
| 42 |
}, |
| 43 |
{ 'event': 'click', |
| 44 |
'element': '#wp-admin-bar-new-page, .wp-admin.post-type-page .wrap .page-title-action, #hst-add_page', |
| 45 |
'action': 'add_page', |
| 46 |
}, |
| 47 |
{ 'event': 'click', |
| 48 |
'element': '.post-type-product #posts-filter .woocommerce-BlankState-cta.button-primary, .post-type-product .wrap .page-title-action', |
| 49 |
'action': 'add_product', |
| 50 |
}, |
| 51 |
]; |
| 52 |
|
| 53 |
onboardingSteps.forEach(step => { |
| 54 |
$(document).on(step.event, step.element, () => { |
| 55 |
$.ajax(getParams(step.action)); |
| 56 |
}); |
| 57 |
}); |
| 58 |
|
| 59 |
}); |
| 60 |
|
| 61 |
})(jQuery); |
| 62 |
|