Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
gilour
/
wp-content
/
plugins
/
kadence-blocks-pro
/
includes
/
settings
:
admin-activate.js
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
/** * Ajax install the Theme Plugin * */ ( function ( $, window, document, undefined ) { 'use strict'; $( function () { $( '.kt-install-blocks-btn' ).on( 'click', function ( event ) { var $button = $( event.target ); event.preventDefault(); /** * Keep button from running twice */ if ( $button.hasClass( 'updating-message' ) || $button.hasClass( 'button-disabled' ) ) { return; } /** * Install a plugin * * @return void */ function installPlugin() { $.ajax( { url: $button.data( 'install-url' ), type: 'GET', data: {}, beforeSend() { buttonStatusInProgress( $button.data( 'installing-label' ) ); }, success( reposnse ) { buttonStatusInstalled( $button.data( 'installed-label' ) ); activatePlugin(); }, error( xhr, ajaxOptions, thrownError ) { // Installation failed buttonStatusDisabled( 'Error' ); }, } ); } /** * Activate a plugin * * @return void */ function activatePlugin() { $.ajax( { url: $button.data( 'activate-url' ), type: 'GET', data: {}, beforeSend() { buttonStatusInProgress( $button.data( 'activating-label' ) ); }, success( reposnse ) { buttonStatusDisabled( $button.data( 'activated-label' ) ); location.replace( $button.data( 'redirect-url' ) ); }, error( xhr, ajaxOptions, thrownError ) { // Activation failed console.log( xhr.responseText ); buttonStatusDisabled( 'Error' ); }, } ); } /** * Change button status to in-progress * * @return void */ function buttonStatusInProgress( message ) { $button .addClass( 'updating-message' ) .removeClass( 'button-disabled kt-not-installed installed' ) .text( message ); } /** * Change button status to disabled * * @return void */ function buttonStatusDisabled( message ) { $button .removeClass( 'updating-message kt-not-installed installed' ) .addClass( 'button-disabled' ) .text( message ); } /** * Change button status to installed * * @return void */ function buttonStatusInstalled( message ) { $button.removeClass( 'updating-message kt-not-installed' ).addClass( 'installed' ).text( message ); } if ( $button.data( 'action' ) === 'install' ) { installPlugin(); } else if ( $button.data( 'action' ) === 'activate' ) { activatePlugin(); } } ); } ); } )( jQuery, window, document );