WP init
This commit is contained in:
@@ -0,0 +1,905 @@
|
||||
span.hfe-shortcode-col-wrap > input {
|
||||
background: inherit;
|
||||
color: inherit;
|
||||
font-size: 12px;
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
padding: 4px 8px;
|
||||
margin: 0;
|
||||
}
|
||||
input.hfe-large-text{
|
||||
width: 99%;
|
||||
}
|
||||
.hfe-options-row-heading {
|
||||
border-right: 1px solid #E1E1E1;
|
||||
padding: 15px;
|
||||
width: 45%;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.hfe-options-row td {
|
||||
padding-left: 12px;
|
||||
padding-right: 12px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
zoom: 1;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.hfe-options-table .hfe-options-row-content {
|
||||
padding: 15px 10px;
|
||||
position: relative;
|
||||
width: 55%;
|
||||
}
|
||||
.hfe-options-table.widefat {
|
||||
border-width: 0;
|
||||
}
|
||||
.hfe-options-row-heading label {
|
||||
display: inline-block;
|
||||
font-size: 13px;
|
||||
line-height: 1.4em;
|
||||
font-weight: bold;
|
||||
padding: 0;
|
||||
margin: 0 0 3px;
|
||||
color: #333;
|
||||
}
|
||||
.hfe-options-row-content select {
|
||||
width: 95%;
|
||||
}
|
||||
.hfe_radio_options {
|
||||
display: inline-block;
|
||||
}
|
||||
li#toplevel_page_Settings-page,
|
||||
.wp-admin #adminmenu .wp-submenu a[href="themes.php?page=hfe-settings"],
|
||||
.wp-admin #adminmenu .wp-submenu a[href="themes.php?page=hfe-guide"],
|
||||
.wp-admin #adminmenu .wp-submenu a[href="themes.php?page=hfe-about"] {
|
||||
display: none;
|
||||
}
|
||||
.post-type-elementor-hf .wp-submenu a[href ="edit.php?post_type=elementor-hf" ] {
|
||||
color: #ffffff !important;
|
||||
font-weight: 600;
|
||||
}
|
||||
.toplevel_page_hfe .wp-submenu a[href ="post-new.php?post_type=elementor-hf" ],
|
||||
.toplevel_page_hfe .wp-submenu a[href ="admin.php?page=hfe#onboarding" ],
|
||||
.toplevel_page_hfe .wp-submenu a[href ="admin.php?page=hfe#onboardingsuccess" ],
|
||||
.toplevel_page_uaepro .wp-submenu a[href ="post-new.php?post_type=elementor-hf" ] {
|
||||
display: none !important;
|
||||
}
|
||||
.hfe-heading-inline {
|
||||
font-size: 23px;
|
||||
font-weight: 400;
|
||||
margin: 0;
|
||||
padding: 9px 0 4px 0;
|
||||
line-height: 1.3;
|
||||
}
|
||||
.hfe-selected-template-type-custom .hfe-shortcode {
|
||||
display: table-row;
|
||||
}
|
||||
.hfe-selected-template-type-custom .bsf-target-rules-row,
|
||||
.hfe-selected-template-type-custom .enable-for-canvas,
|
||||
.hfe-shortcode,
|
||||
.hfe-selected-template-type-none .bsf-target-rules-row,
|
||||
.hfe-selected-template-type-none .hfe-shortcode,
|
||||
.hfe-selected-template-type-none .enable-for-canvas,
|
||||
.hfe-guide-content .form-table th {
|
||||
display: none;
|
||||
}
|
||||
/* Notice */
|
||||
#header-footer-install-notice img.custom-logo {
|
||||
height: 30px;
|
||||
margin-right: 6px;
|
||||
}
|
||||
#header-footer-install-notice .notice-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding-top: 5px;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
#header-footer-install-notice .notice-content {
|
||||
margin-left: 0px;
|
||||
}
|
||||
#header-footer-install-notice .notice-dismiss {
|
||||
height: 100%;
|
||||
}
|
||||
/* EHF Settings - Step by Step guide */
|
||||
#ehf-meta-box .inside,
|
||||
.hfe-admin-guide-section.hfe-admin-about-section {
|
||||
padding: 0px;
|
||||
}
|
||||
.appearance_page_hfe-guide .nav-tab-wrapper,
|
||||
.appearance_page_hfe-about .nav-tab-wrapper,
|
||||
.appearance_page_hfe-settings .nav-tab-wrapper {
|
||||
margin-right: 18px;
|
||||
margin-bottom: 30px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.post-type-elementor-hf .nav-tab-wrapper {
|
||||
margin-bottom: 18px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.post-type-elementor-hf .wrap h1.wp-heading-inline,
|
||||
.hfe-heading-inline {
|
||||
margin-top: 10px
|
||||
}
|
||||
.hfe-admin-about-section,
|
||||
.hfe-subscription-row {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
.hfe-subscription-row .hfe-input-container {
|
||||
width: 50%;
|
||||
text-align: left;
|
||||
position: relative;
|
||||
width: 100%;
|
||||
}
|
||||
.hfe-guide-modal-content .hfe-checkbox-container {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
}
|
||||
.hfe-guide-modal-content .hfe-admin-column-50:not(.hfe-admin-column-last) {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
/* Form CSS */
|
||||
.hfe-subscription-row {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.hfe-subscription-row .hfe-subscribe-field:focus {
|
||||
outline: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
.hfe-subscription-row .hfe-subscribe-field {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
border-radius: 3px;
|
||||
border: 1px solid #585F66;
|
||||
padding: 10px 15px;
|
||||
box-shadow: none;
|
||||
min-height: 44px;
|
||||
font-size: 15px;
|
||||
font-weight: 400;
|
||||
outline: none;
|
||||
background-color: transparent;
|
||||
background-position: right 10px top 55%;
|
||||
margin: 0;
|
||||
}
|
||||
.hfe-subscription-row .subscription-label {
|
||||
color: #585F66;
|
||||
margin: 12px 10px;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
font-weight: 400;
|
||||
padding: 0 5px;
|
||||
font-size: 14px;
|
||||
left: 0;
|
||||
-webkit-transition: all 0.25s ease;
|
||||
transition: all 0.25s ease;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.hfe-subscription-row input#hfe_subscribe_accept {
|
||||
border: 1px solid #585F66;
|
||||
border-radius: 3px;
|
||||
margin: 0 4px 0 0;
|
||||
}
|
||||
|
||||
.hfe-guide-modal-popup .hfe-guide-modal-popup-wrapper .hfe-subscription-row .hfe-input-container:nth-of-type(3) {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.hfe-subscription-row .hfe-input-container:not(.subscription-success, .subscription-error) .hfe-subscribe-field:hover {
|
||||
border-color: #2271b1;
|
||||
}
|
||||
.hfe-subscription-row .hfe-subscribe-field:hover,
|
||||
.hfe-subscription-row .hfe-subscribe-field:focus {
|
||||
color: #2c3338;
|
||||
}
|
||||
.hfe-subscription-row .subscription-anim .subscription-label {
|
||||
background-color: #fff;
|
||||
font-size: 12px;
|
||||
line-height: 12px;
|
||||
margin-top: 0;
|
||||
padding: 0 4px;
|
||||
top: -5px;
|
||||
transition: all 0.125s ease;
|
||||
-webkit-transition: all 0.125s ease;
|
||||
color: #2271b1;
|
||||
}
|
||||
.hfe-subscription-row .subscription-error .hfe-subscribe-field,
|
||||
.hfe-subscription-row .subscription-error .hfe-subscribe-field:focus {
|
||||
border-color: #ff0000;
|
||||
}
|
||||
.hfe-subscription-row .subscription-error .subscription-desc,
|
||||
.hfe-subscription-row .subscription-anim.subscription-error .subscription-label {
|
||||
color: #ff0000;
|
||||
}
|
||||
.hfe-subscription-row .subscription-success .hfe-subscribe-field,
|
||||
.hfe-subscription-row .subscription-success .hfe-subscribe-field:focus {
|
||||
border-color: #66a700;
|
||||
}
|
||||
.hfe-subscription-row .subscription-anim.subscription-success .subscription-label {
|
||||
color: #66a700;
|
||||
}
|
||||
.hfe-input-container .subscription-desc {
|
||||
padding-left: 2px;
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
}
|
||||
.hfe-input-container.subscription-error .subscription-desc {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
}
|
||||
input[type="text"].hfe-subscribe-field,
|
||||
select.hfe-subscribe-field {
|
||||
text-align: left;
|
||||
width: 100%;
|
||||
padding: 10px 15px;
|
||||
outline: none;
|
||||
margin-left: 0px;
|
||||
}
|
||||
.hfe-guide-content p.submit {
|
||||
text-align: center;
|
||||
margin-top: 0px;
|
||||
padding-top: 0px;
|
||||
padding-bottom: 0px;
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
.hfe-privacy-policy-container {
|
||||
margin-top: 0;
|
||||
text-align: center;
|
||||
display: none;
|
||||
}
|
||||
.hfe-subscription-step-2-active ~ .hfe-privacy-policy-container {
|
||||
display: block;
|
||||
}
|
||||
.hfe-privacy-policy-container .hfe-subscription-policy {
|
||||
margin: 0;
|
||||
padding-top: 15px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.button-subscription-skip:focus {
|
||||
box-shadow: none;
|
||||
}
|
||||
.button-subscription-skip {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
margin-top: .8em;
|
||||
display: inline-block;
|
||||
font-size: 14px;
|
||||
}
|
||||
.hfe-guide-content .button {
|
||||
text-transform: uppercase;
|
||||
padding: 10px 20px;
|
||||
width: 100%;
|
||||
font-size: 13px;
|
||||
}
|
||||
.hfe-guide-content .button.submitting {
|
||||
margin-right: 3px;
|
||||
}
|
||||
/* EHF Settings - About Us */
|
||||
.hfe-admin-about-section {
|
||||
margin: 0px 19px 23px 0px;
|
||||
padding: 40px;
|
||||
line-height: 2;
|
||||
}
|
||||
.hfe-admin-about-section p,
|
||||
.hfe-admin-addons .addon-item,
|
||||
.hfe-admin-addons .addon-item p,
|
||||
.hfe-admin-about-section ul {
|
||||
font-size: 15px;
|
||||
}
|
||||
.hfe-admin-about-us {
|
||||
background: #fff;
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
.hfe-admin-about-section h1,
|
||||
.hfe-admin-about-section h2,
|
||||
.hfe-admin-about-section h3,
|
||||
.hfe-admin-about-section h4,
|
||||
.hfe-admin-about-section h5 {
|
||||
margin-top: 0;
|
||||
line-height: 1.3;
|
||||
}
|
||||
.hfe-clear:before {
|
||||
content: " ";
|
||||
display: table;
|
||||
}
|
||||
.hfe-clear:after,
|
||||
.hfe-admin-columns:after {
|
||||
clear: both;
|
||||
content: " ";
|
||||
display: table;
|
||||
}
|
||||
.hfe-admin-columns .hfe-admin-column-40 {
|
||||
width: 40%;
|
||||
}
|
||||
.hfe-admin-columns .hfe-admin-column-50 {
|
||||
width: 50%;
|
||||
background: #fff;
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
.hfe-admin-columns .hfe-admin-column-60 {
|
||||
width: 60%;
|
||||
}
|
||||
.hfe-admin-columns .hfe-admin-column-last .hfe-guide-content {
|
||||
width: 100%;
|
||||
}
|
||||
.hfe-admin-about-section figure {
|
||||
margin: 0;
|
||||
padding-top: 0px;
|
||||
}
|
||||
.hfe-admin-about-section figure img {
|
||||
width: 100%;
|
||||
box-shadow: 0 0 8px rgb(0 0 0 / 10%);
|
||||
}
|
||||
.hfe-admin-about-section figure figcaption {
|
||||
font-size: 15px;
|
||||
color: #686868;
|
||||
margin-top: 5px;
|
||||
text-align: center;
|
||||
line-height: initial;
|
||||
}
|
||||
.hfe-admin-about-section .hfe-admin-column-40 {
|
||||
padding-left: 15px;
|
||||
}
|
||||
.hfe-admin-about-section .hfe-admin-column-60 {
|
||||
padding-right: 15px;
|
||||
}
|
||||
.hfe-admin-about-section *,
|
||||
.hfe-admin-about-section *::before,
|
||||
.hfe-admin-about-section *::after,
|
||||
.hfe-admin-addons *,
|
||||
.hfe-admin-addons *::before,
|
||||
.hfe-admin-addons *::after {
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
/* About Us - Plugins section */
|
||||
.hfe-admin-addons .addon-container:last-child {
|
||||
padding-right: 10px;
|
||||
}
|
||||
.hfe-admin-addons .addon-container:first-child,
|
||||
.hfe-admin-addons .addon-container {
|
||||
padding-left: 10px;
|
||||
}
|
||||
.hfe-admin-addons {
|
||||
padding: 0 27px 0px 10px;
|
||||
}
|
||||
.hfe-admin-addons .addon-item .details {
|
||||
padding: 20px;
|
||||
}
|
||||
.hfe-admin-addons .addon-item img {
|
||||
padding: 13px;
|
||||
padding-top: 0px;
|
||||
}
|
||||
.hfe-admin-addons .addons-container{
|
||||
margin-left: -20px;
|
||||
margin-right: -20px;
|
||||
}
|
||||
.hfe-admin-addons .addon-container {
|
||||
padding-right: 10px;
|
||||
float: left;
|
||||
width: 33.333333%;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.hfe-admin-addons h4 {
|
||||
font-size: 17px;
|
||||
font-weight: 700;
|
||||
}
|
||||
.hfe-admin-addons .addon-item {
|
||||
background-color: #fff;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 3px;
|
||||
margin: 0;
|
||||
}
|
||||
.hfe-admin-addons .addon-item img {
|
||||
float: left;
|
||||
max-width: 80px;
|
||||
}
|
||||
.hfe-admin-addons .addon-item h5 {
|
||||
margin: 0 0 15px 90px;
|
||||
font-size: 17px;
|
||||
line-height: 1.4em;
|
||||
}
|
||||
.hfe-admin-addons .addon-item p {
|
||||
margin: 0 0 0 90px;
|
||||
}
|
||||
.hfe-admin-addons .website-link {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
.hfe-admin-addons .addon-item .details {
|
||||
padding: 30px 20px;
|
||||
}
|
||||
|
||||
.hfe-admin-addons .addon-item .action-button .button {
|
||||
display: inline-block;
|
||||
text-decoration: none;
|
||||
font-size: 14px;
|
||||
line-height: 26px;
|
||||
height: 28px;
|
||||
margin: 0;
|
||||
padding: 0 10px 1px;
|
||||
box-shadow: 0 1px 0 #cccccc;
|
||||
cursor: pointer;
|
||||
-webkit-appearance: none;
|
||||
border-radius: 3px;
|
||||
border: 1px solid #cccccc;
|
||||
background: #f7f7f7;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.hfe-admin-addons .addon-item .action-button .button:hover,
|
||||
.hfe-admin-addons .addon-item .action-button .button:focus {
|
||||
background: #fafafa;
|
||||
border-color: #999;
|
||||
color: #23282d;
|
||||
}
|
||||
|
||||
.hfe-admin-addons .addon-item .action-button .button.button-primary {
|
||||
background: #0085ba;
|
||||
border-color: #0073aa #006799 #006799;
|
||||
box-shadow: 0 1px 0 #006799;
|
||||
color: #fff;
|
||||
text-shadow: 0 -1px 1px #006799, 1px 0 1px #006799, 0 1px 1px #006799, -1px 0 1px #006799;
|
||||
}
|
||||
|
||||
.hfe-admin-addons .addon-item .action-button .button.button-primary:hover,
|
||||
.hfe-admin-addons .addon-item .action-button .button.button-primary:focus {
|
||||
background: #008ec2;
|
||||
border-color: #006799;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.hfe-admin-addons .addon-item .action-button .button.button-secondary {
|
||||
color: #555;
|
||||
border-color: #cccccc;
|
||||
background: #f7f7f7;
|
||||
box-shadow: 0 1px 0 #cccccc;
|
||||
}
|
||||
|
||||
.hfe-admin-addons .addon-item .action-button .button.button-secondary:hover,
|
||||
.hfe-admin-addons .addon-item .action-button .button.button-secondary:focus {
|
||||
background: #fafafa;
|
||||
border-color: #999;
|
||||
color: #23282d;
|
||||
}
|
||||
|
||||
.hfe-admin-addons .addon-item .action-button .button.disabled {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.hfe-admin-addons .addon-item .actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background-color: #f7f7f7;
|
||||
border-top: 1px solid #ddd;
|
||||
padding: 20px;
|
||||
min-height: 75px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.hfe-admin-addons .addon-item .actions .msg {
|
||||
background-color: #f7f7f7;
|
||||
border: none;
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
font-weight: 600;
|
||||
top: 0;
|
||||
left: 0;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
z-index: 99;
|
||||
padding: 20px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.hfe-admin-addons .addon-item .actions .msg.success,
|
||||
.hfe-admin-addons .addon-item .status .status-active,
|
||||
.hfe-admin-addons .addon-item .action-button button.status-active .fa {
|
||||
color: #2a9b39;
|
||||
}
|
||||
|
||||
.hfe-admin-addons .addon-item .actions .msg.error,
|
||||
.hfe-admin-addons .addon-item .status .status-inactive,
|
||||
.hfe-admin-addons .addon-item .action-button button.status-inactive .fa {
|
||||
color: red;
|
||||
}
|
||||
|
||||
.hfe-admin-addons .addon-item .status {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.hfe-admin-addons .addon-item .status .status-download {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.hfe-admin-addons .addon-item .upgrade-button {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.hfe-admin-addons .addon-item .upgrade-button a {
|
||||
font-weight: 600;
|
||||
width: 110px;
|
||||
text-align: center;
|
||||
padding: 8px 5px;
|
||||
}
|
||||
.hfe-admin-addons .addon-item .action-button a.button {
|
||||
width: 110px;
|
||||
text-align: center;
|
||||
}
|
||||
.hfe-admin-addons .addon-item .action-button button {
|
||||
background: none;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 3px;
|
||||
box-shadow: none;
|
||||
cursor: pointer;
|
||||
font-weight: 600;
|
||||
width: 110px;
|
||||
text-align: center;
|
||||
padding: 8px 5px;
|
||||
}
|
||||
|
||||
.hfe-admin-addons .addon-item .action-button button:hover, .hfe-admin-addons .addon-item .action-button button.loading {
|
||||
background-color: #e9e9e9;
|
||||
}
|
||||
|
||||
.hfe-admin-addons .addon-item .action-button button .fa {
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.hfe-admin-addons .addon-item .action-button button .fa.fa-spinner {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.hfe-admin-addons .addon-item .action-button button.status-download .fa {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.hfe-admin-addons .addon-item .action-button button.disabled {
|
||||
cursor: default;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.hfe-admin-addons .addon-item .action-button button.loading .fa {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.hfe-admin-addons .addon-item .action-button a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/* Modal Popup */
|
||||
.hfe-guide-modal-header {
|
||||
padding: 10px;
|
||||
text-align: center;
|
||||
}
|
||||
.hfe-guide-modal-popup-wrapper .heading {
|
||||
background: #ffffff;
|
||||
padding: 5px 20px;
|
||||
margin-top: 0;
|
||||
box-shadow: 0 0 8px rgb(0 0 0 / 10%);
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.hfe-guide-modal-popup-wrapper .hfe-admin-guide-section.hfe-admin-about-section,
|
||||
.hfe-guide-modal-popup-wrapper .hfe-admin-column-50:not(.hfe-admin-column-last) {
|
||||
margin: 0px;
|
||||
}
|
||||
.hfe-guide-modal-popup-wrapper .hfe-admin-column-50:not(.hfe-admin-column-last),
|
||||
.hfe-admin-column-last .hfe-guide-content form {
|
||||
padding: 50px;
|
||||
}
|
||||
.hfe-guide-modal-overlay {
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
visibility: hidden;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 9999;
|
||||
opacity: 0;
|
||||
background: rgba(0,0,0,0.75);
|
||||
-webkit-transition: all .5s;
|
||||
transition: all .5s;
|
||||
}
|
||||
.hfe-guide-modal-content {
|
||||
width: 70%;
|
||||
background-color: #ffffff;
|
||||
opacity: 0;
|
||||
position: relative;
|
||||
margin: 0 auto;
|
||||
transition: all .5s;
|
||||
}
|
||||
.hfe-guide-modal-popup-wrapper {
|
||||
z-index: 99999;
|
||||
top: 51%;
|
||||
transform: translateY(-50%);
|
||||
margin-bottom: 20px;
|
||||
visibility: hidden;
|
||||
position: fixed;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
bottom: auto;
|
||||
}
|
||||
.hfe-guide-modal-popup-wrapper .subscription-anim .subscription-label {
|
||||
background-color: #ffffff;
|
||||
}
|
||||
.hfe-guide-modal-popup-wrapper .hfe-admin-about-section {
|
||||
background-color: #f1f3f5;
|
||||
}
|
||||
.hfe-admin-about-section h3 {
|
||||
font-size: 20px;
|
||||
}
|
||||
.hfe-guide-modal-popup-wrapper .hfe-guide-content form {
|
||||
padding: 0px;
|
||||
}
|
||||
.hfe-guide-modal-popup-wrapper .hfe-guide-content {
|
||||
background-color: #ffffff;
|
||||
box-shadow: 0 2px 30px 0 rgb(0 0 0 / 8%);
|
||||
border: 0px;
|
||||
padding: 50px 50px 25px 50px;
|
||||
}
|
||||
.hfe-guide-modal-popup-wrapper .hfe-admin-columns .hfe-admin-column-50.hfe-admin-column-last {
|
||||
width: 50%;
|
||||
margin: 0;
|
||||
padding: 50px;
|
||||
}
|
||||
.hfe-guide-modal-popup-wrapper .hfe-admin-columns .hfe-admin-column-50 {
|
||||
width: 50%;
|
||||
background: unset;
|
||||
border: 0px;
|
||||
}
|
||||
.hfe-guide-modal-popup-wrapper .heading {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.hfe-guide-modal-popup-wrapper .hfe-logo {
|
||||
height: 35px;
|
||||
}
|
||||
.hfe-guide-modal-popup-wrapper h3 {
|
||||
width: 100%;
|
||||
margin-left: 15px;
|
||||
}
|
||||
.hfe-guide-modal-popup-wrapper .hfe-admin-about-section.hfe-admin-columns.hfe-admin-guide-section {
|
||||
max-height: 75vh;
|
||||
overflow: auto;
|
||||
}
|
||||
.hfe-guide-modal-popup-wrapper .hfe-admin-about-section-column {
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
.hfe-guide-modal-popup-wrapper .hfe-subscription-step-1-active .hfe-subscription-step-2,
|
||||
.hfe-guide-modal-popup-wrapper .hfe-subscription-step-2-active .hfe-subscription-step-1 {
|
||||
display: none;
|
||||
}
|
||||
/* Limited this only for modal Popup */
|
||||
.hfe-guide-modal-popup-wrapper .hfe-subscription-row .hfe-input-container,
|
||||
.hfe-guide-modal-popup-wrapper .button {
|
||||
width: 100%;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.hfe-guide-modal-popup-wrapper .hfe-subscription-row {
|
||||
display: block;
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
.hfe-guide-modal-popup-wrapper .hfe-admin-about-section-column h2 {
|
||||
font-size: 28px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
.hfe-admin-about-section-column h3 {
|
||||
margin-bottom: 0;
|
||||
padding: 15px 30px;
|
||||
border-bottom: 1px solid #c3c4c7;
|
||||
}
|
||||
.hfe-admin-about-section-column h3 {
|
||||
text-align: center;
|
||||
font-size: 18px;
|
||||
line-height: 1.3;
|
||||
}
|
||||
.hfe-show {
|
||||
z-index: 9999;
|
||||
}
|
||||
.hfe-show .hfe-modal-close,
|
||||
.hfe-show .hfe-modal-close.action-button,
|
||||
.hfe-show .hfe-guide-modal-content {
|
||||
visibility: visible;
|
||||
}
|
||||
.hfe-show .hfe-guide-modal-overlay {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
}
|
||||
.hfe-show .hfe-guide-modal-content {
|
||||
opacity: 1;
|
||||
}
|
||||
.hfe-input-container.hfe-error .hfe-subscribe-field {
|
||||
border-color: #d11212;
|
||||
}
|
||||
span.hfe-subscribe-message {
|
||||
width: 100%;
|
||||
display: block;
|
||||
text-align: center;
|
||||
margin-top: 20px;
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
padding: 15px;
|
||||
}
|
||||
span.hfe-subscribe-message.success {
|
||||
color: #3c763d;
|
||||
background-color: #dff0d8;
|
||||
border-left: 4px solid #93d776;
|
||||
}
|
||||
span.hfe-subscribe-message.error {
|
||||
color: #d11212;
|
||||
background-color: #f2dede96;
|
||||
border-left: 4px solid #c01a1a66;
|
||||
}
|
||||
span.dashicons.dashicons-update.hfe-loader {
|
||||
animation: rotation 2s infinite linear;
|
||||
vertical-align: text-top;
|
||||
margin-left: 7px;
|
||||
}
|
||||
|
||||
@media (max-width: 1249px) {
|
||||
.hfe-admin-addons .addon-container {
|
||||
width: 50%;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.hfe-admin-addons .addon-container {
|
||||
width: 100%;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.hfe-admin-about-section .hfe-admin-column-40 {
|
||||
width: 100%;
|
||||
padding-left: 0;
|
||||
padding-top: 20px;
|
||||
}
|
||||
.hfe-admin-about-section .hfe-admin-column-60 {
|
||||
width: 100%;
|
||||
padding-right: 0;
|
||||
}
|
||||
.hfe-admin-addons .addon-item {
|
||||
margin: 0 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and ( max-width: 782px ) {
|
||||
.hfe-subscription-row,
|
||||
.hfe-admin-about-section {
|
||||
display: block;
|
||||
}
|
||||
.hfe-guide-modal-popup-wrapper p.button,
|
||||
.hfe-admin-about-section figure {
|
||||
padding-bottom: 0px;
|
||||
}
|
||||
.hfe-admin-guide-section.hfe-admin-columns .hfe-admin-column-50,
|
||||
.hfe-guide-modal-popup-wrapper .hfe-admin-columns .hfe-admin-column-50.hfe-admin-column-last,
|
||||
.hfe-subscription-row .hfe-input-container {
|
||||
width: 100%;
|
||||
}
|
||||
.hfe-guide-modal-popup-wrapper .hfe-admin-columns .hfe-admin-column-50.hfe-admin-column-last,
|
||||
.hfe-guide-modal-popup-wrapper .hfe-guide-content,
|
||||
.hfe-admin-guide-section .hfe-admin-column-50:not(.hfe-admin-column-last) {
|
||||
padding: 15px;
|
||||
}
|
||||
.hfe-subscribe-email span.dashicons.dashicons-email {
|
||||
font-size: 15px;
|
||||
height: 15px;
|
||||
line-height: 1;
|
||||
width: 15px;
|
||||
}
|
||||
.hfe-subscribe-email input.hfe-subscribe-field {
|
||||
min-height: unset;
|
||||
font-size: 10px;
|
||||
}
|
||||
.hfe-subscribe-field {
|
||||
padding: 5px;
|
||||
}
|
||||
.hfe-admin-guide-section.hfe-admin-about-section {
|
||||
display: block;
|
||||
}
|
||||
.hfe-guide-content .button {
|
||||
font-size: 10px;
|
||||
}
|
||||
.hfe-checkbox-container {
|
||||
display: flex;
|
||||
}
|
||||
.hfe-admin-columns .hfe-admin-column-last {
|
||||
padding-top: 0px;
|
||||
}
|
||||
.hfe-subscription-row select.hfe-subscribe-field {
|
||||
padding: 10px 15px;
|
||||
}
|
||||
.hfe-admin-about-section-column h3 {
|
||||
border-bottom: 0px;
|
||||
}
|
||||
.hfe-admin-about-us {
|
||||
margin-right: 10px;
|
||||
}
|
||||
.hfe-admin-addons .addon-container,
|
||||
.hfe-admin-addons .addon-container:last-child {
|
||||
padding-right: 0px;
|
||||
}
|
||||
}
|
||||
|
||||
#toplevel_page_hfe .wp-submenu li a[href*="https://ultimateelementor.com/pricing/?utm_source=wp-admin&utm_medium=menu&utm_campaign=uae-upgrade"]{
|
||||
background-color:#04a382;
|
||||
color:#fff;
|
||||
font-size:13px;
|
||||
font-weight:500;
|
||||
line-height:20px;
|
||||
padding-right:12px!important;
|
||||
padding-left:12px!important
|
||||
}
|
||||
|
||||
#toplevel_page_hfe .wp-submenu li a[href*="https://ultimateelementor.com/pricing/?utm_source=wp-admin&utm_medium=menu&utm_campaign=uae-upgrade"]:hover
|
||||
{
|
||||
background-color:#018d71;
|
||||
color:#fff;
|
||||
font-size:13px;
|
||||
font-weight:500;
|
||||
line-height:20px;
|
||||
padding-right:12px!important;
|
||||
padding-left:12px!important
|
||||
}
|
||||
|
||||
.uae-plugins-go-pro{
|
||||
color: #93003C;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.uae-plugins-go-pro:active,
|
||||
.uae-plugins-go-pro:focus,
|
||||
.uae-plugins-go-pro:hover
|
||||
{
|
||||
color:#93003C;
|
||||
opacity:.8;
|
||||
}
|
||||
|
||||
/* Rating Stars in Plugin List - Remove all borders and outlines */
|
||||
tr[data-plugin*="header-footer-elementor"] a[href*="reviews"],
|
||||
tr[data-plugin*="header-footer-elementor"] a[href*="reviews"]:focus,
|
||||
tr[data-plugin*="header-footer-elementor"] a[href*="reviews"]:active,
|
||||
tr[data-plugin*="header-footer-elementor"] a[href*="reviews"]:hover,
|
||||
tr[data-plugin*="header-footer-elementor"] .plugin-description-actions a[href*="reviews"],
|
||||
tr[data-plugin*="header-footer-elementor"] .plugin-description-actions a[href*="reviews"]:focus,
|
||||
tr[data-plugin*="header-footer-elementor"] .plugin-description-actions a[href*="reviews"]:active,
|
||||
tr[data-plugin*="header-footer-elementor"] .plugin-description-actions a[href*="reviews"]:hover {
|
||||
text-decoration: none !important;
|
||||
outline: 0 !important;
|
||||
outline: none !important;
|
||||
border: 0 !important;
|
||||
border: none !important;
|
||||
box-shadow: none !important;
|
||||
-webkit-box-shadow: none !important;
|
||||
-moz-box-shadow: none !important;
|
||||
background: transparent !important;
|
||||
display: inline-block;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
tr[data-plugin*="header-footer-elementor"] a[href*="reviews"]:hover,
|
||||
tr[data-plugin*="header-footer-elementor"] .plugin-description-actions a[href*="reviews"]:hover {
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
tr[data-plugin*="header-footer-elementor/header-footer-elementor.php"] .plugin-description-actions a[href*="reviews"] .dashicons {
|
||||
vertical-align: top;
|
||||
margin: 0 1px;
|
||||
}
|
||||
|
||||
/* Rating star styles for plugin meta links */
|
||||
.hfe-rating-star {
|
||||
color: #ffb900;
|
||||
font-size: 16px;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
line-height: 1.2;
|
||||
}
|
||||
@@ -0,0 +1,512 @@
|
||||
;( function( $ ) {
|
||||
|
||||
'use strict';
|
||||
|
||||
// Global settings access.
|
||||
var settings = {
|
||||
iconActivate: '<i class="fa fa-toggle-on fa-flip-horizontal" aria-hidden="true"></i>',
|
||||
iconDeactivate: '<i class="fa fa-toggle-on" aria-hidden="true"></i>',
|
||||
iconInstall: '<i class="fa fa-cloud-download" aria-hidden="true"></i>'
|
||||
};
|
||||
|
||||
var HFEAdmin = {
|
||||
|
||||
/**
|
||||
* Start the engine.
|
||||
*
|
||||
* @since 1.3.9
|
||||
*/
|
||||
_init: function() {
|
||||
|
||||
var ehf_hide_shortcode_field = function() {
|
||||
var selected = $('#ehf_template_type').val() || 'none';
|
||||
$( '.hfe-options-table' ).removeClass().addClass( 'hfe-options-table widefat hfe-selected-template-type-' + selected );
|
||||
}
|
||||
|
||||
var $document = $( document );
|
||||
|
||||
$document.on( 'change', '#ehf_template_type', function( e ) {
|
||||
ehf_hide_shortcode_field();
|
||||
});
|
||||
|
||||
ehf_hide_shortcode_field();
|
||||
|
||||
// Templates page modal popup.
|
||||
HFEAdmin._display_modal();
|
||||
|
||||
$( '.hfe-subscribe-field' ).on( 'keyup', function( e ) {
|
||||
$( '.hfe-subscribe-message' ).remove();
|
||||
});
|
||||
|
||||
$document.on( 'focusout change', '.hfe-subscribe-field', HFEAdmin._validate_single_field );
|
||||
$document.on( 'click input', '.hfe-subscribe-field', HFEAdmin._animate_fields );
|
||||
|
||||
$document.on( 'click', '.hfe-guide-content .submit-1', HFEAdmin._step_one_subscribe );
|
||||
$document.on( 'click', '.hfe-guide-content .submit-2', HFEAdmin._step_two_subscribe );
|
||||
|
||||
$document.on('click', '.hfe-guide-content .button-subscription-skip', HFEAdmin._close_modal );
|
||||
|
||||
// About us - addons functionality.
|
||||
if ( $( '.hfe-admin-addons' ).length ) {
|
||||
|
||||
$document.on( 'click', '.hfe-admin-addons .addon-item button', function( event ) {
|
||||
event.preventDefault();
|
||||
|
||||
if ( $( this ).hasClass( 'disabled' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
HFEAdmin._addons( $( this ) );
|
||||
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
if( "yes" === hfe_admin_data.show_all_hfe ) {
|
||||
// Add the "View All" button next to the "Add New" button.
|
||||
const addNewButton = document.querySelector('.page-title-action');
|
||||
if ( addNewButton ) {
|
||||
// Create the new button.
|
||||
const customButton = document.createElement('a');
|
||||
customButton.href = hfe_admin_data.hfe_edit_url;
|
||||
customButton.textContent = hfe_admin_data.view_all_text;
|
||||
customButton.className = 'page-title-action';
|
||||
customButton.style.marginLeft = '10px';
|
||||
addNewButton.insertAdjacentElement('afterend', customButton);
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
_animate_fields: function ( event ) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
var parentWrapper = $( this ).parents( '.hfe-input-container' );
|
||||
parentWrapper.addClass( 'subscription-anim' );
|
||||
},
|
||||
|
||||
_validate_single_field: function ( event ) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
HFEAdmin._validate_field( event.target );
|
||||
},
|
||||
|
||||
_validate_field: function ( target ) {
|
||||
|
||||
var field = $( target );
|
||||
var fieldValue = field.val() || '';
|
||||
var parentWrapper = field.parents( '.hfe-input-container' );
|
||||
var fieldStatus = fieldValue.length ? true : false;
|
||||
|
||||
if ( ( field.hasClass( 'hfe-subscribe-email' ) && false === HFEAdmin._is_valid_email( fieldValue ) )) {
|
||||
fieldStatus = false;
|
||||
}
|
||||
|
||||
if ( fieldStatus ) {
|
||||
parentWrapper.removeClass( 'subscription-error' ).addClass( 'subscription-success' );
|
||||
} else {
|
||||
parentWrapper.removeClass( 'subscription-success subscription-anim' ).addClass( 'subscription-error' );
|
||||
|
||||
if ( field.hasClass( 'hfe-subscribe-email' ) && fieldValue.length ) {
|
||||
parentWrapper.addClass( 'subscription-anim' );
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Subscribe Form Step One
|
||||
*
|
||||
*/
|
||||
_step_one_subscribe: function( event ) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
var form_one_wrapper = $( '.hfe-subscription-step-1' );
|
||||
|
||||
var first_name_field = form_one_wrapper.find( '.hfe-subscribe-field[name="hfe_subscribe_name"]' );
|
||||
var email_field = form_one_wrapper.find( '.hfe-subscribe-field[name="hfe_subscribe_email"]' );
|
||||
|
||||
HFEAdmin._validate_field( first_name_field );
|
||||
HFEAdmin._validate_field( email_field );
|
||||
|
||||
if ( form_one_wrapper.find( '.hfe-input-container' ).hasClass( 'subscription-error' )) {
|
||||
return;
|
||||
}
|
||||
|
||||
$( '.hfe-guide-content' ).addClass( 'hfe-subscription-step-2-active' ).removeClass( 'hfe-subscription-step-1-active' );
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Subscribe Form
|
||||
*
|
||||
*/
|
||||
_step_two_subscribe: function( event ) {
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
var submit_button = $(this);
|
||||
|
||||
var is_modal = $( '.hfe-guide-modal-popup.hfe-show' );
|
||||
|
||||
var first_name_field = $('.hfe-subscribe-field[name="hfe_subscribe_name"]');
|
||||
var email_field = $('.hfe-subscribe-field[name="hfe_subscribe_email"]');
|
||||
var user_type_field = $('.hfe-subscribe-field[name="wp_user_type"]');
|
||||
var build_for_field = $('.hfe-subscribe-field[name="build_website_for"]');
|
||||
var accept_field = $('.hfe_subscribe_accept[name="hfe_subscribe_accept"]');
|
||||
|
||||
var subscription_first_name = first_name_field.val() || '';
|
||||
var subscription_email = email_field.val() || '';
|
||||
var subscription_user_type = user_type_field.val() || '';
|
||||
var subscription_build_for = build_for_field.val() || '';
|
||||
var button_text = submit_button.find( '.hfe-submit-button-text' );
|
||||
var subscription_accept = accept_field.is( ':checked' ) ? '1' : '0';
|
||||
|
||||
HFEAdmin._validate_field( first_name_field );
|
||||
HFEAdmin._validate_field( email_field );
|
||||
HFEAdmin._validate_field( user_type_field );
|
||||
HFEAdmin._validate_field( build_for_field );
|
||||
|
||||
$( '.hfe-subscribe-message' ).remove();
|
||||
|
||||
if ( $( '.hfe-input-container' ).hasClass( 'subscription-error' )) {
|
||||
return;
|
||||
}
|
||||
|
||||
submit_button.removeClass( 'submitted' );
|
||||
|
||||
if( ! submit_button.hasClass( 'submitting' ) ) {
|
||||
submit_button.addClass( 'submitting' );
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
var subscription_fields = {
|
||||
EMAIL: subscription_email,
|
||||
FIRSTNAME: subscription_first_name,
|
||||
PAGE_BUILDER: "1",
|
||||
WP_USER_TYPE: subscription_user_type,
|
||||
BUILD_WEBSITE_FOR: subscription_build_for,
|
||||
OPT_IN: subscription_accept,
|
||||
SOURCE: hfe_admin_data.data_source
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
url : hfe_admin_data.ajax_url,
|
||||
type : 'POST',
|
||||
data : {
|
||||
action : 'hfe-update-subscription',
|
||||
nonce : hfe_admin_data.nonce,
|
||||
data: JSON.stringify( subscription_fields ),
|
||||
},
|
||||
beforeSend: function() {
|
||||
console.groupCollapsed( 'Email Subscription' );
|
||||
|
||||
button_text.append( '<span class="dashicons dashicons-update hfe-loader"></span>' );
|
||||
|
||||
},
|
||||
})
|
||||
.done( function ( response ) {
|
||||
|
||||
$( '.hfe-loader.dashicons-update' ).remove();
|
||||
|
||||
submit_button.removeClass( 'submitting' ).addClass('submitted');
|
||||
|
||||
if( response.success === true ) {
|
||||
$('.hfe-admin-about-section form').trigger( "reset" );
|
||||
$( '.hfe-input-container' ).removeClass( 'subscription-success subscription-anim' );
|
||||
|
||||
submit_button.after( '<span class="hfe-subscribe-message success">' + hfe_admin_data.subscribe_success + '</span>' );
|
||||
} else {
|
||||
submit_button.after( '<span class="hfe-subscribe-message error">' + hfe_admin_data.subscribe_error + '</span>' );
|
||||
}
|
||||
|
||||
if( is_modal.length ) {
|
||||
window.setTimeout( function () {
|
||||
window.location = $( '.hfe-guide-modal-popup' ).data( 'new-page' );
|
||||
}, 3000 );
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* email Validation
|
||||
*
|
||||
*/
|
||||
_is_valid_email: function(eMail) {
|
||||
if (/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test( eMail ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Display the Modal Popup
|
||||
*
|
||||
*/
|
||||
_display_modal: function() {
|
||||
var hf_new_post = $( '.post-type-elementor-hf' ).find( '.page-title-action' );
|
||||
|
||||
var modal_wrapper = $( '.hfe-guide-modal-popup' );
|
||||
var display_allow = hfe_admin_data.popup_dismiss;
|
||||
|
||||
if( 'dismissed' !== display_allow[0] ) {
|
||||
// Display Modal Popup on click of Add new button.
|
||||
hf_new_post.on( 'click', function(e) {
|
||||
if( modal_wrapper.length && ! modal_wrapper.hasClass( 'hfe-show' ) ) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
modal_wrapper.addClass( 'hfe-show' );
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Close the Modal Popup
|
||||
*
|
||||
*/
|
||||
_close_modal: function() {
|
||||
var modal_wrapper = $( '.hfe-guide-modal-popup' );
|
||||
var new_page_link = modal_wrapper.data( 'new-page' );
|
||||
|
||||
$.ajax({
|
||||
url: hfe_admin_data.ajax_url,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action : 'hfe_admin_modal',
|
||||
nonce : hfe_admin_data.nonce,
|
||||
},
|
||||
});
|
||||
|
||||
if( modal_wrapper.hasClass( 'hfe-show' ) ) {
|
||||
modal_wrapper.removeClass( 'hfe-show' );
|
||||
}
|
||||
|
||||
window.location = new_page_link;
|
||||
},
|
||||
|
||||
/**
|
||||
* Toggle addon state.
|
||||
*/
|
||||
_addons: function( $button ) {
|
||||
|
||||
var $addon = $button.closest( '.addon-item' ),
|
||||
plugin = $button.attr( 'data-plugin' ),
|
||||
addonType = $button.attr( 'data-type' ),
|
||||
addonSlug = $button.attr( 'data-slug' ),
|
||||
addonFile = $button.attr( 'data-file' ),
|
||||
state,
|
||||
cssClass,
|
||||
stateText,
|
||||
buttonText,
|
||||
errorText,
|
||||
successText;
|
||||
|
||||
if ( $button.hasClass( 'status-go-to-url' ) ) {
|
||||
|
||||
// Open url in new tab.
|
||||
window.open( $button.attr( 'data-site' ), '_blank' );
|
||||
return;
|
||||
}
|
||||
|
||||
$button.prop( 'disabled', true ).addClass( 'loading' );
|
||||
$button.html( '<span class="dashicons dashicons-update hfe-loader"></span>' );
|
||||
|
||||
if ( $button.hasClass( 'status-active' ) ) {
|
||||
|
||||
// Deactivate.
|
||||
state = 'deactivate';
|
||||
cssClass = 'status-inactive';
|
||||
cssClass += ' button button-secondary';
|
||||
stateText = hfe_admin_data.addon_inactive;
|
||||
buttonText = hfe_admin_data.addon_activate;
|
||||
errorText = hfe_admin_data.addon_deactivate;
|
||||
|
||||
} else if ( $button.hasClass( 'status-inactive' ) ) {
|
||||
|
||||
// Activate.
|
||||
state = 'activate';
|
||||
cssClass = 'status-active';
|
||||
cssClass += ' button button-secondary disabled';
|
||||
stateText = hfe_admin_data.addon_active;
|
||||
buttonText = hfe_admin_data.addon_deactivate;
|
||||
buttonText = hfe_admin_data.addon_activated;
|
||||
errorText = hfe_admin_data.addon_activate;
|
||||
|
||||
} else if ( $button.hasClass( 'status-download' ) ) {
|
||||
|
||||
// Install & Activate.
|
||||
state = 'install';
|
||||
cssClass = 'status-active';
|
||||
cssClass += ' button disabled';
|
||||
stateText = hfe_admin_data.addon_active;
|
||||
buttonText = hfe_admin_data.addon_activated;
|
||||
errorText = settings.iconInstall;
|
||||
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
HFEAdmin._set_addon_state( plugin, state, addonType, addonSlug, function( res ) {
|
||||
|
||||
if ( res.success ) {
|
||||
if ( 'install' === state ) {
|
||||
successText = res.msg;
|
||||
$button.attr( 'data-plugin', addonFile );
|
||||
|
||||
stateText = hfe_admin_data.addon_inactive;
|
||||
buttonText = ( addonType === 'theme' || addonType === 'plugin' ) ? hfe_admin_data.addon_activate : settings.iconActivate + hfe_admin_data.addon_activate;
|
||||
cssClass = ( addonType === 'theme' || addonType === 'plugin' ) ? 'status-inactive button button-secondary' : 'status-inactive';
|
||||
} else {
|
||||
successText = res.data;
|
||||
}
|
||||
$addon.find( '.actions' ).append( '<div class="msg success">' + successText + '</div>' );
|
||||
$addon.find( 'span.status-label' )
|
||||
.removeClass( 'status-active status-inactive status-download' )
|
||||
.addClass( cssClass )
|
||||
.removeClass( 'button button-primary button-secondary disabled' )
|
||||
.text( stateText );
|
||||
$button
|
||||
.removeClass( 'status-active status-inactive status-download' )
|
||||
.removeClass( 'button button-primary button-secondary disabled' )
|
||||
.addClass( cssClass ).html( buttonText );
|
||||
} else {
|
||||
|
||||
if ( 'install' === state && ( addonType === 'theme' || addonType === 'plugin' ) ) {
|
||||
$addon.find( '.actions' ).append( '<div class="msg error">' + res.msg + '</div>' );
|
||||
$button.addClass( 'status-go-to-url' ).removeClass( 'status-download' );
|
||||
} else {
|
||||
var error_msg = ( 'object' === typeof res.data ) ? hfe_admin_data.plugin_error : res.data;
|
||||
$addon.find( '.actions' ).append( '<div class="msg error">' + error_msg + '</div>' );
|
||||
}
|
||||
|
||||
if( 'ultimate-elementor' === addonSlug ) {
|
||||
$button.addClass( 'status-go-to-url' );
|
||||
$button.html( hfe_admin_data.visit_site );
|
||||
} else {
|
||||
$button.html( hfe_admin_data.addon_download );
|
||||
}
|
||||
}
|
||||
|
||||
$button.prop( 'disabled', false ).removeClass( 'loading' );
|
||||
|
||||
// Automatically clear the messages after 3 seconds.
|
||||
setTimeout( function() {
|
||||
$( '.addon-item .msg' ).remove();
|
||||
}, 3000 );
|
||||
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Change plugin/addon state.
|
||||
*
|
||||
* @since 1.6.0
|
||||
*
|
||||
* @param {string} plugin Plugin/Theme URL for download.
|
||||
* @param {string} state State status activate|deactivate|install.
|
||||
* @param {string} addonType Plugin/Theme type addon or plugin.
|
||||
* @param {string} addonSlug Plugin/Theme slug addon or plugin.
|
||||
* @param {Function} callback Callback for get result from AJAX.
|
||||
*/
|
||||
_set_addon_state: function( plugin, state, addonType, addonSlug, callback ) {
|
||||
|
||||
var actions = {
|
||||
'activate': 'hfe_activate_addon',
|
||||
'install': '',
|
||||
},
|
||||
action = actions[ state ];
|
||||
|
||||
if ( ! action && 'install' !== state ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var data_result = {
|
||||
success : false,
|
||||
msg : hfe_admin_data.subscribe_error,
|
||||
};
|
||||
|
||||
if( 'install' === state ) {
|
||||
|
||||
if ( wp.updates.shouldRequestFilesystemCredentials && ! wp.updates.ajaxLocked ) {
|
||||
wp.updates.requestFilesystemCredentials();
|
||||
}
|
||||
|
||||
if( 'theme' === addonType ) {
|
||||
|
||||
wp.updates.installTheme ( {
|
||||
slug: addonSlug,
|
||||
success: function() {
|
||||
data_result.success = true;
|
||||
data_result.msg = hfe_admin_data.theme_installed;
|
||||
|
||||
},
|
||||
error: function( xhr ) {
|
||||
console.log( xhr.errorCode );
|
||||
if ( 'folder_exists' === xhr.errorCode ) {
|
||||
data_result.success = true;
|
||||
data_result.msg = hfe_admin_data.addon_exists;
|
||||
} else {
|
||||
data_result.success = false;
|
||||
data_result.msg = hfe_admin_data.plugin_error;
|
||||
}
|
||||
},
|
||||
}).always( function () {
|
||||
callback( data_result );
|
||||
});
|
||||
|
||||
} else if( 'plugin' === addonType ) {
|
||||
|
||||
wp.updates.installPlugin ( {
|
||||
slug: addonSlug,
|
||||
success: function() {
|
||||
data_result.success = true;
|
||||
data_result.msg = hfe_admin_data.plugin_installed;
|
||||
},
|
||||
error: function( xhr ) {
|
||||
console.log( xhr.errorCode );
|
||||
if ( 'folder_exists' === xhr.errorCode ) {
|
||||
data_result.success = true;
|
||||
data_result.msg = hfe_admin_data.addon_exists;
|
||||
} else {
|
||||
data_result.success = false;
|
||||
data_result.msg = hfe_admin_data.plugin_error;
|
||||
}
|
||||
},
|
||||
}).always( function () {
|
||||
callback( data_result );
|
||||
});
|
||||
}
|
||||
|
||||
} else if( 'activate' === state ) {
|
||||
|
||||
var data = {
|
||||
action: action,
|
||||
nonce: hfe_admin_data.nonce,
|
||||
plugin: plugin,
|
||||
type: addonType,
|
||||
slug: addonSlug
|
||||
};
|
||||
|
||||
$.post( hfe_admin_data.ajax_url, data, function( res ) {
|
||||
callback( res );
|
||||
} ).fail( function( xhr ) {
|
||||
console.log( xhr.responseText );
|
||||
} );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$( document ).ready( function( e ) {
|
||||
HFEAdmin._init();
|
||||
});
|
||||
|
||||
window.HFEAdmin = HFEAdmin;
|
||||
|
||||
} )( jQuery );
|
||||
wp-content/plugins/header-footer-elementor/admin/bsf-analytics/assets/css/minified/style-rtl.min.css
Vendored
+1
@@ -0,0 +1 @@
|
||||
[ID*="-optin-notice"]{padding:1px 12px;border-right-color:#007cba}[ID*="-optin-notice"] .notice-container{padding-top:10px;padding-bottom:12px}[ID*="-optin-notice"] .notice-content{margin:0}[ID*="-optin-notice"] .notice-heading{padding:0 0 12px 20px}[ID*="-optin-notice"] .button-primary{margin-left:5px}
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
[ID*="-optin-notice"]{padding:1px 12px;border-left-color:#007cba}[ID*="-optin-notice"] .notice-container{padding-top:10px;padding-bottom:12px}[ID*="-optin-notice"] .notice-content{margin:0}[ID*="-optin-notice"] .notice-heading{padding:0 20px 12px 0}[ID*="-optin-notice"] .button-primary{margin-right:5px}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
[ID*="-optin-notice"] {
|
||||
padding: 1px 12px;
|
||||
border-right-color: #007cba;
|
||||
}
|
||||
|
||||
[ID*="-optin-notice"] .notice-container {
|
||||
padding-top: 10px;
|
||||
padding-bottom: 12px;
|
||||
}
|
||||
|
||||
[ID*="-optin-notice"] .notice-content {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
[ID*="-optin-notice"] .notice-heading {
|
||||
padding: 0 0 12px 20px;
|
||||
}
|
||||
|
||||
[ID*="-optin-notice"] .button-primary {
|
||||
margin-left: 5px;
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
[ID*="-optin-notice"] {
|
||||
padding: 1px 12px;
|
||||
border-left-color: #007cba;
|
||||
}
|
||||
|
||||
[ID*="-optin-notice"] .notice-container {
|
||||
padding-top: 10px;
|
||||
padding-bottom: 12px;
|
||||
}
|
||||
|
||||
[ID*="-optin-notice"] .notice-content {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
[ID*="-optin-notice"] .notice-heading {
|
||||
padding: 0 20px 12px 0;
|
||||
}
|
||||
|
||||
[ID*="-optin-notice"] .button-primary {
|
||||
margin-right: 5px;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
v1.1.16 - 15-July-2025
|
||||
- Improvement: Added `SureRank` slug to UTM analytics.
|
||||
|
||||
v1.1.15 - 1-July-2025
|
||||
- Improvement: Added `Ultimate_VC_Addons` slug to UTM analytics.
|
||||
|
||||
v1.1.14 - 6-May-2025
|
||||
- New: Introduced a key 'hide_optin_checkbox' to hide checkbox from Settings > General.
|
||||
- Improvement: Single optin notice for all bsf products.
|
||||
- Improvement: Introduced delay of 7 days for next optin message if user has reqested request from product.
|
||||
|
||||
v1.1.13 - 17-April-2025
|
||||
- Improvement: Ensured unique id for label's `for` attribute in deactivation survey fields by prefixing them with product slugs.
|
||||
- Improvement: Prevented deactivation survey from triggering when switching from a child theme to its parent.
|
||||
|
||||
v1.1.12 - 24-March-2025
|
||||
- Improvement: Added `suremails` and `latepoint` slugs to UTM analytics.
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/**
|
||||
* BSF analytics loader file.
|
||||
*
|
||||
* @version 1.0.0
|
||||
*
|
||||
* @package bsf-analytics
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Class BSF_Analytics_Loader.
|
||||
*/
|
||||
class BSF_Analytics_Loader {
|
||||
|
||||
/**
|
||||
* Analytics Entities.
|
||||
*
|
||||
* @access private
|
||||
* @var array Entities array.
|
||||
*/
|
||||
private $entities = array();
|
||||
|
||||
/**
|
||||
* Analytics Version.
|
||||
*
|
||||
* @access private
|
||||
* @var float analytics version.
|
||||
*/
|
||||
private $analytics_version = '';
|
||||
|
||||
/**
|
||||
* Analytics path.
|
||||
*
|
||||
* @access private
|
||||
* @var string path array.
|
||||
*/
|
||||
private $analytics_path = '';
|
||||
|
||||
/**
|
||||
* Instance
|
||||
*
|
||||
* @access private
|
||||
* @var object Class object.
|
||||
*/
|
||||
private static $instance = null;
|
||||
|
||||
/**
|
||||
* Get instace of class.
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( null === self::$instance ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'init', array( $this, 'load_analytics' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set entity for analytics.
|
||||
*
|
||||
* @param string $data Entity attributes data.
|
||||
* @return void
|
||||
*/
|
||||
public function set_entity( $data ) {
|
||||
array_push( $this->entities, $data );
|
||||
}
|
||||
|
||||
/**
|
||||
* Load Analytics library.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function load_analytics() {
|
||||
$unique_entities = array();
|
||||
|
||||
if ( ! empty( $this->entities ) ) {
|
||||
foreach ( $this->entities as $entity ) {
|
||||
foreach ( $entity as $key => $data ) {
|
||||
|
||||
if ( isset( $data['path'] ) ) {
|
||||
if ( file_exists( $data['path'] . '/version.json' ) ) {
|
||||
$file_contents = file_get_contents( $data['path'] . '/version.json' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
|
||||
$analytics_version = json_decode( $file_contents, 1 );
|
||||
$analytics_version = $analytics_version['bsf-analytics-ver'];
|
||||
|
||||
if ( version_compare( $analytics_version, $this->analytics_version, '>' ) ) {
|
||||
$this->analytics_version = $analytics_version;
|
||||
$this->analytics_path = $data['path'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! isset( $unique_entities[ $key ] ) ) {
|
||||
$unique_entities[ $key ] = $data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( file_exists( $this->analytics_path ) && ! class_exists( 'BSF_Analytics' ) ) {
|
||||
require_once $this->analytics_path . '/class-bsf-analytics.php';
|
||||
new BSF_Analytics( $unique_entities, $this->analytics_path, $this->analytics_version );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+258
@@ -0,0 +1,258 @@
|
||||
<?php
|
||||
/**
|
||||
* BSF analytics stat class file.
|
||||
*
|
||||
* @package bsf-analytics
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'BSF_Analytics_Stats' ) ) {
|
||||
/**
|
||||
* BSF analytics stat class.
|
||||
*/
|
||||
class BSF_Analytics_Stats {
|
||||
|
||||
/**
|
||||
* Active plugins.
|
||||
*
|
||||
* Holds the sites active plugins list.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $plugins;
|
||||
|
||||
/**
|
||||
* Instance of BSF_Analytics_Stats.
|
||||
*
|
||||
* Holds only the first object of class.
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
private static $instance = null;
|
||||
|
||||
/**
|
||||
* Create only once instance of a class.
|
||||
*
|
||||
* @return object
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function instance() {
|
||||
if ( null === self::$instance ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get stats.
|
||||
*
|
||||
* @return array stats data.
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function get_stats() {
|
||||
return apply_filters( 'bsf_core_stats', $this->get_default_stats() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve stats for site.
|
||||
*
|
||||
* @return array stats data.
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function get_default_stats() {
|
||||
return array(
|
||||
'graupi_version' => defined( 'BSF_UPDATER_VERSION' ) ? BSF_UPDATER_VERSION : false,
|
||||
'domain_name' => get_site_url(),
|
||||
'php_os' => PHP_OS,
|
||||
'server_software' => isset( $_SERVER['SERVER_SOFTWARE'] ) ? wp_kses( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ), [] ) : '',
|
||||
'mysql_version' => $this->get_mysql_version(),
|
||||
'php_version' => $this->get_php_version(),
|
||||
'php_max_input_vars' => ini_get( 'max_input_vars' ), // phpcs:ignore:PHPCompatibility.IniDirectives.NewIniDirectives.max_input_varsFound
|
||||
'php_post_max_size' => ini_get( 'post_max_size' ),
|
||||
'php_max_execution_time' => ini_get( 'max_execution_time' ),
|
||||
'php_memory_limit' => ini_get( 'memory_limit' ),
|
||||
'zip_installed' => extension_loaded( 'zip' ),
|
||||
'imagick_availabile' => extension_loaded( 'imagick' ),
|
||||
'xmlreader_exists' => class_exists( 'XMLReader' ),
|
||||
'gd_available' => extension_loaded( 'gd' ),
|
||||
'curl_version' => $this->get_curl_version(),
|
||||
'curl_ssl_version' => $this->get_curl_ssl_version(),
|
||||
'is_writable' => $this->is_content_writable(),
|
||||
|
||||
'wp_version' => get_bloginfo( 'version' ),
|
||||
'user_count' => $this->get_user_count(),
|
||||
'posts_count' => wp_count_posts()->publish,
|
||||
'page_count' => wp_count_posts( 'page' )->publish,
|
||||
'site_language' => get_locale(),
|
||||
'timezone' => wp_timezone_string(),
|
||||
'is_ssl' => is_ssl(),
|
||||
'is_multisite' => is_multisite(),
|
||||
'network_url' => network_site_url(),
|
||||
'external_object_cache' => (bool) wp_using_ext_object_cache(),
|
||||
'wp_debug' => WP_DEBUG,
|
||||
'wp_debug_display' => WP_DEBUG_DISPLAY,
|
||||
'script_debug' => SCRIPT_DEBUG,
|
||||
|
||||
'active_plugins' => $this->get_active_plugins(),
|
||||
|
||||
'active_theme' => get_template(),
|
||||
'active_stylesheet' => get_stylesheet(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get installed PHP version.
|
||||
*
|
||||
* @return float PHP version.
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function get_php_version() {
|
||||
if ( defined( 'PHP_MAJOR_VERSION' ) && defined( 'PHP_MINOR_VERSION' ) && defined( 'PHP_RELEASE_VERSION' ) ) { // phpcs:ignore
|
||||
return PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION;
|
||||
}
|
||||
|
||||
return phpversion();
|
||||
}
|
||||
|
||||
/**
|
||||
* User count on site.
|
||||
*
|
||||
* @return int User count.
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function get_user_count() {
|
||||
if ( is_multisite() ) {
|
||||
$user_count = get_user_count();
|
||||
} else {
|
||||
$count = count_users();
|
||||
$user_count = $count['total_users'];
|
||||
}
|
||||
|
||||
return $user_count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get active plugin's data.
|
||||
*
|
||||
* @return array active plugin's list.
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function get_active_plugins() {
|
||||
if ( ! $this->plugins ) {
|
||||
// Ensure get_plugin_data function is loaded.
|
||||
if ( ! function_exists( 'get_plugin_data' ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||
}
|
||||
|
||||
$plugins = wp_get_active_and_valid_plugins();
|
||||
$plugins = array_map( 'get_plugin_data', $plugins );
|
||||
$this->plugins = array_map( array( $this, 'format_plugin' ), $plugins );
|
||||
}
|
||||
|
||||
return $this->plugins;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format plugin data.
|
||||
*
|
||||
* @param string $plugin plugin.
|
||||
* @return array formatted plugin data.
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function format_plugin( $plugin ) {
|
||||
return array(
|
||||
'name' => html_entity_decode( $plugin['Name'], ENT_COMPAT, 'UTF-8' ),
|
||||
'url' => $plugin['PluginURI'],
|
||||
'version' => $plugin['Version'],
|
||||
'slug' => $plugin['TextDomain'],
|
||||
'author_name' => html_entity_decode( wp_strip_all_tags( $plugin['Author'] ), ENT_COMPAT, 'UTF-8' ),
|
||||
'author_url' => $plugin['AuthorURI'],
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Curl SSL version.
|
||||
*
|
||||
* @return float SSL version.
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function get_curl_ssl_version() {
|
||||
$curl = array();
|
||||
if ( function_exists( 'curl_version' ) ) {
|
||||
$curl = curl_version(); // phpcs:ignore WordPress.WP.AlternativeFunctions.curl_curl_version
|
||||
}
|
||||
|
||||
return isset( $curl['ssl_version'] ) ? $curl['ssl_version'] : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cURL version.
|
||||
*
|
||||
* @return float cURL version.
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function get_curl_version() {
|
||||
if ( function_exists( 'curl_version' ) ) {
|
||||
$curl = curl_version(); // phpcs:ignore WordPress.WP.AlternativeFunctions.curl_curl_version
|
||||
}
|
||||
|
||||
return isset( $curl['version'] ) ? $curl['version'] : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get MySQL version.
|
||||
*
|
||||
* @return float MySQL version.
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function get_mysql_version() {
|
||||
global $wpdb;
|
||||
return $wpdb->db_version();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if content directory is writable.
|
||||
*
|
||||
* @return bool
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function is_content_writable() {
|
||||
$upload_dir = wp_upload_dir();
|
||||
return wp_is_writable( $upload_dir['basedir'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Polyfill for sites using WP version less than 5.3
|
||||
*/
|
||||
if ( ! function_exists( 'wp_timezone_string' ) ) {
|
||||
/**
|
||||
* Get timezone string.
|
||||
*
|
||||
* @return string timezone string.
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function wp_timezone_string() {
|
||||
$timezone_string = get_option( 'timezone_string' );
|
||||
|
||||
if ( $timezone_string ) {
|
||||
return $timezone_string;
|
||||
}
|
||||
|
||||
$offset = (float) get_option( 'gmt_offset' );
|
||||
$hours = (int) $offset;
|
||||
$minutes = ( $offset - $hours );
|
||||
|
||||
$sign = ( $offset < 0 ) ? '-' : '+';
|
||||
$abs_hour = abs( $hours );
|
||||
$abs_mins = abs( $minutes * 60 );
|
||||
$tz_offset = sprintf( '%s%02d:%02d', $sign, $abs_hour, $abs_mins );
|
||||
|
||||
return $tz_offset;
|
||||
}
|
||||
}
|
||||
+603
@@ -0,0 +1,603 @@
|
||||
<?php
|
||||
/**
|
||||
* BSF analytics class file.
|
||||
*
|
||||
* @version 1.0.0
|
||||
*
|
||||
* @package bsf-analytics
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'BSF_Analytics' ) ) {
|
||||
|
||||
/**
|
||||
* BSF analytics
|
||||
*/
|
||||
class BSF_Analytics {
|
||||
|
||||
/**
|
||||
* Member Variable
|
||||
*
|
||||
* @var array Entities data.
|
||||
*/
|
||||
private $entities;
|
||||
|
||||
/**
|
||||
* Member Variable
|
||||
*
|
||||
* @var string Usage tracking document URL
|
||||
*/
|
||||
public $usage_doc_link = 'https://store.brainstormforce.com/usage-tracking/?utm_source=wp_dashboard&utm_medium=general_settings&utm_campaign=usage_tracking';
|
||||
|
||||
/**
|
||||
* Setup actions, load files.
|
||||
*
|
||||
* @param array $args entity data for analytics.
|
||||
* @param string $analytics_path directory path to analytics library.
|
||||
* @param float $analytics_version analytics library version.
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct( $args, $analytics_path, $analytics_version ) {
|
||||
|
||||
// Bail when no analytics entities are registered.
|
||||
if ( empty( $args ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->entities = $args;
|
||||
|
||||
define( 'BSF_ANALYTICS_VERSION', $analytics_version );
|
||||
define( 'BSF_ANALYTICS_URI', $this->get_analytics_url( $analytics_path ) );
|
||||
|
||||
add_action( 'admin_init', array( $this, 'handle_optin_optout' ) );
|
||||
add_action( 'admin_init', array( $this, 'option_notice' ) );
|
||||
add_action( 'init', array( $this, 'maybe_track_analytics' ), 99 );
|
||||
|
||||
$this->set_actions();
|
||||
|
||||
add_action( 'admin_init', array( $this, 'register_usage_tracking_setting' ) );
|
||||
|
||||
$this->includes();
|
||||
|
||||
$this->load_deactivation_survey_actions();
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to load the deactivation survey form actions.
|
||||
*
|
||||
* @since 1.1.6
|
||||
* @return void
|
||||
*/
|
||||
public function load_deactivation_survey_actions() {
|
||||
|
||||
// If not in a admin area then return it.
|
||||
if ( ! is_admin() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
add_filter( 'uds_survey_vars', array( $this, 'add_slugs_to_uds_vars' ) );
|
||||
add_action( 'admin_footer', array( $this, 'load_deactivation_survey_form' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup actions for admin notice style and analytics cron event.
|
||||
*
|
||||
* @since 1.0.4
|
||||
*/
|
||||
public function set_actions() {
|
||||
|
||||
foreach ( $this->entities as $key => $data ) {
|
||||
add_action( 'astra_notice_before_markup_' . $key . '-optin-notice', array( $this, 'enqueue_assets' ) );
|
||||
add_action( 'update_option_' . $key . '_analytics_optin', array( $this, 'update_analytics_option_callback' ), 10, 3 );
|
||||
add_action( 'add_option_' . $key . '_analytics_optin', array( $this, 'add_analytics_option_callback' ), 10, 2 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* BSF Analytics URL
|
||||
*
|
||||
* @param string $analytics_path directory path to analytics library.
|
||||
* @return String URL of bsf-analytics directory.
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function get_analytics_url( $analytics_path ) {
|
||||
|
||||
$content_dir_path = wp_normalize_path( WP_CONTENT_DIR );
|
||||
|
||||
$analytics_path = wp_normalize_path( $analytics_path );
|
||||
|
||||
return str_replace( $content_dir_path, content_url(), $analytics_path );
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue Scripts.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue_assets() {
|
||||
|
||||
/**
|
||||
* Load unminified if SCRIPT_DEBUG is true.
|
||||
*
|
||||
* Directory and Extensions.
|
||||
*/
|
||||
$dir_name = ( SCRIPT_DEBUG ) ? 'unminified' : 'minified';
|
||||
$file_rtl = ( is_rtl() ) ? '-rtl' : '';
|
||||
$css_ext = ( SCRIPT_DEBUG ) ? '.css' : '.min.css';
|
||||
|
||||
$css_uri = BSF_ANALYTICS_URI . '/assets/css/' . $dir_name . '/style' . $file_rtl . $css_ext;
|
||||
|
||||
wp_enqueue_style( 'bsf-analytics-admin-style', $css_uri, false, BSF_ANALYTICS_VERSION, 'all' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Send analytics API call.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function send() {
|
||||
|
||||
$api_url = BSF_Analytics_Helper::get_api_url();
|
||||
|
||||
wp_remote_post(
|
||||
$api_url . 'api/analytics/',
|
||||
array(
|
||||
'body' => BSF_Analytics_Stats::instance()->get_stats(),
|
||||
'timeout' => 5,
|
||||
'blocking' => false,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if usage tracking is enabled.
|
||||
*
|
||||
* @return bool
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function is_tracking_enabled() {
|
||||
|
||||
foreach ( $this->entities as $key => $data ) {
|
||||
|
||||
$is_enabled = get_site_option( $key . '_analytics_optin' ) === 'yes' ? true : false;
|
||||
$is_enabled = $this->is_white_label_enabled( $key ) ? false : $is_enabled;
|
||||
|
||||
if ( apply_filters( $key . '_tracking_enabled', $is_enabled ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if WHITE label is enabled for BSF products.
|
||||
*
|
||||
* @param string $source source of analytics.
|
||||
* @return bool
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function is_white_label_enabled( $source ) {
|
||||
|
||||
$options = apply_filters( $source . '_white_label_options', array() );
|
||||
$is_enabled = false;
|
||||
|
||||
if ( is_array( $options ) ) {
|
||||
foreach ( $options as $option ) {
|
||||
if ( true === $option ) {
|
||||
$is_enabled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $is_enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display admin notice for usage tracking.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function option_notice() {
|
||||
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( $this->is_tracking_enabled() ) {
|
||||
return; // Don't need to display notice if any of our plugin already have the permission.
|
||||
}
|
||||
|
||||
// If the user has opted out of tracking, don't show the notice till 7 days.
|
||||
if ( get_site_option( 'bsf_analytics_last_displayed_time' ) > time() - ( 7 * DAY_IN_SECONDS ) ) {
|
||||
return; // Don't display the notice if it was displayed recently.
|
||||
}
|
||||
|
||||
foreach ( $this->entities as $key => $data ) {
|
||||
|
||||
$time_to_display = isset( $data['time_to_display'] ) ? $data['time_to_display'] : '+24 hours';
|
||||
$usage_doc_link = isset( $data['usage_doc_link'] ) ? $data['usage_doc_link'] : $this->usage_doc_link;
|
||||
|
||||
// Don't display the notice if tracking is disabled or White Label is enabled for any of our plugins.
|
||||
if ( false !== get_site_option( $key . '_analytics_optin', false ) || $this->is_white_label_enabled( $key ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Show tracker consent notice after 24 hours from installed time.
|
||||
if ( strtotime( $time_to_display, $this->get_analytics_install_time( $key ) ) > time() ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* translators: %s product name */
|
||||
$notice_string = sprintf(
|
||||
__(
|
||||
'Help us improve %1$s and our other products!<br><br>With your permission, we\'d like to collect <strong>non-sensitive information</strong> from your website — like your PHP version and which features you use — so we can fix bugs faster, make smarter decisions, and build features that actually matter to you. <em>No personal info. Ever.</em>'
|
||||
),
|
||||
'<strong>' . esc_html( $data['product_name'] ) . '</strong>'
|
||||
);
|
||||
|
||||
if ( is_multisite() ) {
|
||||
$notice_string .= __( 'This will be applicable for all sites from the network.' );
|
||||
}
|
||||
|
||||
$language_dir = is_rtl() ? 'rtl' : 'ltr';
|
||||
|
||||
Astra_Notices::add_notice(
|
||||
array(
|
||||
'id' => $key . '-optin-notice',
|
||||
'type' => '',
|
||||
'message' => sprintf(
|
||||
'<div class="notice-content">
|
||||
<div class="notice-heading">
|
||||
%1$s
|
||||
</div>
|
||||
<div class="astra-notices-container">
|
||||
<a href="%2$s" class="astra-notices button-primary">
|
||||
%3$s
|
||||
</a>
|
||||
<a href="%4$s" data-repeat-notice-after="%5$s" class="astra-notices button-secondary">
|
||||
%6$s
|
||||
</a>
|
||||
</div>
|
||||
</div>',
|
||||
/* translators: %s usage doc link */
|
||||
sprintf( $notice_string . '<span dir="%1s"><a href="%2s" target="_blank" rel="noreferrer noopener">%3s</a><span><br><br>', $language_dir, esc_url( $usage_doc_link ), __( ' Know More.' ) ),
|
||||
esc_url(
|
||||
add_query_arg(
|
||||
array(
|
||||
$key . '_analytics_optin' => 'yes',
|
||||
$key . '_analytics_nonce' => wp_create_nonce( $key . '_analytics_optin' ),
|
||||
'bsf_analytics_source' => $key,
|
||||
)
|
||||
)
|
||||
),
|
||||
__( 'Yes! Allow it' ),
|
||||
esc_url(
|
||||
add_query_arg(
|
||||
array(
|
||||
$key . '_analytics_optin' => 'no',
|
||||
$key . '_analytics_nonce' => wp_create_nonce( $key . '_analytics_optin' ),
|
||||
'bsf_analytics_source' => $key,
|
||||
)
|
||||
)
|
||||
),
|
||||
MONTH_IN_SECONDS,
|
||||
__( 'No Thanks' )
|
||||
),
|
||||
'show_if' => true,
|
||||
'repeat-notice-after' => false,
|
||||
'priority' => 18,
|
||||
'display-with-other-notices' => true,
|
||||
)
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process usage tracking opt out.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function handle_optin_optout() {
|
||||
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$source = isset( $_GET['bsf_analytics_source'] ) ? sanitize_text_field( wp_unslash( $_GET['bsf_analytics_source'] ) ) : '';
|
||||
|
||||
if ( ! isset( $_GET[ $source . '_analytics_nonce' ] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET[ $source . '_analytics_nonce' ] ) ), $source . '_analytics_optin' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$optin_status = isset( $_GET[ $source . '_analytics_optin' ] ) ? sanitize_text_field( wp_unslash( $_GET[ $source . '_analytics_optin' ] ) ) : '';
|
||||
|
||||
if ( 'yes' === $optin_status ) {
|
||||
$this->optin( $source );
|
||||
} elseif ( 'no' === $optin_status ) {
|
||||
$this->optout( $source );
|
||||
}
|
||||
|
||||
wp_safe_redirect(
|
||||
esc_url_raw(
|
||||
remove_query_arg(
|
||||
array(
|
||||
$source . '_analytics_optin',
|
||||
$source . '_analytics_nonce',
|
||||
'bsf_analytics_source',
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opt in to usage tracking.
|
||||
*
|
||||
* @param string $source source of analytics.
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function optin( $source ) {
|
||||
update_site_option( $source . '_analytics_optin', 'yes' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Opt out to usage tracking.
|
||||
*
|
||||
* @param string $source source of analytics.
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function optout( $source ) {
|
||||
update_site_option( $source . '_analytics_optin', 'no' );
|
||||
update_site_option( 'bsf_analytics_last_displayed_time', time() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Load analytics stat class.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function includes() {
|
||||
require_once __DIR__ . '/classes/class-bsf-analytics-helper.php';
|
||||
require_once __DIR__ . '/class-bsf-analytics-stats.php';
|
||||
|
||||
// Loads all the modules.
|
||||
require_once __DIR__ . '/modules/deactivation-survey/classes/class-deactivation-survey-feedback.php';
|
||||
require_once __DIR__ . '/modules/utm-analytics.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Register usage tracking option in General settings page.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function register_usage_tracking_setting() {
|
||||
|
||||
foreach ( $this->entities as $key => $data ) {
|
||||
|
||||
if ( ! apply_filters( $key . '_tracking_enabled', true ) || $this->is_white_label_enabled( $key ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Introducing a new key 'hide_optin_checkbox, which allows individual plugin to hide optin checkbox
|
||||
* If they are providing providing in-plugin option to manage this option.
|
||||
* from General > Settings page.
|
||||
*
|
||||
* @since 1.1.14
|
||||
*/
|
||||
if( ! empty( $data['hide_optin_checkbox'] ) && true === $data['hide_optin_checkbox'] ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$usage_doc_link = isset( $data['usage_doc_link'] ) ? $data['usage_doc_link'] : $this->usage_doc_link;
|
||||
$author = isset( $data['author'] ) ? $data['author'] : 'Brainstorm Force';
|
||||
|
||||
register_setting(
|
||||
'general', // Options group.
|
||||
$key . '_analytics_optin', // Option name/database.
|
||||
array( 'sanitize_callback' => array( $this, 'sanitize_option' ) ) // sanitize callback function.
|
||||
);
|
||||
|
||||
add_settings_field(
|
||||
$key . '-analytics-optin', // Field ID.
|
||||
__( 'Usage Tracking' ), // Field title.
|
||||
array( $this, 'render_settings_field_html' ), // Field callback function.
|
||||
'general',
|
||||
'default', // Settings page slug.
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'title' => $author,
|
||||
'name' => $key . '_analytics_optin',
|
||||
'label_for' => $key . '-analytics-optin',
|
||||
'id' => $key . '-analytics-optin',
|
||||
'usage_doc_link' => $usage_doc_link,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize Callback Function
|
||||
*
|
||||
* @param bool $input Option value.
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function sanitize_option( $input ) {
|
||||
|
||||
if ( ! $input || 'no' === $input ) {
|
||||
return 'no';
|
||||
}
|
||||
|
||||
return 'yes';
|
||||
}
|
||||
|
||||
/**
|
||||
* Print settings field HTML.
|
||||
*
|
||||
* @param array $args arguments to field.
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function render_settings_field_html( $args ) {
|
||||
?>
|
||||
<fieldset>
|
||||
<label for="<?php echo esc_attr( $args['label_for'] ); ?>">
|
||||
<input id="<?php echo esc_attr( $args['id'] ); ?>" type="checkbox" value="1" name="<?php echo esc_attr( $args['name'] ); ?>" <?php checked( get_site_option( $args['name'], 'no' ), 'yes' ); ?>>
|
||||
<?php
|
||||
/* translators: %s Product title */
|
||||
echo esc_html( sprintf( __( 'Allow %s products to track non-sensitive usage tracking data.' ), $args['title'] ) );// phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
|
||||
|
||||
if ( is_multisite() ) {
|
||||
esc_html_e( ' This will be applicable for all sites from the network.' );
|
||||
}
|
||||
?>
|
||||
</label>
|
||||
<?php
|
||||
echo wp_kses_post( sprintf( '<a href="%1s" target="_blank" rel="noreferrer noopener">%2s</a>', esc_url( $args['usage_doc_link'] ), __( 'Learn More.' ) ) );
|
||||
?>
|
||||
</fieldset>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Set analytics installed time in option.
|
||||
*
|
||||
* @param string $source source of analytics.
|
||||
* @return string $time analytics installed time.
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function get_analytics_install_time( $source ) {
|
||||
|
||||
$time = get_site_option( $source . '_analytics_installed_time' );
|
||||
|
||||
if ( ! $time ) {
|
||||
$time = time();
|
||||
update_site_option( $source . '_analytics_installed_time', time() );
|
||||
}
|
||||
|
||||
return $time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule/unschedule cron event on updation of option.
|
||||
*
|
||||
* @param string $old_value old value of option.
|
||||
* @param string $value value of option.
|
||||
* @param string $option Option name.
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function update_analytics_option_callback( $old_value, $value, $option ) {
|
||||
if ( is_multisite() ) {
|
||||
$this->add_option_to_network( $option, $value );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Analytics option add callback.
|
||||
*
|
||||
* @param string $option Option name.
|
||||
* @param string $value value of option.
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function add_analytics_option_callback( $option, $value ) {
|
||||
if ( is_multisite() ) {
|
||||
$this->add_option_to_network( $option, $value );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send analytics track event if tracking is enabled.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function maybe_track_analytics() {
|
||||
|
||||
if ( ! $this->is_tracking_enabled() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$analytics_track = get_site_transient( 'bsf_analytics_track' );
|
||||
|
||||
// If the last data sent is 2 days old i.e. transient is expired.
|
||||
if ( ! $analytics_track ) {
|
||||
$this->send();
|
||||
set_site_transient( 'bsf_analytics_track', true, 2 * DAY_IN_SECONDS );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save analytics option to network.
|
||||
*
|
||||
* @param string $option name of option.
|
||||
* @param string $value value of option.
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function add_option_to_network( $option, $value ) {
|
||||
|
||||
// If action coming from general settings page.
|
||||
if ( isset( $_POST['option_page'] ) && 'general' === $_POST['option_page'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
|
||||
|
||||
if ( get_site_option( $option ) ) {
|
||||
update_site_option( $option, $value );
|
||||
} else {
|
||||
add_site_option( $option, $value );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to load the deactivation survey form on the admin footer.
|
||||
*
|
||||
* This function checks if the Deactivation_Survey_Feedback class exists and if so, it loads the deactivation survey form.
|
||||
* The form is configured with specific settings for plugin. Example: For CartFlows, including the source, logo, plugin slug, title, support URL, description, and the screen on which to show the form.
|
||||
*
|
||||
* @since 1.1.6
|
||||
* @return void
|
||||
*/
|
||||
public function load_deactivation_survey_form() {
|
||||
|
||||
if ( class_exists( 'Deactivation_Survey_Feedback' ) ) {
|
||||
foreach ( $this->entities as $key => $data ) {
|
||||
// If the deactivation_survey info in available then only add the form.
|
||||
if ( ! empty( $data['deactivation_survey'] ) && is_array( $data['deactivation_survey'] ) ) {
|
||||
foreach ( $data['deactivation_survey'] as $key => $survey_args ) {
|
||||
Deactivation_Survey_Feedback::show_feedback_form(
|
||||
$survey_args
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to add plugin slugs to Deactivation Survey vars for JS operations.
|
||||
*
|
||||
* @param array $vars UDS vars array.
|
||||
* @return array Modified UDS vars array with plugin slugs.
|
||||
* @since 1.1.6
|
||||
*/
|
||||
public function add_slugs_to_uds_vars( $vars ) {
|
||||
foreach ( $this->entities as $key => $data ) {
|
||||
if ( ! empty( $data['deactivation_survey'] ) && is_array( $data['deactivation_survey'] ) ) {
|
||||
foreach ( $data['deactivation_survey'] as $key => $survey_args ) {
|
||||
$vars['_plugin_slug'] = isset( $vars['_plugin_slug'] ) ? array_merge( $vars['_plugin_slug'], array( $survey_args['plugin_slug'] ) ) : array( $survey_args['plugin_slug'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $vars;
|
||||
}
|
||||
}
|
||||
}
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/**
|
||||
* BSF analytics Helper Class File.
|
||||
*
|
||||
* @package bsf-analytics
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'BSF_Analytics_Helper' ) ) {
|
||||
/**
|
||||
* BSF analytics stat class.
|
||||
*/
|
||||
class BSF_Analytics_Helper {
|
||||
|
||||
/**
|
||||
* Check is error in the received response.
|
||||
*
|
||||
* @param object $response Received API Response.
|
||||
* @return array $result Error result.
|
||||
*/
|
||||
public static function is_api_error( $response ) {
|
||||
|
||||
$result = array(
|
||||
'error' => false,
|
||||
'error_message' => __( 'Oops! Something went wrong. Please refresh the page and try again.' ),
|
||||
'error_code' => 0,
|
||||
);
|
||||
|
||||
if ( is_wp_error( $response ) ) {
|
||||
$result['error'] = true;
|
||||
$result['error_message'] = $response->get_error_message();
|
||||
$result['error_code'] = $response->get_error_code();
|
||||
} elseif ( ! empty( wp_remote_retrieve_response_code( $response ) ) && ! in_array( wp_remote_retrieve_response_code( $response ), array( 200, 201, 204 ), true ) ) {
|
||||
$result['error'] = true;
|
||||
$result['error_message'] = wp_remote_retrieve_response_message( $response );
|
||||
$result['error_code'] = wp_remote_retrieve_response_code( $response );
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get API headers
|
||||
*
|
||||
* @since 1.1.6
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function get_api_headers() {
|
||||
return array(
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get API URL for sending analytics.
|
||||
*
|
||||
* @return string API URL.
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function get_api_url() {
|
||||
return defined( 'BSF_ANALYTICS_API_BASE_URL' ) ? BSF_ANALYTICS_API_BASE_URL : 'https://analytics.brainstormforce.com/';
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the current screen is allowed for the survey.
|
||||
*
|
||||
* This function checks if the current screen is one of the allowed screens for displaying the survey.
|
||||
* It uses the `get_current_screen` function to get the current screen information and compares it with the list of allowed screens.
|
||||
*
|
||||
* @since 1.1.6
|
||||
* @return bool True if the current screen is allowed, false otherwise.
|
||||
*/
|
||||
public static function is_allowed_screen() {
|
||||
|
||||
// This filter allows to dynamically modify the list of allowed screens for the survey.
|
||||
$allowed_screens = apply_filters( 'uds_survey_allowed_screens', array( 'plugins' ) );
|
||||
|
||||
$current_screen = get_current_screen();
|
||||
|
||||
// Check if $current_screen is a valid object before accessing its properties.
|
||||
if ( ! is_object( $current_screen ) ) {
|
||||
return false; // Return false if current screen is not valid.
|
||||
}
|
||||
|
||||
$screen_id = $current_screen->id;
|
||||
|
||||
if ( ! empty( $screen_id ) && in_array( $screen_id, $allowed_screens, true ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
+237
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+236
@@ -0,0 +1,236 @@
|
||||
/* Base CSS to normalize the default. */
|
||||
.uds-feedback-form--wrapper h2,
|
||||
.uds-feedback-form--wrapper p,
|
||||
.uds-feedback-form--wrapper input[type="radio"] {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.uds-feedback-form--wrapper .show {
|
||||
display: block;
|
||||
}
|
||||
.uds-feedback-form--wrapper .hide {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.uds-feedback-form--wrapper {
|
||||
align-items: center;
|
||||
background-color: rgba( 0, 0, 0, 0.75 );
|
||||
bottom: 0;
|
||||
display: none;
|
||||
justify-content: center;
|
||||
left: 0;
|
||||
position: fixed;
|
||||
right: 0;
|
||||
top: 0;
|
||||
user-select: none;
|
||||
z-index: -9999;
|
||||
}
|
||||
|
||||
.uds-feedback-form--wrapper.show_popup {
|
||||
display: flex !important;
|
||||
z-index: 99999;
|
||||
}
|
||||
|
||||
.uds-feedback-form--wrapper .uds-feedback-form--container {
|
||||
background-color: #fff;
|
||||
border-radius: 8px;
|
||||
box-shadow: 4px 4px 24px rgba( 0, 0, 0, 0.25 );
|
||||
max-width: 90%;
|
||||
width: 540px;
|
||||
}
|
||||
|
||||
.uds-feedback-form--container .uds-form-header--wrapper {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 16px 20px 0;
|
||||
}
|
||||
|
||||
.uds-feedback-form--container .uds-form-title--icon-wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.uds-feedback-form--container .uds-form-title--icon-wrapper .uds-icon,
|
||||
.uds-feedback-form--container .uds-form-header--wrapper .uds-close {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
.uds-feedback-form--container .uds-form-title--icon-wrapper .uds-title {
|
||||
color: #1f2937;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
line-height: 24px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.uds-feedback-form--container .uds-form-header--wrapper .uds-close {
|
||||
color: #9ca3af;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.uds-feedback-form--container .uds-form-header--wrapper .uds-close:hover {
|
||||
color: #4b5563;
|
||||
}
|
||||
|
||||
.uds-feedback-form--container .uds-form-body--content {
|
||||
padding: 20px 20px 0 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.uds-feedback-form--container .uds-form-body--content .uds-form-description {
|
||||
color: #1f2937;
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
line-height: 24px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.uds-feedback-form--container .uds-form-body--content #uds-feedback-form .reason {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.uds-feedback-form--container .uds-form-body--content #uds-feedback-form .uds-options-feedback {
|
||||
color: #6b7280;
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
line-height: 20px;
|
||||
text-align: left;
|
||||
width: 100%;
|
||||
padding: 9px 13px;
|
||||
border-radius: 6px;
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
border-color: #e5e7eb;
|
||||
box-shadow: 0 1px 2px 0 #0000000d;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.uds-feedback-form--container .uds-form-body--content #uds-feedback-form .uds-options-feedback:hover,
|
||||
.uds-feedback-form--container .uds-form-body--content #uds-feedback-form .uds-options-feedback:focus,
|
||||
.uds-feedback-form--container .uds-form-body--content #uds-feedback-form .uds-options-feedback:active {
|
||||
border-color: #d1d5db;
|
||||
}
|
||||
|
||||
.uds-feedback-form--container .uds-form-body--content #uds-feedback-form .uds-option-feedback-cta {
|
||||
color: #4b5563;
|
||||
margin-top: 10px;
|
||||
font-size: 13px;
|
||||
font-weight: 400;
|
||||
line-height: 20px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.uds-feedback-form--container .uds-form-body--content #uds-feedback-form .uds-option-feedback-cta a {
|
||||
text-decoration: none;
|
||||
color: #006ba1;
|
||||
}
|
||||
|
||||
.uds-feedback-form--container .uds-form-body--content #uds-feedback-form .uds-options-feedback::placeholder {
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
line-height: 20px;
|
||||
text-align: left;
|
||||
color: #6b7280;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.uds-feedback-form--container .uds-form-body--content .uds-feedback-form-sumbit--actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 16px 20px;
|
||||
background-color: #f6f7f7;
|
||||
border-top: 1px solid #e1e1e1;
|
||||
margin: 40px -20px 0;
|
||||
border-bottom-left-radius: 8px;
|
||||
border-bottom-right-radius: 8px;
|
||||
}
|
||||
|
||||
.uds-feedback-form--container .uds-form-body--content .uds-feedback-form-sumbit--actions .button {
|
||||
padding: 7px 13px;
|
||||
border-radius: 3px;
|
||||
border-width: 1px;
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
line-height: 20px;
|
||||
text-align: left;
|
||||
border-style: solid;
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.uds-feedback-form--container .uds-form-body--content .uds-feedback-form-sumbit--actions .button:focus {
|
||||
outline: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
.uds-feedback-form--container .uds-form-body--content .uds-feedback-form-sumbit--actions .button.processing {
|
||||
pointer-events: none;
|
||||
opacity: 0.8;
|
||||
}
|
||||
.uds-feedback-form--container .uds-form-body--content .uds-feedback-form-sumbit--actions .button.processing::before {
|
||||
content: "\f463";
|
||||
animation: spin 2s linear infinite;
|
||||
font-family: dashicons, sans-serif;
|
||||
font-weight: 400;
|
||||
font-size: 18px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.uds-feedback-form--container .uds-form-body--content #uds-feedback-form .uds-reason-label {
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
line-height: 20px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.uds-feedback-form--container .uds-form-body--content #uds-feedback-form input[type="radio"] {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
height: 18px;
|
||||
width: 18px;
|
||||
cursor: pointer;
|
||||
margin: 0;
|
||||
border: 1px solid #d1d5db;
|
||||
border-radius: 50%;
|
||||
line-height: 0;
|
||||
box-shadow: inset 0 1px 2px rgb( 0 0 0 / 10% );
|
||||
transition: 0.05s border-color ease-in-out;
|
||||
-webkit-appearance: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.uds-feedback-form--container .uds-form-body--content #uds-feedback-form input[type="radio"]:checked {
|
||||
vertical-align: middle;
|
||||
background-color: #006ba1;
|
||||
}
|
||||
|
||||
.uds-feedback-form--container .uds-form-body--content #uds-feedback-form input[type="radio"]:checked::before {
|
||||
background-color: #fff !important;
|
||||
border-radius: 50px;
|
||||
content: "\2022";
|
||||
font-size: 24px;
|
||||
height: 6px;
|
||||
line-height: 13px;
|
||||
margin: 5px;
|
||||
text-indent: -9999px;
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
0% {
|
||||
transform: rotate( 0deg );
|
||||
}
|
||||
100% {
|
||||
transform: rotate( 360deg );
|
||||
}
|
||||
}
|
||||
+1
File diff suppressed because one or more lines are too long
+239
@@ -0,0 +1,239 @@
|
||||
( function ( $ ) {
|
||||
const UserDeactivationPopup = {
|
||||
slug: '',
|
||||
skipButton: '',
|
||||
formWrapper: '',
|
||||
radioButton: '',
|
||||
closeButton: '',
|
||||
buttonAction: '',
|
||||
feedbackForm: '',
|
||||
feedbackInput: '',
|
||||
deactivateUrl: '',
|
||||
buttonTrigger: '',
|
||||
deactivateButton: '',
|
||||
submitDeactivate: '',
|
||||
|
||||
/**
|
||||
* Caches elements for later use.
|
||||
*/
|
||||
_cacheElements() {
|
||||
this.slug = udsVars?._plugin_slug || '';
|
||||
this.skipButton = $( '.uds-feedback-skip' );
|
||||
this.submitDeactivate = $( '.uds-feedback-submit' );
|
||||
this.deactivateButton = $( '#the-list' ).find(
|
||||
`.row-actions span.deactivate a`
|
||||
);
|
||||
this.feedbackForm = $( '.uds-feedback-form' ); // Feedback Form.
|
||||
this.feedbackInput = $( '.uds-options-feedback' ); // Feedback Textarea.
|
||||
this.formWrapper = $( '.uds-feedback-form--wrapper' );
|
||||
this.closeButton = $( '.uds-feedback-form--wrapper .uds-close' );
|
||||
this.radioButton = $( '.uds-reason-input' );
|
||||
},
|
||||
|
||||
/**
|
||||
* Shows the feedback popup by adding the 'show' class to the form wrapper.
|
||||
*
|
||||
* @param {string} slug - The slug of the plugin.
|
||||
*/
|
||||
_showPopup( slug ) {
|
||||
$( `#deactivation-survey-${ slug }` ).addClass( 'show_popup' );
|
||||
},
|
||||
|
||||
/**
|
||||
* Hides the feedback popup by removing the 'show' class from the form wrapper.
|
||||
*/
|
||||
_hidePopup() {
|
||||
this.formWrapper.removeClass( 'show_popup' );
|
||||
},
|
||||
|
||||
/**
|
||||
* Redirects to the deactivate URL if it exists, otherwise reloads the current page.
|
||||
*/
|
||||
_redirectOrReload() {
|
||||
if ( this.deactivateUrl ) {
|
||||
window.location.href = this.deactivateUrl;
|
||||
} else {
|
||||
location.reload();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Toggles the visibility of the feedback form and CTA based on the event target's attributes.
|
||||
*
|
||||
* @param {Event} event - The event that triggered this function.
|
||||
*/
|
||||
_hideShowFeedbackAndCTA( event ) {
|
||||
const acceptFeedback =
|
||||
$( event.target ).attr( 'data-accept_feedback' ) === 'true';
|
||||
const showCta =
|
||||
$( event.target ).attr( 'data-show_cta' ) === 'true';
|
||||
|
||||
$( event.target )
|
||||
.closest( this.formWrapper )
|
||||
.find( '.uds-options-feedback' )
|
||||
.removeClass( 'hide' )
|
||||
.addClass( acceptFeedback ? 'show' : 'hide' );
|
||||
$( event.target )
|
||||
.closest( this.formWrapper )
|
||||
.find( '.uds-option-feedback-cta' )
|
||||
.removeClass( 'hide' )
|
||||
.addClass( showCta ? 'show' : 'hide' );
|
||||
},
|
||||
|
||||
/**
|
||||
* Changes the placeholder text of the feedback input based on the event target's attribute.
|
||||
*
|
||||
* @param {Event} event - The event that triggered this function.
|
||||
*/
|
||||
_changePlaceholderText( event ) {
|
||||
const radioButtonPlaceholder =
|
||||
event.target.getAttribute( 'data-placeholder' );
|
||||
|
||||
$( event.target )
|
||||
.closest( this.formWrapper )
|
||||
.find( this.feedbackInput )
|
||||
.attr( 'placeholder', radioButtonPlaceholder || '' );
|
||||
|
||||
this._hideShowFeedbackAndCTA( event );
|
||||
},
|
||||
|
||||
/**
|
||||
* Submits the feedback form and handles the response.
|
||||
*
|
||||
* @param {Event} event - The event that triggered this function.
|
||||
* @param {Object} self - A reference to the current object.
|
||||
*/
|
||||
_submitFeedback( event, self ) {
|
||||
event.preventDefault();
|
||||
|
||||
const currentForm = $( event.target );
|
||||
const closestForm = currentForm.closest( this.feedbackForm ); // Cache the closest form
|
||||
|
||||
// Gather form data.
|
||||
const formData = {
|
||||
action: 'uds_plugin_deactivate_feedback',
|
||||
security: udsVars?._ajax_nonce || '',
|
||||
reason:
|
||||
closestForm
|
||||
.find( this.radioButton.filter( ':checked' ) )
|
||||
.val() || '', // Get the selected radio button value from the current form.
|
||||
source: closestForm.find( 'input[name="source"]' ).val() || '',
|
||||
referer:
|
||||
closestForm.find( 'input[name="referer"]' ).val() || '',
|
||||
version:
|
||||
closestForm.find( 'input[name="version"]' ).val() || '',
|
||||
feedback: closestForm.find( this.feedbackInput ).val() || '', // Get the feedback input value from the current form.
|
||||
};
|
||||
|
||||
currentForm
|
||||
.find( '.uds-feedback-' + this.buttonAction )
|
||||
.text( 'Deactivating.' )
|
||||
.addClass( 'processing' );
|
||||
|
||||
// Prepare AJAX call.
|
||||
$.ajax( {
|
||||
url: udsVars?.ajaxurl, // URL to send the request to.
|
||||
type: 'POST', // HTTP method.
|
||||
data: formData, // Data to be sent.
|
||||
success( response ) {
|
||||
if ( response.success ) {
|
||||
self._redirectOrReload();
|
||||
}
|
||||
self._hidePopup();
|
||||
},
|
||||
/* eslint-disable */
|
||||
error( xhr, status, error ) {
|
||||
/* eslint-disable */
|
||||
self._redirectOrReload();
|
||||
},
|
||||
} );
|
||||
},
|
||||
|
||||
_handleClick( e ) {
|
||||
// Close feedback form or show/hide popup if clicked outside and add a click on a Activate button of Theme.
|
||||
if (
|
||||
e.target.classList.contains( 'show_popup' ) &&
|
||||
e.target.closest( '.uds-feedback-form--wrapper' )
|
||||
) {
|
||||
this._hidePopup();
|
||||
} else if ( e.target.classList.contains( 'activate' ) ) {
|
||||
this.deactivateUrl = e.target.href;
|
||||
|
||||
// Don't show for Child Themes if parent theme is active & Parent Theme if child theme is active.
|
||||
if (
|
||||
-1 !==
|
||||
this.deactivateUrl.indexOf(
|
||||
`stylesheet=${ udsVars?._current_theme }-child`
|
||||
) ||
|
||||
-1 !==
|
||||
this.deactivateUrl.indexOf(`stylesheet=${udsVars?._current_theme}&`)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
this._showPopup( udsVars?._current_theme );
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Initializes the feedback popup by caching elements and binding events.
|
||||
*/
|
||||
_init() {
|
||||
this._cacheElements();
|
||||
this._bind();
|
||||
},
|
||||
|
||||
/**
|
||||
* Binds event listeners to various elements to handle user interactions.
|
||||
*/
|
||||
_bind() {
|
||||
const self = this; // Store reference to the current object.
|
||||
|
||||
// Open the popup when clicked on the deactivate button.
|
||||
this.deactivateButton.on( 'click', function ( event ) {
|
||||
let closestTr = $( event.target ).closest( 'tr' );
|
||||
let slug = closestTr.data( 'slug' );
|
||||
|
||||
if ( self.slug.includes( slug ) ) {
|
||||
event.preventDefault();
|
||||
// Set the deactivation URL.
|
||||
self.deactivateUrl = $( event.target ).attr( 'href' );
|
||||
self._showPopup( slug );
|
||||
}
|
||||
} );
|
||||
|
||||
// Close the popup on a click of Close button.
|
||||
this.closeButton.on( 'click', function ( event ) {
|
||||
event.preventDefault();
|
||||
self._hidePopup(); // Use self to refer to the UserDeactivationPopup instance.
|
||||
} );
|
||||
|
||||
// Click event on radio button to change the placeholder of textarea.
|
||||
this.radioButton.on( 'click', function ( event ) {
|
||||
self._changePlaceholderText( event );
|
||||
} );
|
||||
|
||||
// Combined submit and skip button actions.
|
||||
this.submitDeactivate
|
||||
.add( this.skipButton )
|
||||
.on( 'click', function ( event ) {
|
||||
event.preventDefault(); // Prevent default button action.
|
||||
self.buttonAction = $( event.target ).attr( 'data-action' );
|
||||
$( event.target ).closest( self.feedbackForm ).submit();
|
||||
} );
|
||||
|
||||
this.feedbackForm.on( 'submit', function ( event ) {
|
||||
self._submitFeedback( event, self );
|
||||
} );
|
||||
|
||||
document.addEventListener( 'click', function ( e ) {
|
||||
self._handleClick( e );
|
||||
} );
|
||||
},
|
||||
};
|
||||
|
||||
$( function () {
|
||||
UserDeactivationPopup._init();
|
||||
} );
|
||||
} )( jQuery );
|
||||
+1
@@ -0,0 +1 @@
|
||||
(i=>{let t={slug:"",skipButton:"",formWrapper:"",radioButton:"",closeButton:"",buttonAction:"",feedbackForm:"",feedbackInput:"",deactivateUrl:"",buttonTrigger:"",deactivateButton:"",submitDeactivate:"",_cacheElements(){this.slug=udsVars?._plugin_slug||"",this.skipButton=i(".uds-feedback-skip"),this.submitDeactivate=i(".uds-feedback-submit"),this.deactivateButton=i("#the-list").find(".row-actions span.deactivate a"),this.feedbackForm=i(".uds-feedback-form"),this.feedbackInput=i(".uds-options-feedback"),this.formWrapper=i(".uds-feedback-form--wrapper"),this.closeButton=i(".uds-feedback-form--wrapper .uds-close"),this.radioButton=i(".uds-reason-input")},_showPopup(t){i("#deactivation-survey-"+t).addClass("show_popup")},_hidePopup(){this.formWrapper.removeClass("show_popup")},_redirectOrReload(){this.deactivateUrl?window.location.href=this.deactivateUrl:location.reload()},_hideShowFeedbackAndCTA(t){var e="true"===i(t.target).attr("data-accept_feedback"),a="true"===i(t.target).attr("data-show_cta");i(t.target).closest(this.formWrapper).find(".uds-options-feedback").removeClass("hide").addClass(e?"show":"hide"),i(t.target).closest(this.formWrapper).find(".uds-option-feedback-cta").removeClass("hide").addClass(a?"show":"hide")},_changePlaceholderText(t){var e=t.target.getAttribute("data-placeholder");i(t.target).closest(this.formWrapper).find(this.feedbackInput).attr("placeholder",e||""),this._hideShowFeedbackAndCTA(t)},_submitFeedback(t,s){t.preventDefault();var t=i(t.target),e=t.closest(this.feedbackForm),e={action:"uds_plugin_deactivate_feedback",security:udsVars?._ajax_nonce||"",reason:e.find(this.radioButton.filter(":checked")).val()||"",source:e.find('input[name="source"]').val()||"",referer:e.find('input[name="referer"]').val()||"",version:e.find('input[name="version"]').val()||"",feedback:e.find(this.feedbackInput).val()||""};t.find(".uds-feedback-"+this.buttonAction).text("Deactivating.").addClass("processing"),i.ajax({url:udsVars?.ajaxurl,type:"POST",data:e,success(t){t.success&&s._redirectOrReload(),s._hidePopup()},error(t,e,a){s._redirectOrReload()}})},_handleClick(t){t.target.classList.contains("show_popup")&&t.target.closest(".uds-feedback-form--wrapper")?this._hidePopup():t.target.classList.contains("activate")&&(this.deactivateUrl=t.target.href,-1===this.deactivateUrl.indexOf(`stylesheet=${udsVars?._current_theme}-child`))&&-1===this.deactivateUrl.indexOf(`stylesheet=${udsVars?._current_theme}&`)&&(t.preventDefault(),this._showPopup(udsVars?._current_theme))},_init(){this._cacheElements(),this._bind()},_bind(){let a=this;this.deactivateButton.on("click",function(t){var e=i(t.target).closest("tr").data("slug");a.slug.includes(e)&&(t.preventDefault(),a.deactivateUrl=i(t.target).attr("href"),a._showPopup(e))}),this.closeButton.on("click",function(t){t.preventDefault(),a._hidePopup()}),this.radioButton.on("click",function(t){a._changePlaceholderText(t)}),this.submitDeactivate.add(this.skipButton).on("click",function(t){t.preventDefault(),a.buttonAction=i(t.target).attr("data-action"),i(t.target).closest(a.feedbackForm).submit()}),this.feedbackForm.on("submit",function(t){a._submitFeedback(t,a)}),document.addEventListener("click",function(t){a._handleClick(t)})}};i(function(){t._init()})})(jQuery);
|
||||
+324
@@ -0,0 +1,324 @@
|
||||
<?php
|
||||
/**
|
||||
* Deactivation Survey Feedback.
|
||||
*
|
||||
* @package bsf-analytics
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'Deactivation_Survey_Feedback' ) ) {
|
||||
|
||||
/**
|
||||
* Class Deactivation_Survey_Feedback.
|
||||
*/
|
||||
class Deactivation_Survey_Feedback {
|
||||
|
||||
/**
|
||||
* Feedback URL.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $feedback_api_endpoint = 'api/plugin-deactivate';
|
||||
|
||||
/**
|
||||
* Instance
|
||||
*
|
||||
* @access private
|
||||
* @var object Class object.
|
||||
* @since 1.1.6
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* Initiator
|
||||
*
|
||||
* @since 1.1.6
|
||||
* @return object initialized object of class.
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'load_form_styles' ) );
|
||||
add_action( 'wp_ajax_uds_plugin_deactivate_feedback', array( $this, 'send_plugin_deactivate_feedback' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Render feedback HTML on plugins.php admin page only.
|
||||
*
|
||||
* This function renders the feedback form HTML on the plugins.php admin page.
|
||||
* It takes an optional string parameter $id for the form wrapper ID and an optional array parameter $args for customizing the form.
|
||||
*
|
||||
* @since 1.1.6
|
||||
* @param array $args Optional. Custom arguments for the form. Defaults to an empty array.
|
||||
* @return void
|
||||
*/
|
||||
public static function show_feedback_form( array $args = array() ) {
|
||||
|
||||
// Return if not in admin.
|
||||
if ( ! is_admin() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Set default arguments for the feedback form.
|
||||
$defaults = array(
|
||||
'source' => 'User Deactivation Survey',
|
||||
'popup_logo' => '',
|
||||
'plugin_slug' => 'user-deactivation-survey',
|
||||
'plugin_version' => '',
|
||||
'popup_title' => __( 'Quick Feedback' ),
|
||||
'support_url' => 'https://brainstormforce.com/contact/',
|
||||
'popup_reasons' => self::get_default_reasons(),
|
||||
'popup_description' => __( 'If you have a moment, please share why you are deactivating the plugin.' ),
|
||||
'show_on_screens' => array( 'plugins' ),
|
||||
);
|
||||
|
||||
// Parse the arguments with defaults.
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
$id = '';
|
||||
|
||||
// Set a default ID if none is provided.
|
||||
if ( empty( $args['id'] ) ) {
|
||||
$id = 'uds-feedback-form--wrapper';
|
||||
}
|
||||
|
||||
$id = sanitize_text_field( $args['id'] );
|
||||
|
||||
// Return if not on the allowed screen.
|
||||
if ( ! BSF_Analytics_Helper::is_allowed_screen() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Product slug used for input fields and labels in each plugin's deactivation survey.
|
||||
$product_slug = isset( $args['plugin_slug'] ) ? sanitize_text_field( $args['plugin_slug'] ) : 'bsf';
|
||||
|
||||
?>
|
||||
<div id="<?php echo esc_attr( $id ); ?>" class="uds-feedback-form--wrapper" style="display: none">
|
||||
<div class="uds-feedback-form--container">
|
||||
<div class="uds-form-header--wrapper">
|
||||
<div class="uds-form-title--icon-wrapper">
|
||||
<?php if ( ! empty( $args['popup_logo'] ) ) { ?>
|
||||
<img class="uds-icon" src="<?php echo esc_url( $args['popup_logo'] ); ?>" title="<?php echo esc_attr( $args['plugin_slug'] ); ?> <?php echo esc_attr( __( 'Icon' ) ); ?>" />
|
||||
<?php } ?>
|
||||
<h2 class="uds-title"><?php echo esc_html( $args['popup_title'] ); ?></h2>
|
||||
</div>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="uds-close">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6M6 6l12 12" />
|
||||
</svg>
|
||||
</div>
|
||||
<div class="uds-form-body--content">
|
||||
|
||||
<?php if ( ! empty( $args['popup_description'] ) ) { ?>
|
||||
<p class="uds-form-description"><?php echo esc_html( $args['popup_description'] ); ?></p>
|
||||
<?php } ?>
|
||||
|
||||
<form class="uds-feedback-form" id="uds-feedback-form" method="post">
|
||||
<?php foreach ( $args['popup_reasons'] as $key => $value ) {
|
||||
$input_id = $product_slug . '_uds_reason_input_' . $key;
|
||||
?>
|
||||
<fieldset>
|
||||
<div class="reason">
|
||||
<input type="radio" class="uds-reason-input" name="uds_reason_input" id="<?php echo esc_attr( $input_id ); ?>" value="<?php echo esc_attr( $key ); ?>" data-placeholder="<?php echo esc_attr( $value['placeholder'] ); ?>" data-show_cta="<?php echo esc_attr( $value['show_cta'] ); ?>" data-accept_feedback="<?php echo esc_attr( $value['accept_feedback'] ); ?>">
|
||||
<label class="uds-reason-label" for="<?php echo esc_attr( $input_id ); ?>"><?php echo esc_html( $value['label'] ); ?></label>
|
||||
</div>
|
||||
</fieldset>
|
||||
<?php } ?>
|
||||
|
||||
<fieldset>
|
||||
<textarea class="uds-options-feedback hide" id="uds-options-feedback" rows="3" name="uds_options_feedback" placeholder="<?php echo esc_attr( __( 'Please tell us more details.' ) ); ?>"></textarea>
|
||||
<?php
|
||||
if ( ! empty( $args['support_url'] ) ) {
|
||||
?>
|
||||
<p class="uds-option-feedback-cta hide">
|
||||
<?php
|
||||
echo wp_kses_post(
|
||||
sprintf(
|
||||
/* translators: %1$s: link html start, %2$s: link html end*/
|
||||
__( 'Need help from our experts? %1$sClick here to contact us.%2$s' ),
|
||||
'<a href="' . esc_url( $args['support_url'] ) . '" target="_blank">',
|
||||
'</a>'
|
||||
)
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
<?php } ?>
|
||||
</fieldset>
|
||||
|
||||
<div class="uds-feedback-form-sumbit--actions">
|
||||
<button class="button button-primary uds-feedback-submit" data-action="submit"><?php esc_html_e( 'Submit & Deactivate' ); ?></button>
|
||||
<button class="button button-secondary uds-feedback-skip" data-action="skip"><?php esc_html_e( 'Skip & Deactivate' ); ?></button>
|
||||
<input type="hidden" name="referer" value="<?php echo esc_url( get_site_url() ); ?>">
|
||||
<input type="hidden" name="version" value="<?php echo esc_attr( $args['plugin_version'] ); ?>">
|
||||
<input type="hidden" name="source" value="<?php echo esc_attr( $args['plugin_slug'] ); ?>">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Load form styles.
|
||||
*
|
||||
* This function loads the necessary styles for the feedback form.
|
||||
*
|
||||
* @since 1.1.6
|
||||
* @return void
|
||||
*/
|
||||
public static function load_form_styles() {
|
||||
|
||||
if ( ! BSF_Analytics_Helper::is_allowed_screen() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$dir_path = BSF_ANALYTICS_URI . '/modules/deactivation-survey/';
|
||||
$file_ext = ! SCRIPT_DEBUG ? '.min' : '';
|
||||
|
||||
wp_enqueue_script(
|
||||
'uds-feedback-script',
|
||||
$dir_path . 'assets/js/feedback' . $file_ext . '.js',
|
||||
array( 'jquery' ),
|
||||
BSF_ANALYTICS_VERSION,
|
||||
true
|
||||
);
|
||||
|
||||
$data = apply_filters(
|
||||
'uds_survey_vars',
|
||||
array(
|
||||
'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),
|
||||
'_ajax_nonce' => wp_create_nonce( 'uds_plugin_deactivate_feedback' ),
|
||||
'_current_theme' => function_exists( 'wp_get_theme' ) ? wp_get_theme()->get_template() : '',
|
||||
'_plugin_slug' => array(),
|
||||
)
|
||||
);
|
||||
|
||||
// Add localize JS.
|
||||
wp_localize_script(
|
||||
'uds-feedback-script',
|
||||
'udsVars',
|
||||
$data
|
||||
);
|
||||
|
||||
wp_enqueue_style( 'uds-feedback-style', $dir_path . 'assets/css/feedback' . $file_ext . '.css', array(), BSF_ANALYTICS_VERSION );
|
||||
wp_style_add_data( 'uds-feedback-style', 'rtl', 'replace' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends plugin deactivation feedback to the server.
|
||||
*
|
||||
* This function checks the user's permission and verifies the nonce for the request.
|
||||
* If the checks pass, it sends the feedback data to the server for processing.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function send_plugin_deactivate_feedback() {
|
||||
|
||||
$response_data = array( 'message' => __( 'Sorry, you are not allowed to do this operation.' ) );
|
||||
|
||||
/**
|
||||
* Check permission
|
||||
*/
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
wp_send_json_error( $response_data );
|
||||
}
|
||||
|
||||
/**
|
||||
* Nonce verification
|
||||
*/
|
||||
if ( ! check_ajax_referer( 'uds_plugin_deactivate_feedback', 'security', false ) ) {
|
||||
$response_data = array( 'message' => __( 'Nonce validation failed' ) );
|
||||
wp_send_json_error( $response_data );
|
||||
}
|
||||
|
||||
$feedback_data = array(
|
||||
'reason' => isset( $_POST['reason'] ) ? sanitize_text_field( wp_unslash( $_POST['reason'] ) ) : '',
|
||||
'feedback' => isset( $_POST['feedback'] ) ? sanitize_text_field( wp_unslash( $_POST['feedback'] ) ) : '',
|
||||
'domain_name' => isset( $_POST['referer'] ) ? sanitize_text_field( wp_unslash( $_POST['referer'] ) ) : '',
|
||||
'version' => isset( $_POST['version'] ) ? sanitize_text_field( wp_unslash( $_POST['version'] ) ) : '',
|
||||
'plugin' => isset( $_POST['source'] ) ? sanitize_text_field( wp_unslash( $_POST['source'] ) ) : '',
|
||||
);
|
||||
|
||||
$api_args = array(
|
||||
'body' => wp_json_encode( $feedback_data ),
|
||||
'headers' => BSF_Analytics_Helper::get_api_headers(),
|
||||
'timeout' => 90, //phpcs:ignore WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout
|
||||
);
|
||||
|
||||
$target_url = BSF_Analytics_Helper::get_api_url() . self::$feedback_api_endpoint;
|
||||
|
||||
$response = wp_safe_remote_post( $target_url, $api_args );
|
||||
|
||||
$has_errors = BSF_Analytics_Helper::is_api_error( $response );
|
||||
|
||||
if ( $has_errors['error'] ) {
|
||||
wp_send_json_error(
|
||||
array(
|
||||
'success' => false,
|
||||
'message' => $has_errors['error_message'],
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
wp_send_json_success();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array of default reasons.
|
||||
*
|
||||
* @return array Default reasons.
|
||||
*/
|
||||
public static function get_default_reasons() {
|
||||
|
||||
return apply_filters(
|
||||
'uds_default_deactivation_reasons',
|
||||
array(
|
||||
'temporary_deactivation' => array(
|
||||
'label' => esc_html__( 'This is a temporary deactivation for testing.' ),
|
||||
'placeholder' => esc_html__( 'How can we assist you?' ),
|
||||
'show_cta' => 'false',
|
||||
'accept_feedback' => 'false',
|
||||
),
|
||||
'plugin_not_working' => array(
|
||||
'label' => esc_html__( 'The plugin isn\'t working properly.' ),
|
||||
'placeholder' => esc_html__( 'Please tell us more about what went wrong?' ),
|
||||
'show_cta' => 'true',
|
||||
'accept_feedback' => 'true',
|
||||
),
|
||||
'found_better_plugin' => array(
|
||||
'label' => esc_html__( 'I found a better alternative plugin.' ),
|
||||
'placeholder' => esc_html__( 'Could you please specify which plugin?' ),
|
||||
'show_cta' => 'false',
|
||||
'accept_feedback' => 'true',
|
||||
),
|
||||
'missing_a_feature' => array(
|
||||
'label' => esc_html__( 'It\'s missing a specific feature.' ),
|
||||
'placeholder' => esc_html__( 'Please tell us more about the feature.' ),
|
||||
'show_cta' => 'false',
|
||||
'accept_feedback' => 'true',
|
||||
),
|
||||
'other' => array(
|
||||
'label' => esc_html__( 'Other' ),
|
||||
'placeholder' => esc_html__( 'Please tell us more details.' ),
|
||||
'show_cta' => 'false',
|
||||
'accept_feedback' => 'true',
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Deactivation_Survey_Feedback::get_instance();
|
||||
}
|
||||
+166
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
/**
|
||||
* UTM Analytics class
|
||||
*
|
||||
* @package bsf-analytics
|
||||
*/
|
||||
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'BSF_UTM_Analytics' ) ) {
|
||||
|
||||
|
||||
if ( ! defined( 'BSF_UTM_ANALYTICS_REFERER' ) ) {
|
||||
define( 'BSF_UTM_ANALYTICS_REFERER', 'bsf_product_referers' );
|
||||
}
|
||||
|
||||
/**
|
||||
* UTM Analytics class
|
||||
*
|
||||
* @since 1.1.10
|
||||
*/
|
||||
class BSF_UTM_Analytics {
|
||||
|
||||
/**
|
||||
* List of slugs of all the bsf products that will be referer, referring another product.
|
||||
*
|
||||
* @var array<string>
|
||||
* @since 1.1.10
|
||||
*/
|
||||
private static $bsf_product_slugs = [
|
||||
'all-in-one-schemaorg-rich-snippets',
|
||||
'astra',
|
||||
'astra-portfolio',
|
||||
'astra-sites',
|
||||
'bb-ultimate-addon',
|
||||
'cartflows',
|
||||
'checkout-paypal-woo',
|
||||
'checkout-plugins-stripe-woo',
|
||||
'convertpro',
|
||||
'header-footer-elementor',
|
||||
'latepoint',
|
||||
'presto-player',
|
||||
'surecart',
|
||||
'sureforms',
|
||||
'suremails',
|
||||
'surerank',
|
||||
'suretriggers',
|
||||
'ultimate-addons-for-beaver-builder-lite',
|
||||
'ultimate-addons-for-gutenberg',
|
||||
'ultimate-elementor',
|
||||
'Ultimate_VC_Addons',
|
||||
'variation-swatches-woo',
|
||||
'woo-cart-abandonment-recovery',
|
||||
'wp-schema-pro',
|
||||
'zipwp'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* This function will help to determine if provided slug is a valid bsf product or not,
|
||||
* This way we will maintain consistency through out all our products.
|
||||
*
|
||||
* @param string $slug unique slug of the product which can be used for referer, product.
|
||||
* @since 1.1.10
|
||||
* @return boolean
|
||||
*/
|
||||
public static function is_valid_bsf_product_slug( $slug ) {
|
||||
if ( empty( $slug ) || ! is_string( $slug ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return in_array( $slug, self::$bsf_product_slugs, true );
|
||||
}
|
||||
|
||||
/**
|
||||
* This function updates value of referer and product in option
|
||||
* bsf_product_referer in form of key value pair as 'product' => 'referer'
|
||||
*
|
||||
* @param string $referer slug of the product which is refering another product.
|
||||
* @param string $product slug of the product which is refered.
|
||||
* @since 1.1.10
|
||||
* @return void
|
||||
*/
|
||||
public static function update_referer( $referer, $product ) {
|
||||
|
||||
$slugs = [
|
||||
'referer' => $referer,
|
||||
'product' => $product,
|
||||
];
|
||||
$error_count = 0;
|
||||
|
||||
foreach ( $slugs as $type => $slug ) {
|
||||
if ( ! self::is_valid_bsf_product_slug( $slug ) ) {
|
||||
error_log( sprintf( 'Invalid %1$s slug provided "%2$s", does not match bsf_product_slugs', $type, $slug ) ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log -- adding logs in case of failure will help in debugging.
|
||||
$error_count++;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $error_count > 0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$slugs = array_map( 'sanitize_text_field', $slugs );
|
||||
|
||||
$bsf_product_referers = get_option( BSF_UTM_ANALYTICS_REFERER, [] );
|
||||
if ( ! is_array( $bsf_product_referers ) ) {
|
||||
$bsf_product_referers = [];
|
||||
}
|
||||
|
||||
$bsf_product_referers[ $slugs['product'] ] = $slugs['referer'];
|
||||
|
||||
update_option( BSF_UTM_ANALYTICS_REFERER, $bsf_product_referers );
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will add utm_args to pro link or purchase link
|
||||
* added utm_source by default additional utm_args such as utm_medium etc can be provided to generate location specific links
|
||||
*
|
||||
* @param string $link Ideally this should be product site link where utm_params can be tracked.
|
||||
* @param string $product Product slug whose utm_link need to be created.
|
||||
* @param mixed $utm_args additional args to be passed ex: [ 'utm_medium' => 'dashboard'].
|
||||
* @since 1.1.10
|
||||
* @return string
|
||||
*/
|
||||
public static function get_utm_ready_link( $link, $product, $utm_args = [] ) {
|
||||
|
||||
if ( false === wp_http_validate_url( $link ) ) {
|
||||
error_log( 'Invalid url passed to get_utm_ready_link function' ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log -- adding logs in case of failure will help in debugging.
|
||||
return $link;
|
||||
}
|
||||
|
||||
if ( empty( $product ) || ! is_string( $product ) || ! self::is_valid_bsf_product_slug( $product ) ) {
|
||||
error_log( sprintf( 'Invalid product slug provided "%1$s", does not match bsf_product_slugs', $product ) ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log -- adding logs in case of failure will help in debugging.
|
||||
return $link;
|
||||
}
|
||||
|
||||
$bsf_product_referers = get_option( BSF_UTM_ANALYTICS_REFERER, [] );
|
||||
|
||||
if ( ! is_array( $bsf_product_referers ) || empty( $bsf_product_referers[ $product ] ) ) {
|
||||
return $link;
|
||||
}
|
||||
|
||||
if ( ! self::is_valid_bsf_product_slug( $bsf_product_referers[ $product ] ) ) {
|
||||
return $link;
|
||||
}
|
||||
|
||||
if ( ! is_array( $utm_args ) ) {
|
||||
$utm_args = [];
|
||||
}
|
||||
|
||||
$utm_args['utm_source'] = $bsf_product_referers[ $product ];
|
||||
|
||||
$link = add_query_arg(
|
||||
$utm_args,
|
||||
$link
|
||||
);
|
||||
|
||||
return $link;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"bsf-analytics-ver": "1.1.16"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,608 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin AJAX functions.
|
||||
*
|
||||
* @package header-footer-elementor
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
use HFE\WidgetsManager\Base\HFE_Helper;
|
||||
|
||||
if ( ! class_exists( 'HFE_Addons_Actions' ) ) {
|
||||
|
||||
/**
|
||||
* Initialization
|
||||
*
|
||||
* @since 1.6.0
|
||||
*/
|
||||
class HFE_Addons_Actions {
|
||||
|
||||
/**
|
||||
* Member Variable
|
||||
*
|
||||
* @var HFE_Addons_Actions
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* Widget list variable
|
||||
*
|
||||
* @var HFE_Addons_Actions
|
||||
*/
|
||||
private static $widget_list;
|
||||
|
||||
/**
|
||||
* Initiator
|
||||
*
|
||||
* @return HFE_Addons_Actions
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'wp_ajax_hfe_recommended_plugin_activate', [ $this, 'hfe_activate_addon' ] );
|
||||
add_action( 'wp_ajax_hfe_recommended_plugin_install', [ $this, 'hfe_plugin_install' ] );
|
||||
add_action( 'wp_ajax_hfe_recommended_theme_install', [ $this, 'hfe_theme_install' ] );
|
||||
add_action( 'wp_ajax_hfe_admin_modal', [ $this, 'hfe_admin_modal' ] );
|
||||
add_action( 'wp_ajax_hfe-update-subscription', [ $this, 'update_subscription' ] );
|
||||
|
||||
add_action( 'wp_ajax_hfe_activate_widget', [ $this, 'activate_widget' ] );
|
||||
add_action( 'wp_ajax_hfe_deactivate_widget', [ $this, 'deactivate_widget' ] );
|
||||
|
||||
add_action( 'wp_ajax_hfe_bulk_activate_widgets', [ $this, 'bulk_activate_widgets' ] );
|
||||
add_action( 'wp_ajax_hfe_bulk_deactivate_widgets', [ $this, 'bulk_deactivate_widgets' ] );
|
||||
add_action( 'wp_ajax_hfe_bulk_deactivate_unused_widgets', [ $this, 'bulk_deactivate_unused_widgets' ] );
|
||||
|
||||
add_action( 'wp_ajax_save_theme_compatibility_option', [ $this, 'save_hfe_compatibility_option_callback' ] );
|
||||
add_action( 'wp_ajax_save_analytics_option', [ $this, 'save_analytics_option' ] );
|
||||
|
||||
add_action( 'wp_ajax_update_permalink_notice_option', [ $this, 'update_permalink_notice_option' ] );
|
||||
add_action( 'wp_ajax_nopriv_update_permalink_notice_option', [ $this, 'update_permalink_notice_option' ] );
|
||||
add_action( 'wp_ajax_hfe_flush_permalink_notice', [ $this, 'hfe_flush_permalink_notice' ] );
|
||||
add_action( 'wp_ajax_nopriv_hfe_flush_permalink_notice', [ $this, 'hfe_flush_permalink_notice' ] );
|
||||
|
||||
add_action( 'wp_ajax_hfe_dismiss_upgrade_notice', [ $this, 'dismiss_upgrade_notice' ] );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Updated the permalink notice option.
|
||||
*
|
||||
* @since 2.2.1
|
||||
*/
|
||||
public function update_permalink_notice_option() {
|
||||
// Verify the nonce.
|
||||
if ( ! isset( $_POST['nonce'] ) || ! check_ajax_referer( 'hfe_permalink_clear_notice_nonce', 'nonce', false ) ) {
|
||||
wp_send_json_error( 'Invalid nonce' );
|
||||
}
|
||||
|
||||
// Check if the current user has the capability to manage options.
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
wp_send_json_error( 'Unauthorized user' );
|
||||
}
|
||||
|
||||
// Update the option to true.
|
||||
update_user_meta( get_current_user_id(), 'hfe_permalink_notice_option', 'notice-dismissed' );
|
||||
|
||||
// Send a success response.
|
||||
wp_send_json_success( 'Option updated successfully' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Updated the permalink notice option.
|
||||
*
|
||||
* @since 2.2.1
|
||||
*/
|
||||
public function hfe_flush_permalink_notice() {
|
||||
// Verify the nonce.
|
||||
if ( ! isset( $_POST['nonce'] ) || ! check_ajax_referer( 'hfe_permalink_clear_notice_nonce', 'nonce', false ) ) {
|
||||
wp_send_json_error( 'Invalid nonce' );
|
||||
}
|
||||
|
||||
// Check if the current user has the capability to manage options.
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
wp_send_json_error( 'Unauthorized user' );
|
||||
}
|
||||
|
||||
$permalink_structure = get_option('permalink_structure');
|
||||
// Check if the permalink structure is not empty.
|
||||
if ( '' !== $permalink_structure )
|
||||
{
|
||||
update_option('permalink_structure', $permalink_structure);
|
||||
flush_rewrite_rules();
|
||||
// Update the option to true.
|
||||
update_user_meta( get_current_user_id(), 'hfe_permalink_notice_option', 'notice-dismissed' );
|
||||
|
||||
}
|
||||
|
||||
// Send a success response.
|
||||
wp_send_json_success( 'Permalink Flushed successfully' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the installation and saving of required plugins.
|
||||
*
|
||||
* This function is responsible for installing and saving required plugins.
|
||||
* It checks for the plugin slug in the AJAX request, verifies the nonce, and initiates the plugin installation process.
|
||||
* If the plugin is successfully installed, it schedules a database update to map the plugin slug to a custom key for analytics tracking.
|
||||
*
|
||||
* @since 2.2.0
|
||||
*/
|
||||
public function hfe_plugin_install() {
|
||||
|
||||
check_ajax_referer( 'updates', '_ajax_nonce' );
|
||||
|
||||
// Check if user has permission to install plugin.
|
||||
if ( ! current_user_can( 'install_plugins' ) ) {
|
||||
wp_send_json_error( esc_html__( 'Plugin installation is disabled for you on this site.', 'header-footer-elementor' ) );
|
||||
}
|
||||
// Fetching the plugin slug from the AJAX request.
|
||||
// @psalm-suppress PossiblyInvalidArgument.
|
||||
$plugin_slug = isset( $_POST['slug'] ) && is_string( $_POST['slug'] ) ? sanitize_text_field( wp_unslash( $_POST['slug'] ) ) : '';
|
||||
|
||||
if ( empty( $plugin_slug ) ) {
|
||||
wp_send_json_error( [ 'message' => __( 'Plugin slug is missing.', 'header-footer-elementor' ) ] );
|
||||
}
|
||||
|
||||
// Schedule the database update if the plugin is installed successfully.
|
||||
add_action(
|
||||
'shutdown',
|
||||
function () use ( $plugin_slug ) {
|
||||
// Iterate through all plugins to check if the installed plugin matches the current plugin slug.
|
||||
$all_plugins = get_plugins();
|
||||
foreach ( $all_plugins as $plugin_file => $_ ) {
|
||||
if ( class_exists( 'BSF_UTM_Analytics' ) && is_callable( 'BSF_UTM_Analytics::update_referer' ) && strpos( $plugin_file, $plugin_slug . '/' ) === 0 ) {
|
||||
// If the plugin is found and the update_referer function is callable, update the referer with the corresponding product slug.
|
||||
BSF_UTM_Analytics::update_referer( 'header-footer-elementor', $plugin_slug );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
if ( function_exists( 'wp_ajax_install_plugin' ) ) {
|
||||
// @psalm-suppress NoValue
|
||||
wp_ajax_install_plugin();
|
||||
} else {
|
||||
wp_send_json_error( [ 'message' => __( 'Plugin installation function not found.', 'header-footer-elementor' ) ] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handles the installation and saving of required theme.
|
||||
*
|
||||
* This function is responsible for installing and saving required plugins.
|
||||
* It checks for the plugin slug in the AJAX request, verifies the nonce, and initiates the plugin installation process.
|
||||
* If the theme is successfully installed, it schedules a database update to map the plugin slug to a custom key for analytics tracking.
|
||||
*
|
||||
* @since 2.2.0
|
||||
*/
|
||||
public function hfe_theme_install() {
|
||||
|
||||
check_ajax_referer( 'updates', '_ajax_nonce' );
|
||||
|
||||
// Check if user has permission to install theme.
|
||||
if ( ! current_user_can( 'install_themes' ) ) {
|
||||
wp_send_json_error( esc_html__( 'Theme installation is disabled for you on this site.', 'header-footer-elementor' ) );
|
||||
}
|
||||
// Fetching the plugin slug from the AJAX request.
|
||||
// @psalm-suppress PossiblyInvalidArgument.
|
||||
$theme_slug = isset( $_POST['slug'] ) && is_string( $_POST['slug'] ) ? sanitize_text_field( wp_unslash( $_POST['slug'] ) ) : '';
|
||||
|
||||
if ( empty( $theme_slug ) ) {
|
||||
wp_send_json_error( [ 'message' => __( 'Theme slug is missing.', 'header-footer-elementor' ) ] );
|
||||
}
|
||||
|
||||
// Schedule the database update if the theme is installed successfully.
|
||||
add_action(
|
||||
'shutdown',
|
||||
function () use ( $theme_slug ) {
|
||||
// Iterate through all themes to check if the installed theme matches the current theme slug.
|
||||
$all_themes = wp_get_themes();
|
||||
foreach ( $all_themes as $theme_file => $_ ) {
|
||||
if ( class_exists( 'BSF_UTM_Analytics' ) && is_callable( 'BSF_UTM_Analytics::update_referer' ) && strpos( $theme_file, $theme_slug . '/' ) === 0 ) {
|
||||
// If the theme is found and the update_referer function is callable, update the referer with the corresponding product slug.
|
||||
BSF_UTM_Analytics::update_referer( 'header-footer-elementor', $theme_slug );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
if ( function_exists( 'wp_ajax_install_theme' ) ) {
|
||||
// @psalm-suppress NoValue
|
||||
wp_ajax_install_theme();
|
||||
} else {
|
||||
wp_send_json_error( [ 'message' => __( 'Theme installation function not found.', 'header-footer-elementor' ) ] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate all module
|
||||
*/
|
||||
public static function bulk_activate_widgets() {
|
||||
|
||||
check_ajax_referer( 'hfe-admin-nonce', 'nonce' );
|
||||
|
||||
// Check if user has permission to manage options.
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
wp_send_json_error( __( 'You do not have permission to perform this action.', 'header-footer-elementor' ) );
|
||||
}
|
||||
|
||||
if ( ! isset( self::$widget_list ) ) {
|
||||
self::$widget_list = HFE_Helper::get_widget_list();
|
||||
}
|
||||
|
||||
$new_widgets = [];
|
||||
|
||||
// Set all extension to enabled.
|
||||
foreach ( self::$widget_list as $slug => $value ) {
|
||||
$new_widgets[ $slug ] = $slug;
|
||||
}
|
||||
|
||||
// Escape attrs.
|
||||
$new_widgets = array_map( 'esc_attr', $new_widgets );
|
||||
|
||||
// Update new_extensions.
|
||||
HFE_Helper::update_admin_settings_option( '_hfe_widgets', $new_widgets );
|
||||
|
||||
// Send a JSON response.
|
||||
wp_send_json_success( 'Widgets activated successfully.' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Deactivate all module
|
||||
*/
|
||||
public static function bulk_deactivate_widgets() {
|
||||
|
||||
check_ajax_referer( 'hfe-admin-nonce', 'nonce' );
|
||||
|
||||
// Check if user has permission to manage options.
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
wp_send_json_error( __( 'You do not have permission to perform this action.', 'header-footer-elementor' ) );
|
||||
}
|
||||
|
||||
if ( ! isset( self::$widget_list ) ) {
|
||||
self::$widget_list = HFE_Helper::get_widget_list();
|
||||
}
|
||||
|
||||
$new_widgets = [];
|
||||
|
||||
// Set all extension to enabled.
|
||||
foreach ( self::$widget_list as $slug => $value ) {
|
||||
$new_widgets[ $slug ] = 'disabled';
|
||||
}
|
||||
|
||||
// Escape attrs.
|
||||
$new_widgets = array_map( 'esc_attr', $new_widgets );
|
||||
|
||||
// Update new_extensions.
|
||||
HFE_Helper::update_admin_settings_option( '_hfe_widgets', $new_widgets );
|
||||
|
||||
// Send a JSON response.
|
||||
wp_send_json_success( 'Widgets deactivated successfully.' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Deactivate all unused module
|
||||
*/
|
||||
public static function bulk_deactivate_unused_widgets() {
|
||||
|
||||
check_ajax_referer( 'hfe-admin-nonce', 'nonce' );
|
||||
|
||||
// Check if user has permission to manage options.
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
wp_send_json_error( __( 'You do not have permission to perform this action.', 'header-footer-elementor' ) );
|
||||
}
|
||||
|
||||
if ( ! isset( self::$widget_list ) ) {
|
||||
self::$widget_list = HFE_Helper::get_widget_list();
|
||||
}
|
||||
$used_widgets = HFE_Helper::get_used_widget();
|
||||
// var_dump($used_widgets);
|
||||
$unused_widgets = [];
|
||||
|
||||
// Compare slugs from widget_list to keys in $used_widgets
|
||||
foreach ( self::$widget_list as $slug => $value ) {
|
||||
if ( ! isset( $used_widgets[ $value['slug'] ] ) ) {
|
||||
if( $slug === 'Scroll_To_Top' || $slug === 'Reading_Progress_Bar' ){
|
||||
continue;
|
||||
}
|
||||
$unused_widgets[] = $slug;
|
||||
}
|
||||
}
|
||||
|
||||
$deactivated = [];
|
||||
|
||||
// Set all extension to enabled.
|
||||
foreach ( self::$widget_list as $slug => $value ) {
|
||||
if ( in_array( $slug, $unused_widgets ) ) {
|
||||
$widgets[ $slug ] = 'disabled';
|
||||
$deactivated[] = $slug;
|
||||
}
|
||||
}
|
||||
|
||||
$widgets = array_map( 'esc_attr', $widgets );
|
||||
|
||||
HFE_Helper::update_admin_settings_option( '_hfe_widgets', $widgets );
|
||||
|
||||
wp_send_json_success( [ 'deactivated' => $deactivated ] );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deactivate module
|
||||
*/
|
||||
public static function deactivate_widget() {
|
||||
|
||||
check_ajax_referer( 'hfe-admin-nonce', 'nonce' );
|
||||
|
||||
// Check if user has permission to manage options.
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
wp_send_json_error( __( 'You do not have permission to perform this action.', 'header-footer-elementor' ) );
|
||||
}
|
||||
|
||||
$module_id = isset( $_POST['module_id'] ) ? sanitize_text_field( $_POST['module_id'] ) : '';
|
||||
$widgets = HFE_Helper::get_admin_settings_option( '_hfe_widgets', [] );
|
||||
|
||||
$widgets[ $module_id ] = 'disabled';
|
||||
$widgets = array_map( 'esc_attr', $widgets );
|
||||
|
||||
// Update widgets.
|
||||
HFE_Helper::update_admin_settings_option( '_hfe_widgets', $widgets );
|
||||
|
||||
wp_send_json( $module_id );
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate module
|
||||
*/
|
||||
public static function activate_widget() {
|
||||
|
||||
check_ajax_referer( 'hfe-admin-nonce', 'nonce' );
|
||||
|
||||
// Check if user has permission to manage options.
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
wp_send_json_error( __( 'You do not have permission to perform this action.', 'header-footer-elementor' ) );
|
||||
}
|
||||
|
||||
$module_id = isset( $_POST['module_id'] ) ? sanitize_text_field( $_POST['module_id'] ) : '';
|
||||
$widgets = HFE_Helper::get_admin_settings_option( '_hfe_widgets', [] );
|
||||
$widgets[ $module_id ] = $module_id;
|
||||
$widgets = array_map( 'esc_attr', $widgets );
|
||||
|
||||
// Update widgets.
|
||||
HFE_Helper::update_admin_settings_option( '_hfe_widgets', $widgets );
|
||||
|
||||
wp_send_json( $module_id );
|
||||
}
|
||||
|
||||
/**
|
||||
* Open modal popup.
|
||||
*
|
||||
* @since 1.6.0
|
||||
* @return void
|
||||
*/
|
||||
public function hfe_admin_modal() {
|
||||
|
||||
// Run a security check.
|
||||
check_ajax_referer( 'hfe-admin-nonce', 'nonce' );
|
||||
|
||||
// Check if user has permission to manage options.
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
wp_send_json_error( __( 'You do not have permission to perform this action.', 'header-footer-elementor' ) );
|
||||
}
|
||||
|
||||
update_user_meta( get_current_user_id(), 'hfe-popup', 'dismissed' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Subscription
|
||||
*
|
||||
* @since 1.6.0
|
||||
* @return void
|
||||
*/
|
||||
public function update_subscription() {
|
||||
|
||||
check_ajax_referer( 'hfe-admin-nonce', 'nonce' );
|
||||
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
wp_send_json_error( 'You can\'t perform this action.' );
|
||||
}
|
||||
|
||||
$api_domain = trailingslashit( $this->get_api_domain() );
|
||||
// PHPCS:Ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This code is deprecated and will be removed in future versions.
|
||||
$arguments = isset( $_POST['data'] ) ? array_map( 'sanitize_text_field', json_decode( stripslashes( wp_unslash( $_POST['data'] ) ), true ) ) : [];
|
||||
|
||||
$url = add_query_arg( $arguments, $api_domain . 'wp-json/starter-templates/v1/subscribe/' ); // add URL of your site or mail API.
|
||||
|
||||
$response = wp_remote_post( $url, [ 'timeout' => 60 ] );
|
||||
|
||||
if ( ! is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) === 200 ) {
|
||||
$response = json_decode( wp_remote_retrieve_body( $response ), true );
|
||||
|
||||
// Successfully subscribed.
|
||||
if ( isset( $response['success'] ) && $response['success'] ) {
|
||||
update_user_meta( get_current_user_ID(), 'hfe-subscribed', 'yes' );
|
||||
wp_send_json_success( $response );
|
||||
}
|
||||
} else {
|
||||
wp_send_json_error( $response );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the API URL.
|
||||
*
|
||||
* @since 1.6.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_api_domain() {
|
||||
return apply_filters( 'hfe_api_domain', 'https://websitedemos.net/' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate addon.
|
||||
*
|
||||
* @since 1.6.0
|
||||
* @return void
|
||||
*/
|
||||
public function hfe_activate_addon() {
|
||||
|
||||
// Run a security check.
|
||||
check_ajax_referer( 'hfe-admin-nonce', 'nonce' );
|
||||
|
||||
if ( isset( $_POST['plugin'] ) ) {
|
||||
|
||||
$type = '';
|
||||
if ( ! empty( $_POST['type'] ) ) {
|
||||
$type = sanitize_key( wp_unslash( $_POST['type'] ) );
|
||||
}
|
||||
|
||||
$plugin = sanitize_text_field( wp_unslash( $_POST['plugin'] ) );
|
||||
|
||||
if ( 'plugin' === $type ) {
|
||||
|
||||
// Check for permissions.
|
||||
if ( ! current_user_can( 'activate_plugins' ) ) {
|
||||
wp_send_json_error( esc_html__( 'Plugin activation is disabled for you on this site.', 'header-footer-elementor' ) );
|
||||
}
|
||||
|
||||
$activate = activate_plugins( $plugin );
|
||||
|
||||
if ( ! is_wp_error( $activate ) ) {
|
||||
|
||||
do_action( 'hfe_plugin_activated', $plugin );
|
||||
|
||||
wp_send_json_success( esc_html__( 'Plugin Activated.', 'header-footer-elementor' ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'theme' === $type ) {
|
||||
|
||||
if ( isset( $_POST['slug'] ) ) {
|
||||
$slug = sanitize_key( wp_unslash( $_POST['slug'] ) );
|
||||
|
||||
// Check for permissions.
|
||||
if ( ! ( current_user_can( 'switch_themes' ) ) ) {
|
||||
wp_send_json_error( esc_html__( 'Theme activation is disabled for you on this site.', 'header-footer-elementor' ) );
|
||||
}
|
||||
|
||||
$activate = switch_theme( $slug );
|
||||
|
||||
if ( ! is_wp_error( $activate ) ) {
|
||||
|
||||
do_action( 'hfe_theme_activated', $plugin );
|
||||
|
||||
wp_send_json_success( esc_html__( 'Theme Activated.', 'header-footer-elementor' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'plugin' === $type ) {
|
||||
wp_send_json_error( esc_html__( 'Could not activate plugin. Please activate from the Plugins page.', 'header-footer-elementor' ) );
|
||||
} elseif ( 'theme' === $type ) {
|
||||
wp_send_json_error( esc_html__( 'Could not activate theme. Please activate from the Themes page.', 'header-footer-elementor' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save HFE compatibility option via AJAX.
|
||||
*
|
||||
* @since 2.2.0
|
||||
* @return void
|
||||
*/
|
||||
public function save_hfe_compatibility_option_callback() {
|
||||
// Check nonce for security.
|
||||
check_ajax_referer( 'hfe-admin-nonce', 'nonce' );
|
||||
|
||||
// Check if user has permission to manage options.
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
wp_send_json_error( esc_html__( 'You do not have permission to perform this action.', 'header-footer-elementor' ) );
|
||||
}
|
||||
|
||||
if ( isset( $_POST['hfe_compatibility_option'] ) ) {
|
||||
// Sanitize and update option.
|
||||
$option = sanitize_text_field( $_POST['hfe_compatibility_option'] );
|
||||
update_option( 'hfe_compatibility_option', $option );
|
||||
|
||||
// Return a success response.
|
||||
wp_send_json_success( esc_html__( 'Settings saved successfully!', 'header-footer-elementor' ) );
|
||||
} else {
|
||||
// Return an error response if the option is not set.
|
||||
wp_send_json_error( esc_html__( 'Unable to save settings.', 'header-footer-elementor' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save HFE analytics compatibility option via AJAX.
|
||||
*
|
||||
* @since 2.2.1
|
||||
* @return void
|
||||
*/
|
||||
public function save_analytics_option() {
|
||||
// Check nonce for security.
|
||||
check_ajax_referer( 'hfe-admin-nonce', 'nonce' );
|
||||
|
||||
// Check if user has permission to manage options.
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
wp_send_json_error( __( 'You do not have permission to perform this action.', 'header-footer-elementor' ) );
|
||||
}
|
||||
|
||||
if ( isset( $_POST['uae_analytics_optin'] ) ) {
|
||||
// Sanitize and update option.
|
||||
$option = sanitize_text_field( $_POST['uae_analytics_optin'] );
|
||||
update_option( 'uae_analytics_optin', $option );
|
||||
|
||||
// Return a success response.
|
||||
wp_send_json_success( __( 'Settings saved successfully!', 'header-footer-elementor' ) );
|
||||
} else {
|
||||
// Return an error response if the option is not set.
|
||||
wp_send_json_error( __( 'Unable to save settings.', 'header-footer-elementor' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dismiss upgrade notice
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function dismiss_upgrade_notice() {
|
||||
|
||||
// Check if user has permission to manage options.
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
wp_send_json_error( __( 'You do not have permission to perform this action.', 'header-footer-elementor' ) );
|
||||
return;
|
||||
}
|
||||
|
||||
// Verify nonce for security
|
||||
if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'hfe-admin-nonce' ) ) {
|
||||
wp_send_json_error( __( 'Security check failed.', 'header-footer-elementor' ) );
|
||||
return;
|
||||
}
|
||||
|
||||
// Update option to remember the dismissal
|
||||
update_user_meta( get_current_user_id(), 'hfe_upgrade_notice_dismissed', 'true' );
|
||||
wp_send_json_success( __( 'Upgrade notice dismissed.', 'header-footer-elementor' ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Kicking this off by calling 'get_instance()' method
|
||||
*/
|
||||
HFE_Addons_Actions::get_instance();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,861 @@
|
||||
<?php
|
||||
/**
|
||||
* Entry point for the plugin. Checks if Elementor is installed and activated and loads it's own files and actions.
|
||||
*
|
||||
* @package header-footer-elementor
|
||||
*/
|
||||
|
||||
use HFE\Lib\Astra_Target_Rules_Fields;
|
||||
use HFE\WidgetsManager\Base\HFE_Helper;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* HFE_Admin setup
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class HFE_Admin {
|
||||
|
||||
/**
|
||||
* Instance of HFE_Admin
|
||||
*
|
||||
* @var HFE_Admin
|
||||
*/
|
||||
private static $_instance = null;
|
||||
|
||||
/**
|
||||
* Instance of Elemenntor Frontend class.
|
||||
*
|
||||
* @var object \Elementor\Frontend()
|
||||
*/
|
||||
private static $elementor_instance;
|
||||
|
||||
/**
|
||||
* Instance of HFE_Admin
|
||||
*
|
||||
* @return HFE_Admin Instance of HFE_Admin
|
||||
*/
|
||||
public static function instance() {
|
||||
if ( ! isset( self::$_instance ) ) {
|
||||
self::$_instance = new self();
|
||||
}
|
||||
|
||||
add_action( 'elementor/init', __CLASS__ . '::load_admin', 0 );
|
||||
|
||||
return self::$_instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the icons style in editor.
|
||||
*
|
||||
* @since 1.3.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public static function load_admin() {
|
||||
add_action( 'elementor/editor/after_enqueue_styles', __CLASS__ . '::hfe_admin_enqueue_scripts' );
|
||||
add_action( 'admin_head', __CLASS__ . '::hfe_admin_enqueue_scripts' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue admin scripts
|
||||
*
|
||||
* @since 1.3.0
|
||||
* @param string $hook Current page hook.
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public static function hfe_admin_enqueue_scripts( $hook ) {
|
||||
|
||||
// Register the icons styles.
|
||||
wp_register_style(
|
||||
'hfe-style',
|
||||
HFE_URL . 'assets/css/style.css',
|
||||
[],
|
||||
HFE_VER
|
||||
);
|
||||
|
||||
wp_enqueue_style( 'hfe-style' );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function __construct() {
|
||||
add_action( 'init', [ $this, 'header_footer_posttype' ] );
|
||||
if ( is_admin() && current_user_can( 'manage_options' ) ) {
|
||||
add_action( 'admin_menu', [ $this, 'register_admin_menu' ], 50 );
|
||||
}
|
||||
|
||||
$is_elementor_callable = ( defined( 'ELEMENTOR_VERSION' ) && is_callable( 'Elementor\Plugin::instance' ) ) ? true : false;
|
||||
if ( $is_elementor_callable ) {
|
||||
self::$elementor_instance = Elementor\Plugin::instance();
|
||||
}
|
||||
|
||||
add_action( 'add_meta_boxes', [ $this, 'ehf_register_metabox' ] );
|
||||
add_action( 'save_post', [ $this, 'ehf_save_meta' ] );
|
||||
add_action( 'admin_notices', [ $this, 'location_notice' ] );
|
||||
add_action( 'template_redirect', [ $this, 'block_template_frontend' ] );
|
||||
add_filter( 'single_template', [ $this, 'load_canvas_template' ] );
|
||||
add_filter( 'manage_elementor-hf_posts_columns', [ $this, 'set_shortcode_columns' ] );
|
||||
add_action( 'manage_elementor-hf_posts_custom_column', [ $this, 'render_shortcode_column' ], 10, 2 );
|
||||
if ( defined( 'ELEMENTOR_PRO_VERSION' ) && ELEMENTOR_PRO_VERSION > 2.8 ) {
|
||||
add_action( 'elementor/editor/footer', [ $this, 'register_hfe_epro_script' ], 99 );
|
||||
}
|
||||
|
||||
add_action( 'admin_notices', [ $this, 'hide_admin_notices' ], 1 );
|
||||
add_action( 'all_admin_notices', [ $this, 'hide_admin_notices' ], 1 );
|
||||
|
||||
if ( is_admin() ) {
|
||||
add_action( 'manage_elementor-hf_posts_custom_column', [ $this, 'column_content' ], 10, 2 );
|
||||
add_filter( 'manage_elementor-hf_posts_columns', [ $this, 'column_headings' ] );
|
||||
require_once HFE_DIR . 'admin/class-hfe-addons-actions.php';
|
||||
}
|
||||
add_action( 'elementor/editor/footer', [ $this, 'print_permalink_clear_notice' ] );
|
||||
add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_permalink_clear_notice_js' ] );
|
||||
add_action( 'elementor/editor/before_enqueue_styles', [ $this, 'enqueue_permalink_clear_notice_css' ] );
|
||||
// Hook into Elementor's editor styles
|
||||
add_action('elementor/editor/before_enqueue_scripts', [$this, 'enqueue_editor_scripts']);
|
||||
if ( 'yes' === get_option( 'uae_analytics_optin', false ) ) {
|
||||
add_action('shutdown', [ $this, 'maybe_run_hfe_widgets_usage_check' ] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueuing Promotion widget scripts.
|
||||
*/
|
||||
public function enqueue_editor_scripts() {
|
||||
wp_enqueue_script(
|
||||
'uae-pro-promotion',
|
||||
HFE_URL . 'build/promotion-widget.js',
|
||||
[ 'jquery', 'wp-element', 'wp-dom-ready' ],
|
||||
HFE_VER,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the page on which Widget check need to be run.
|
||||
*/
|
||||
public function maybe_run_hfe_widgets_usage_check() {
|
||||
// Run only on admin.php?page=hfe
|
||||
if (
|
||||
is_admin() &&
|
||||
isset( $_GET['page'] ) &&
|
||||
( 'uaepro' === $_GET['page'] || 'hfe' === $_GET['page'])
|
||||
) {
|
||||
$this->hfe_check_widgets_data_usage();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Handle AJAX request to get widgets usage data.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
public function hfe_check_widgets_data_usage() {
|
||||
// Check user permissions
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$transient_key = 'uae_widgets_usage_data';
|
||||
$widgets_usage = get_transient( $transient_key );
|
||||
|
||||
if ( false === $widgets_usage || false === get_option( 'uae_widgets_usage_data_option' ) ) {
|
||||
$filtered_widgets_usage = HFE_Helper::get_used_widget();
|
||||
set_transient( $transient_key, $filtered_widgets_usage, MONTH_IN_SECONDS ); // Store for 5 minutes
|
||||
update_option( 'uae_widgets_usage_data_option', $filtered_widgets_usage );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue notice style based on option and posttype.
|
||||
*
|
||||
* @since 2.2.1
|
||||
*/
|
||||
public function enqueue_permalink_clear_notice_css() {
|
||||
|
||||
if ( get_user_meta( get_current_user_id(), 'hfe_permalink_notice_option', true ) === 'notice-dismissed' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(isset(self::$elementor_instance)){
|
||||
$current_post_type = get_post_type( self::$elementor_instance->editor->get_post_id() );
|
||||
|
||||
if ( $current_post_type !== 'elementor-hf' ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
wp_enqueue_style(
|
||||
'hfe-permalink-clear-notice',
|
||||
HFE_URL . 'inc/widgets-css/permalink-clear-notice.css',
|
||||
[],
|
||||
HFE_VER
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue and localize notice script based on option and posttype.
|
||||
*
|
||||
* @since 2.2.1
|
||||
*/
|
||||
public function enqueue_permalink_clear_notice_js() {
|
||||
|
||||
if ( get_user_meta( get_current_user_id(), 'hfe_permalink_notice_option', true ) === 'notice-dismissed' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(isset(self::$elementor_instance)){
|
||||
$current_post_type = get_post_type( self::$elementor_instance->editor->get_post_id() );
|
||||
|
||||
if ( $current_post_type !== 'elementor-hf' ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
wp_enqueue_script(
|
||||
'hfe-permalink-clear-notice',
|
||||
HFE_URL . 'inc/js/permalink-clear-notice.js',
|
||||
[ 'jquery' ],
|
||||
HFE_VER
|
||||
);
|
||||
|
||||
wp_localize_script(
|
||||
'hfe-permalink-clear-notice',
|
||||
'hfePermalinkClearNotice',
|
||||
[
|
||||
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
||||
'nonce' => wp_create_nonce( 'hfe_permalink_clear_notice_nonce' ),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creating notice for permaliink reset in Elementor Editor.
|
||||
*
|
||||
* @since 2.2.1
|
||||
*/
|
||||
public function print_permalink_clear_notice() {
|
||||
if ( is_admin() ) {
|
||||
if ( get_user_meta( get_current_user_id(), 'hfe_permalink_notice_option', true ) === 'notice-dismissed' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(isset(self::$elementor_instance)){
|
||||
$current_post_type = get_post_type( self::$elementor_instance->editor->get_post_id() );
|
||||
|
||||
if ( $current_post_type !== 'elementor-hf' ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<div class="uae-permalink-clear-notice" id="uae-permalink-clear-notice">
|
||||
<header>
|
||||
<i class="eicon-warning"></i>
|
||||
<h2><?php echo esc_html__( 'Important Notice:', 'header-footer-elementor' ); ?></h2>
|
||||
<button class="uae-permalink-notice-close"><i class="eicon-close"></i></button>
|
||||
</header>
|
||||
<div class="uae-permalink-notice-content">
|
||||
<b><?php echo esc_html__( 'Can\'t edit your header or footer?', 'header-footer-elementor' ); ?></b><br/>
|
||||
<?php echo esc_html__( 'Try clearing your cache or resetting permalinks (Settings > Permalinks > Save Changes).', 'header-footer-elementor' ); ?>
|
||||
<a href="<?php echo esc_url( 'https://ultimateelementor.com/docs/elementor-header-footer-template-not-loading-or-stuck-on-loading/' ); ?>" target="_blank"><?php echo esc_html_e( 'Learn More', 'header-footer-elementor' ); ?></a>
|
||||
<br>
|
||||
<?php if(!is_multisite()){ ?>
|
||||
<button class="uae-permalink-flush-btn" type="button">
|
||||
<span class="uae-btn-main-text"><?php echo esc_html__( 'Flush Permalink', 'header-footer-elementor' ); ?></span>
|
||||
<span class="uae-notice-loader"></span>
|
||||
</button>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Hide admin notices on the custom settings page.
|
||||
*
|
||||
* @since 2.2.1
|
||||
* @return void
|
||||
*/
|
||||
public static function hide_admin_notices() {
|
||||
$screen = get_current_screen();
|
||||
$pages_to_hide_notices = [
|
||||
'edit-elementor-hf', // Edit screen for elementor-hf post type.
|
||||
'elementor-hf', // New post screen for elementor-hf post type.
|
||||
];
|
||||
|
||||
if ( in_array( $screen->id, $pages_to_hide_notices ) || 'toplevel_page_hfe' === $screen->id ) {
|
||||
remove_all_actions( 'admin_notices' );
|
||||
remove_all_actions( 'all_admin_notices' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Script for Elementor Pro full site editing support.
|
||||
*
|
||||
* @since 1.4.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register_hfe_epro_script() {
|
||||
$ids_array = [
|
||||
[
|
||||
'id' => get_hfe_header_id(),
|
||||
'value' => 'Header',
|
||||
],
|
||||
[
|
||||
'id' => get_hfe_footer_id(),
|
||||
'value' => 'Footer',
|
||||
],
|
||||
[
|
||||
'id' => hfe_get_before_footer_id(),
|
||||
'value' => 'Before Footer',
|
||||
],
|
||||
];
|
||||
|
||||
wp_enqueue_script( 'hfe-elementor-pro-compatibility', HFE_URL . 'inc/js/hfe-elementor-pro-compatibility.js', [ 'jquery' ], HFE_VER, true );
|
||||
|
||||
wp_localize_script(
|
||||
'hfe-elementor-pro-compatibility',
|
||||
'hfe_admin',
|
||||
[
|
||||
'ids_array' => wp_json_encode( $ids_array ),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds or removes list table column headings.
|
||||
*
|
||||
* @param array $columns Array of columns.
|
||||
* @return array
|
||||
*/
|
||||
public function column_headings( $columns ) {
|
||||
unset( $columns['date'] );
|
||||
|
||||
$columns['elementor_hf_display_rules'] = __( 'Display Rules', 'header-footer-elementor' );
|
||||
$columns['date'] = __( 'Date', 'header-footer-elementor' );
|
||||
|
||||
return $columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the custom list table column content.
|
||||
*
|
||||
* @since 1.2.0
|
||||
* @param array $column Name of column.
|
||||
* @param int $post_id Post id.
|
||||
* @return void
|
||||
*/
|
||||
public function column_content( $column, $post_id ) {
|
||||
|
||||
if ( 'elementor_hf_display_rules' === $column ) {
|
||||
|
||||
$locations = get_post_meta( $post_id, 'ehf_target_include_locations', true );
|
||||
if ( ! empty( $locations ) ) {
|
||||
echo '<div class="ast-advanced-headers-location-wrap" style="margin-bottom: 5px;">';
|
||||
echo '<strong>Display: </strong>';
|
||||
$this->column_display_location_rules( $locations );
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
$locations = get_post_meta( $post_id, 'ehf_target_exclude_locations', true );
|
||||
if ( ! empty( $locations ) ) {
|
||||
echo '<div class="ast-advanced-headers-exclusion-wrap" style="margin-bottom: 5px;">';
|
||||
echo '<strong>Exclusion: </strong>';
|
||||
$this->column_display_location_rules( $locations );
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
$users = get_post_meta( $post_id, 'ehf_target_user_roles', true );
|
||||
if ( isset( $users ) && is_array( $users ) ) {
|
||||
if ( isset( $users[0] ) && ! empty( $users[0] ) ) {
|
||||
$user_label = [];
|
||||
foreach ( $users as $user ) {
|
||||
$user_label[] = Astra_Target_Rules_Fields::get_user_by_key( $user );
|
||||
}
|
||||
echo '<div class="ast-advanced-headers-users-wrap">';
|
||||
echo '<strong>Users: </strong>';
|
||||
echo esc_html( join( ', ', $user_label ) );
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Markup of Location rules for Display rule column.
|
||||
*
|
||||
* @param array $locations Array of locations.
|
||||
* @return void
|
||||
*/
|
||||
public function column_display_location_rules( $locations ) {
|
||||
|
||||
$location_label = [];
|
||||
if ( is_array( $locations ) && is_array( $locations['rule'] ) && isset( $locations['rule'] ) ) {
|
||||
$index = array_search( 'specifics', $locations['rule'] );
|
||||
if ( false !== $index && ! empty( $index ) ) {
|
||||
unset( $locations['rule'][ $index ] );
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $locations['rule'] ) && is_array( $locations['rule'] ) ) {
|
||||
foreach ( $locations['rule'] as $location ) {
|
||||
$location_label[] = Astra_Target_Rules_Fields::get_location_by_key( $location );
|
||||
}
|
||||
}
|
||||
if ( isset( $locations['specific'] ) && is_array( $locations['specific'] ) ) {
|
||||
foreach ( $locations['specific'] as $location ) {
|
||||
$location_label[] = Astra_Target_Rules_Fields::get_location_by_key( $location );
|
||||
}
|
||||
}
|
||||
|
||||
echo esc_html( join( ', ', $location_label ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register Post type for Elementor Header & Footer Builder templates
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function header_footer_posttype() {
|
||||
|
||||
$setting_location = $this->is_pro_active() ? 'uaepro' : 'hfe';
|
||||
|
||||
$labels = [
|
||||
'name' => esc_html__( 'Elementor Header & Footer Builder', 'header-footer-elementor' ),
|
||||
'singular_name' => esc_html__( 'Elementor Header & Footer Builder', 'header-footer-elementor' ),
|
||||
'menu_name' => esc_html__( 'Elementor Header & Footer Builder', 'header-footer-elementor' ),
|
||||
'name_admin_bar' => esc_html__( 'Elementor Header & Footer Builder', 'header-footer-elementor' ),
|
||||
'add_new' => esc_html__( 'Add New', 'header-footer-elementor' ),
|
||||
'add_new_item' => esc_html__( 'Add New', 'header-footer-elementor' ),
|
||||
'new_item' => esc_html__( 'New Template', 'header-footer-elementor' ),
|
||||
'edit_item' => esc_html__( 'Edit Template', 'header-footer-elementor' ),
|
||||
'view_item' => esc_html__( 'View Template', 'header-footer-elementor' ),
|
||||
'all_items' => esc_html__( 'View All', 'header-footer-elementor' ),
|
||||
'search_items' => esc_html__( 'Search Templates', 'header-footer-elementor' ),
|
||||
'parent_item_colon' => esc_html__( 'Parent Templates:', 'header-footer-elementor' ),
|
||||
'not_found' => esc_html__( 'No Templates found.', 'header-footer-elementor' ),
|
||||
'not_found_in_trash' => esc_html__( 'No Templates found in Trash.', 'header-footer-elementor' ),
|
||||
];
|
||||
|
||||
$args = [
|
||||
'labels' => $labels,
|
||||
'public' => true,
|
||||
'show_ui' => true,
|
||||
'show_in_menu' => false,
|
||||
'show_in_nav_menus' => false,
|
||||
'exclude_from_search' => true,
|
||||
'capability_type' => 'post',
|
||||
'hierarchical' => false,
|
||||
'menu_icon' => 'dashicons-editor-kitchensink',
|
||||
'supports' => [ 'title', 'thumbnail', 'elementor' ],
|
||||
'menu_position' => 5,
|
||||
'capabilities' => [
|
||||
'edit_post' => 'manage_options',
|
||||
'read_post' => 'read',
|
||||
'delete_post' => 'manage_options',
|
||||
'edit_posts' => 'manage_options',
|
||||
'edit_others_posts' => 'manage_options',
|
||||
'publish_posts' => 'manage_options',
|
||||
'read_private_posts' => 'manage_options',
|
||||
'delete_posts' => 'manage_options',
|
||||
'delete_others_posts' => 'manage_options',
|
||||
'delete_private_posts' => 'manage_options',
|
||||
'delete_published_posts' => 'manage_options',
|
||||
'create_posts' => 'manage_options',
|
||||
],
|
||||
];
|
||||
|
||||
register_post_type( 'elementor-hf', $args );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the admin menu for Elementor Header & Footer Builder.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 1.0.1
|
||||
* Moved the menu under Appearance -> Elementor Header & Footer Builder
|
||||
* @return void
|
||||
*/
|
||||
public function register_admin_menu() {
|
||||
|
||||
$setting_location = $this->is_pro_active() ? 'uaepro' : 'hfe';
|
||||
|
||||
add_submenu_page(
|
||||
$setting_location,
|
||||
__( 'Create New', 'header-footer-elementor' ),
|
||||
__( 'Create New', 'header-footer-elementor' ),
|
||||
'edit_pages',
|
||||
'post-new.php?post_type=elementor-hf',
|
||||
'',
|
||||
1
|
||||
);
|
||||
|
||||
add_submenu_page(
|
||||
$setting_location,
|
||||
__( 'Header/Footer Builder', 'header-footer-elementor' ),
|
||||
__( 'Header & Footer', 'header-footer-elementor' ),
|
||||
'edit_pages',
|
||||
'edit.php?post_type=elementor-hf',
|
||||
'',
|
||||
2
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if UAE Pro is active.
|
||||
*
|
||||
* @return bool True if UAE Pro is active, false otherwise.
|
||||
*/
|
||||
public function is_pro_active() {
|
||||
if ( is_plugin_active( 'ultimate-elementor/ultimate-elementor.php' ) && defined( 'UAEL_PRO' ) && UAEL_PRO ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register meta box(es).
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function ehf_register_metabox() {
|
||||
add_meta_box(
|
||||
'ehf-meta-box',
|
||||
__( 'Elementor Header & Footer Builder Options', 'header-footer-elementor' ),
|
||||
[
|
||||
$this,
|
||||
'efh_metabox_render',
|
||||
],
|
||||
'elementor-hf',
|
||||
'normal',
|
||||
'high'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render Meta field.
|
||||
*
|
||||
* @param array $post Currennt post object which is being displayed.
|
||||
* @return void
|
||||
*/
|
||||
public function efh_metabox_render( $post ) {
|
||||
$values = get_post_custom( $post->ID );
|
||||
$template_type = isset( $values['ehf_template_type'] ) ? esc_attr( sanitize_text_field( $values['ehf_template_type'][0] ) ) : '';
|
||||
$display_on_canvas = isset( $values['display-on-canvas-template'] ) ? true : false;
|
||||
|
||||
// We'll use this nonce field later on when saving.
|
||||
wp_nonce_field( 'ehf_meta_nounce', 'ehf_meta_nounce' );
|
||||
?>
|
||||
<table class="hfe-options-table widefat">
|
||||
<tbody>
|
||||
<tr class="hfe-options-row type-of-template">
|
||||
<td class="hfe-options-row-heading">
|
||||
<label for="ehf_template_type"><?php esc_html_e( 'Type of Template', 'header-footer-elementor' ); ?></label>
|
||||
</td>
|
||||
<td class="hfe-options-row-content">
|
||||
<select name="ehf_template_type" id="ehf_template_type">
|
||||
<option value="" <?php selected( $template_type, '' ); ?>><?php esc_html_e( 'Select Option', 'header-footer-elementor' ); ?></option>
|
||||
<option value="type_header" <?php selected( $template_type, 'type_header' ); ?>><?php esc_html_e( 'Header', 'header-footer-elementor' ); ?></option>
|
||||
<option value="type_before_footer" <?php selected( $template_type, 'type_before_footer' ); ?>><?php esc_html_e( 'Before Footer', 'header-footer-elementor' ); ?></option>
|
||||
<option value="type_footer" <?php selected( $template_type, 'type_footer' ); ?>><?php esc_html_e( 'Footer', 'header-footer-elementor' ); ?></option>
|
||||
<option value="custom" <?php selected( $template_type, 'custom' ); ?>><?php esc_html_e( 'Custom Block', 'header-footer-elementor' ); ?></option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php $this->display_rules_tab(); ?>
|
||||
<tr class="hfe-options-row hfe-shortcode">
|
||||
<td class="hfe-options-row-heading">
|
||||
<label for="ehf_template_type"><?php esc_html_e( 'Shortcode', 'header-footer-elementor' ); ?></label>
|
||||
<i class="hfe-options-row-heading-help dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Copy this shortcode and paste it into your post, page, or text widget content.', 'header-footer-elementor' ); ?>">
|
||||
</i>
|
||||
</td>
|
||||
<td class="hfe-options-row-content">
|
||||
<span class="hfe-shortcode-col-wrap">
|
||||
<input type="text" onfocus="this.select();" readonly="readonly" value="[hfe_template id='<?php echo esc_attr( $post->ID ); ?>']" class="hfe-large-text code">
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="hfe-options-row enable-for-canvas">
|
||||
<td class="hfe-options-row-heading">
|
||||
<label for="display-on-canvas-template">
|
||||
<?php esc_html_e( 'Enable Layout for Elementor Canvas Template?', 'header-footer-elementor' ); ?>
|
||||
</label>
|
||||
<i class="hfe-options-row-heading-help dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enabling this option will display this layout on pages using Elementor Canvas Template.', 'header-footer-elementor' ); ?>"></i>
|
||||
</td>
|
||||
<td class="hfe-options-row-content">
|
||||
<input type="checkbox" id="display-on-canvas-template" name="display-on-canvas-template" value="1" <?php checked( $display_on_canvas, true ); ?> />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Markup for Display Rules Tabs.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function display_rules_tab() {
|
||||
// Load Target Rule assets.
|
||||
Astra_Target_Rules_Fields::get_instance()->admin_styles();
|
||||
|
||||
$include_locations = get_post_meta( get_the_id(), 'ehf_target_include_locations', true );
|
||||
$exclude_locations = get_post_meta( get_the_id(), 'ehf_target_exclude_locations', true );
|
||||
$users = get_post_meta( get_the_id(), 'ehf_target_user_roles', true );
|
||||
?>
|
||||
<tr class="bsf-target-rules-row hfe-options-row">
|
||||
<td class="bsf-target-rules-row-heading hfe-options-row-heading">
|
||||
<label><?php esc_html_e( 'Display On', 'header-footer-elementor' ); ?></label>
|
||||
<i class="bsf-target-rules-heading-help dashicons dashicons-editor-help"
|
||||
title="<?php echo esc_attr__( 'Add locations for where this template should appear.', 'header-footer-elementor' ); ?>"></i>
|
||||
</td>
|
||||
<td class="bsf-target-rules-row-content hfe-options-row-content">
|
||||
<?php
|
||||
Astra_Target_Rules_Fields::target_rule_settings_field(
|
||||
'bsf-target-rules-location',
|
||||
[
|
||||
'title' => __( 'Display Rules', 'header-footer-elementor' ),
|
||||
'value' => '[{"type":"basic-global","specific":null}]',
|
||||
'tags' => 'site,enable,target,pages',
|
||||
'rule_type' => 'display',
|
||||
'add_rule_label' => __( 'Add Display Rule', 'header-footer-elementor' ),
|
||||
],
|
||||
$include_locations
|
||||
);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="bsf-target-rules-row hfe-options-row">
|
||||
<td class="bsf-target-rules-row-heading hfe-options-row-heading">
|
||||
<label><?php esc_html_e( 'Do Not Display On', 'header-footer-elementor' ); ?></label>
|
||||
<i class="bsf-target-rules-heading-help dashicons dashicons-editor-help"
|
||||
title="<?php echo esc_attr__( 'Add locations for where this template should not appear.', 'header-footer-elementor' ); ?>"></i>
|
||||
</td>
|
||||
<td class="bsf-target-rules-row-content hfe-options-row-content">
|
||||
<?php
|
||||
Astra_Target_Rules_Fields::target_rule_settings_field(
|
||||
'bsf-target-rules-exclusion',
|
||||
[
|
||||
'title' => __( 'Exclude On', 'header-footer-elementor' ),
|
||||
'value' => '[]',
|
||||
'tags' => 'site,enable,target,pages',
|
||||
'add_rule_label' => __( 'Add Exclusion Rule', 'header-footer-elementor' ),
|
||||
'rule_type' => 'exclude',
|
||||
],
|
||||
$exclude_locations
|
||||
);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="bsf-target-rules-row hfe-options-row">
|
||||
<td class="bsf-target-rules-row-heading hfe-options-row-heading">
|
||||
<label><?php esc_html_e( 'User Roles', 'header-footer-elementor' ); ?></label>
|
||||
<i class="bsf-target-rules-heading-help dashicons dashicons-editor-help" title="<?php echo esc_attr__( 'Display custom template based on user role.', 'header-footer-elementor' ); ?>"></i>
|
||||
</td>
|
||||
<td class="bsf-target-rules-row-content hfe-options-row-content">
|
||||
<?php
|
||||
Astra_Target_Rules_Fields::target_user_role_settings_field(
|
||||
'bsf-target-rules-users',
|
||||
[
|
||||
'title' => __( 'Users', 'header-footer-elementor' ),
|
||||
'value' => '[]',
|
||||
'tags' => 'site,enable,target,pages',
|
||||
'add_rule_label' => __( 'Add User Rule', 'header-footer-elementor' ),
|
||||
],
|
||||
$users
|
||||
);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Save meta field.
|
||||
*
|
||||
* @param POST $post_id Currennt post object which is being displayed.
|
||||
*
|
||||
* @return Void
|
||||
*/
|
||||
public function ehf_save_meta( $post_id ) {
|
||||
|
||||
// Bail if we're doing an auto save.
|
||||
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// if our nonce isn't there, or we can't verify it, bail.
|
||||
if ( ! isset( $_POST['ehf_meta_nounce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['ehf_meta_nounce'] ) ), 'ehf_meta_nounce' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// if our current user can't edit this post, bail.
|
||||
if ( ! current_user_can( 'edit_posts' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$target_locations = Astra_Target_Rules_Fields::get_format_rule_value( $_POST, 'bsf-target-rules-location' );
|
||||
$target_exclusion = Astra_Target_Rules_Fields::get_format_rule_value( $_POST, 'bsf-target-rules-exclusion' );
|
||||
$target_users = [];
|
||||
|
||||
if ( isset( $_POST['bsf-target-rules-users'] ) ) {
|
||||
$target_users = array_map( 'sanitize_text_field', wp_unslash( $_POST['bsf-target-rules-users'] ) );
|
||||
}
|
||||
|
||||
update_post_meta( $post_id, 'ehf_target_include_locations', $target_locations );
|
||||
update_post_meta( $post_id, 'ehf_target_exclude_locations', $target_exclusion );
|
||||
update_post_meta( $post_id, 'ehf_target_user_roles', $target_users );
|
||||
|
||||
if ( isset( $_POST['ehf_template_type'] ) ) {
|
||||
update_post_meta( $post_id, 'ehf_template_type', sanitize_text_field( wp_unslash( $_POST['ehf_template_type'] ) ) );
|
||||
}
|
||||
|
||||
if ( isset( $_POST['display-on-canvas-template'] ) ) {
|
||||
update_post_meta( $post_id, 'display-on-canvas-template', sanitize_text_field( wp_unslash( $_POST['display-on-canvas-template'] ) ) );
|
||||
} else {
|
||||
delete_post_meta( $post_id, 'display-on-canvas-template' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display notice when editing the header or footer when there is one more of similar layout is active on the site.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function location_notice() {
|
||||
global $pagenow;
|
||||
global $post;
|
||||
|
||||
if ( 'post.php' != $pagenow || ! is_object( $post ) || 'elementor-hf' != $post->post_type ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$template_type = get_post_meta( $post->ID, 'ehf_template_type', true );
|
||||
|
||||
if ( '' !== $template_type ) {
|
||||
$templates = Header_Footer_Elementor::get_template_id( $template_type );
|
||||
|
||||
// Check if more than one template is selected for current template type.
|
||||
if ( is_array( $templates ) && isset( $templates[1] ) && $post->ID != $templates[0] ) {
|
||||
$post_title = '<strong>' . esc_html( get_the_title( $templates[0] ) ) . '</strong>';
|
||||
$template_location = '<strong>' . esc_html( $this->template_location( $template_type ) ) . '</strong>';
|
||||
/* Translators: Post title, Template Location */
|
||||
$message = sprintf( __( 'Template %1$s is already assigned to the location %2$s', 'header-footer-elementor' ), $post_title, $template_location );
|
||||
|
||||
echo '<div class="error"><p>';
|
||||
echo esc_html( $message );
|
||||
echo '</p></div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the Template name to be added in the notice.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @param string $template_type Template type name.
|
||||
*
|
||||
* @return string $template_type Template type name.
|
||||
*/
|
||||
public function template_location( $template_type ) {
|
||||
$template_type = ucfirst( str_replace( 'type_', '', $template_type ) );
|
||||
|
||||
return $template_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't display the elementor Elementor Header & Footer Builder templates on the frontend for non edit_posts capable users.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function block_template_frontend() {
|
||||
if ( is_singular( 'elementor-hf' ) && ! current_user_can( 'edit_posts' ) ) {
|
||||
wp_redirect( site_url(), 301 );
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Single template function which will choose our template
|
||||
*
|
||||
* @since 1.0.1
|
||||
*
|
||||
* @param string $single_template Single template.
|
||||
* @return string
|
||||
*/
|
||||
public function load_canvas_template( $single_template ) {
|
||||
global $post;
|
||||
|
||||
if ( 'elementor-hf' == $post->post_type ) {
|
||||
$elementor_2_0_canvas = ELEMENTOR_PATH . '/modules/page-templates/templates/canvas.php';
|
||||
|
||||
if ( file_exists( $elementor_2_0_canvas ) ) {
|
||||
return $elementor_2_0_canvas;
|
||||
} else {
|
||||
return ELEMENTOR_PATH . '/includes/page-templates/canvas.php';
|
||||
}
|
||||
}
|
||||
|
||||
return $single_template;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set shortcode column for template list.
|
||||
*
|
||||
* @param array $columns template list columns.
|
||||
* @return array
|
||||
*/
|
||||
public function set_shortcode_columns( $columns ) {
|
||||
$date_column = $columns['date'];
|
||||
|
||||
unset( $columns['date'] );
|
||||
|
||||
$columns['shortcode'] = __( 'Shortcode', 'header-footer-elementor' );
|
||||
$columns['date'] = $date_column;
|
||||
|
||||
return $columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display shortcode in template list column.
|
||||
*
|
||||
* @param array $column template list column.
|
||||
* @param int $post_id post id.
|
||||
* @return void
|
||||
*/
|
||||
public function render_shortcode_column( $column, $post_id ) {
|
||||
switch ( $column ) {
|
||||
case 'shortcode':
|
||||
ob_start();
|
||||
?>
|
||||
<span class="hfe-shortcode-col-wrap">
|
||||
<input type="text" onfocus="this.select();" readonly="readonly" value="[hfe_template id='<?php echo esc_attr( $post_id ); ?>']" class="hfe-large-text code">
|
||||
</span>
|
||||
|
||||
<?php
|
||||
|
||||
ob_get_contents();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HFE_Admin::instance();
|
||||
Reference in New Issue
Block a user