if ( ! empty( $result ) ) { if ( 'success' === $result['status'] ) { wp_send_json_success( $result['payload'] ); } else { wp_send_json_error( $result['payload'] ); } } } public function __construct() { add_action( 'elementor/init', function() { // Only load when viewing the onboarding app. if ( Plugin::$instance->app->is_current() ) { $this->set_onboarding_settings(); // Needed for installing the Hello Elementor theme. wp_enqueue_script( 'updates' ); // Needed for uploading Logo from WP Media Library. wp_enqueue_media(); } }, 12 ); // Needed for uploading Logo from WP Media Library. The 'admin_menu' hook is used because it runs before // 'admin_init', and the App triggers printing footer scripts on 'admin_init' at priority 0. add_action( 'admin_menu', function () { add_action( 'wp_print_footer_scripts', function () { if ( function_exists( 'wp_print_media_templates' ) ) { wp_print_media_templates(); } } ); } ); add_action( 'admin_init', function() { if ( wp_doing_ajax() && isset( $_POST['action'] ) && isset( $_POST['_nonce'] ) && wp_verify_nonce( Utils::get_super_global_value( $_POST, '_nonce' ), Ajax::NONCE_KEY ) && current_user_can( 'manage_options' ) ) { $this->maybe_handle_ajax(); } } ); } }