realpath( $_GET['ai1ec_theme_dir'] ), 'theme_root' => realpath( $_GET['ai1ec_theme_root'] ), 'theme_url' => $_GET['ai1ec_theme_url'], 'legacy' => (bool)intval( $_GET['ai1ec_legacy'] ), 'stylesheet' => $stylesheet, ) ); // Delete user variables from database so fresh ones are used by new theme. $this->_registry->get( 'model.option' )->delete( Ai1ec_Less_Lessphp::DB_KEY_FOR_LESS_VARIABLES ); // Recompile CSS for new theme. $css_controller = $this->_registry->get( 'css.frontend' ); $css_controller->invalidate_cache( null, false ); // Return user to themes list page with success message. return array( 'url' => admin_url( 'edit.php?post_type=ai1ec_event&page=all-in-one-event-calendar-themes' ), 'query_args' => array( 'activated' => 1 ) ); } /* (non-PHPdoc) * @see Ai1ec_Command_Save_Abstract::set_render_strategy() */ public function set_render_strategy( Ai1ec_Request_Parser $request ) { $this->_render_strategy = $this->_registry->get( 'http.response.render.strategy.redirect' ); } /* (non-PHPdoc) * @see Ai1ec_Command::is_this_to_execute() */ public function is_this_to_execute() { if ( isset( $_GET['ai1ec_action'] ) && $_GET['ai1ec_action'] === 'activate_theme' && current_user_can( 'switch_themes' ) && is_dir( $_GET['ai1ec_theme_dir'] ) && is_dir( $_GET['ai1ec_theme_root'] ) ) { check_admin_referer( 'switch-ai1ec_theme_' . $_GET['ai1ec_stylesheet'] ); return true; } return false; } }