add_cap( $cap ); } } } /** * Remove quote capabilities (uninstall). */ public static function remove_capabilities() { foreach ( self::ROLES as $role_name ) { $role = get_role( $role_name ); if ( ! $role ) { continue; } foreach ( self::capabilities() as $cap ) { $role->remove_cap( $cap ); } } } /** * Custom table for guest quote-list sessions. * Deliberately NOT wp_options: avoids autoload bloat (lesson from YITH). */ private static function create_sessions_table() { global $wpdb; $table = $wpdb->prefix . 'bbquote_sessions'; $charset_collate = $wpdb->get_charset_collate(); $sql = "CREATE TABLE {$table} ( session_key CHAR(32) NOT NULL, session_value LONGTEXT NOT NULL, session_expiry BIGINT UNSIGNED NOT NULL, PRIMARY KEY (session_key), KEY session_expiry (session_expiry) ) {$charset_collate};"; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; dbDelta( $sql ); } /** * Create the "Request a Quote" page with the list shortcode. */ private static function create_quote_page() { $page_id = (int) get_option( 'bbquote_page_id' ); if ( $page_id && get_post( $page_id ) ) { return; } $existing = get_page_by_path( 'request-a-quote' ); if ( $existing ) { update_option( 'bbquote_page_id', $existing->ID ); return; } $page_id = wp_insert_post( array( 'post_status' => 'publish', 'post_type' => 'page', 'post_name' => 'request-a-quote', 'post_title' => __( 'Request a Quote', 'boring-quote' ), // Wide group: block themes give the list and the form room for two columns; classic themes ignore it. 'post_content' => '
[bbquote_quote_list]
', 'comment_status' => 'closed', ) ); if ( $page_id && ! is_wp_error( $page_id ) ) { update_option( 'bbquote_page_id', $page_id ); } } }