array( 'message' => esc_html__( 'Invalid Access', 'bizsmart' ) ), 'status' => 400 ); if( wp_verify_nonce( $_POST['nonce'], 'rt-welcome-nonce' ) ){ set_transient( 'bizsmart_welcome_notice', 'dismiss_notice', 3*MONTH_IN_SECONDS ); $response[ 'data' ][ 'message' ] = esc_html__( 'Notice dismissed.', 'bizsmart' ); $response[ 'status' ] = 200; } wp_send_json( $response[ 'data' ], $response[ 'status' ] ); } public static function rt_welcome_ajax_action(){ $response = array( 'data' => array( 'message' => esc_html__( 'Invalid Access', 'bizsmart' ) ), 'status' => 400 ); if( wp_verify_nonce( $_POST['nonce'], 'rt-welcome-nonce' ) ){ if( isset( $_POST[ 'status' ] ) && 'install' == $_POST[ 'status' ] ){ include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; wp_cache_flush(); $upgrader = new Plugin_Upgrader(); $installed = $upgrader->install( self::$plugin_zip); if ( !is_wp_error( $installed ) && $installed ) { activate_plugin( self::$plugin_path ); } }elseif( isset( $_POST[ 'status' ] ) && 'active' == $_POST[ 'status' ] ){ activate_plugin( self::$plugin_path ); } $response[ 'data' ][ 'message' ] = esc_html__( 'Plugin Installed and Activated Successfully', 'bizsmart' ); $response[ 'status' ] = 200; } wp_send_json( $response[ 'data' ], $response[ 'status' ] ); } /** * Display welcome notice * * @static * @access public * */ public static function display_welcome_notice(){ set_query_var( 'rt_welcome_notice_theme', self::$theme_detail ); get_template_part( 'classes/welcome-notice/templates/content', 'welcome' ); } /** * Enqueue styles and scripts on admin * * @static * @access public * @return object * */ public static function module_admin_scripts(){ wp_enqueue_style( 'welcome-style', get_theme_file_uri( '/classes/welcome-notice/assets/css/welcome-notice.css' ) ); wp_enqueue_script( 'welcome-script', get_theme_file_uri( '/classes/welcome-notice/assets/js/welcome-notice.js' ), array( 'jquery' ) ); $data = array( 'admin_url' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce('rt-welcome-nonce'), 'confirm_msg' => esc_html__( 'Are you sure?', 'bizsmart' ), 'install_msg' => esc_html__( 'Installing...', 'bizsmart' ), 'active_msg' => esc_html__( 'Activating...', 'bizsmart' ) ); wp_localize_script( 'welcome-script' , 'RTWELCOMENOTICE' , $data ); } } }